Resize /var partition on a remote system (Linux Debian Lenny)
If you have room on your root partition for the contents of /var you could:
- stop anything that is using
/var
where possible - remount /var readonly for good measure
mount -f -oremount,ro /var
- copy
/var
to/
under a different name withmkdir /vartmp; cp -av /var/* /vartmp/
- move things around with
mv /var /varmount; mv /vartmp /var
- comment out the entry for
/var
in/etc/fstab
- reboot
You should now have /var
in place as-was on your root partition instead of its own. You can now resize the old partition as needed. Step 4 should let you rename the /var
directory even though it is in use as a mount-point and otherwise busy (and proceses with open files there will track the change as the open files are not referred to by path+name, but instead by inode, once open).
If you don't have space on /
but do on /someotherfs
then you could try move it there with a symlink in /
like so:
- stop anything that is using
/var
where possible - remount /var readonly for good measure
mount -f -oremount,ro /var
- copy
/var
withcp -av /var /someotherfs/var
- move things around with
mv /var /varmount; ln -s /someotherfs/var /var
- comment out the entry for
/var
in/etc/fstab
- reboot
This is slightly more risky though as you need to be sure that /someotherfs
gets mounted before /var
when booting.
If you don't have room where you want to copy it to temporarily you might be able to reduce the size of /var
by removing things like cached packages (aptitude clean
on Debian style setups, there is no doubt an equivalent yum
command), moving other stuff away (for instance, Debian keeps the default httpdocs in /var/www
so if it is still there and you have lots of data in there, move it to another partition), and deleting files from /var/log
that are not very recent (backing the up first, in case you do need to refer to them later).
As Zoredache says: what ever you do, make sure you are happy with your backup arrangement before proceeding.
Caveat: all the above is from memory, I've not tested it anywhere, follow at own risk!