I fear I already know the answer to this question, but here goes.
I need to carve out a new partition on a running system. /var/
is mounted from an LVM volume (hdd1_vg-var) and has only 3% used disk space.
/
is mounted separately (hdd1_vg-root) and has about 80% used disk space.
Filesystem Size Used Avail Use% Mounted on
/dev/**/hdd1_vg-root
2.0G 1.4G 481M 75% /
/dev/**/hdd1_vg-var
33G 699M 31G 3% /var
Unfortunately I don't have any free extents to grow this partition organically – vgdisplay shows:
Total PE 10000
Alloc PE / Size 10000 / 39.06 GB
Free PE / Size 0 / 0
So seeing that I have all this free disk space on /var/
, can I shrink /var/
without un-mounting it or is this just a pipe dream?
I am really hoping to be able to do this work on a running system – un-mounting would of course not be difficult but it would interfere with system functionality.
Best Answer
Yes, you can shrink/move/grow an online root partition without any reboots (nor livecd, nor usbkey): consult this answer. It's very well written and easy to follow, although quite long and a little risky.
This allows to bypass limitation of
resize2fs
not being able to shrinkext4
partitions.Of course, if you only want to grow your ext4 partition, you can stick to the conventional working
resize2fs
solutions.The general solution I've lnked will work on any type of dedicated or VPS solution for instance.
TLDR; this solution implies to
pivot_root
totmpfs
so you canumount
safely your root partition live and fiddle with it. Once done, you'llpivot_root
back on your new root partition.This allows pretty much any manipulation on the root file system (move it, change filesystem, changing it's physical device...).
I have personally used this, and it works very well on debian system also, but the guide was initially written in 2007 for redhat, the answer I've linked was updated for CentOS7. It's highly probable that it'll work on your CentOS6.