VirtualBox - split partitioned VDI into separate VDIs

Solution 1:

I'm not aware of a way to split the file, but you could try creating new virtual disks and then rsync the files or dd the blocks from old to new partition. Like this:

modprobe nbd max_part=16

qemu-nbd -c /dev/nbd0 /PATH/TO/YOUR/old.vdi
qemu-nbd -c /dev/nbd1 /PATH/TO/YOUR/new.vdi

dd if=/dev/nbd0p1 of=/dev/nbd1p1 bs=512

qemu-nbd -d /dev/nbd1
qemu-nbd -d /dev/nbd0

rmmod nbd

Solution 2:

Based off @AnsgarWiecher's comment of not being aware of a way to split the file, I did the following:

In virtualbox:

  • select the VM
  • select 'Clone' and 'Full Clone' to create a new .vdi file (it is 25GB though, and contains the dual-boot setup).
  • Boot into this new machine into Arch, and delete the Ubuntu partitions.
  • Resize the .vdi to contain just the Arch partition(s)

This is the new arch-only machine.

Now I can boot up into the original (non-clone) dual-boot machine, and remove Arch from it similarly so that I end up with an Ubuntu-only machine.