Re: [Lxc-users] * fix cached rootfs update * fix rootfs path * add handling of systemd (aka f15)
On Mon, Mar 5, 2012 at 10:28 PM, rha...@informatiq.org wrote: From: InformatiQ rha...@informatiq.org Signed-off-by: InformatiQ rha...@informatiq.org --- templates/lxc-fedora.in | 35 +++ 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in index e7f42a6..3f50895 100644 --- a/templates/lxc-fedora.in +++ b/templates/lxc-fedora.in @@ -69,11 +69,6 @@ EOF 127.0.0.1 localhost $name EOF - sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit - sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit - chroot ${rootfs_path} chkconfig udev-post off - chroot ${rootfs_path} chkconfig network on - dev_path=${rootfs_path}/dev rm -rf $dev_path mkdir -p $dev_path @@ -99,6 +94,23 @@ EOF return 0 } +configure_fedora_init() +{ + sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit + sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit + chroot ${rootfs_path} chkconfig udev-post off + chroot ${rootfs_path} chkconfig network on +} + +configure_fedora_systemd() +{ + unlink ${rootfs_path}/etc/systemd/system/default.target + touch ${rootfs_path}/etc/fstab + chroot ${rootfs_path} ln -s /dev/null //etc/systemd/system/udev.service + chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target + #dependency on a device unit fails it specially that we disabled udev + sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service +} download_fedora() { @@ -170,7 +182,8 @@ copy_fedora() update_fedora() { - chroot $cache/rootfs yum -y update + YUM=yum --installroot $cache/rootfs -y --nogpgcheck + $YUM update } install_fedora() @@ -353,7 +366,7 @@ if [ $(id -u) != 0 ]; then fi -rootfs_path=$path/$name/rootfs +rootfs_path=$path/rootfs config_path=$default_path/$name cache=$cache_base/$release @@ -362,7 +375,7 @@ revert() echo Interrupted, so cleaning up lxc-destroy -n $name # maybe was interrupted before copy config - rm -rf $path/$name + rm -rf $path rm -rf $default_path/$name echo exiting... exit 1 @@ -388,6 +401,12 @@ if [ $? -ne 0 ]; then exit 1 fi +type /bin/systemd /dev/null 21 +if [ $? -ne 0 ]; then + configure_fedora_init +else + configure_fedora_systemd +fi if [ ! -z $clean ]; then clean || exit 1 -- 1.7.7.6 there is only problem about systemd not addressed by this script is that it does mount /dev which stops getty from starting on tty1 so either make it start on any tty higher than what your host is using and allow that in your lxc cgroup conf or mount the $rootfs/dev to a different block dev that way systemd won't mount /dev the script below does it nicely in the case you don't have a free block device. the script create a non persistant mount which you don't need if you are using lvm [rhanna@hovercraft bin]$ cat lxc-start-fedora #! /bin/bash options=$(getopt -o n: -l name: -- $@) eval set -- $options while true do case $1 in -n|--name) name=$2; shift 2;; --) shift break;; *) break ;; esac done if [ -z $name ]; then echo container name must be set, use -n|--name exit 1 fi lxc-ls |grep $name /dev/null 21 if [ $? -ne 0 ]; then echo Container does not exist exit 1 fi lxc-info -s -n$name|grep RUNNING /dev/null 21 if [ $? -eq 0 ]; then echo container already started exit 1 fi mount |grep /tmp/lxc/$name /dev/null 21 if [ $? -eq 0 ]; then umount /tmp/lxc/$name fi rm -rf /tmp/lxc/$name mkdir -p /tmp/lxc/$name mount none /tmp/lxc/$name -t tmpfs rsync -a /var/lib/lxc/$name/rootfs/dev/ /tmp/lxc/$name mount /tmp/lxc/$name f16/rootfs/dev/ -obind lxc-start $* -n $name -- BR RH http://informatiq.org -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users
Re: [Lxc-users] * fix cached rootfs update * fix rootfs path * add handling of systemd (aka f15)
Quoting Ramez Hanna (rha...@informatiq.org): On Mon, Mar 5, 2012 at 10:28 PM, rha...@informatiq.org wrote: From: InformatiQ rha...@informatiq.org Signed-off-by: InformatiQ rha...@informatiq.org --- templates/lxc-fedora.in | 35 +++ 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in index e7f42a6..3f50895 100644 --- a/templates/lxc-fedora.in +++ b/templates/lxc-fedora.in @@ -69,11 +69,6 @@ EOF 127.0.0.1 localhost $name EOF - sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit - sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit - chroot ${rootfs_path} chkconfig udev-post off - chroot ${rootfs_path} chkconfig network on - dev_path=${rootfs_path}/dev rm -rf $dev_path mkdir -p $dev_path @@ -99,6 +94,23 @@ EOF return 0 } +configure_fedora_init() +{ + sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit + sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit + chroot ${rootfs_path} chkconfig udev-post off + chroot ${rootfs_path} chkconfig network on +} + +configure_fedora_systemd() +{ + unlink ${rootfs_path}/etc/systemd/system/default.target + touch ${rootfs_path}/etc/fstab + chroot ${rootfs_path} ln -s /dev/null //etc/systemd/system/udev.service + chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target + #dependency on a device unit fails it specially that we disabled udev + sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service +} download_fedora() { @@ -170,7 +182,8 @@ copy_fedora() update_fedora() { - chroot $cache/rootfs yum -y update + YUM=yum --installroot $cache/rootfs -y --nogpgcheck + $YUM update } install_fedora() @@ -353,7 +366,7 @@ if [ $(id -u) != 0 ]; then fi -rootfs_path=$path/$name/rootfs +rootfs_path=$path/rootfs config_path=$default_path/$name cache=$cache_base/$release @@ -362,7 +375,7 @@ revert() echo Interrupted, so cleaning up lxc-destroy -n $name # maybe was interrupted before copy config - rm -rf $path/$name + rm -rf $path rm -rf $default_path/$name echo exiting... exit 1 @@ -388,6 +401,12 @@ if [ $? -ne 0 ]; then exit 1 fi +type /bin/systemd /dev/null 21 +if [ $? -ne 0 ]; then + configure_fedora_init +else + configure_fedora_systemd +fi if [ ! -z $clean ]; then clean || exit 1 -- 1.7.7.6 there is only problem about systemd not addressed by this script is that it does mount /dev which stops getty from starting on tty1 so either make it start on any tty higher than what your host is using and allow that in your lxc cgroup conf or mount the $rootfs/dev to a different block dev that way systemd won't mount /dev Could the template create a 1M loopback file, /var/lib/lxc/container/dev.loopback, populated with /dev and mounted by a lxc.mount.entry? -serge -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users
Re: [Lxc-users] * fix cached rootfs update * fix rootfs path * add handling of systemd (aka f15)
Yes, I think ideally you'd have a single /var/lib/lxc/fedora-devs mounted from a single loopback or block device, with each container having a /var/lib/lxc/fedora-devs/containername directory, populated, for its dev, bind-mounted in through lxc.mount.entry. -serge Quoting rha...@informatiq.org (rha...@informatiq.org): i can do that but i didn't do it brcause it could be done differently for different backingsrorage I'll do it anyway and send patch later -- Sent from my Nokia N9On 6.3.2012 16:59 Serge Hallyn wrote: Quoting Ramez Hanna (rha...@informatiq.org): On Mon, Mar 5, 2012 at 10:28 PM, rha...@informatiq.org wrote: From: InformatiQ rha...@informatiq.org Signed-off-by: InformatiQ rha...@informatiq.org --- templates/lxc-fedora.in | 35 +++ 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in index e7f42a6..3f50895 100644 --- a/templates/lxc-fedora.in +++ b/templates/lxc-fedora.in @@ -69,11 +69,6 @@ EOF 127.0.0.1 localhost $name EOF - sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit - sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit - chroot ${rootfs_path} chkconfig udev-post off - chroot ${rootfs_path} chkconfig network on - dev_path=${rootfs_path}/dev rm -rf $dev_path mkdir -p $dev_path @@ -99,6 +94,23 @@ EOF return 0 } +configure_fedora_init() +{ + sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit + sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit + chroot ${rootfs_path} chkconfig udev-post off + chroot ${rootfs_path} chkconfig network on +} + +configure_fedora_systemd() +{ + unlink ${rootfs_path}/etc/systemd/system/default.target + touch ${rootfs_path}/etc/fstab + chroot ${rootfs_path} ln -s /dev/null //etc/systemd/system/udev.service + chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target + #dependency on a device unit fails it specially that we disabled udev + sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service +} download_fedora() { @@ -170,7 +182,8 @@ copy_fedora() update_fedora() { - chroot $cache/rootfs yum -y update + YUM=yum --installroot $cache/rootfs -y --nogpgcheck + $YUM update } install_fedora() @@ -353,7 +366,7 @@ if [ $(id -u) != 0 ]; then fi -rootfs_path=$path/$name/rootfs +rootfs_path=$path/rootfs config_path=$default_path/$name cache=$cache_base/$release @@ -362,7 +375,7 @@ revert() echo Interrupted, so cleaning up lxc-destroy -n $name # maybe was interrupted before copy config - rm -rf $path/$name + rm -rf $path rm -rf $default_path/$name echo exiting... exit 1 @@ -388,6 +401,12 @@ if [ $? -ne 0 ]; then exit 1 fi +type /bin/systemd /dev/null 21 +if [ $? -ne 0 ]; then + configure_fedora_init +else + configure_fedora_systemd +fi if [ ! -z $clean ]; then clean || exit 1 -- 1.7.7.6 there is only problem about systemd not addressed by this script is that it does mount /dev which stops getty from starting on tty1 so either make it start on any tty higher than what your host is using and allow that in your lxc cgroup conf or mount the $rootfs/dev to a different block dev that way systemd won't mount /dev Could the template create a 1M loopback file, /var/lib/lxc/container/dev.loopback, populated with /dev and mounted by a lxc.mount.entry? -serge -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users
Re: [Lxc-users] * fix cached rootfs update * fix rootfs path * add handling of systemd (aka f15)
On Tue, Mar 6, 2012 at 5:11 PM, Serge Hallyn serge.hal...@canonical.com wrote: Yes, I think ideally you'd have a single /var/lib/lxc/fedora-devs mounted from a single loopback or block device, with each container having a /var/lib/lxc/fedora-devs/containername directory, populated, for its dev, bind-mounted in through lxc.mount.entry. -serge Quoting rha...@informatiq.org (rha...@informatiq.org): i can do that but i didn't do it brcause it could be done differently for different backingsrorage I'll do it anyway and send patch later -- Sent from my Nokia N9On 6.3.2012 16:59 Serge Hallyn wrote: Quoting Ramez Hanna (rha...@informatiq.org): On Mon, Mar 5, 2012 at 10:28 PM, rha...@informatiq.org wrote: From: InformatiQ rha...@informatiq.org Signed-off-by: InformatiQ rha...@informatiq.org --- templates/lxc-fedora.in | 35 +++ 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in index e7f42a6..3f50895 100644 --- a/templates/lxc-fedora.in +++ b/templates/lxc-fedora.in @@ -69,11 +69,6 @@ EOF 127.0.0.1 localhost $name EOF - sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit - sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit - chroot ${rootfs_path} chkconfig udev-post off - chroot ${rootfs_path} chkconfig network on - dev_path=${rootfs_path}/dev rm -rf $dev_path mkdir -p $dev_path @@ -99,6 +94,23 @@ EOF return 0 } +configure_fedora_init() +{ + sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit + sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit + chroot ${rootfs_path} chkconfig udev-post off + chroot ${rootfs_path} chkconfig network on +} + +configure_fedora_systemd() +{ + unlink ${rootfs_path}/etc/systemd/system/default.target + touch ${rootfs_path}/etc/fstab + chroot ${rootfs_path} ln -s /dev/null //etc/systemd/system/udev.service + chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target + #dependency on a device unit fails it specially that we disabled udev + sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service +} download_fedora() { @@ -170,7 +182,8 @@ copy_fedora() update_fedora() { - chroot $cache/rootfs yum -y update + YUM=yum --installroot $cache/rootfs -y --nogpgcheck + $YUM update } install_fedora() @@ -353,7 +366,7 @@ if [ $(id -u) != 0 ]; then fi -rootfs_path=$path/$name/rootfs +rootfs_path=$path/rootfs config_path=$default_path/$name cache=$cache_base/$release @@ -362,7 +375,7 @@ revert() echo Interrupted, so cleaning up lxc-destroy -n $name # maybe was interrupted before copy config - rm -rf $path/$name + rm -rf $path rm -rf $default_path/$name echo exiting... exit 1 @@ -388,6 +401,12 @@ if [ $? -ne 0 ]; then exit 1 fi +type /bin/systemd /dev/null 21 +if [ $? -ne 0 ]; then + configure_fedora_init +else + configure_fedora_systemd +fi if [ ! -z $clean ]; then clean || exit 1 -- 1.7.7.6 there is only problem about systemd not addressed by this script is that it does mount /dev which stops getty from starting on tty1 so either make it start on any tty higher than what your host is using and allow that in your lxc cgroup conf or mount the $rootfs/dev to a different block dev that way systemd won't mount /dev Could the template create a 1M loopback file, /var/lib/lxc/container/dev.loopback, populated with /dev and mounted by a lxc.mount.entry? -serge creating a loopback file for each container will not work from lxc.conf as lxc won't mount it, it has to be bound to a loopdevice first i was hoping to make it happen with no pre steps any ideas? to avoid manual intervention at all -- BR RH http://informatiq.org -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users
Re: [Lxc-users] * fix cached rootfs update * fix rootfs path * add handling of systemd (aka f15)
Quoting Ramez Hanna (rha...@informatiq.org): creating a loopback file for each container will not work from lxc.conf as lxc won't mount it, it has to be bound to a loopdevice first Adding support for a loopback file (or a qemu-nbd file perhaps) to lxc seems worthwhile. i was hoping to make it happen with no pre steps Agreed that'd be nicer. any ideas? to avoid manual intervention at all Not offhand. Maybe use an overlay or aufs mount of the container's /dev over itself? :) -serge -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users
[Lxc-users] * fix cached rootfs update* fix rootfs path* add handling of systemd (aka f15)
From: InformatiQ rha...@informatiq.org Signed-off-by: InformatiQ rha...@informatiq.org --- templates/lxc-fedora.in | 35 +++ 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in index e7f42a6..3f50895 100644 --- a/templates/lxc-fedora.in +++ b/templates/lxc-fedora.in @@ -69,11 +69,6 @@ EOF 127.0.0.1 localhost $name EOF -sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit -sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit -chroot ${rootfs_path} chkconfig udev-post off -chroot ${rootfs_path} chkconfig network on - dev_path=${rootfs_path}/dev rm -rf $dev_path mkdir -p $dev_path @@ -99,6 +94,23 @@ EOF return 0 } +configure_fedora_init() +{ +sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit +sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit +chroot ${rootfs_path} chkconfig udev-post off +chroot ${rootfs_path} chkconfig network on +} + +configure_fedora_systemd() +{ +unlink ${rootfs_path}/etc/systemd/system/default.target +touch ${rootfs_path}/etc/fstab +chroot ${rootfs_path} ln -s /dev/null //etc/systemd/system/udev.service +chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target +#dependency on a device unit fails it specially that we disabled udev +sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service +} download_fedora() { @@ -170,7 +182,8 @@ copy_fedora() update_fedora() { -chroot $cache/rootfs yum -y update +YUM=yum --installroot $cache/rootfs -y --nogpgcheck +$YUM update } install_fedora() @@ -353,7 +366,7 @@ if [ $(id -u) != 0 ]; then fi -rootfs_path=$path/$name/rootfs +rootfs_path=$path/rootfs config_path=$default_path/$name cache=$cache_base/$release @@ -362,7 +375,7 @@ revert() echo Interrupted, so cleaning up lxc-destroy -n $name # maybe was interrupted before copy config -rm -rf $path/$name +rm -rf $path rm -rf $default_path/$name echo exiting... exit 1 @@ -388,6 +401,12 @@ if [ $? -ne 0 ]; then exit 1 fi +type /bin/systemd /dev/null 21 +if [ $? -ne 0 ]; then +configure_fedora_init +else +configure_fedora_systemd +fi if [ ! -z $clean ]; then clean || exit 1 -- 1.7.7.6 -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users