Cloning Instances

766 views
Skip to first unread message

Coalescence

unread,
Mar 16, 2010, 6:51:55 AM3/16/10
to ganeti
Hi!

Is it possible to clone an instance, or perhaps create empty instances
and disks that I can then dd into or mount up and rsync?

Tried searching the list but couldn't find anything to do with cloning

Thanks!

Iustin Pop

unread,
Mar 16, 2010, 6:53:11 AM3/16/10
to gan...@googlegroups.com

Nope :)

What you want is a gnt-instance add --no-install, which should be
trivial to do, but it's not yet there...

iustin

Coalescence

unread,
Mar 16, 2010, 6:58:16 AM3/16/10
to ganeti


Could I create another OS instance script that just does the
partitioning, but doesn't debootstrap etc.. suppose that would work?

Iustin Pop

unread,
Mar 16, 2010, 7:00:18 AM3/16/10
to gan...@googlegroups.com

Sure. Or you could wait for 2.1.2 which will allow creation of instances
based on existing LV volumes.

iustin

Sp4rKY

unread,
Mar 16, 2010, 7:02:02 AM3/16/10
to ganeti

> > Is it possible to clone an instance, or perhaps create empty instances
> > and disks that I can then dd into or mount up and rsync?
>
> > Tried searching the list but couldn't find anything to do with cloning

Hi,

we need to do this all the time :) 2 ways :

- when you have an instance ready to be a source for cloning, use gnt-
instance export,
then, to create the clone, use gnt-instance --import
- If you want to use dd: when you have an instance ready, shutdown
it, then :
- gnt-instance activate-disk yourinstance
it will display the node/drbd device used, for ex foo2.node.gnt:/
dev/drbd33, so :
ssh foo2 "dd if=/dev/drbd33 of=mysystem.iso"
- to recreate it, add a vm with gnt-instance add, then shutdown
it, activate-disk ,and dd.

NOTE : the first way will update hostname, network etc (if needed),
but don't work atm with full-virt vm (on a kvm cluster) (a bug is
opened for this).
The second will work for everything, but you will need to update
hostname / remove /etc/udev/rules.d/persistent-net.rules / update
network if static ip yourself.

Regards.

Maxence

Coalescence

unread,
Mar 16, 2010, 7:08:13 AM3/16/10
to ganeti

Thanks for this will try it out...

Will also investigate the rsync route too as I'd like to do some
remote P2V migrations if possible. I'm sure it is with a little elbow
grease :)


Iustin: Very cool on the new feature, look forward to it

Sp4rKY

unread,
Mar 16, 2010, 7:13:42 AM3/16/10
to ganeti

>
> Will also investigate the rsync route too as I'd like to do some
> remote P2V migrations if possible. I'm sure it is with a little elbow
> grease :)

The idea is the same as for dd, create a basic vm, shutdown, activate-
disk, then :
{{{
kpartx -av /dev/drbd33
mkdir /mnt/mountpoint
mount /dev/mapper/drbd33p1 /mnt/mountpoint
}}}
and after your rsync :
{{{
umount /mnt/mountpoint
kpartx -dv /dev/drbd33
}}}

Coalescence

unread,
Mar 16, 2010, 8:46:01 AM3/16/10
to ganeti


Works great! Thanks for sharing.

Just done a proof of concept move of one of our webmail servers.. All
is well :)

Lance Albertson

unread,
Mar 16, 2010, 12:23:35 PM3/16/10
to gan...@googlegroups.com

Sweet, I was hoping an option like that would be available at some
point. I'm assuming it'll only setup the disks and nothing more? Is
there a issue open for that yet? I'd like to track its progress.

Cheers-

--
Lance Albertson
Systems Administrator / Architect Open Source Lab
Network Services Oregon State University

signature.asc

Lance Albertson

unread,
Mar 16, 2010, 12:30:59 PM3/16/10
to gan...@googlegroups.com

We're in the process of starting to migrate all of our virtual machines
from our old non-ganeti xen cluster onto a new ganeti cluster in the
next coming weeks. This isn't quite the same situation that you're in
but I thought I'd at least mention it here.

The process we're going to use basically is this:

1. Create LVM snapshot of the current VM
2. Create filesystem dump using dump from the snapshot
3. Create empty instance on the Ganeti cluster
4. Restore dump on Ganeti cluster (activate-disks, kpartx, mount, etc)
5. Shutdown VM on old cluster, create an incremental filesystem dump
6. Restore incremental backup (re-run grub if needed)
7. Start VM on Ganeti

This provides us a migration plan with the lowest downtime for the VMs
(usually under 5-10min). Using dump instead of rsync is great because
it'll preserve almost everything including SELinux labels and ACLs (if
you're using them). It'll also only copy the files and directories you
need instead of whole blocks like dd does.

signature.asc

Iustin Pop

unread,
Mar 16, 2010, 12:34:02 PM3/16/10
to gan...@googlegroups.com
On Tue, Mar 16, 2010 at 09:23:35AM -0700, Lance Albertson wrote:
> On 03/16/2010 03:53 AM, Iustin Pop wrote:
> > On Tue, Mar 16, 2010 at 03:51:55AM -0700, Coalescence wrote:
> >> Hi!
> >>
> >> Is it possible to clone an instance, or perhaps create empty instances
> >> and disks that I can then dd into or mount up and rsync?
> >>
> >> Tried searching the list but couldn't find anything to do with cloning
> >
> > Nope :)
> >
> > What you want is a gnt-instance add --no-install, which should be
> > trivial to do, but it's not yet there...
>
> Sweet, I was hoping an option like that would be available at some
> point. I'm assuming it'll only setup the disks and nothing more? Is
> there a issue open for that yet? I'd like to track its progress.

No, there isn't, I'd appreciate if you file one :)

iustin

Reply all
Reply to author
Forward
0 new messages