HOWTO: extend virtual box partition (hdd)

Assumption: you are running virtualbox under windows and want to extend a linux partition. gparted should be installed.


  1. start a command line (window+r -> cmd
  2. go to your virtual installation directory (e.g.: cd C:\Program Files\Oracle\VirtualBox\)
  3. run the following command:
    VBoxManage.exe modifyhd "C:\Users\maxmustermann\VirtualBox VMs\linuxhdd.vdi" --resize 51200

    Replace maxmustermann with your username and the following directories with the path to your virtual disk image.
    Replace 51200 with your desired size in MB (51200 is 50Gb).

  4. start virtual OS
  5. open terminal
  6. if swap is between the partition you want to extend and the free space, then you have to turn off swap. Otherwise, go to step 7.
    sudo swapoff -a
  7. start gparted
    sudo gparted
  8. delete swap
  9. extend partion
  10. recreate swap: create linux extended partition. Right click on this partition and select create linux swap.
  11. activate swap
    sudo swapon /dev/sdXX

    Press TAB after sudo swapon and the right swap partition should be autocompleted.

    *Thanks to Moritz Stolz for his help.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.