Step 1: expand the virtual disk
In Hyper-V, VMWare or whatever hypervisor you use.
Step 2: rescan the block device
Note: You should be root
for the rest of this tutorial.
echo 1 > /sys/block/sda/device/rescan
Step 3: parted
Run
parted /dev/sda
and choose
p
(for print) and then:
Fix
Resize the partition (e.g. for sda3, type 3)
resizepart 3 100%
Quit parted:
quit
pvresize
“pv” means PhysicalVolume. Expand it to 100% (no parameters means max available):
pvresize /dev/sda3
lvextend
Find out what your root partition is:
sudo lvdisplay -C -o "lv_path" | grep root
Now expand the LogicalVolume and the filesystem. The -r
flag just means resizefs
.
lvextend -l +100%FREE -r /dev/rhel_web2-lon/root
Verification
Check if your changes worked:
df -h
Thanks
Credit to TobiasJ on AskUbuntu for a solid original answer (here) which has helped me many times in the past. This post is slightly adapted for RedHat specifically but very little is different for most other distros, as long as you’re using LVM.