Skip to content

Instantly share code, notes, and snippets.

@flackend
Last active November 8, 2019 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flackend/994daea288cb4b30d94cefdb1ed326ec to your computer and use it in GitHub Desktop.
Save flackend/994daea288cb4b30d94cefdb1ed326ec to your computer and use it in GitHub Desktop.
Instructions for resizing a VirtualBox VDI

Resize VDI

Note: sudo cfdisk and df -h can come in handy to identify disks, etc. See there output below which will help identify how to adapt the commands.

df -h output:

Filesystem                   Size  Used Avail Use% Mounted on
udev                         980M     0  980M   0% /dev
tmpfs                        201M  3.4M  197M   2% /run
/dev/mapper/ubuntu--vg-root  8.1G  7.7G   30M 100% /
tmpfs                       1001M     0 1001M   0% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                       1001M     0 1001M   0% /sys/fs/cgroup
/dev/sda1                    720M  158M  526M  23% /boot
tmpfs                        201M     0  201M   0% /run/user/1000

cfdisk output:

    Device             Boot                 Start              End          Sectors         Size        Id Type
    /dev/sda1          *                     2048          1499135          1497088         731M        83 Linux
    /dev/sda2                             1501182        104857599        103356418        49.3G         5 Extended
    └─/dev/sda5                           1501184        104857599        103356416        49.3G        8e Linux LVM

Note: This was performed on Ubuntu and I believe it has LVM as the "partitioning system".

Use VBoxManage to resize the VDI:

VBoxManage modifymedium /path/to/disk.vdi --resize 51200

--resize takes MB so the above resizes it to 50GB.

Now use GParted to resize the partition. Download the live CD and boot to that.

After using GParted to resize the partition and I booted back into the VM, I had some trouble getting the filesystem to resize. No errors, it was just reporting the old partition size. I found the commands I needed here:

https://askubuntu.com/questions/1013775/help-extending-lvm

pvresize /dev/sda5
sudo lvresize -l+100%FREE --resizefs /dev/mapper/ubuntu--vg-root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment