During my Fedora 15 installation, i made two Logical Volumes, HomeLV 50GB for /home and RootLV 5GB for /. This was a mistake and very soon the / was full.
[root@localhost ~]# df -h / Filesystem Size Used Avail Use% Mounted on /dev/mapper/FedVG-RootLV 4.8G 4.5G 4.9G 94% /
So i now wanted to shrink the /home and extend the /.
To reduce a logical volume. We first need to reduce the filesystem on it using
fsadm. Then use
lvreduce) to resize the logical volume.
[root@localhost ~]# resize2fs /dev/mapper/FedVG-HomLV 45G resize2fs 1.41.14 (22-Dec-2010) Filesystem at /dev/mapper/FedVG-HomLV is mounted on /home; on-line resizing required resize2fs: On-line shrinking not supported
Online shrinking is not supported. So now the option is to unmount the underlying filesystem ie, /home. For that i had to logout of the GNOME and work in a Virtual console (Ctrl+Alt+F[1-6]).
Now, a bit more reading of the man page of
lvresize and i found that by using
-r switch, we can resize the underlying filesystem together with the logical volume.
[root@localhost ~]# umount /dev/mapper/FedVG-HomLV [root@localhost ~]# lvresize -r -L -5G /dev/mapper/FedVG-HomLV fsck from util-linux2.19.1 dev/mapper/FedVG-HomLV: 900/2949120 files (1.2% non-contiguous), 250200/11796480 blocks resize2fs 1.41.14 (22-Dec-2010) Resizing the filesystem on /dev/mapper/FedVG-HomLV to 10977280 (4k) blocks. The filesystem on /dev/mapper/FedVG-HomLV is now 10977280 blocks long. Reducing logical volume HomLV to 41.88 GiB Logical volume HomLV successfully resized
-L switch with
lvresize it to add or reduce
[root@localhost ~]# mount /home [root@localhost ~]# df -h /home Filesystem Size Used Avail Use% Mounted on /dev/mapper/FedVG-HomLV 42G 253M 39G 1% /home
The next step is to extend the RootLV logical volume and then grow the root filesystem.
[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/FedVG-RootLV Extending logical volume RootLV to 10.00 GiB Logical volume RootLV successfully resized
+100%FREE option directs the
lvextend to use the available free extents(free space). Note that the
-r switch to resize the underlying filesystem is available here too though i didnt use it.
Grow the filesystem using
resizefs. By default, most file system resizing tools will increase the size of the file system to be the size of the underlying logical volume so you do not need to worry about specifying the same size for each of the two commands.
[root@localhost ~]# resize2fs /dev/mapper/FedVG-RootLV resize2fs 1.41.14 (22-Dec-2010) Filesystem at /dev/mapper/FedVG-RootLV is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/mapper/FedVG-RootLV to 2621440 (4k) blocks. The filesystem on /dev/mapper/FedVG-RootLV is now 2621440 blocks long.
Online growing of filesystem is supported although online shrinking not supported as we saw earlier.
[root@localhost ~]# df -h / Filesystem Size Used Avail Use% Mounted on /dev/mapper/FedVG-RootLV 9.9G 4.5G 4.9G 48% /