The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "LXC Fun"
Line 1: | Line 1: | ||
Linux Containers, or LXC, is a Linux feature that allows Linux to run one or more isolated virtual systems (with their own network interfaces, process namespace, user namespace, and power state) using a single Linux kernel on a single server. | Linux Containers, or LXC, is a Linux feature that allows Linux to run one or more isolated virtual systems (with their own network interfaces, process namespace, user namespace, and power state) using a single Linux kernel on a single server. To learn more take a look at the [[LXC]] article. | ||
== Creating containers == | |||
Creating containers is quite easy using lxc-templates. They are located in the /usr/share/lxc/templates directory. You can find there many distributions like archlinux, centos, debian, fedora, opensuse, ubuntu, gentoo and some more. There is also an inofficial funtoo template that can be found at https://github.com/golodhrim/lxc-funtoo/blob/master/lxc-funtoo. The script creates funtoo container, however I was not able to use it with lxc-create script from the lxc utils. | |||
So how do you create other containers? I am going to use a debian container for this purpose. You will have to emerge debootstrap. | |||
<console> | |||
###i## emerge -av debootstrap | |||
* IMPORTANT: 8 news items need reading for repository 'gentoo'. | |||
* Use eselect news to read news items. | |||
These are the packages that would be merged, in order: | |||
Calculating dependencies... done! | |||
[ebuild N ] dev-perl/TimeDate-2.300.0 31 kB | |||
[ebuild N ] app-arch/dpkg-1.17.10 USE="bzip2 lzma nls unicode update-alternatives zlib -dselect {-test}" 4,100 kB | |||
[ebuild N ] dev-util/debootstrap-1.0.59 96 kB | |||
Total: 3 packages (3 new), Size of downloads: 4,226 kB | |||
Would you like to merge these packages? [Yes/No] | |||
</console> | |||
After this you can create your debian container using: | |||
<console> | |||
###i## lxc-create -n vm1 -t debian | |||
debootstrap is /usr/bin/debootstrap | |||
Checking cache download in /var/cache/lxc/debian/rootfs-wheezy-armhf ... | |||
Copying rootfs to /var/lib/lxc/vm1/rootfs...Generating locales (this might take a while)... | |||
en_US.UTF-8... done | |||
Generation complete. | |||
update-rc.d: using dependency based boot sequencing | |||
update-rc.d: using dependency based boot sequencing | |||
update-rc.d: using dependency based boot sequencing | |||
update-rc.d: using dependency based boot sequencing | |||
Creating SSH2 RSA key; this may take some time ... | |||
Creating SSH2 DSA key; this may take some time ... | |||
Creating SSH2 ECDSA key; this may take some time ... | |||
invoke-rc.d: policy-rc.d denied execution of restart. | |||
Timezone in container is not configured. Adjust it manually. | |||
Root password is 'root', please change ! | |||
</console> | |||
=== | |||
[[Category:Virtualization]] | [[Category:Virtualization]] |
Revision as of 16:11, November 14, 2014
Linux Containers, or LXC, is a Linux feature that allows Linux to run one or more isolated virtual systems (with their own network interfaces, process namespace, user namespace, and power state) using a single Linux kernel on a single server. To learn more take a look at the LXC article.
Creating containers
Creating containers is quite easy using lxc-templates. They are located in the /usr/share/lxc/templates directory. You can find there many distributions like archlinux, centos, debian, fedora, opensuse, ubuntu, gentoo and some more. There is also an inofficial funtoo template that can be found at https://github.com/golodhrim/lxc-funtoo/blob/master/lxc-funtoo. The script creates funtoo container, however I was not able to use it with lxc-create script from the lxc utils.
So how do you create other containers? I am going to use a debian container for this purpose. You will have to emerge debootstrap.
root # emerge -av debootstrap * IMPORTANT: 8 news items need reading for repository 'gentoo'. * Use eselect news to read news items. These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild N ] dev-perl/TimeDate-2.300.0 31 kB [ebuild N ] app-arch/dpkg-1.17.10 USE="bzip2 lzma nls unicode update-alternatives zlib -dselect {-test}" 4,100 kB [ebuild N ] dev-util/debootstrap-1.0.59 96 kB Total: 3 packages (3 new), Size of downloads: 4,226 kB Would you like to merge these packages? [Yes/No]
After this you can create your debian container using:
root # lxc-create -n vm1 -t debian debootstrap is /usr/bin/debootstrap Checking cache download in /var/cache/lxc/debian/rootfs-wheezy-armhf ... Copying rootfs to /var/lib/lxc/vm1/rootfs...Generating locales (this might take a while)... en_US.UTF-8... done Generation complete. update-rc.d: using dependency based boot sequencing update-rc.d: using dependency based boot sequencing update-rc.d: using dependency based boot sequencing update-rc.d: using dependency based boot sequencing Creating SSH2 RSA key; this may take some time ... Creating SSH2 DSA key; this may take some time ... Creating SSH2 ECDSA key; this may take some time ... invoke-rc.d: policy-rc.d denied execution of restart. Timezone in container is not configured. Adjust it manually. Root password is 'root', please change !