|
|
|
|
|
|
|
|
|
|
xen-users
Re: [Xen-users] How can I duplicate a running guest OS in Xen ?
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
|
|
|
|
|