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: tim.post@xxxxxxxxxxx
Subject: Re: [Xen-users] How can I duplicate a running guest OS in Xen ?
From: Nico Kadel-Garcia <nkadel@xxxxxxxxx>
Date: Sat, 28 Apr 2007 07:13:11 +0100
Cc: xen-users@xxxxxxxxxxxxxxxxxxx, openbsd shen <openbsd.shen@xxxxxxxxx>
Delivery-date: Fri, 27 Apr 2007 23:09:56 -0700
Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=XgvbMcMkCD4QZOw1pwYFyGBQEUykAjX7sNjuvYWv/PxeTAFL6+al1hxZ6cBL6eqvwGWVsn8bwWLxuI4Ljn/W2mKn9U/sjyA4B0nq6prZZLSXw3nQ3/7w7QF/2T4l5AbAysxYZD9nnpvjXhRar45Jkckg6w1Tpk5vXcAmQ3LhuEY=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=ZzNZRpFHnkDUfnCwPCDWjiMXA5n/Jb6l3+1HLY606abh4jYjhtVrjPjg1EgsQWtSjSJssMaujIubhYLHv1ZPCDANzBxJRTPF/3BUaAZrFf/7dQEVaaf4PZzQi0BwXV9siC8iYnmbY9PZ/Tydd9J3372Boo1T7bgHUYRQVOKdCWc=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <1177735802.27115.141.camel@xxxxxxxxxxxxxxxxxxxxx>
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>
References: <6ff3e7140704271858w6c9322d0yc8cf914c3568fd1a@xxxxxxxxxxxxxx> <1177735802.27115.141.camel@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.10 (Windows/20070221)
Tim Post wrote:
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


Use rsync on the live OS to push to a mounted partition of another OS. Be sure to exclude /proc, /sys, and similar mount run-time created directories, and manally push things like /dev/null and /sev/serial that reside under the udev created countents of /dev/ For databases which cannot safely be duplicated while live, exclude them from the push and use tools like mysqldump to dump them to pushable text files.

I use this technique to create nightly backup snapshots with "rsnapshot" for recovery purposes. Works pretty well!

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)
That's where I do the rsync stuff one final time, with the shutdown and manually mounted filesystem. This also avoids the target having to be the same size or even set up with the same filesystems. Or if the target need not be absolutely identical, such as slave copies of master servers, it allows in-vivo operations to preserve configurations of the slave.


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
And you should be dumping them regularly as part of backup and recovery techniques.

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

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