cloudstack-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francois Gaudreault <>
Subject Re: LXC template
Date Wed, 02 Apr 2014 15:07:29 GMT
On 2014-04-02, 1:34 AM, Chinu wrote:
> Hello all,
>      Please can someone advice how to create an LXC template image  in tar format to
spawn containers in KVM for Cloudstack version 4.2 or 4.3
> Regards,
> Chinu
I have that. This is for a CentOS image. I apologize for the formatting, 
I am using text emails ;)

On your *HOST* run:

|mkdir||/var/lib/libvirt/lxc/centos-6-x86_64/etc/yum||.repos.d/ -p |
|yum groupinstall core 
--installroot=||/var/lib/libvirt/lxc/centos-6-x86_64/||--nogpgcheck -y|
|yum||install||plymouth libselinux-python 
--installroot=||/var/lib/libvirt/lxc/centos-6-x86_64/||--nogpgcheck -y|

On your *CHROOTED* container:
|echo||password |||passwd||root --stdin|
|#Fix root login on console|
|sed||-i s/||"session required close"||/||"#session 
required close"||/g||/etc/pam||.d||/login|
|sed||-i s/||"session required open"||/||"#session 
required open"||/g||/etc/pam||.d||/login|
|sed||-i s/||"session required"||/||"#session 
|#Configuring basic networking|
|cat||>||/etc/sysconfig/network||<< EOF|
|cat||>||/etc/sysconfig/network-scripts/ifcfg-eth0||<< EOF|
|#Enabling sshd|
|chkconfig sshd on|
|# Fixing root login for sshd|
|sed||-i s/||"session required close"||/||"#session 
required close"||/g||/etc/pam||.d||/sshd|
|sed||-i s/||"session required"||/||"#session 
|sed||-i s/||"session required open 
env_params"||/||"#session required open 
|cat||>||/etc/fstab||<< END|
|/dev/root| |/ rootfs   defaults        0 0|
|none ||/dev/shm| |tmpfs nosuid,nodev    0 0|
|cat||>||/etc/init/lxc-sysinit||.conf << END|
|start on startup|
|pre-start script|
|||initctl start||tty||TTY=console|
|||telinit 3|
|end script|
|#Exit the chroot|

Tar it:
|tar||cvf centos-6-x86_64_lxc.||tar||.

Upload to CloudStack and enjoy!

Francois Gaudreault
Architecte de Solution Cloud | Cloud Solutions Architect
- - -
420 rue Guy
Montréal QC  H3J 1S6

View raw message