Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm very new to VirtualBox. I set up an Arch Linux VM and a Ubuntu VM (Ubuntu host), both sharing the same .vdi like so (I had in my mind a dual-boot situation):

VDI file (25GB)
|- /dev/sda1: 5GB (Arch Linux)
|- /dev/sda2:  [Ubuntu]
    |- /dev/sda5 (swap, 1GB)
    |- /dev/sda6 Ubuntu /, 9GB
    |- /dev/sda7 Ubuntu /home, 10GB

I've now realised that I don't want a dual-boot-type setup, I'd rather boot each machine independently (my initial thought was to share /home between Ubunto and Arch).

So, my question: Can I split /dev/sda1 and /dev/sda2 each to their own .vdi files so I can use them as completely separate machines? I'd rather not have to re-install either Arch (because it took me ages to work it out!) or Ubuntu (because I've already done a few GB of updates and don't want to redo them).

I haven't been able to find anything about this - most questions I see are about converting a .vdi to a partition on the host, or splitting a .vdi into multiple smaller files (that are not independent), or converting a partition on the host to a .vdi file.

cheers.

share|improve this question
add comment

2 Answers

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
share|improve this answer
    
Thanks - I ended up finding a roundabout/simliar way to do it through VirtualBox –  mathematical.coffee Sep 4 '12 at 3:35
add comment
up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.