I was deploying a VM and I needed more space for /.
So first I turned off the machine and modified the machine.ovf file to increase de size of the hard disk:
From
<Disk ovf:capacity="8589934592" ovf:diskId="vmdisk2" ovf:fileRef="file1"…
To
<Disk ovf:capacity="28589934592" ovf:diskId="vmdisk2" ovf:fileRef="file1"…
Then I started the VM to expand the fs
Initial situation (take a look at /)
root@machine:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/dm-0 7.2G 5.7G 1.2G 84% / udev 10M 0 10M 0% /dev tmpfs 403M 5.5M 397M 2% /run tmpfs 1006M 0 1006M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 1006M 0 1006M 0% /sys/fs/cgroup /dev/sda1 236M 33M 191M 15% /boot
Physical Volumes
root@machine:~# pvs PV VG Fmt Attr PSize PFree /dev/sda5 debian-jessie-vg lvm2 a-- 26.38g 18.62g
Virtual Groups
root@machine:~# vgs VG #PV #LV #SN Attr VSize VFree debian-jessie-vg 1 2 0 wz--n- 26.38g 18.62g
Logical Volumes
root@machine:~# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root debian-jessie-vg -wi-ao---- 7.39g swap_1 debian-jessie-vg -wi-ao---- 376.00m
So I have one PV with 18 free GB (that’s thanks to the machine.ovf modification), one VG and two LVS. The one I want to increase is “root”.
Just a last check:
root@machine:~# pvscan PV /dev/sda5 VG debian-jessie-vg lvm2 [26.38 GiB / 18.62 GiB free] Total: 1 [26.38 GiB] / in use: 1 [26.38 GiB] / in no VG: 0 [0 ] root@machine:~# lvdisplay --- Logical volume --- LV Path /dev/debian-jessie-vg/root LV Name root VG Name debian-jessie-vg LV UUID OdIAov-a7qm-ThOR-58YP-D7FG-zq5n-r73dUq LV Write Access read/write LV Creation host, time debian-jessie, 2015-04-27 10:42:28 +0200 LV Status available # open 1 LV Size 7.39 GiB Current LE 1892 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:0 --- Logical volume --- LV Path /dev/debian-jessie-vg/swap_1 LV Name swap_1 VG Name debian-jessie-vg LV UUID dS5vEu-w8LQ-uoZd-IGk8-cmaK-8tBQ-ZtSyvO LV Write Access read/write LV Creation host, time debian-jessie, 2015-04-27 10:42:28 +0200 LV Status available # open 2 LV Size 376.00 MiB Current LE 94 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:1
So the path for my LV is /dev/debian-jessie-vg/root
And…
root@machine:~# vgdisplay --- Volume group --- VG Name debian-jessie-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 26.38 GiB PE Size 4.00 MiB Total PE 6754 Alloc PE / Size 1986 / 7.76 GiB Free PE / Size 4768 / 18.62 GiB VG UUID V2oYD9-uoYy-sFLY-QSLG-FPyx-Ejce-QANYo4
…I have 4768 Free PE for it! :-)
So, let’s use them. I extend first the LV:
root@machine:~# lvextend -l +4768 /dev/debian-jessie-vg/root Size of logical volume debian-jessie-vg/root changed from 7.39 GiB (1892 extents) to 26.02 GiB (6660 extents). Logical volume root successfully resized
Then I resize the fs
root@machine:~# resize2fs /dev/debian-jessie-vg/root resize2fs ... (it does it all automatically)
And that’s all!
Let’s check:
root@machine:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/dm-0 26G 5.7G 19G 24% / udev 10M 0 10M 0% /dev tmpfs 403M 5.5M 397M 2% /run tmpfs 1006M 0 1006M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 1006M 0 1006M 0% /sys/fs/cgroup /dev/sda1 236M 33M 191M 15% /boot root@machine:~# lvdisplay --- Logical volume --- LV Path /dev/debian-jessie-vg/root LV Name root VG Name debian-jessie-vg LV UUID OdIAov-a7qm-ThOR-58YP-D7FG-zq5n-r73dUq LV Write Access read/write LV Creation host, time debian-jessie, 2015-04-27 10:42:28 +0200 LV Status available # open 1 LV Size 26.02 GiB Current LE 6660 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:0 --- Logical volume --- LV Path /dev/debian-jessie-vg/swap_1 LV Name swap_1 VG Name debian-jessie-vg LV UUID dS5vEu-w8LQ-uoZd-IGk8-cmaK-8tBQ-ZtSyvO LV Write Access read/write LV Creation host, time debian-jessie, 2015-04-27 10:42:28 +0200 LV Status available # open 2 LV Size 376.00 MiB Current LE 94 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:1