Skip to content

Instantly share code, notes, and snippets.

@mojoaxel
Last active October 25, 2017 08:15
Show Gist options
  • Save mojoaxel/af379eb6fedb9c165a574a9bc8288419 to your computer and use it in GitHub Desktop.
Save mojoaxel/af379eb6fedb9c165a574a9bc8288419 to your computer and use it in GitHub Desktop.
Resize a VirtualBox Disk

Increase size of virtual drive

  1. First open the VirtualBox "Manager vor virtual Drives" and disconnect the drive from any machiene
  2. Backup old image: cp ubuntu-14.10-server-amd64.vdi ubuntu-14.10-server-amd64.backup.vdi
  3. Increase Size (in MB, here ~50 GB): VBoxManage modifyhd ubuntu-14.10-server-amd64.vdi --resize 50000
  4. Reconnect the drive to your virtual machine and start it up.

Increase size of main partition

  1. Find the main partition: lsblk
  2. Run fdisk on this partition: sudo fdisk /dev/sda
    1. Use p to list the partitions. Make note of the start cylinder of /dev/sda1.
    2. Use d to delete first the swap partition (2) and then the /dev/sda1 partition. This is very scary but is actually harmless as the data is not written to the disk until you write the changes to the disk.
    3. Use n to create a new primary partition. Make sure its start cylinder is exactly the same as the old /dev/sda1 used to have. For the end cylinder agree with the default choice, which is to make the partition to span the whole disk (or e.g. 100000000=47.7GB).
    4. Use a to toggle the bootable flag on the new /dev/sda1
    5. Review your changes, make a deep breath and use w to write the new partition table to disk. You'll get a message telling that the kernel couldn't re-read the partition table because the device is busy, but that's ok.
  3. Reboot: sudo reboot
  4. Increase partition size: sudo resize2fs /dev/sda1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment