Thanks Daniel for suggestion, i have made changes in my xml script.
I am able to set up lxc container on fedora 18
i created a container using yum
yum --installroot=/containers/cont1 --releasever=18 install -y httpd
openssh, bridge-utils, dhclient
cont1.xml
<domain type="lxc">
<name>cont1</name>
<vcpu placement="static">1</vcpu>
<cputune>
<shares>1024</shares>
<period>1000000</period>
</cputune>
<memtune>
<hard_limit unit="M">256</hard_limit>
<soft_limit unit="M">32</soft_limit>
<min_guarantee unit="M">64</min_guarantee>
</memtune>
<blkiotune>
<weight>800</weight>
</blkiotune>
<memory unit="KiB">102400</memory>
<os>
<type>exe</type>
<init>/bin/lxc_defaultinit.sh</init>
</os>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<filesystem accessmode="passthrough" type="mount">
<source dir="/containers/cont1/"/>
<target dir="/"/>
</filesystem>
<interface type="bridge">
<source bridge="br0"/>
</interface>
<console port="0" type="pty"/>
</devices>
</domain>
Network setting at host
/etc/sysconfig/network-script/ifcfg-p2p1
TYPE="Ethernet"
DEVICE="p2p1"
BOOTPROTO="dhcp"
ONBOOT="yes"
BRIDGE="br0"
NM_CONTROLLED="no"
/etc/sysconfig/network-script/ifcfg-br0
DEVICE="br0"
TYPE="Bridge"
USERCTL="no"
ONBOOT="yes"
BOOTPROTO="dhcp"
NM_CONTROLLED="no"
Network setting at Guest
/containers/cont1/etc/sysconfig/network-script/ifcfg-eth0
TYPE="Ethernet"
DEVICE="eth0"
BOOTPROTO="static"
ONBOOT="yes"
GATEWAY=172.26.126.254
IPADDR=172.26.126.204
at host
/etc/fstab
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts defaults 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
none /sys/fs/cgroup cgroup defaults 0 0
at guest
/containers/bin/lxc-defaultinit.sh
#!/bin/bash
export
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib
export PS1="[\u@\h \W]\$ "
export HOME="/root"
mount -t devtmpfs none /dev
mount -t devpts none /dev/pts
mount -t tmpfs none /dev/shm
mount -t sysfs none /sys
/etc/init.d/network start
exec /bin/bash
On Wed, Jul 31, 2013 at 3:03 PM, Daniel P. Berrange <berrange(a)redhat.com>wrote:
On Wed, Jul 31, 2013 at 12:46:58PM +0530, Aarti Sawant wrote:
> hello,
>
> i am new to lxc, i have created a lxc container on fedora 19
> i created a container rootfs of fedora 19 by using
> yum --installroot=/containers/test1 --releasever=19 install openssh
>
> test1.xml file for container test1
> <domain type="lxc">
> <name>test1</name>
> <vcpu placement="static">1</vcpu>
> <cputune>
> <shares>1024</shares>
> <period>1000000</period>
> </cputune>
> <memtune>
> <hard_limit unit="M">1024</hard_limit>
> <soft_limit unit="M">128</soft_limit>
> <min_guarantee unit="M">64</min_guarantee>
> </memtune>
> <blkiotune>
> <weight>800</weight>
> </blkiotune>
> <memory unit="KiB">102400</memory>
> <os>
> <type>exe</type>
> <init>/bin/bash</init>
> </os>
> <clock offset="utc"/>
> <on_poweroff>destroy</on_poweroff>
> <on_reboot>restart</on_reboot>
> <on_crash>destroy</on_crash>
> <devices>
> <emulator>/usr/libexec/libvirt_lxc</emulator>
> <filesystem accessmode="passthrough" type="mount">
> <source dir="/containers/test1/"/>
> <target dir="/"/>
> </filesystem>
> <filesystem accessmode="passthrough" type="mount">
> <source dir="/containers/test1/var"/>
> <target dir="/var"/>
> </filesystem>
....snip more <filesystem> elements...
Why are you adding all these sub-mounts for /var, /dev, etc, etc?
You installed the entire OS tree into /containers/test1, so it
should be sufficient to just have that first <filesystem>
entry for '/'. You'd only want to add extra mounts for
/var, etc if the directory on the host came from somewhere
outside the /containers/test1 location.
NB, also libvirt sets up /dev - you shouldn't try to
override it, or you'll loose access to the pre-populate
device nodes, which is probably what's causing your
failure.
> <interface type="bridge">
> <source bridge="br0"/>
> </interface>
> <console port="0" type="pty"/>
> </devices>
> </domain>
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/:|
|:
http://libvirt.org -o-
http://virt-manager.org:|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/:|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc:|