In this post we will see how to grow a Linux filesystem without reboot.
- Let's check our current filesystem. We want to extend this filesystem by 200MB.
[root@cloudvedas CVFS1]# df -h /CVFS1
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cvsvg-cldvdsvol1 47M 12M 32M 26% /CVFS1
[root@cloudvedas CVFS1]#
- First check if we have free space in VG
[root@cloudvedas /]# vgs
VG #PV #LV #SN Attr VSize VFree
cvsvg 1 1 0 wz--n- 196.00m 144.00m
rhel 1 3 0 wz--n- 7.51g 36.00m
[root@cloudvedas /]#
- Since we don't have 200MB free in "cvsvg" so we will add a new disk to it. First label the disk for LVM and get it under LVM control using pvcreate.
[root@cloudvedas CVFS1]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created
[root@cloudvedas CVFS1]#
- Add the new partition to our VG.
[root@cloudvedas CVFS1]# vgextend cvsvg /dev/sdb2
Volume group "cvsvg" successfully extended
[root@cloudvedas CVFS1]#
[root@cloudvedas CVFS1]# vgs
VG #PV #LV #SN Attr VSize VFree
cvsvg 2 1 0 wz--n- 444.00m 392.00m
rhel 1 3 0 wz--n- 7.51g 36.00m
[root@cloudvedas CVFS1]#
- Now we have the required space so, let's extend the volume first.
[root@cloudvedas CVFS1]# lvextend -L +200M /dev/cvsvg/cldvdsvol1
Size of logical volume cvsvg/cldvdsvol1 changed from 52.00 MiB (13 extents) to 252.00 MiB (63 extents).
Logical volume cldvdsvol1 successfully resized
- On checking the LV we can see it's now extended as is now of 252MB.
[root@cloudvedas CVFS1]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
cldvdsvol1 cvsvg -wi-ao---- 252.00m
root rhel -wi-ao---- 6.67g
swap rhel -wi-ao---- 820.00m
testvol1 rhel -wi-a----- 4.00m
[root@cloudvedas CVFS1]#
- Let's increase the filesystem now using resize2fs.
[root@cloudvedas CVFS1]# resize2fs /dev/cvsvg/cldvdsvol1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/cvsvg/cldvdsvol1 is mounted on /CVFS1; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/cvsvg/cldvdsvol1 is now 258048 blocks long.
- Check the file system now.
[root@cloudvedas CVFS1]# df -h /CVFS1
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cvsvg-cldvdsvol1 241M 13M 217M 6% /CVFS1
[root@cloudvedas CVFS1]#
Great so we have now extended the filesystem.