<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=David455</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=David455"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/David455"/>
	<updated>2026-06-10T00:57:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5901</id>
		<title>Gentoo template creation</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5901"/>
		<updated>2008-05-18T17:53:13Z</updated>

		<summary type="html">&lt;p&gt;David455: /* Create directory for the new VE and unarchive stage3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about making a template cache for OpenVZ VE from Gentoo Linux. The method is basically the same as described in [[Slackware template creation]] article.&lt;br /&gt;
&lt;br /&gt;
===Download stage3===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
===Create directory for the new VE and unarchive stage3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/private/777&lt;br /&gt;
tar -xjf /root/stage3-i686-2008.0_beta2.tar.bz2 -C /vz/private/777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create VE config===&lt;br /&gt;
Now you need to create the configuration file for the VE, 777.conf: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 777 --applyconfig vps.basic --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit VE config===&lt;br /&gt;
&lt;br /&gt;
Add the following to &amp;lt;code&amp;gt;/etc/vz/conf/777.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISTRIBUTION=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
OSTEMPLATE=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make /etc/mtab a symlink to /proc/mounts===&lt;br /&gt;
The VE root filesystem is mounted by the host system, not the guest -- and therefore root fs will not appear in /etc/mtab. It will lead to a non-working df command. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm -f /vz/private/777/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/777/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After replacing &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; with a symlink to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;, you will always have up-to-date information of what is mounted in &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Replace /etc/fstab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;proc /proc proc defaults 0 0&amp;quot; &amp;gt; /vz/private/777/etc/fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need only &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; to be mounted at boot time.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/inittab&amp;lt;/code&amp;gt; and put a hash mark (#) at the beginning of the lines containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;c?:1235:respawn:/sbin/agetty 38400 tty? linux&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents &amp;lt;code&amp;gt;getty&amp;lt;/code&amp;gt; and login from starting on ttys that do not exist in VEs.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/shadow===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/shadow&amp;lt;/code&amp;gt; and change root's password in the first line to an exclamation mark (!): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;root:!:10071:0:::::&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will disable root login until the password is changed with &amp;lt;code&amp;gt;vzctl set VEID --userpasswd root:password&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Disable unneeded init scripts===&lt;br /&gt;
&lt;br /&gt;
The checkroot and consolefont init scripts should not be started inside VEs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/checkroot&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/consolefont&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit /sbin/rc===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/sbin/rc&amp;lt;/code&amp;gt; and put a hash mark (#) at the beginning of line 244 (your line number may be different):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents the VE from attempting to mount &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To ensure that this change isn't automatically overwritten on update, add the following to &amp;lt;code&amp;gt;/vz/private/777/etc/make.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CONFIG_PROTECT = /sbin/rc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;previewnote&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;NOTE: udev-state does not exists anymore!! ../lib/udev/state and ../lib/udev/devices are empty directories now... maybe someone knows how to handle it the right way?&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delete &amp;lt;code&amp;gt;/lib/udev-state/devices.tar.bz2&amp;lt;/code&amp;gt; and create some device nodes needed to enter a VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/lib&lt;br /&gt;
rm udev-state/devices.tar.bz2&lt;br /&gt;
mknod udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod udev/devices/ptmx c 5 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/conf.d/rc&amp;lt;/code&amp;gt; and change the &amp;lt;code&amp;gt;RC_DEVICES&amp;lt;/code&amp;gt; line to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RC_DEVICES=&amp;quot;static&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You have to leave the directory you are in for the next step to be OK, otherwise you will get this error message : &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota : (error) Quota on syscall for 777: Device or resource busy &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota on failed [3] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 777&lt;br /&gt;
vzctl enter 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check running services:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rc-status -a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All services in boot and default runlevels must be started. If everything all right, stop the VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl stop 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Making distfiles and portage tree of the host system available in a VE===&lt;br /&gt;
&lt;br /&gt;
{{Warning|This step is optional and will result in shared files between VEs!  These steps can save space on disk but trade isolation and security... consider your options carefully!}}&lt;br /&gt;
&lt;br /&gt;
To install software into a VE with portage, you should mount &amp;lt;code&amp;gt;/usr/portage&amp;lt;/code&amp;gt; into the VE with the &amp;quot;bind&amp;quot; option. Do the following on the host after the VE is started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/root/777/usr/portage&lt;br /&gt;
mount -o bind /usr/portage /vz/root/777/usr/portage&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; directory resides on a different partition than your &amp;lt;code&amp;gt;/usr/portage&amp;lt;/code&amp;gt; directory, do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount -n -o bind /usr/portage/distfiles /vz/root/777/usr/portage/distfiles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, to install a package into a VE, you just need to enter the VE using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt; and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
emerge package_name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while you have all the needed files in the &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; of host system.&lt;br /&gt;
&lt;br /&gt;
For security reasons, you should have these directories mounted only while installing software into a VE.&lt;br /&gt;
&lt;br /&gt;
{{Note|you have to &amp;lt;code&amp;gt;umount /vz/root/777/usr/portage/distfiles&amp;lt;/code&amp;gt; before trying to stop your VE.}}&lt;br /&gt;
&lt;br /&gt;
===Create the template cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/&lt;br /&gt;
tar czf /vz/template/cache/gentoo.tar.gz *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test the new template cache file===&lt;br /&gt;
&lt;br /&gt;
Create a new VE from the template file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl create 800 --ostemplate gentoo --ipadd 192.168.0.10 --hostname testvps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the VE was created successfully, try to start it: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 800&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it started, and you can ssh in, congratulations, you've got a working Gentoo template!&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Templates]]&lt;br /&gt;
[[Category: Gentoo]]&lt;/div&gt;</summary>
		<author><name>David455</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5900</id>
		<title>Gentoo template creation</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5900"/>
		<updated>2008-05-18T17:44:08Z</updated>

		<summary type="html">&lt;p&gt;David455: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about making a template cache for OpenVZ VE from Gentoo Linux. The method is basically the same as described in [[Slackware template creation]] article.&lt;br /&gt;
&lt;br /&gt;
===Download stage3===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
===Create directory for the new VE and unarchive stage3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/private/777&lt;br /&gt;
tar -xjf /root/stage3-i686-2006.0.tar.bz2 -C /vz/private/777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create VE config===&lt;br /&gt;
Now you need to create the configuration file for the VE, 777.conf: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 777 --applyconfig vps.basic --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit VE config===&lt;br /&gt;
&lt;br /&gt;
Add the following to &amp;lt;code&amp;gt;/etc/vz/conf/777.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISTRIBUTION=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
OSTEMPLATE=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make /etc/mtab a symlink to /proc/mounts===&lt;br /&gt;
The VE root filesystem is mounted by the host system, not the guest -- and therefore root fs will not appear in /etc/mtab. It will lead to a non-working df command. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm -f /vz/private/777/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/777/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After replacing &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; with a symlink to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;, you will always have up-to-date information of what is mounted in &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Replace /etc/fstab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;proc /proc proc defaults 0 0&amp;quot; &amp;gt; /vz/private/777/etc/fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need only &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; to be mounted at boot time.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/inittab&amp;lt;/code&amp;gt; and put a hash mark (#) at the beginning of the lines containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;c?:1235:respawn:/sbin/agetty 38400 tty? linux&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents &amp;lt;code&amp;gt;getty&amp;lt;/code&amp;gt; and login from starting on ttys that do not exist in VEs.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/shadow===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/shadow&amp;lt;/code&amp;gt; and change root's password in the first line to an exclamation mark (!): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;root:!:10071:0:::::&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will disable root login until the password is changed with &amp;lt;code&amp;gt;vzctl set VEID --userpasswd root:password&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Disable unneeded init scripts===&lt;br /&gt;
&lt;br /&gt;
The checkroot and consolefont init scripts should not be started inside VEs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/checkroot&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/consolefont&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit /sbin/rc===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/sbin/rc&amp;lt;/code&amp;gt; and put a hash mark (#) at the beginning of line 244 (your line number may be different):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents the VE from attempting to mount &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To ensure that this change isn't automatically overwritten on update, add the following to &amp;lt;code&amp;gt;/vz/private/777/etc/make.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CONFIG_PROTECT = /sbin/rc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;previewnote&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;NOTE: udev-state does not exists anymore!! ../lib/udev/state and ../lib/udev/devices are empty directories now... maybe someone knows how to handle it the right way?&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delete &amp;lt;code&amp;gt;/lib/udev-state/devices.tar.bz2&amp;lt;/code&amp;gt; and create some device nodes needed to enter a VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/lib&lt;br /&gt;
rm udev-state/devices.tar.bz2&lt;br /&gt;
mknod udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod udev/devices/ptmx c 5 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/conf.d/rc&amp;lt;/code&amp;gt; and change the &amp;lt;code&amp;gt;RC_DEVICES&amp;lt;/code&amp;gt; line to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RC_DEVICES=&amp;quot;static&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You have to leave the directory you are in for the next step to be OK, otherwise you will get this error message : &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota : (error) Quota on syscall for 777: Device or resource busy &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota on failed [3] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 777&lt;br /&gt;
vzctl enter 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check running services:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rc-status -a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All services in boot and default runlevels must be started. If everything all right, stop the VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl stop 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Making distfiles and portage tree of the host system available in a VE===&lt;br /&gt;
&lt;br /&gt;
{{Warning|This step is optional and will result in shared files between VEs!  These steps can save space on disk but trade isolation and security... consider your options carefully!}}&lt;br /&gt;
&lt;br /&gt;
To install software into a VE with portage, you should mount &amp;lt;code&amp;gt;/usr/portage&amp;lt;/code&amp;gt; into the VE with the &amp;quot;bind&amp;quot; option. Do the following on the host after the VE is started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/root/777/usr/portage&lt;br /&gt;
mount -o bind /usr/portage /vz/root/777/usr/portage&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; directory resides on a different partition than your &amp;lt;code&amp;gt;/usr/portage&amp;lt;/code&amp;gt; directory, do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount -n -o bind /usr/portage/distfiles /vz/root/777/usr/portage/distfiles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, to install a package into a VE, you just need to enter the VE using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt; and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
emerge package_name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while you have all the needed files in the &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; of host system.&lt;br /&gt;
&lt;br /&gt;
For security reasons, you should have these directories mounted only while installing software into a VE.&lt;br /&gt;
&lt;br /&gt;
{{Note|you have to &amp;lt;code&amp;gt;umount /vz/root/777/usr/portage/distfiles&amp;lt;/code&amp;gt; before trying to stop your VE.}}&lt;br /&gt;
&lt;br /&gt;
===Create the template cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/&lt;br /&gt;
tar czf /vz/template/cache/gentoo.tar.gz *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test the new template cache file===&lt;br /&gt;
&lt;br /&gt;
Create a new VE from the template file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl create 800 --ostemplate gentoo --ipadd 192.168.0.10 --hostname testvps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the VE was created successfully, try to start it: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 800&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it started, and you can ssh in, congratulations, you've got a working Gentoo template!&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Templates]]&lt;br /&gt;
[[Category: Gentoo]]&lt;/div&gt;</summary>
		<author><name>David455</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5899</id>
		<title>Gentoo template creation</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5899"/>
		<updated>2008-05-18T17:42:28Z</updated>

		<summary type="html">&lt;p&gt;David455: /* Set up udev */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about making a template cache for OpenVZ VE from Gentoo Linux. The method is basically the same as described in [[Slackware template creation]] article.&lt;br /&gt;
&lt;br /&gt;
===Download stage3===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
===Create directory for the new VE and unarchive stage3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/private/777&lt;br /&gt;
tar -xjf /root/stage3-i686-2006.0.tar.bz2 -C /vz/private/777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create VE config===&lt;br /&gt;
Now you need to create the configuration file for the VE, 777.conf: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 777 --applyconfig vps.basic --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit VE config===&lt;br /&gt;
&lt;br /&gt;
Add the following to &amp;lt;code&amp;gt;/etc/vz/conf/777.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISTRIBUTION=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
OSTEMPLATE=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make /etc/mtab a symlink to /proc/mounts===&lt;br /&gt;
The VE root filesystem is mounted by the host system, not the guest -- and therefore root fs will not appear in /etc/mtab. It will lead to a non-working df command. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm -f /vz/private/777/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/777/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After replacing &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; with a symlink to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;, you will always have up-to-date information of what is mounted in &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Replace /etc/fstab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;proc /proc proc defaults 0 0&amp;quot; &amp;gt; /vz/private/777/etc/fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need only &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; to be mounted at boot time.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/inittab&amp;lt;/code&amp;gt;, and put a hash mark (#) at the beginning of the lines containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;c?:1235:respawn:/sbin/agetty 38400 tty? linux&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents &amp;lt;code&amp;gt;getty&amp;lt;/code&amp;gt; and login from starting on ttys that do not exist in VEs.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/shadow===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/shadow&amp;lt;/code&amp;gt;, and change root's password in the first line to an exclamation mark (!): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;root:!:10071:0:::::&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will disable root login until the password is changed with &amp;lt;code&amp;gt;vzctl set VEID --userpasswd root:password&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Disable unneeded init scripts===&lt;br /&gt;
&lt;br /&gt;
The checkroot and consolefont init scripts should not be started inside VEs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/checkroot&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/consolefont&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit /sbin/rc===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/sbin/rc&amp;lt;/code&amp;gt;, and put a hash mark (#) at the beginning of line 244 (your line number may be different):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents the VE from attempting to mount &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To ensure that this change isn't automatically overwritten on update, add the following to &amp;lt;code&amp;gt;/vz/private/777/etc/make.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CONFIG_PROTECT = /sbin/rc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;previewnote&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;NOTE: udev-state does not exists anymore!! ../lib/udev/state and ../lib/udev/devices are empty directories now... maybe someone knows how to handle it the right way?&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delete &amp;lt;code&amp;gt;/lib/udev-state/devices.tar.bz2&amp;lt;/code&amp;gt; and create some device nodes needed to enter a VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/lib&lt;br /&gt;
rm udev-state/devices.tar.bz2&lt;br /&gt;
mknod udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod udev/devices/ptmx c 5 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/conf.d/rc&amp;lt;/code&amp;gt; and change the &amp;lt;code&amp;gt;RC_DEVICES&amp;lt;/code&amp;gt; line to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RC_DEVICES=&amp;quot;static&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You have to leave the directory you are in for the next step to be OK, otherwise you will get this error message : &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota : (error) Quota on syscall for 777: Device or resource busy &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota on failed [3] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 777&lt;br /&gt;
vzctl enter 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check running services:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rc-status -a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All services in boot and default runlevels must be started. If everything all right, stop the VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl stop 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Making distfiles and portage tree of the host system available in a VE===&lt;br /&gt;
&lt;br /&gt;
{{Warning|This step is optional and will result in shared files between VEs!  These steps can save space on disk but trade isolation and security... consider your options carefully!}}&lt;br /&gt;
&lt;br /&gt;
To install software into a VE with portage, you should mount &amp;lt;code&amp;gt;/usr/portage&amp;lt;/code&amp;gt; into the VE with the &amp;quot;bind&amp;quot; option. Do the following on the host after the VE is started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/root/777/usr/portage&lt;br /&gt;
mount -o bind /usr/portage /vz/root/777/usr/portage&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; directory resides on a different partition than your &amp;lt;code&amp;gt;/usr/portage&amp;lt;/code&amp;gt; directory, do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount -n -o bind /usr/portage/distfiles /vz/root/777/usr/portage/distfiles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, to install a package into a VE, you just need to enter the VE using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt; and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
emerge package_name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while you have all the needed files in the &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; of host system.&lt;br /&gt;
&lt;br /&gt;
For security reasons, you should have these directories mounted only while installing software into a VE.&lt;br /&gt;
&lt;br /&gt;
{{Note|you have to &amp;lt;code&amp;gt;umount /vz/root/777/usr/portage/distfiles&amp;lt;/code&amp;gt; before trying to stop your VE.}}&lt;br /&gt;
&lt;br /&gt;
===Create the template cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/&lt;br /&gt;
tar czf /vz/template/cache/gentoo.tar.gz *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test the new template cache file===&lt;br /&gt;
&lt;br /&gt;
Create a new VE from the template file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl create 800 --ostemplate gentoo --ipadd 192.168.0.10 --hostname testvps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the VE was created successfully, try to start it: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 800&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it started, and you can ssh in, congratulations, you've got a working Gentoo template!&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Templates]]&lt;br /&gt;
[[Category: Gentoo]]&lt;/div&gt;</summary>
		<author><name>David455</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5898</id>
		<title>Gentoo template creation</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5898"/>
		<updated>2008-05-18T17:27:49Z</updated>

		<summary type="html">&lt;p&gt;David455: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about making a template cache for OpenVZ VE from Gentoo Linux. The method is basically the same as described in [[Slackware template creation]] article.&lt;br /&gt;
&lt;br /&gt;
===Download stage3===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
===Create directory for the new VE and unarchive stage3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/private/777&lt;br /&gt;
tar -xjf /root/stage3-i686-2006.0.tar.bz2 -C /vz/private/777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create VE config===&lt;br /&gt;
Now you need to create the configuration file for the VE, 777.conf: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 777 --applyconfig vps.basic --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit VE config===&lt;br /&gt;
&lt;br /&gt;
Add the following to &amp;lt;code&amp;gt;/etc/vz/conf/777.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISTRIBUTION=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
OSTEMPLATE=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make /etc/mtab a symlink to /proc/mounts===&lt;br /&gt;
The VE root filesystem is mounted by the host system, not the guest -- and therefore root fs will not appear in /etc/mtab. It will lead to a non-working df command. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm -f /vz/private/777/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/777/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After replacing &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; with a symlink to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;, you will always have up-to-date information of what is mounted in &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Replace /etc/fstab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;proc /proc proc defaults 0 0&amp;quot; &amp;gt; /vz/private/777/etc/fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need only &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; to be mounted at boot time.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/inittab&amp;lt;/code&amp;gt;, and put a hash mark (#) at the beginning of the lines containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;c?:1235:respawn:/sbin/agetty 38400 tty? linux&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents &amp;lt;code&amp;gt;getty&amp;lt;/code&amp;gt; and login from starting on ttys that do not exist in VEs.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/shadow===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/shadow&amp;lt;/code&amp;gt;, and change root's password in the first line to an exclamation mark (!): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;root:!:10071:0:::::&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will disable root login until the password is changed with &amp;lt;code&amp;gt;vzctl set VEID --userpasswd root:password&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Disable unneeded init scripts===&lt;br /&gt;
&lt;br /&gt;
The checkroot and consolefont init scripts should not be started inside VEs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/checkroot&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/consolefont&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit /sbin/rc===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/sbin/rc&amp;lt;/code&amp;gt;, and put a hash mark (#) at the beginning of line 244 (your line number may be different):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents the VE from attempting to mount &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To ensure that this change isn't automatically overwritten on update, add the following to &amp;lt;code&amp;gt;/vz/private/777/etc/make.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CONFIG_PROTECT = /sbin/rc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;previewnote&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;NOTE: udev-state does not exists anymore!! ../lib/udev/state and ../lib/udev/devices are empty directories now... maybe someone knows how to handle it the right way?&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter a VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/lib&lt;br /&gt;
rm udev-state/devices.tar.bz2&lt;br /&gt;
mknod udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod udev/devices/ptmx c 5 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Set RC_DEVICES=&amp;quot;static&amp;quot; in /vz/private/777/etc/conf.d/rc&lt;br /&gt;
&lt;br /&gt;
You have to leave the directory you are in for the next step to be ok, otherwise you will get this error message : &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota : (error) Quota on syscall for 777: Device or resource busy &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota on failed [3] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 777&lt;br /&gt;
vzctl enter 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check running services:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rc-status -a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All services in boot and default runlevels must be started. If everything all right, stop the VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl stop 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Making distfiles and portage tree of the host system available in a VE===&lt;br /&gt;
&lt;br /&gt;
{{Warning|This step is optional and will result in shared files between VEs!  These steps can save space on disk but trade isolation and security... consider your options carefully!}}&lt;br /&gt;
&lt;br /&gt;
To install software into a VE with portage, you should mount &amp;lt;code&amp;gt;/usr/portage&amp;lt;/code&amp;gt; into the VE with the &amp;quot;bind&amp;quot; option. Do the following on the host after the VE is started:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/root/777/usr/portage&lt;br /&gt;
mount -o bind /usr/portage /vz/root/777/usr/portage&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; directory resides on a different partition than your &amp;lt;code&amp;gt;/usr/portage&amp;lt;/code&amp;gt; directory, do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount -n -o bind /usr/portage/distfiles /vz/root/777/usr/portage/distfiles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, to install a package into a VE, you just need to enter the VE using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt; and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
emerge package_name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while you have all the needed files in the &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; of host system.&lt;br /&gt;
&lt;br /&gt;
For security reasons, you should have these directories mounted only while installing software into a VE.&lt;br /&gt;
&lt;br /&gt;
{{Note|you have to &amp;lt;code&amp;gt;umount /vz/root/777/usr/portage/distfiles&amp;lt;/code&amp;gt; before trying to stop your VE.}}&lt;br /&gt;
&lt;br /&gt;
===Create the template cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/&lt;br /&gt;
tar czf /vz/template/cache/gentoo.tar.gz *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test the new template cache file===&lt;br /&gt;
&lt;br /&gt;
Create a new VE from the template file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl create 800 --ostemplate gentoo --ipadd 192.168.0.10 --hostname testvps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the VE was created successfully, try to start it: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 800&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it started, and you can ssh in, congratulations, you've got a working Gentoo template!&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Templates]]&lt;br /&gt;
[[Category: Gentoo]]&lt;/div&gt;</summary>
		<author><name>David455</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5897</id>
		<title>Gentoo template creation</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5897"/>
		<updated>2008-05-18T16:14:42Z</updated>

		<summary type="html">&lt;p&gt;David455: /* Download stage3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about making a template cache for OpenVZ VE from Gentoo Linux. The method is basically the same as described in [[Slackware template creation]] article.&lt;br /&gt;
&lt;br /&gt;
===Download stage3===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
===Create directory for the new VE and unarchive stage3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/private/777&lt;br /&gt;
tar -xjf /root/stage3-i686-2006.0.tar.bz2 -C /vz/private/777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create VE config===&lt;br /&gt;
Now you need to create the configuration file for the VE, 777.conf: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 777 --applyconfig vps.basic --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit config===&lt;br /&gt;
&lt;br /&gt;
Add to the /etc/vz/conf/777.conf:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISTRIBUTION=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
OSTEMPLATE=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make /etc/mtab a symlink to /proc/mounts===&lt;br /&gt;
The VE root filesystem is mounted by the host system, not the guest -- and therefore root fs will not appear in /etc/mtab. It will lead to df command non-working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm -f /vz/private/777/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/777/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After replacing /etc/mtab with a symlink to /proc/mounts, you will always have up-to-date information of what is mounted in /etc/mtab.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/fstab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;proc /proc proc defaults 0 0&amp;quot; &amp;gt; /vz/private/777/etc/fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need only &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; to be mounted at the boot time.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/inittab&amp;lt;/code&amp;gt;, putting a hashmark (#) before the lines containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;c?:1235:respawn:/sbin/agetty 38400 tty? linux&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents from starting &amp;lt;code&amp;gt;getty&amp;lt;/code&amp;gt; and login on ttys that does not exist in VEs.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/shadow===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/shadow&amp;lt;/code&amp;gt;, change root's password in the first line to an exclamation mark (!): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;root:!:10071:0:::::&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will disable the root login until the password changed with &amp;lt;code&amp;gt;vzctl set VEID --userpasswd root:password&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Disable unneeded init scripts===&lt;br /&gt;
&lt;br /&gt;
The checkroot and consolefont init scripts should not be started inside VEs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/checkroot&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/consolefont&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit /sbin/rc===&lt;br /&gt;
&lt;br /&gt;
Comment out line number 244 in /vz/private/777/sbin/rc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents the VE from attempting to mount &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To ensure that these changes aren't automatically overwritten on update, add the following to /vz/private/777/etc/make.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CONFIG_PROTECT = /sbin/rc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;previewnote&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;NOTE: udev-state does not exists anymore!! ../lib/udev/state and ../lib/udev/devices are empty directories now... maybe someone knows how to handle it the right way?&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter a VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/lib&lt;br /&gt;
rm udev-state/devices.tar.bz2&lt;br /&gt;
mknod udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod udev/devices/ptmx c 5 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Set RC_DEVICES=&amp;quot;static&amp;quot; in /vz/private/777/etc/conf.d/rc&lt;br /&gt;
&lt;br /&gt;
You have to leave the directory you are in for the next step to be ok, otherwise you will get this error message : &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota : (error) Quota on syscall for 777: Device or resource busy &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota on failed [3] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 777&lt;br /&gt;
vzctl enter 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check running services.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rc-status -a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All services in boot and default runlevels must be started. If everything all right, stop it&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl stop 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make distfiles and portage tree of the host system available in a VE===&lt;br /&gt;
&lt;br /&gt;
{{Warning|This step is optional and will result in shared files between VEs!  These steps can save space on disk but trade isolation and security... consider your options carefully!}}&lt;br /&gt;
&lt;br /&gt;
To install software into a VE with portage you should mount /usr/portage into VE with &amp;quot;bind&amp;quot; option. Do this after VE starts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/root/777/usr/portage&lt;br /&gt;
mount -o bind /usr/portage /vz/root/777/usr/portage&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your /usr/portage/distfiles placed on the other partition do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount -n -o bind /usr/portage/distfiles /vz/root/777/usr/portage/distfiles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, to install package into a VE you just need enter there by &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt; and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
emerge package_name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while you have all the needed files in the &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; of host system.&lt;br /&gt;
&lt;br /&gt;
For security reasons hold this directories mounted only while you are installing software into a VE.&lt;br /&gt;
&lt;br /&gt;
{{Note|you have to &amp;lt;code&amp;gt;umount /vz/root/777/usr/portage/distfiles&amp;lt;/code&amp;gt; before trying to stop your VE.}}&lt;br /&gt;
&lt;br /&gt;
===Create the cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/&lt;br /&gt;
tar czf /vz/template/cache/gentoo.tar.gz *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test the new cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl create 800 --ostemplate gentoo --ipadd 192.168.0.10 --hostname testvps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If created successfully, try to start it: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 800&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it started, and you can ssh in, congratulations, you've got a working Gentoo template!&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Templates]]&lt;br /&gt;
[[Category: Gentoo]]&lt;/div&gt;</summary>
		<author><name>David455</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5896</id>
		<title>Gentoo template creation</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5896"/>
		<updated>2008-05-18T16:03:11Z</updated>

		<summary type="html">&lt;p&gt;David455: /* Edit /sbin/rc */ Update to reflect current /sbin/rc file and some minor edits&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about making a template cache for OpenVZ VE from Gentoo Linux. The method is basically the same as described in [[Slackware template creation]] article.&lt;br /&gt;
&lt;br /&gt;
===Download stage3===&lt;br /&gt;
&lt;br /&gt;
We shall make the template from stage3 file. OpenVZ OS template should be an archive of root of the 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.&lt;br /&gt;
&lt;br /&gt;
===Create directory for the new VE and unarchive stage3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/private/777&lt;br /&gt;
tar -xjf /root/stage3-i686-2006.0.tar.bz2 -C /vz/private/777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create VE config===&lt;br /&gt;
Now you need to create the configuration file for the VE, 777.conf: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 777 --applyconfig vps.basic --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit config===&lt;br /&gt;
&lt;br /&gt;
Add to the /etc/vz/conf/777.conf:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISTRIBUTION=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
OSTEMPLATE=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make /etc/mtab a symlink to /proc/mounts===&lt;br /&gt;
The VE root filesystem is mounted by the host system, not the guest -- and therefore root fs will not appear in /etc/mtab. It will lead to df command non-working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm -f /vz/private/777/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/777/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After replacing /etc/mtab with a symlink to /proc/mounts, you will always have up-to-date information of what is mounted in /etc/mtab.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/fstab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;proc /proc proc defaults 0 0&amp;quot; &amp;gt; /vz/private/777/etc/fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need only &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; to be mounted at the boot time.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/inittab&amp;lt;/code&amp;gt;, putting a hashmark (#) before the lines containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;c?:1235:respawn:/sbin/agetty 38400 tty? linux&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents from starting &amp;lt;code&amp;gt;getty&amp;lt;/code&amp;gt; and login on ttys that does not exist in VEs.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/shadow===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/shadow&amp;lt;/code&amp;gt;, change root's password in the first line to an exclamation mark (!): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;root:!:10071:0:::::&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will disable the root login until the password changed with &amp;lt;code&amp;gt;vzctl set VEID --userpasswd root:password&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Disable unneeded init scripts===&lt;br /&gt;
&lt;br /&gt;
The checkroot and consolefont init scripts should not be started inside VEs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/checkroot&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/consolefont&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit /sbin/rc===&lt;br /&gt;
&lt;br /&gt;
Comment out line number 244 in /vz/private/777/sbin/rc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents the VE from attempting to mount &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To ensure that these changes aren't automatically overwritten on update, add the following to /vz/private/777/etc/make.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CONFIG_PROTECT = /sbin/rc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;previewnote&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;NOTE: udev-state does not exists anymore!! ../lib/udev/state and ../lib/udev/devices are empty directories now... maybe someone knows how to handle it the right way?&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter a VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/lib&lt;br /&gt;
rm udev-state/devices.tar.bz2&lt;br /&gt;
mknod udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod udev/devices/ptmx c 5 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Set RC_DEVICES=&amp;quot;static&amp;quot; in /vz/private/777/etc/conf.d/rc&lt;br /&gt;
&lt;br /&gt;
You have to leave the directory you are in for the next step to be ok, otherwise you will get this error message : &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota : (error) Quota on syscall for 777: Device or resource busy &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota on failed [3] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 777&lt;br /&gt;
vzctl enter 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check running services.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rc-status -a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All services in boot and default runlevels must be started. If everything all right, stop it&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl stop 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make distfiles and portage tree of the host system available in a VE===&lt;br /&gt;
&lt;br /&gt;
{{Warning|This step is optional and will result in shared files between VEs!  These steps can save space on disk but trade isolation and security... consider your options carefully!}}&lt;br /&gt;
&lt;br /&gt;
To install software into a VE with portage you should mount /usr/portage into VE with &amp;quot;bind&amp;quot; option. Do this after VE starts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/root/777/usr/portage&lt;br /&gt;
mount -o bind /usr/portage /vz/root/777/usr/portage&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your /usr/portage/distfiles placed on the other partition do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount -n -o bind /usr/portage/distfiles /vz/root/777/usr/portage/distfiles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, to install package into a VE you just need enter there by &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt; and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
emerge package_name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while you have all the needed files in the &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; of host system.&lt;br /&gt;
&lt;br /&gt;
For security reasons hold this directories mounted only while you are installing software into a VE.&lt;br /&gt;
&lt;br /&gt;
{{Note|you have to &amp;lt;code&amp;gt;umount /vz/root/777/usr/portage/distfiles&amp;lt;/code&amp;gt; before trying to stop your VE.}}&lt;br /&gt;
&lt;br /&gt;
===Create the cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/&lt;br /&gt;
tar czf /vz/template/cache/gentoo.tar.gz *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test the new cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl create 800 --ostemplate gentoo --ipadd 192.168.0.10 --hostname testvps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If created successfully, try to start it: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 800&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it started, and you can ssh in, congratulations, you've got a working Gentoo template!&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Templates]]&lt;br /&gt;
[[Category: Gentoo]]&lt;/div&gt;</summary>
		<author><name>David455</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5895</id>
		<title>Gentoo template creation</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=5895"/>
		<updated>2008-05-18T15:49:16Z</updated>

		<summary type="html">&lt;p&gt;David455: /* Edit /etc/init.d/checkroot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about making a template cache for OpenVZ VE from Gentoo Linux. The method is basically the same as described in [[Slackware template creation]] article.&lt;br /&gt;
&lt;br /&gt;
===Download stage3===&lt;br /&gt;
&lt;br /&gt;
We shall make the template from stage3 file. OpenVZ OS template should be an archive of root of the 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.&lt;br /&gt;
&lt;br /&gt;
===Create directory for the new VE and unarchive stage3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/private/777&lt;br /&gt;
tar -xjf /root/stage3-i686-2006.0.tar.bz2 -C /vz/private/777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create VE config===&lt;br /&gt;
Now you need to create the configuration file for the VE, 777.conf: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 777 --applyconfig vps.basic --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit config===&lt;br /&gt;
&lt;br /&gt;
Add to the /etc/vz/conf/777.conf:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISTRIBUTION=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
OSTEMPLATE=&amp;quot;gentoo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make /etc/mtab a symlink to /proc/mounts===&lt;br /&gt;
The VE root filesystem is mounted by the host system, not the guest -- and therefore root fs will not appear in /etc/mtab. It will lead to df command non-working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm -f /vz/private/777/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/777/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After replacing /etc/mtab with a symlink to /proc/mounts, you will always have up-to-date information of what is mounted in /etc/mtab.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/fstab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;proc /proc proc defaults 0 0&amp;quot; &amp;gt; /vz/private/777/etc/fstab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need only &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; to be mounted at the boot time.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/inittab&amp;lt;/code&amp;gt;, putting a hashmark (#) before the lines containing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;c?:1235:respawn:/sbin/agetty 38400 tty? linux&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents from starting &amp;lt;code&amp;gt;getty&amp;lt;/code&amp;gt; and login on ttys that does not exist in VEs.&lt;br /&gt;
&lt;br /&gt;
===Edit /etc/shadow===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/vz/private/777/etc/shadow&amp;lt;/code&amp;gt;, change root's password in the first line to an exclamation mark (!): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;root:!:10071:0:::::&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will disable the root login until the password changed with &amp;lt;code&amp;gt;vzctl set VEID --userpasswd root:password&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Disable unneeded init scripts===&lt;br /&gt;
&lt;br /&gt;
The checkroot and consolefont init scripts should not be started inside VEs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/checkroot&lt;br /&gt;
rm /vz/private/777/etc/runlevels/boot/consolefont&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Edit /sbin/rc===&lt;br /&gt;
&lt;br /&gt;
Comment line number 141 in /vz/private/777/sbin/rc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;try mount -n ${mntcmd:--t sysfs sysfs /sys}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prevents from attepting to mount &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To ensure these changes aren't automatically overwritten on update, add the following to /vz/private/777/etc/make.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CONFIG_PROTECT = /sbin/rc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;previewnote&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;NOTE: udev-state does not exists anymore!! ../lib/udev/state and ../lib/udev/devices are empty directories now... maybe someone knows how to handle it the right way?&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter a VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/lib&lt;br /&gt;
rm udev-state/devices.tar.bz2&lt;br /&gt;
mknod udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod udev/devices/ptmx c 5 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Set RC_DEVICES=&amp;quot;static&amp;quot; in /vz/private/777/etc/conf.d/rc&lt;br /&gt;
&lt;br /&gt;
You have to leave the directory you are in for the next step to be ok, otherwise you will get this error message : &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota : (error) Quota on syscall for 777: Device or resource busy &amp;lt;br&amp;gt;&lt;br /&gt;
vzquota on failed [3] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 777&lt;br /&gt;
vzctl enter 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check running services.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rc-status -a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All services in boot and default runlevels must be started. If everything all right, stop it&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl stop 777&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Make distfiles and portage tree of the host system available in a VE===&lt;br /&gt;
&lt;br /&gt;
{{Warning|This step is optional and will result in shared files between VEs!  These steps can save space on disk but trade isolation and security... consider your options carefully!}}&lt;br /&gt;
&lt;br /&gt;
To install software into a VE with portage you should mount /usr/portage into VE with &amp;quot;bind&amp;quot; option. Do this after VE starts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /vz/root/777/usr/portage&lt;br /&gt;
mount -o bind /usr/portage /vz/root/777/usr/portage&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your /usr/portage/distfiles placed on the other partition do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount -n -o bind /usr/portage/distfiles /vz/root/777/usr/portage/distfiles&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, to install package into a VE you just need enter there by &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt; and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
emerge package_name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while you have all the needed files in the &amp;lt;code&amp;gt;/usr/portage/distfiles&amp;lt;/code&amp;gt; of host system.&lt;br /&gt;
&lt;br /&gt;
For security reasons hold this directories mounted only while you are installing software into a VE.&lt;br /&gt;
&lt;br /&gt;
{{Note|you have to &amp;lt;code&amp;gt;umount /vz/root/777/usr/portage/distfiles&amp;lt;/code&amp;gt; before trying to stop your VE.}}&lt;br /&gt;
&lt;br /&gt;
===Create the cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /vz/private/777/&lt;br /&gt;
tar czf /vz/template/cache/gentoo.tar.gz *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test the new cache file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl create 800 --ostemplate gentoo --ipadd 192.168.0.10 --hostname testvps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If created successfully, try to start it: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl start 800&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it started, and you can ssh in, congratulations, you've got a working Gentoo template!&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Templates]]&lt;br /&gt;
[[Category: Gentoo]]&lt;/div&gt;</summary>
		<author><name>David455</name></author>
		
	</entry>
</feed>