Xen VM Cloning

Ok, now on to the cool stuff.  From my earlier post, you may be aware that I have a machine grant (or, to put it another way, domain0) — with 2 Xen VMs (sherman and mcpherson).  Actually, sherman and mcpherson are more like placeholders for VMs — I want to be able to test out different configurations in each one, re-using the same IP address.  So I’ve actually got sherman01 and mcpherson01.  Today I wondered how hard it would be to create sherman02 or simply clone sherman01.  It turned out to be dead simple:

  1. Go to /etc/xen and copy the sherman01 config file to sherman02
  2. Edit the sherman02 config file replacing all references to sherman01 with sherman02
  3. Since I’m using file-backed VMs, copy the files representing the disks for sherman01 to sherman02 equivalents and make sure the config file references them
  4. Shutdown sherman01
  5. Start sherman02

Worked like a charm.

Leave a Reply

Posting code can be a pain. To make sure your code doesn't get eaten, you may want to pre-format it first by using HTML Encoder