Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Gentoo template creation

2,850 bytes added, 15:23, 12 March 2016
no edit summary
== Download stage3 ==
We will make the template from a stage3 file. An OpenVZ OS template should be an archive (.tar.gz) of the root of a working system, but without the kernel and some files. You can download stage3 from the nearest mirror here: from http://www.gentoo.org/main/en/mirrors.xml.or here [directly from http://distfiles.gentoo.org/releases/x86/current-stage3/]
---- == Or try to Download 64 bit stage3 == If you experience with 32bit containers you can also try to create Gentoo template with 64bits binary support. Try to download '''64bit''' stage3. For 64bit Gentoo template creation, search for nearest mirrors http://www.gentoo.org/main/en/mirrors.xml or directly from: http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3/ with 32bit binary '''multilib''' support, or  http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3/hardened/ (stage3-amd64-hardened+nomultilib-20xxxxxx.tar.bz2) try the hardend profile without multilib support (only 64bit binary support for gentoo template containers!!)  Don't forget that hostnode must support 64bit binary too, with or without 32bit multilib support!! Hostnodes that supports multilib can start 64bits containers with 32bits containers but with a '''''slight''''' performance degradation. Don't forget to look for:<pre>ACCEPT_KEYWORDS="amd64" in /etc/make.conf</pre> there you can accept 64bit binary packages support for your containers.<pre>cat /proc/cpuinfo</pre> for 64 bits Intel\AMD CPU instructions set support.  '''WARNING''': There is no warrantied that template should work, you can bugtack the errors. But I haven't confronted with problem. == Create directory directories for the new container and unarchive stage3 ==
<pre>
mkdir /vz/root/1001
mkdir /vz/private/1001
tar -xjf xvjpf /root/stage3-i686-20111213.tar.bz2 -C /vz/private/1001
</pre>
</pre>
Gentoo users wil see warning, but nothing to wary worry just ignore it
<pre>
WARNING: /etc/vz/conf/1001.conf not found: No such file or directory
</pre>
If you get the following error, you need to change the file /etc/vz/vz.conf to "VE_LAYOUT=simfs". Unfortunately, I couldn't find a solution for ploop.
<pre>
# vzctl set 1001 --applyconfig basic --save
Error in ploop_open_dd (di.c:288): Can't resolve /vz/private/1001/root.hdd/DiskDescriptor.xml: No such file or directory
Failed to read /vz/private/1001/root.hdd/DiskDescriptor.xml
Error: failed to apply some parameters, not saving configuration file!
</pre>
== Edit CT Config ==
Add the following First, you need to <code>/etc/vz/conf/1001.conf</code>let vzctl know that this CT is using Gentoo:<pre> echo 'OSTEMPLATE="gentoo"' >>/etc/vz/conf/1001.conf</pre>
Creation of container at end of this HowTo obeys quota limits and might exceed
those limits set in <code>vps.basic</code> by default (at least encountered with Gentoo
10.1 release). Thus it might be required to increase limits now. The following
values are providing 2 GiByte GB soft limit with 2.5 GiByte GB hard limit:<pre> DISKSPACE="20971522.4G:2.5G" If you use independed Gentoo portage tree for each container, is considered correct in the use of gentoo containers, don't forget to raise inodes number  DISKINODES="400000:2621440420000"</pre>You should also increase the ram to a minimum of 512 MB. Otherwise, you will get errors during compilation. Since vzctl 3.0.30 you can do:  vzctl set 1001 --ram 512M --swap 1G --save Prior to vzctl 3.0.30 you have to do, which gives you 512 MB guaranteed and 1024 MB burstable:  vzctl set 1001 --vmguarpages 512M --save vzctl set 1001 --oomguarpages 512M --save vzctl set 1001 --privvmpages 512M:1024M --save vzctl set 1001 --swappages 0:1024M --save
But if you using Independed Gentoo 11portage tree for each container would be good idea, because newer portage can delete older ebuilds already installed in container with other dependences.2 release and future Otherwise you can skip 't reinstall already installed packages if you bind the increasing the disk space limits, by deafult you have 2 GiByte soft limit and 2.3 GiByte hard limitnewer version of portage in gentoo containers.
After that you copy that configuration file turning it into a sample configuration for later use:
<pre> # cp /etc/vz/conf/1001.conf /etc/vz/conf/ve-gentoo.conf-sample</pre>
== Make /etc/mtab a symlink to /proc/mounts ==
</pre>
Gentoo 11.2 release have an option in /vz/private/1001/etc/'''rc.conf'''
just uncoment rc_sys and type "openvz" and it disables init scripts
<pre>
nano /vz/private/1001/etc/rc.conf
rc_sys="openvz"
</pre>
</pre>
'''Baselayout 2 and OpenRC:''' <code>/vz/private/1001/etc/conf.d/rc</code> is obsolete (http://www.gentoo.org/doc/en/openrc-migration.xml#doc_chap2_sect2) and <code>/vz/private/1001/etc/rc.conf</code> should be used instead. But, RC_DEVICES is missing in <code>/vz/private/1001/etc/rc.conf</code>?!?
If you want to enable udev read on.
If you decide not to share portage with host as described before, you'll still need a portage installed into your container.
Get latest snapshot of portage tree from your favourite mirror (http://www.gentoo.org/main/en/mirrors.xml) and extract it into <code>/vz/private/7771001/usr</code>:
<pre>
# wget <your-mirro>http://distfiles.gentoo.org/releases/snapshots/current/portage-latest.tar.bz2# tar xjf portage-latest.tar.bz2 -C /vz/private/7771001/usr
</pre>
Add the following strings to the <code>/vz/private/7771001/etc/make.conf</code>:
<pre>
</pre>
You should update host-node portage tree on regular basis to keep it up to date because <code>emerge --sync</code> won't work inside guest container.
== Create the template cache file ==
<pre>
cd /vz/private/7771001/
tar --numeric-owner -czf /vz/template/cache/gentoo.tar.gz *
</pre>
4
edits