Site Feed

Tuesday, October 2, 2018

Create a Symlink as a Workaround for Partition Full Error

Sometimes, a mounted partition does not have enough space, and it may take time to expand the LVM volume, if there is not currently enough physical space available, and a separate team handles storage.  Of course making a separate partition is a more proper fix, and LVM is flexible enough to accommodate the changes, but sometimes space is filling up, and something has to be done right away.  Maybe /var/log, or /opt is filling up, and you did not think ahead to make it a separate partition.

As a quick workaround, it is fairly common to use a symbolic link, or as sysadmins affectionately call it, a symlimk.

Let's say an application wants to install under /opt, and you are out of space in /opt, but have plenty of space in /app.  You can use a symlink to trick the system into thinking that it is using /opt, when in fact it is using /app/opt.

I like to perform a directory move and symlink creation at the same time.  Note that both /opt and /app already exist, but we are moving the entire /opt directory to be under /app, as /app/opt.

mv /opt /app/ && ln -s /app/opt /opt

Note the use of double ampersand "&&", which tells the shell to run the next command, only if the result of the first command was successful.

Results of ls -l, should give something like this:

     lrwxrwxrwx   1 root   root       8 Oct  1 18:01 opt -> /app/opt

Sometimes this will fail, if there is not enough space at the target location, or if files are in use.  You can use fuser -c /opt to see which files are open, and if necessary, close them with fuser -ck /opt.  It may also be necessary to temporarily close any apps that are using the old partition.

Note that there can also be occasional problems with symlinks, for example mounting across different volume types or NAS shares, but a symlink can be a very convenient solution in many cases.