Hi All,

I think I share quite similar approach with Pablo's approach in cloning a
VirtualBox VM. But mine is a little bit different, since my VirtualBox host
uses ZFS filesystem. Hopefully it is not off topic, since I am still
talking about cloning a working VirtualBox VM. Unfortunately ZFS is
currently not supported on Windows platform, please CMIIW. This will be
quite a bit long explanation, if you are not interested you can skip my
email. :)

Using ZFS filesystems as the underlying VirtualBox VM filesystem has some
benefit, at least these are two of them:

   1. Using the ZFS compression, we can improve the I/O and gain a smaller
   overral disk usage. One of my VM is supposed to be have around 460 GB,
   using ZFS compression the disk usage is only around 130 GB. That's around
   3.51 compress ratio! :D
   2. The clone process using ZFS' clone is a snap and almost without any
   additional overhead disk usage. I can always clone the 460 GB VM as many as
   I want without adding great disk usage.


In order for the cloning process to be success, I always create a ZFS
filesystem for each VM configuration. These are the steps whenever I create
a template OS:

   1. Create an empty VM of any OS type from VirtualBox, I usually use the
   GUI. No need to put a hard disk as we will add it later. Let's say the VM
   name is "Test.VM".
   2. Remove the newly created VM, but not delete it. Close the VirtuaLBox
   Manager GUI.
   3. Find the directory location of the removed VM, usually on *"~/VirtualBox
   VMs/Test.VM"*, and rename the directory to something else, let's
say *"~/VirtualBox
   VMs/Test.VM-deleted"*.
   4. Create a ZFS filesystem (preferably that has compression enabled)
   let's say *"sudo zfs create <poolname>/Test.VM**"*, change the ownership
   if needed.
   5. Create a softlink to the created ZFS filesystem under *"~/VirtualBox
   VMs"* so *"~/VirtualBox VMs/Test.VM"* points to *"/<poolname>/Test.VM"*.
   6. Move all the contents of *"~/VirtualBox VMs/Test.VM-deleted/"*
to *"~/VirtualBox
   VMs/Test.VM/"* and remove the directory *"~/VirtualBox
   VMs/Test.VM-deleted"*.
   7. Startup the VirtualBox Manager GUI, add the VM by opening the
   Test.VM's .vbox file.
   8. Add the disks, configure the type, version, etc., and install it like
   usual.
   9. When I feel the OS is usable and stable, I powered off the VM and
   snapshot the filesystem using ZFS. Something like *"sudo zfs snapshot
   <poolname>/Test.VM@template".*
   10. Finished creating template VM on top of ZFS filesystem.


The steps (1), (2), (3), (6), and (7), is needed since VirtualBox v4.2.x
validates the filesystem for any existing directory with the same name as
the newly created VM. The softlinking steps should not be required if you
change the default VirtualBox library directory path and not having
separate filesytems like I do.

Okay, now I have a ZFS snapshot as the template. Once I wanted to create a
clone, this is what I do: (some steps are quite similar with before)

   1. Create an empty VM of any OS type from VirtualBox, I usually use the
   GUI. No need to put a hard disk as we will add it later. Let's say the VM
   name is "Clone.VM".
   2. Remove the newly created VM, but not delete it. Close the VirtuaLBox
   Manager GUI.
   3. Find the directory location of the removed VM, usually on *"~/VirtualBox
   VMs/Clone.VM"*, and rename the directory to something else, let's
say *"~/VirtualBox
   VMs/Clone.VM-deleted"*.
   4. Clone the ZFS filesystem of the Test.VM to Clone.VM, something like
   this *"sudo zfs clone <poolname>/Test.VM@template <poolname>/Clone.VM"*.
   5. Create a softlink to the created ZFS filesystem under *"~/VirtualBox
   VMs"* so *"~/VirtualBox VMs/Clone.VM"* points to *"/<poolname>/Clone.VM"*
   .
   6. Remove all the contents inside *"~/VirtualBox VMs/Clone.VM/"* but
   reserve all the VDI disk files.
   7. Regenerate all the disks UUID by running *"VBoxManage
   internalcommands sethduuid <vdi_filename>"*.
   8. Move the .vbox and .vbox-prev files from *"~/VirtualBox
   VMs/Clone.VM-deleted/"* to *"~/VirtualBox VMs/Clone.VM/" *and remove the
   directory *"~/VirtualBox VMs/Clone.VM-deleted"*.
   9. Startup the VirtualBox Manager GUI, add the cloned VM by opening
   Clone.VM's .vbox file.
   10. Configure the cloned VM, add disk, verify OS type, architecture and
   such. Make sure to regenerate all the cloned VM's network interface MAC
   addresses if you want to differentiate the DHCP IP address assign for it.
   11. Launch the cloned VM, make sure the Test.VM is not running first to
   prevent same hostname warning.
   12. Change the hostname inside the cloned VM, shutdown the cloned VM.
   13. Finished cloning a template VM using ZFS clone feature.

Thank you.

Regards,
Okky Hendriansyah

On Mon, Oct 29, 2012 at 7:57 AM, Pablo Sanchez <[email protected]> wrote:

> [ Comments below, in-line ]
>
> On 10/28/2012 06:41 PM, Mark Cranness wrote:
> >
> > internalcommands won't help you if your intent is to run the two VMs
> > on the same host instance.
>
> Hi Mark,
>
> I'm not sure I follow you but perhaps my cloning need was different than
> other folks but I don't think it was ...
>
> As an experiment, I did the following:
>
> o Shutdown the W7 VM, ensuring there were no snapshots.
> o Using `cp' (far faster than using the Virtualbox method as I could
> copy to a second disk), I copied the .vdi
> o I set the .vdi's UUID
> o Using the VBox GUI, I created a new VM and plugged in the freshly
> minted .VDI.
> o Booted the new .VDI and changed its host name.
>
> I can't recall if I did anything more but the above covers the gist of
> what I did.  It's been a looooong time ago since I've done the above
> though ...
>
> Cheers,
> --
> Pablo Sanchez - Blueoak Database Engineering, Inc
> Ph:    819.459.1926         Blog:  http://pablo.blog.blueoakdb.com
> Fax:   760.860.5225 (US)
>
>
> ------------------------------------------------------------------------------
> The Windows 8 Center - In partnership with Sourceforge
> Your idea - your app - 30 days.
> Get started!
> http://windows8center.sourceforge.net/
> what-html-developers-need-to-know-about-coding-windows-8-metro-style-apps/
> _______________________________________________
> VBox-users-community mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/vbox-users-community
> _______________________________________________
> Unsubscribe:  mailto:[email protected]
> ?subject=unsubscribe
>
------------------------------------------------------------------------------
The Windows 8 Center - In partnership with Sourceforge
Your idea - your app - 30 days.
Get started!
http://windows8center.sourceforge.net/
what-html-developers-need-to-know-about-coding-windows-8-metro-style-apps/
_______________________________________________
VBox-users-community mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vbox-users-community
_______________________________________________
Unsubscribe:  
mailto:[email protected]?subject=unsubscribe

Reply via email to