Re: [Lxc-users] help regarding lxc

2011-08-29 Thread nishant mungse
hii


The entry in host's fstab contains
none /cgroup cgroup defaults 0 0s


And i have deleted all entries from guest's fstab file

The guest container is created abut when i exe it it shows following error


lxc-execute -n guest -f /home/nishant/lxc/conf.guest /bin/bash

lxc-execute: No such file or directory - failed to mount a new instance of
'/dev/pts'
lxc-execute: failed to setup the new pts instance

lxc-execute: failed to setup the container
lxc-execute: invalid sequence number 1. expected 2
lxc-execute: failed to spawn 'guest'

Regards,
Nishant.

On Wed, Aug 24, 2011 at 3:00 PM, nishant mungse nishantmun...@gmail.comwrote:

 Hii all

 I am using lxc for creating containers.

  But when i create lxc container using lxc-create -n abc it creates a abc
 container and when i do lxc-info -n abc its show abc is stopped and when i
 perform lxc-start -n abc [-f conf file ] the terminal hangs and if do
 lxc-execute -n abc [-f conf file ] \bin\bash terminal hangs.

 It is not even working for  /usr/bin/lxc-execute -n foo -f
 /usr/share/doc/lxc/examples/lxc-macvlan.conf /bin/bash.

 I am using UBUNTU 10.10.

 Plz help me ASAP.

 Regards,
 Nishant.

--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] help regarding lxc

2011-08-29 Thread Joerg Gollnick
Hi Nishant,
your rootfs is missing rootfs/dev/pts.
I use normaly following script: (replace rootfs with your location of the 
container rootfs)

DEV=rootfs/dev
rm ${DEV}/null
rm ${DEV}/zero
mknod -m 666 ${DEV}/null c 1 3
mknod -m 666 ${DEV}/zero c 1 5
mknod -m 666 ${DEV}/random c 1 8
mknod -m 666 ${DEV}/urandom c 1 9
mkdir -m 755 ${DEV}/pts
mkdir -m 1777 ${DEV}/shm
mknod -m 666 ${DEV}/tty c 5 0
mknod -m 666 ${DEV}/tty0 c 4 0
mknod -m 666 ${DEV}/tty1 c 4 1
mknod -m 666 ${DEV}/full c 1 7
mknod -m 600 ${DEV}/initctl p
mknod -m 666 ${DEV}/ptmx c 5 2

With best regards Joerg

Am Montag, 29. August 2011, 13:22:28 schrieb nishant mungse:
 hii
 
 
 
 The entry in host's fstab contains
 none /cgroup cgroup defaults 0 0s
 
 
 And i have deleted all entries from guest's fstab file
 
 The guest container is created abut when i exe it it shows following error
 
 
 lxc-execute -n guest -f /home/nishant/lxc/conf.guest /bin/bash
 
 lxc-execute: No such file or directory - failed to mount a new instance of
 '/dev/pts'
 lxc-execute: failed to setup the new pts instance
 
 lxc-execute: failed to setup the container
 lxc-execute: invalid sequence number 1. expected 2
 lxc-execute: failed to spawn 'guest'
 
 Regards,
 Nishant.
 
 On Wed, Aug 24, 2011 at 3:00 PM, nishant mungse 
nishantmun...@gmail.comwrote:
  Hii all
  
  I am using lxc for creating containers.
  
   But when i create lxc container using lxc-create -n abc it creates a
   abc 
  container and when i do lxc-info -n abc its show abc is stopped and
  when i perform lxc-start -n abc [-f conf file ] the terminal hangs
  and if do lxc-execute -n abc [-f conf file ] \bin\bash terminal
  hangs.
  
  It is not even working for  /usr/bin/lxc-execute -n foo -f
  /usr/share/doc/lxc/examples/lxc-macvlan.conf /bin/bash.
  
  I am using UBUNTU 10.10.
  
  Plz help me ASAP.
  
  Regards,
  Nishant.

--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] lxc-clone

2011-08-29 Thread Serge Hallyn
Quoting Ramez Hanna (rha...@informatiq.org):
 Hi,
 
 I have started using lxc to setup a pre-production system instead of KVM
 at first glance clone seemd to me that it would copy everything to a new roots
 but turns out that in case of LVM it will snapshot
 AFAIK snapshots are meant more for backup or testing some changes and
 discarding them later
 do you think it makes sense if I modify the script in this way
 if user doesn't specify -s, then a new lv is created and copy all
 comtents to it, rather than snapshot which would work if user uses the
 -s option?

Yes, I guess I didn't implement that bit yet, but not specifying -s was
meant to do a simple copy.  You'll probably want to check whether the
original was a simple directory tree or an lvm, and only lvcreate if the
original was an lvm.  (then lxc-convert can offer conversion from one to
the other.)

-serge

--
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] lxc-clone

2011-08-29 Thread Ramez Hanna
On Mon, Aug 29, 2011 at 4:19 PM, Serge Hallyn
serge.hal...@canonical.com wrote:
 Quoting Ramez Hanna (rha...@informatiq.org):
 Hi,

 I have started using lxc to setup a pre-production system instead of KVM
 at first glance clone seemd to me that it would copy everything to a new 
 roots
 but turns out that in case of LVM it will snapshot
 AFAIK snapshots are meant more for backup or testing some changes and
 discarding them later
 do you think it makes sense if I modify the script in this way
 if user doesn't specify -s, then a new lv is created and copy all
 comtents to it, rather than snapshot which would work if user uses the
 -s option?

 Yes, I guess I didn't implement that bit yet, but not specifying -s was
 meant to do a simple copy.  You'll probably want to check whether the
 original was a simple directory tree or an lvm, and only lvcreate if the
 original was an lvm.  (then lxc-convert can offer conversion from one to
 the other.)

 -serge


I did implemet that
patch submitted yesterday, would appreciate any comments

--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] [PATCH] multiple mods to lxc-clone

2011-08-29 Thread Serge Hallyn
Thanks, Ramez.  It looks good to me.  My only comment would be that
if the rootfs copy fails (either rsync or lvm clone), and you've
frozen the original container, then you need to unfreeze the original
container before erroring out.

-serge

Quoting Ramez Hanna (rha...@informatiq.org):
 * allow cloning of non-snapshot lvm devices
* if no -s then create a copy of the lvm block device and copy data
 from the orig to the new container device
* first take a snapshot, then use this snapshot to copy data,
 remove  snapshot after done
  * if orig container is running freeze it while copying
* in case lvm block device, the container is only frozen during
 creation of snapshot ~1 sec
  * use rsync -ax insted of cp -a
* in case copying a live contrainer it won't copy runtine mounted
 files such as /proc, /sys and some /dev
  * new opts
* fstype: type of fs for the newly created lvm device in case of
 non-snapshot lvm
* lvprefix: prefix for new lvm device name.
  * do not delete the lines lxc.mount by default
* check is fstab exists then copy it
* only modify lines that contain lxc.mount =, debian template
 seems to not have that line but uses lxc.mount. lines which get
 screwed
 
 
 Signed-off-by: InformatiQ rha...@informatiq.org
 ---
  src/lxc/lxc-clone.in |   98 
 ++
  1 files changed, 75 insertions(+), 23 deletions(-)
  mode change 100644 = 100755 src/lxc/lxc-clone.in
 
 diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in
 old mode 100644
 new mode 100755
 index 91944a0..d42160b
 --- a/src/lxc/lxc-clone.in
 +++ b/src/lxc/lxc-clone.in
 @@ -1,4 +1,4 @@
 -#!/bin/bash
 +#!/bin/bash
 
  #
  # lxc: linux Container library
 @@ -22,7 +22,7 @@
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
  usage() {
 -echo usage: lxc-clone -o orig -n new [-s] [-h] [-L fssize]
 [-v vgname]
 +echo usage: lxc-clone -o orig -n new [-s] [-h] [-L fssize]
 [-v vgname] [-p lxc_lv_prefix] [-t fstype]
  }
 
  help() {
 @@ -36,15 +36,19 @@ help() {
  echo -s  : make the new rootfs a snapshot of the original
  echo fssize  : size if creating a new fs.  By default, 2G
  echo vgname  : lvm volume group name, lxc by default
 +echo lvprefix   : lvm volume name prefix, none by default, e.g.
 --lvprefix=lxc_ then new lxc lv name will be lxc_newname
 +echo fstype : new container file system type, ext3 by
 default (only works for non-snapshot lvm)
  }
 
 -shortoptions='ho:n:sL:v:'
 -longoptions='help,orig:,name:,snapshot,fssize,vgname'
 +shortoptions='ho:n:sL:v:p:t:'
 +longoptions='help,orig:,name:,snapshot,fssize:,vgname:,lvprefix:,fstype:'
  lxc_path=/var/lib/lxc
  bindir=/usr/bin
  snapshot=no
  lxc_size=2G
  lxc_vg=lxc
 +lxc_lv_prefix=
 +fstype=ext3
 
  getopt=$(getopt -o $shortoptions --longoptions  $longoptions -- $@)
  if [ $? != 0 ]; then
 @@ -63,6 +67,7 @@ while true; do
   -s|--snapshot)
   shift
   snapshot=yes
 +snapshot_opt=-s
   ;;
   -o|--orig)
   shift
 @@ -84,6 +89,11 @@ while true; do
   lxc_new=$1
   shift
   ;;
 +-p|--lvprefix)
 +shift
 +lxc_lv_prefix=$1
 +shift
 +;;
  --)
   shift
   break;;
 @@ -141,50 +151,92 @@ trap ${bindir}/lxc-destroy -n $lxc_new; echo
 aborted; exit 1 SIGHUP SIGINT SIG
 
  mkdir -p $lxc_path/$lxc_new
 
 +hostname=$lxc_new
 +
  echo Tweaking configuration
  cp $lxc_path/$lxc_orig/config $lxc_path/$lxc_new/config
  sed -i '/lxc.utsname/d' $lxc_path/$lxc_new/config
  echo lxc.utsname = $hostname  $lxc_path/$lxc_new/config
 
 -sed -i '/lxc.mount/d' $lxc_path/$lxc_new/config
 -echo lxc.mount = $lxc_path/$lxc_new/fstab  $lxc_path/$lxc_new/config
 +grep lxc.mount = $lxc_path/$lxc_new/config /dev/null 21  { sed
 -i '/lxc.mount =/d' $lxc_path/$lxc_new/config; echo lxc.mount =
 $lxc_path/$lxc_new/fstab  $lxc_path/$lxc_new/config; }
 
 -cp $lxc_path/$lxc_orig/fstab $lxc_path/$lxc_new/fstab
 -sed -i s@$lxc_path/$lxc_orig@$lxc_path/$lxc_new@ $lxc_path/$lxc_new/fstab
 +if [ -e  $lxc_path/$lxc_orig/fstab ];then
 +cp $lxc_path/$lxc_orig/fstab $lxc_path/$lxc_new/fstab
 +sed -i s@$lxc_path/$lxc_orig@$lxc_path/$lxc_new@ 
 $lxc_path/$lxc_new/fstab
 +fi
 
  echo Copying rootfs...
  rootfs=$lxc_path/$lxc_new/rootfs
  # First figure out if the old is a device.  For now we only support
  # lvm devices.
  mounted=0
 +#is container running
 +lxc-info -s -n $lxc_orig|grep RUNNING /dev/null 21
 +if [ $? -ne 0 ]; then
 +container_running=True
 +fi
  sed -i '/lxc.rootfs/d' $lxc_path/$lxc_new/config
  oldroot=`grep lxc.rootfs $lxc_path/$lxc_orig/config | awk -F= '{ print $2 '}`
  if [ -b $oldroot ]; then
   # this is a device.  If we don't want to snapshot, then mkfs, mount
   # and rsync.  Trivial but not yet implemented
 - if [