Resize VM HDD
Let’s assume you want to increase the size of the filesystem /tmp from 3 GB to 5 GB. This can be done online without rebooting the machine. First you should verify if there is enough space left on your volume group:
1[root@examplehost ~]# pvs
2 PV VG Fmt Attr PSize PFree
3 /dev/sdb vg00 lvm2 a-- <95.00g <47.00gIn this example you can see that there are 47 GB left.
If there is enough space left you need to re-size the according logical volume first:
1[root@examplehost ~]# df -h /tmp
2Filesystem Size Used Avail Use% Mounted on
3/dev/mapper/vg00-tmplv 3.0G 33M 3.0G 2% /tmpThe filesystem /tmp is located on the logical volume vg00-tmplv. Now that you now where the filesystem is located you can increase it as follows:
1[root@examplehost ~]# lvresize -rL +2G /dev/mapper/vg00-tmplv
2 Size of logical volume vg00/tmplv changed from 3.00 GiB (768 extents) to 5.00 GiB (1280 extents).
3 Logical volume vg00/tmplv successfully resized.If you now verify the new size of the filesystem it should be 5 GB of size:
1[root@examplehost ~]# df -h /tmp/
2Filesystem Size Used Avail Use% Mounted on
3/dev/mapper/vg00-tmplv 5.0G 33M 5.0G 1% /tmp