vboxmanage modifyhd u140464-02-disk1.vmdk --resize 30000What?!
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!
Turned out "modifyhd" only support .vdi, not .vmdk. OK I will just use .vdi then:
vboxmanage clonehd u140464-02-disk1.vmdk u140464-02-disk1.vdi --format vdiThen detach vmdk disk from the VM and attach the vdi.
vboxmanage modifyhd u140464-02-disk1.vdi --resize 30000
But after I boot it up, the disk was still full. The disk size wasn't changed. After some googling I found I need to install gparted and use it to grow the partition, and gparted has to be run at boot. Too much hassle. All I want was some additional disk space. So I did it my way.
(Inside the VM)
sudo fdisk /dev/sdathen enter p, it showed:
Device Boot Start End Blocks Id SystemEnter n to create a new partition, press enter 2 times to accept default partition size. For some reason, there was a stray segment, so I have to enter n again to create a new partition. 2 partitions were created, after a p, my partition table looked like this:
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 33552383 16525313 5 Extended
/dev/sda5 501760 33552383 16525312 8e Linux LVM
Device Boot Start End Blocks Id Systemsda3 is useless, so I deleted it by a 'd' followed by a '3'. sda4 is the one I will use. Enter 'w' to write to disk. Then reboot the VM.
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 33552383 16525313 5 Extended
/dev/sda3 499712 501757 1023 83 Linux
/dev/sda4 33552384 61439999 13943808 83 Linux
/dev/sda5 501760 33552383 16525312 8e Linux LVM
After reboot, do a:
sudo mkfs.ext4 /dev/sda4My /opt was not used, so I just mount sda4 as /opt
sudo mount /dev/sda4 /optAdd "/dev/sda4 /opt ext4 defaults 0 2" to the end of /etc/fstab so it was mounted automatically at boot.
In the end, I should have just add another virtual disk without bothering resizing the current one.