WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

Re: [Xen-users] How can I duplicate a running guest OS in Xen ?

To: openbsd shen <openbsd.shen@xxxxxxxxx>
Subject: Re: [Xen-users] How can I duplicate a running guest OS in Xen ?
From: Tim Post <tim.post@xxxxxxxxxxx>
Date: Sat, 28 Apr 2007 12:50:02 +0800
Cc: xen-users@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 27 Apr 2007 21:48:50 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <6ff3e7140704271858w6c9322d0yc8cf914c3568fd1a@xxxxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Organization: Gridnix
References: <6ff3e7140704271858w6c9322d0yc8cf914c3568fd1a@xxxxxxxxxxxxxx>
Reply-to: tim.post@xxxxxxxxxxx
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
On Sat, 2007-04-28 at 09:58 +0800, openbsd shen wrote:
> When a guest OS is running in Xen, how can I duplicate it?
> Thanks.
> 
> Sailer

There is no "elegant" way to do this if the guest is running. The best
way I've found is to follow these steps :

1.) On dom-0 create a vbd of equal size (or the size you want for your
clone). This can be a loop, lv , whatever.

2.) xm block-attach it to the running dom-U

3.) Enter the dom-u, most likely you will have to use mknod to create
the device for the new drive in /dev (probably going to be sdc1 if its a
pv guest) in which case you'd type 'mknod /dev/sdc1 b 8 33' 

4.) Format it (this can also be done on dom-0) and mount it.

5.) Use rsync or a similar utility to make a copy of the root file
system. Get only the stuff you need.

6.) Once copy is done, unmount the second fs, 'sync' and exit the dom-u

7.) Go to dom-0 xm block-detach the cloned drive. create your config for
the new VM, make a swap vbd for it, get it all set up. Mount the file
system in dom-0 and make your edits in etc/ to change networking (ip and
stuff)

8.) Unmount and boot the new clone :)

Like another poster has said, if your current dom-u is under heavy
stress (lots of SQL activity or so) this isn't the best idea even using
the above method which doesn't need to worry about locking. You still
should watch inodes like you would in any other regular GNU/Linux
system.

If you are running database servers, you should dump -> import them from
old to new after booting the clone so that they're identical. Lots of
stuff could have changed after rsync left /var/lib.

Hope this helps, 
--Tim

> 
> _______________________________________________
> Xen-users mailing list
> Xen-users@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-users


_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users

<Prev in Thread] Current Thread [Next in Thread>