<?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=Rtanner</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=Rtanner"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Rtanner"/>
	<updated>2026-06-13T17:46:12Z</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=2409</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=2409"/>
		<updated>2006-10-13T14:02:09Z</updated>

		<summary type="html">&lt;p&gt;Rtanner: /* 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 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.&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;
===Edit /etc/init.d/checkroot===&lt;br /&gt;
&lt;br /&gt;
We have to clean this script and make them dummy, because we don't need mount or check root. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;gt; /vz/private/777/etc/init.d/checkroot&lt;br /&gt;
#!/sbin/runscript&lt;br /&gt;
depend()&lt;br /&gt;
{&lt;br /&gt;
  echo&lt;br /&gt;
}&lt;br /&gt;
start()&lt;br /&gt;
{&lt;br /&gt;
  echo&lt;br /&gt;
}&lt;br /&gt;
end()&lt;br /&gt;
{&lt;br /&gt;
  echo&lt;br /&gt;
}&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;
===Set up udev===&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;
===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;
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 -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;/div&gt;</summary>
		<author><name>Rtanner</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=1981</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=1981"/>
		<updated>2006-08-15T07:39:22Z</updated>

		<summary type="html">&lt;p&gt;Rtanner: /* 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 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 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.&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;
===Edit /etc/init.d/checkroot===&lt;br /&gt;
&lt;br /&gt;
We have to clean this script and make them dummy, because we don't need mount or check root. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;gt; /vz/private/777/etc/init.d/checkroot&lt;br /&gt;
#!/sbin/runscript&lt;br /&gt;
depend()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
start()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
end()&lt;br /&gt;
{&lt;br /&gt;
}&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;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter VPS:&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;
===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;
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 -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;
===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;/div&gt;</summary>
		<author><name>Rtanner</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=1980</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=1980"/>
		<updated>2006-08-15T07:36:00Z</updated>

		<summary type="html">&lt;p&gt;Rtanner: /* 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 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 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.&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;
===Edit /etc/init.d/checkroot===&lt;br /&gt;
&lt;br /&gt;
We have to clean this script and make them dummy, because we don't need mount or check root. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;gt; /vz/private/777/etc/init.d/checkroot&lt;br /&gt;
#!/sbin/runscript&lt;br /&gt;
depend()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
start()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
end()&lt;br /&gt;
{&lt;br /&gt;
}&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;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter VPS:&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;
===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;
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 -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;
===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;/div&gt;</summary>
		<author><name>Rtanner</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=1979</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=1979"/>
		<updated>2006-08-15T07:33:10Z</updated>

		<summary type="html">&lt;p&gt;Rtanner: /* Edit /sbin/rc */&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 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.&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;
===Edit /etc/init.d/checkroot===&lt;br /&gt;
&lt;br /&gt;
We have to clean this script and make them dummy, because we don't need mount or check root. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;gt; /vz/private/777/etc/init.d/checkroot&lt;br /&gt;
#!/sbin/runscript&lt;br /&gt;
depend()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
start()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
end()&lt;br /&gt;
{&lt;br /&gt;
}&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;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter VPS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /lib/udev-state/devices.tar.bz2&lt;br /&gt;
mknod /lib/udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod /lib/udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod /lib/udev/devices/ptmx c 5 2&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;
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 -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;
===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;/div&gt;</summary>
		<author><name>Rtanner</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=1978</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=1978"/>
		<updated>2006-08-15T07:31:15Z</updated>

		<summary type="html">&lt;p&gt;Rtanner: /* 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 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.&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;
===Edit /etc/init.d/checkroot===&lt;br /&gt;
&lt;br /&gt;
We have to clean this script and make them dummy, because we don't need mount or check root. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;gt; /vz/private/777/etc/init.d/checkroot&lt;br /&gt;
#!/sbin/runscript&lt;br /&gt;
depend()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
start()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
end()&lt;br /&gt;
{&lt;br /&gt;
}&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:&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;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter VPS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /lib/udev-state/devices.tar.bz2&lt;br /&gt;
mknod /lib/udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod /lib/udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod /lib/udev/devices/ptmx c 5 2&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;
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 -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;
===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;/div&gt;</summary>
		<author><name>Rtanner</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=1977</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=1977"/>
		<updated>2006-08-15T07:30:20Z</updated>

		<summary type="html">&lt;p&gt;Rtanner: /* Edit inittab */&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 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.&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;
===Edit /etc/init.d/checkroot===&lt;br /&gt;
&lt;br /&gt;
We have to clean this script and make them dummy, because we don't need mount or check root. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;gt; /etc/init.d/checkroot&lt;br /&gt;
#!/sbin/runscript&lt;br /&gt;
depend()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
start()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
end()&lt;br /&gt;
{&lt;br /&gt;
}&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:&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;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter VPS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /lib/udev-state/devices.tar.bz2&lt;br /&gt;
mknod /lib/udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod /lib/udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod /lib/udev/devices/ptmx c 5 2&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;
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 -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;
===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;/div&gt;</summary>
		<author><name>Rtanner</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=1976</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=1976"/>
		<updated>2006-08-15T07:29:36Z</updated>

		<summary type="html">&lt;p&gt;Rtanner: /* Edit /etc/fstab */&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 inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/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.&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;
===Edit /etc/init.d/checkroot===&lt;br /&gt;
&lt;br /&gt;
We have to clean this script and make them dummy, because we don't need mount or check root. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;gt; /etc/init.d/checkroot&lt;br /&gt;
#!/sbin/runscript&lt;br /&gt;
depend()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
start()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
end()&lt;br /&gt;
{&lt;br /&gt;
}&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:&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;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter VPS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /lib/udev-state/devices.tar.bz2&lt;br /&gt;
mknod /lib/udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod /lib/udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod /lib/udev/devices/ptmx c 5 2&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;
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 -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;
===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;/div&gt;</summary>
		<author><name>Rtanner</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Gentoo_template_creation&amp;diff=1975</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=1975"/>
		<updated>2006-08-15T07:29:06Z</updated>

		<summary type="html">&lt;p&gt;Rtanner: /* Make /etc/mtab a symlink to /proc/mounts */&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 mounted at the boot time.&lt;br /&gt;
&lt;br /&gt;
===Edit inittab===&lt;br /&gt;
&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/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.&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;
===Edit /etc/init.d/checkroot===&lt;br /&gt;
&lt;br /&gt;
We have to clean this script and make them dummy, because we don't need mount or check root. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;gt; /etc/init.d/checkroot&lt;br /&gt;
#!/sbin/runscript&lt;br /&gt;
depend()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
start()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
end()&lt;br /&gt;
{&lt;br /&gt;
}&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:&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;
===Set up udev===&lt;br /&gt;
&lt;br /&gt;
Delete /lib/udev-state/devices.tar.bz2 and create some device nodes needed to enter VPS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm /lib/udev-state/devices.tar.bz2&lt;br /&gt;
mknod /lib/udev/devices/ttyp0 c 3 0&lt;br /&gt;
mknod /lib/udev/devices/ptyp0 c 2 0&lt;br /&gt;
mknod /lib/udev/devices/ptmx c 5 2&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;
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 -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;
===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;/div&gt;</summary>
		<author><name>Rtanner</name></author>
		
	</entry>
</feed>