Resize a Virtual Hard Disk¶
VBoxManage list hdds
VBoxManage showmediuminfo ${DISK_UUID}
# resize to 10 GiB
VBoxManage modifymedium disk ${DISK_UUID} --resizebyte $((10 * 1024 * 1024 * 1024))
Confirm Resize¶
Inside the VM:
lsblk
Reshape Partition Table¶
Inside the VM:
apt install gdisk
gdisk ${DEVICE}
Use p
to view the current layout, and remember the current geometry.
If you have a GPT disk, then you may need to use x
→ e
to relocate the backup data to the end of the disk... Before doing this, the "free space" will likely be close to zero.
x
- enter "expert" menue
- relocate backup data structures to the end of the diskm
- return to main menu
Now delete the last partition, and re-create using the same start sector, and a further end sector.
d
- delete a partition?
- the partition's number
n
- add a new partition?
- the partition's number?
- the partition's start sector (exactly as above)?
- the partition's end sector - leave blank to use all available space?
- the partition's type (8300
= "Linux filesystem")
p
- print the partition table and confirm the changesw
- write table to disk and exit
Verify changes: (reboot if they are not yet reflected)
partprobe
lsblk
Resize Filesystem¶
Ext 2 / 3 / 4¶
Online resize is possible:
resize2fs ${DEVICE}
Confirm Resize¶
df -h ${MOUNT_POINT}