Editing Gentoo template creation

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 3: Line 3:
 
== Download stage3 ==
 
== 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 from http://www.gentoo.org/main/en/mirrors.xml
+
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: http://www.gentoo.org/main/en/mirrors.xml.
or directly from http://distfiles.gentoo.org/releases/x86/current-stage3/
+
or here [http://distfiles.gentoo.org/releases/x86/current-stage3/
 +
]
  
----
+
== Create directory for the new container and unarchive 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 directories for the new container and unarchive stage3 ==
 
  
 
<pre>
 
<pre>
mkdir /vz/root/1001
 
 
mkdir /vz/private/1001
 
mkdir /vz/private/1001
tar -xvjpf /root/stage3-i686-20111213.tar.bz2 -C /vz/private/1001
+
tar -xjf /root/stage3-i686-20111213.tar.bz2 -C /vz/private/1001
 
</pre>
 
</pre>
  
Line 42: Line 21:
 
</pre>
 
</pre>
  
Gentoo users wil see warning, but nothing to worry just ignore it
+
Gentoo users wil see warning, but nothing to wary just ignore it
 
<pre>
 
<pre>
 
WARNING: /etc/vz/conf/1001.conf not found: No such file or directory
 
WARNING: /etc/vz/conf/1001.conf not found: No such file or directory
 
</pre>
 
</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.
+
== Edit CT Config ==
 +
 
 +
Add the following to <code>/etc/vz/conf/1001.conf</code>:
 
<pre>
 
<pre>
# vzctl set 1001 --applyconfig basic --save
+
echo 'OSTEMPLATE="gentoo"' >>/etc/vz/conf/1001.conf
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>
 
</pre>
== Edit CT Config ==
 
 
First, you need to let vzctl know that this CT is using Gentoo:
 
 
echo 'OSTEMPLATE="gentoo"' >> /etc/vz/conf/1001.conf
 
  
 
Creation of container at end of this HowTo obeys quota limits and might exceed  
 
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  
 
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  
 
10.1 release). Thus it might be required to increase limits now. The following  
values are providing 2 GB soft limit with 2.5 GB hard limit:
+
values are providing 2 GiByte soft limit with 2.5 GiByte hard limit:
 
+
<pre>
DISKSPACE="2.4G:2.5G"
+
DISKSPACE="2097152:2621440"
 
+
</pre>
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:420000"
 
 
 
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
 
  
Independed Gentoo portage tree for each container would be good idea, because newer portage can delete older ebuilds already installed in container with other dependences.
+
But if you using Gentoo 11.2 release and future you can skip the increasing the disk space limits, by deafult you have 2 GiByte soft limit and 2.3 GiByte hard limit.
Otherwise you can't reinstall already installed packages if you bind the newer version of portage in gentoo containers.
 
  
 
After that you copy that configuration file turning it into a sample configuration for later use:
 
After that you copy that configuration file turning it into a sample configuration for later use:
  
# cp /etc/vz/conf/1001.conf /etc/vz/conf/ve-gentoo.conf-sample
+
<pre>
 +
# cp /etc/vz/conf/1001.conf /etc/vz/conf/ve-gentoo.conf-sample
 +
</pre>
  
 
== Make /etc/mtab a symlink to /proc/mounts ==
 
== Make /etc/mtab a symlink to /proc/mounts ==
Line 149: Line 109:
  
 
The checkroot and consolefont init scripts should not be started inside containers:
 
The checkroot and consolefont init scripts should not be started inside containers:
(NOT! for Gentoo 11.2)
+
 
 
<pre>
 
<pre>
 
rm /vz/private/1001/etc/runlevels/boot/checkroot
 
rm /vz/private/1001/etc/runlevels/boot/checkroot
 
rm /vz/private/1001/etc/runlevels/boot/consolefont
 
rm /vz/private/1001/etc/runlevels/boot/consolefont
</pre>
 
 
Gentoo 11.2 release have an option in '''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>
  
 
== Edit /sbin/rc ==
 
== Edit /sbin/rc ==
  
Edit <code>/vz/private/1001/sbin/rc</code> and put a hash mark (#) at the beginning of line 244 (your line number may be different):
+
Edit <code>/vz/private/777/sbin/rc</code> and put a hash mark (#) at the beginning of line 244 (your line number may be different):
  
 
<pre># try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}</pre>
 
<pre># try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}</pre>
Line 170: Line 123:
 
This prevents the container from attempting to mount <code>/sys</code>.
 
This prevents the container from attempting to mount <code>/sys</code>.
  
To ensure that this change isn't automatically overwritten on update, add the following to <code>/vz/private/1001/etc/make.conf</code>:
+
To ensure that this change isn't automatically overwritten on update, add the following to <code>/vz/private/777/etc/make.conf</code>:
  
 
<pre>CONFIG_PROTECT="/sbin/rc"</pre>
 
<pre>CONFIG_PROTECT="/sbin/rc"</pre>
 
'''Gentoo 11.2''' <code>/vz/private/1001/sbin/rc</code> is '''binary''', i just skipped this post
 
  
 
== Set up udev ==
 
== Set up udev ==
Line 181: Line 132:
 
For example sshd will fail to start since /dev/random and /dev/urandom are missing.
 
For example sshd will fail to start since /dev/random and /dev/urandom are missing.
 
So it's recommended to disable udev.
 
So it's recommended to disable udev.
Edit <code>/vz/private/1001/etc/conf.d/rc</code> or <code>/vz/private/1001/etc/conf.d/udev</code> if you using Gentoo 11.2 or future and change the <code>RC_DEVICES</code> line to:
+
Edit <code>/vz/private/777/etc/conf.d/rc</code> and change the <code>RC_DEVICES</code> line to:
 
<pre>
 
<pre>
 
RC_DEVICES="static"
 
RC_DEVICES="static"
 
</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 want to enable udev read on.
Line 193: Line 143:
  
 
<pre>
 
<pre>
cd /vz/private/1001/lib
+
cd /vz/private/777/lib
 
mknod udev/devices/ttyp0 c 3 0
 
mknod udev/devices/ttyp0 c 3 0
 
mknod udev/devices/ptyp0 c 2 0
 
mknod udev/devices/ptyp0 c 2 0
Line 199: Line 149:
 
</pre>
 
</pre>
  
Edit <code>/vz/private/1001/etc/conf.d/rc</code> or <code>/vz/private/1001/etc/conf.d/udev</code> if you using Gentoo 11.2 or future and change the <code>RC_DEVICES</code> and <code>RC_DEVICE_TARBALL</code> lines to:
+
Edit <code>/vz/private/777/etc/conf.d/rc</code> and change the <code>RC_DEVICES</code> and <code>RC_DEVICE_TARBALL</code> lines to:
  
 
<pre>
 
<pre>
Line 207: Line 157:
  
 
You have to leave the directory you are in for the next step to be OK, otherwise you will get this error message:
 
You have to leave the directory you are in for the next step to be OK, otherwise you will get this error message:
  vzquota : (error) Quota on syscall for 1001: Device or resource busy
+
  vzquota : (error) Quota on syscall for 777: Device or resource busy
 
  vzquota on failed [3]
 
  vzquota on failed [3]
  
Line 217: Line 167:
  
 
Some changes are required for successful setting user's password with <code>vzctl</code> util.
 
Some changes are required for successful setting user's password with <code>vzctl</code> util.
Edit <code>/vz/private/1001/etc/pam.d/chpasswd</code> and change the <code>password</code> lines to:
+
Edit <code>/vz/private/777/etc/pam.d/chpasswd</code> and change the <code>password</code> lines to:
  
 
<pre>
 
<pre>
Line 226: Line 176:
  
 
<pre>
 
<pre>
vzctl start 1001
+
vzctl start 777
vzctl enter 1001
+
vzctl enter 777
 
</pre>
 
</pre>
  
Line 249: Line 199:
  
 
<pre>
 
<pre>
vzctl stop 1001
+
vzctl stop 777
 
</pre>
 
</pre>
  
Line 259: Line 209:
  
 
<pre>
 
<pre>
mkdir /vz/root/1001/usr/portage
+
mkdir /vz/root/777/usr/portage
mount -o bind /usr/portage /vz/root/1001/usr/portage
+
mount -o bind /usr/portage /vz/root/777/usr/portage
 
</pre>
 
</pre>
  
Line 266: Line 216:
  
 
<pre>
 
<pre>
mount -n -o bind /usr/portage/distfiles /vz/root/1001/usr/portage/distfiles
+
mount -n -o bind /usr/portage/distfiles /vz/root/777/usr/portage/distfiles
 
</pre>
 
</pre>
  
Line 279: Line 229:
 
For security reasons, you should have these directories mounted only while installing software into a container.
 
For security reasons, you should have these directories mounted only while installing software into a container.
  
{{Note|you have to <code>umount /vz/root/1001/usr/portage/distfiles</code> before trying to stop your container.}}
+
{{Note|you have to <code>umount /vz/root/777/usr/portage/distfiles</code> before trying to stop your container.}}
 +
 
  
 
== Dedicated installation of portage ==
 
== Dedicated installation of portage ==
Line 285: Line 236:
 
If you decide not to share portage with host as described before, you'll still need a portage installed into your container.
 
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/1001/usr</code>:
+
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/777/usr</code>:
  
 
<pre>
 
<pre>
# wget http://distfiles.gentoo.org/releases/snapshots/current/portage-latest.tar.bz2
+
# wget <your-mirro>/snapshots/portage-latest.tar.bz2
# tar xjf portage-latest.tar.bz2 -C /vz/private/1001/usr
+
# tar xjf portage-latest.tar.bz2 -C /vz/private/777/usr
 
</pre>
 
</pre>
  
Line 314: Line 265:
  
  
Add the following strings to the <code>/vz/private/1001/etc/make.conf</code>:
+
Add the following strings to the <code>/vz/private/777/etc/make.conf</code>:
  
 
<pre>
 
<pre>
Line 321: Line 272:
 
</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.
+
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 ==
 
== Create the template cache file ==
  
 
<pre>
 
<pre>
cd /vz/private/1001/
+
cd /vz/private/777/
 
tar --numeric-owner -czf /vz/template/cache/gentoo.tar.gz *
 
tar --numeric-owner -czf /vz/template/cache/gentoo.tar.gz *
 
</pre>
 
</pre>

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: