Can I resize the root partition without uninstalling and reinstalling Linux (or losing data)?
Warning: doing anything to your filesystems without a known-restorable backup is ill-advised.
Do not run any of the following steps if you're not sure your /
is clean. If you're not sure, run the following (as root):
# touch /forcefsck
and reboot. This will do an fsck
of all your partitions, to be on the safe side.
That being said, since you're using LVM for your root device and an ext3
filesystem, you can extend it online. Before you start make sure you have resize2fs
installed. If not, it's usually in a package called e2fsprogs
. (If you can't install it because you don't have enough room, try to do a bit of cleanup in /var/log
for instance.)
First you extend the underlying volume with (as root):
# lvextend -L+2G /dev/mapper/HU-root
(Adjust the 2G
part as you wish - it's the amount of space you want to add.)
Then you need to resize the filesystem. This can be done online with resize2fs
:
# resize2fs /dev/mapper/HU-root
This can take a few seconds/minutes. Don't interrupt. Do another reboot at the end, possibly with another /forcefsck
, if you want to. It's not necessary, but I often do it anyway.
You do have free space available in your PV for allocating to the / partition. You can use the following to increase the space of /dev/mapper/HU-root.
lvextend -L +10G /dev/mapper/HU-root
e2resize /dev/mapper/HU-root
The above command will add 10G from your Volume Group to HU-root logical volume. The e2resize command will "grow" the ext3 filesystem to use the remaining free space.