Add space to a dynamic virtual hard drive with VirtualBox with a RHEL/CentOS/OEL 6 VM

This blog assumes your VM is RHEL or clone of RHEL using the logical volume manager – if you are not using LVM – this approach will not work.
To start with expand the virtual drive from the command line (Windows in the example).
VBoxManage modifyhd <absolute path to file> –resize <size in MB>
For example to resize to your virtual dynamic drive to 100GB do the following ( note: you must provide the path to VBoxManage – installed with VirtualBox in the same directory – your path will vary).
C:\VirtualBox>VBoxManage modifyhd “C:\Users\u2\VirtualBox VMs\oel66-411gr2\oel66-411gr2.vdi” –resize 102400
Now start your VM
# from your started Linux VM and a terminal emulator
# this works on RHEL/CentOS/OEL 6.6
# make a backup (this operation has some risk)- and if it is critical data – make sure you can recover with that backup
# take note of logical volume mapping
df
# this approach uses fdisk to clean up the partition info – that LVM created for you to start with then recreates it with the expanded using the virtual drive – what surprised me – is that when you delete the partition information with fdisk below – you lose nothing.
# take note of your file system partition
fdisk -l
# Run fdisk to remove the old partitioning info
fdisk /dev/sda
d
2
n
p
2
<return>
<return>
w
# now reboot your VM to make the OS pick up the updated partition table
# OK – after the VM has restarted… use LVM commands to update your partitions using the new space allocated
pvresize /dev/sda2
pvscan
lvextend -l +100%FREE /dev/mapper/vg_oel66411gr2-lv_root
resize2fs /dev/mapper/vg_oel66411gr2-lv_root
# Voila, the df command should now show your new disk space
df
credit should be given to the blog at for teaching me this technique:
https://blog.jyore.com/2013/06/virtualbox-increase-size-of-rhelfedoracentosscientificos-guest-file-system/
BTW – now that you manually corrected the LVM – you can use the LVM GUI to view it
If the LVM GUI is not installed… yum install system-config-lvm
[root@oel66-411gr2 Desktop]# system-config-lvm

Leave a Comment

Scroll to Top