We have an Ubuntu 20.04 VM running under VMware. The users reported that the root partition is running out of free space. We first deleted some unused files, and it’s still not enough. The user decicded to increase the virtual disk size. After the increase of the virtual disk size, the OS does not recognize the increase automatically. Additional work is needed.
If you’re thinking about purchasing a new GPU, we’d greatly appreciate it if you used our Amazon Associate links. The price you pay will be exactly the same, but Amazon provides us with a small commission for each purchase. It’s a simple way to support our site and helps us keep creating useful content for you. Recommended GPUs: RTX 5090, RTX 5080, and RTX 5070. #ad
First problem I had is that I got this warning whenever I use the pvdisplay command:
WARNING: PV /dev/sda5 in VG ubuntuos is using an old PV header, modify the VG to update.
To fix this problem, I typed in this command to update the PV header:
vgck --updatemetadata ubuntuos
Let’s take a look of the physical volumes and logical volumes on my VM.
# pvdisplay -m
--- Physical volume ---
PV Name /dev/sda5
VG Name ubuntuos
PV Size 49.52 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12677
Free PE 0
Allocated PE 12677
PV UUID bVLY9f-TeqI-MWL8-ClLq-s0jg-DKtx-ZjSNf1
--- Physical Segments ---
Physical extent 0 to 12164:
Logical volume /dev/ubuntuos/root
Logical extents 0 to 12164
Physical extent 12165 to 12676:
Logical volume /dev/ubuntuos/swap_1
Logical extents 0 to 511
--- Physical volume ---
PV Name /dev/sdb
VG Name ubuntuos
PV Size 150.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 38399
Free PE 0
Allocated PE 38399
PV UUID BiYKGF-dRxj-SjO1-RHhK-IcLk-fYUL-KmUMZF
--- Physical Segments ---
Physical extent 0 to 38398:
Logical volume /dev/ubuntuos/root
Logical extents 12165 to 50563
# lvdisplay -m
--- Logical volume ---
LV Path /dev/ubuntuos/root
LV Name root
VG Name ubuntuos
LV UUID uzEY5B-BYzA-D2c5-1ajf-fpp6-2Vrb-uNrYyC
LV Write Access read/write
LV Creation host, time ubuntu16-generic-template-01, 2017-06-30 08:41:06 -0400
LV Status available
# open 1
LV Size <197.52 GiB
Current LE 50564
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Segments ---
Logical extents 0 to 12164:
Type linear
Physical volume /dev/sda5
Physical extents 0 to 12164
Logical extents 12165 to 50563:
Type linear
Physical volume /dev/sdb
Physical extents 0 to 38398
--- Logical volume ---
LV Path /dev/ubuntuos/swap_1
LV Name swap_1
VG Name ubuntuos
LV UUID bmOnUR-0jWp-P89p-uskY-wT4Q-yX2G-C56F2s
LV Write Access read/write
LV Creation host, time ubuntu16-generic-template-01, 2017-06-30 08:41:06 -0400
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Segments ---
Logical extents 0 to 511:
Type linear
Physical volume /dev/sda5
Physical extents 12165 to 12676
The logical volume /dev/ubuntuos/root has two segments: /dev/sda5 and /dev/sdb. /dev/sdb is the increased virtual disk. The size has been increased from 150 GB to 250 GB. However, the system does not recognize the increase. I typed in this command to resize the physical volume:
pvresize /dev/sdb
Now that the physical volume size is fixed, I can extend the logical volume by using this command:
lvextend -l +100%FREE /dev/ubuntuos/root
Finally, I can grow the file system to utilize the extra space. The file system is xfs, so I used this command:
xfs_growfs -d /dev/mapper/ubuntuos-root
If you have a ext4 file system, use the command resize2fs to resize it.
Leave a Reply