Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ehsanhoushmand/fe18c0c1250e6e143261c444282377c2 to your computer and use it in GitHub Desktop.
Save ehsanhoushmand/fe18c0c1250e6e143261c444282377c2 to your computer and use it in GitHub Desktop.
extend hard disk of virtual linux machine on virtualbox
#first convert vmdk to vdi format
vboxmanage clonehd disk.vmdk cloned.vdi --format vdi
#resize the vdi (in MB)
vboxmanage modifyhd cloned.vdi --resize 51200
# convert to vmdk format (optional)
vboxmanage clonehd cloned.vdi resized.vmdk --format vmdk
# download gparted live to extend the hard disk and the iso file from setting > storage > add optical drive and delete the old vmdk file and add new hard disk(resized.vmdk)
# then from setting > system > motherboared > change boot order from hard disk to optical .
# after that start the virtual machine and boot gparted.
# from gparted extend the old drive to new size and shutdown the machine.
# again change the boot order to hard disk and start machine .
# if gparted does not extend the root filesystem automatically (you can check with `lsblk` command) then append physical volume to volume group and run this command
sudo vgextend ubuntu-vg /dev/vdb1
sudo pvdisplay
# extend logical volume
sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
# Extend filesystem with resize2fs without umount.
sudo resize2fs /dev/ubuntu-vg/root
# it's finished. you can check `lsblk`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment