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

From: Grzegorz Nosek <grzegorz.nosek_at_gmail.com>
Date: Sat 03 Jun 2006 - 11:09:17 BST
Message-ID: <121a28810606030309t62f5068fq5bf64a064287ae99@mail.gmail.com>

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
_______________________________________________
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver
Received on Sat Jun 3 11:09:43 2006

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