• 200910.27

    VirtualBox: how to "clone" your VMs

    Notice the "clone" in quotes. Why? You can't actually clone a VM technically. We can work around that, though. Keep in mind, this guide is for VirtualBox <= 3.0.8 (later versions may have a clone button or something).

    One thing you CAN do is export to OVF and re-import, but I've found that OVF loses many settings (like video ram, network settings, whether you use SATA or not, etc). I prefer not to even bother with this method.

    The next thing you can do is just clone your VM's hard disk(s):

    1. Go into the ~/.VirtualBox/HardDisks/ folder. Copy and paste (windows) or cp (linux/unix) from db_master1.vdi to db_master2.vdi. If you try to import this into the Virtual Media Manager, it will piss and moan about the UUID being duplicate or some shit.
    2. VBoxManage internalcommands setvdiuuid db_master2.vdi - this is the magic command that allows you to import that new HD.
    3. Create a new VM, and set db_master2.vdi as the primary drive.
    4. Configure your new VM to have the same settings. (this is a pain, but there really aren't that many settings).

    There are a few things you'll have to dick with once you have your VM cloned. If you're into networking/cluster/HA crap like me, you'll probably have a static IP. This obviously needs to be changed. It's different for every distro, but it's in /etc/rc.d/rc.inet1.conf for Slackware, and /etc/networking/interfaces for Debian (any other distro can go to hell).

    Your old network interfaces, eth[0...n] will now be eth[(n+1)...(n*2)]: eg, if you had eth0 and eth1 before, they will now be eth2 and eth3. To reset this, (in Slackware):

    1. Open/etc/udev/rules.d/75-network-devices.rules in your favorite editor
    2. Remove all the entries.
    3. Restart. (note - someone please correct me if you don't need a restart... perhaps /sbin/udevtrigger will fix this?)
    4. You will now have eth0 and eth1 again. Hoo-fucking-ray.

    The process is the same for Debian, but the 75-network-devices.rules will most likely have a different name.

    Good luck.

    Comments