Re: [Vserver] Transparently Creating Multiple Instances of Vservers Using COW?

From: Bruno <bonbons67_at_internet.lu>
Date: Sat 03 Jun 2006 - 11:31:50 BST
Message-Id: <200606031231.51483.bonbons67@internet.lu>

On Saturday 03 June 2006 12:09, Grzegorz Nosek wrote:
> 2006/6/3, EKC <webmaster@generalsynthesis.com>:
> > Hello,
> >
> > Given a running vserver <parent_vserver>, I would like to create
> > multiple <child_vserver> instances of the running parent vserver as
> > quickly as possible.
> >
> > Currently, I am doing this by:
> > ==Creating the parent vserver:==
> > 1) Building the <parent_vserver> from scratch using: 'vserver
> > parent_vserver debootstrap...'
> > 2) Running 'vserver parent_vserver hashify'
> > ==Stopping The Parent vserver==
> > 1) vserver parent_vserver stop
> > ==Creating an instance of the parent:==
> > 1) vserver child_vserver build -m skeleton --interface eth0:192.168.1.2
> > 2) rm -rf /vservers/child_vserver/*
> > 3) vcopy --manually -v /vservers/child_vserver ' '
> > /vservers/parent_vserver ' ' 4) vserver child_vserver hashify
> > 5) vserver child_vserver start
> > ==Restarting the parent_vserver:==
> > 1) vserver parent_vserver start
> >
> > Question: This procedure is _very_ slow to execute (on the order of
> > minutes); is there a faster way to do this? Also, can a copy and
> > hashify a running vserver without stopping it first?
> >
> > Specifically: I want to use the COW feature of linux-vserver to create
> > copies of vservers. Ideally, I would create a copy by creating a hard
> > link to the parent_vserver and passing the hard link to 'vserver
> > <hard_link_to_parent_vserver> start'. How would I go about doing this?
> > This would allow me to clone vservers almost instantly. COW would take
> > care of copying files from the hashified parent vserver to the child
> > vserver when the child vserver reads/writes/renames/chmods/chowns a
> > file.
> >
> > I'm really hoping there's a way to do this.
> >
> > Thanks for vserver! And thanks in advance for your help.
> >
> > EKC
>
> As a quick guess, you might cp -la the unified files and cp -a (or
> rsync or whatever) the guest-specific data. This might or might not
> work (I'm not sure how will the CoW mechanism work with a plain cp -l)
> but it might be a starting point for a more elegant solution.
>
> Hardlinking the files in the first place instead of cp + vhashify
> (which AFAIK computes the sha1sum and replaces the original file with
> a hardlink) should be significantly faster. Still, it's just a quick
> idea based mostly on speculation. If you try this, please provide some
> feedback (if it helps anything etc.)
>
> Best regards,
> Grzegorz Nosek

I don't know if vhashify and friends of util-vserver keep some state of their
operations (like a DB of hashed files)

What may be useful is e.g. an adjusted 'cp' tool that copies regular files as
hardlink to the reference and adds IUNLINK and IMMUTABLE flags to the
hardlinked files (where the flags are not alreay present)
This will copy a whole guest as quickly as scanning the existing tree and
creating a new inode/hardlink for each inode encountered.

There is a minimal such tool in vserver-utils 1.0.4 branch (that one only
knows how to handle regular files and directories; for other filetypes
(sockets, device nodes, pipes) it will print a warning and skip them)
I used it a few times to make copies of kernel sources, quite effective!

Regards,
Bruno
_______________________________________________
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver
Received on Sat Jun 3 11:32:18 2006

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Sat 03 Jun 2006 - 11:32:22 BST by hypermail 2.1.8