<?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=Ysidoro</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=Ysidoro"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Ysidoro"/>
	<updated>2026-06-13T17:47:39Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Using_private_IPs_for_Hardware_Nodes&amp;diff=6770</id>
		<title>Using private IPs for Hardware Nodes</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Using_private_IPs_for_Hardware_Nodes&amp;diff=6770"/>
		<updated>2008-12-01T01:55:32Z</updated>

		<summary type="html">&lt;p&gt;Ysidoro: /* Create On-umount script for remove HW → CT route(s) */  where to put vps.umount script&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article describes how to assign public IPs to containers running on OVZ Hardware Nodes in case you have a following network topology:&lt;br /&gt;
&lt;br /&gt;
[[Image:PrivateIPs_fig1.gif|An initial network topology]]&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
This configuration was tested on a RHEL5 OpenVZ Hardware Node and a container based on a Fedora Core 5 template.&lt;br /&gt;
Other host OSs and templates might require some configuration changes, please add corresponding OS specific changes if you've faced any.&lt;br /&gt;
&lt;br /&gt;
This article assumes the presence of 'brctl', 'ip' and 'ifconfig' utils. You may need to install missing packages like 'bridge-utils'/'iproute'/'net-tools' or others which contain those utilities.&lt;br /&gt;
&lt;br /&gt;
This article assumes you have already [[Quick installation|installed OpenVZ]],&lt;br /&gt;
prepared the [[OS template cache]](s) and have&lt;br /&gt;
[[Basic_operations_in_OpenVZ_environment|container(s) created]]. If not, follow the links to perform the steps needed.&lt;br /&gt;
{{Note|don't assign an IP after container creation.}}&lt;br /&gt;
&lt;br /&gt;
== An OVZ Hardware Node has the only one Ethernet interface ==&lt;br /&gt;
(assume eth0)&lt;br /&gt;
&lt;br /&gt;
=== Hardware Node configuration ===&lt;br /&gt;
&lt;br /&gt;
==== Create a bridge device ====&lt;br /&gt;
 [HN]# brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
==== Remove an IP from eth0 interface ====&lt;br /&gt;
 [HN]# ifconfig eth0 0&lt;br /&gt;
&lt;br /&gt;
==== Add eth0 interface into the bridge ====&lt;br /&gt;
 [HN]# brctl addif br0 eth0&lt;br /&gt;
 &lt;br /&gt;
==== Assign the IP to the bridge ====&lt;br /&gt;
(the same that was assigned on eth0 earlier)&lt;br /&gt;
 [HN]# ifconfig br0 10.0.0.2/24&lt;br /&gt;
&lt;br /&gt;
==== Resurrect the default routing ====&lt;br /&gt;
 [HN]# ip route add default via 10.0.0.1 dev br0&lt;br /&gt;
 &lt;br /&gt;
{{Warning|if you are '''configuring''' the node '''remotely''' you '''must''' prepare a '''script''' with the above commands and run it in background with the redirected output or you'll '''lose the access''' to the Node.}}&lt;br /&gt;
&lt;br /&gt;
==== A script example ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[HN]# cat /tmp/br_add &lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
brctl addbr br0&lt;br /&gt;
ifconfig eth0 0 &lt;br /&gt;
brctl addif br0 eth0 &lt;br /&gt;
ifconfig br0 10.0.0.2/24 &lt;br /&gt;
ip route add default via 10.0.0.1 dev br0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 [HN]# /tmp/br_add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;br /&gt;
&lt;br /&gt;
=== Container configuration ===&lt;br /&gt;
&lt;br /&gt;
==== Start a container ====&lt;br /&gt;
 [HN]# vzctl start 101&lt;br /&gt;
&lt;br /&gt;
==== Add a [[Virtual_Ethernet_device|veth interface]] to the container ====&lt;br /&gt;
 [HN]# vzctl set 101 --netif_add eth0 --save&lt;br /&gt;
&lt;br /&gt;
==== Set up an IP to the newly created container's veth interface ====&lt;br /&gt;
 [HN]# vzctl exec 101 ifconfig eth0 85.86.87.195/26&lt;br /&gt;
 &lt;br /&gt;
==== Add the container's veth interface to the bridge ====&lt;br /&gt;
 [HN]# brctl addif br0 veth101.0&lt;br /&gt;
&lt;br /&gt;
{{Note|There will be a delay of about 15 seconds(default for 2.6.18 kernel) while the bridge software runs STP to detect loops and transitions the veth interface to the forwarding state.&lt;br /&gt;
&amp;lt;!-- /sys/class/net/$BR_NAME/bridge/forward_delay in SEC*USER_HZ --&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Set up the default route for the container ====&lt;br /&gt;
 [HN]# vzctl exec 101 ip route add default via 85.86.87.193 dev eth0&lt;br /&gt;
 &lt;br /&gt;
==== (Optional) Add CT↔HN routes ====&lt;br /&gt;
The above configuration provides the following connections:&lt;br /&gt;
* CT X ↔ CT Y (where CT X and CT Y can locate on any OVZ HN)&lt;br /&gt;
* CT   ↔ Internet&lt;br /&gt;
&lt;br /&gt;
Note that&lt;br /&gt;
&lt;br /&gt;
* The accessability of the CT from the HN depends on the local gateway providing NAT (probably - yes)&lt;br /&gt;
&lt;br /&gt;
* The accessability of the HN from the CT depends on the ISP gateway being aware of the local network (probably not)&lt;br /&gt;
&lt;br /&gt;
So to provide CT ↔ HN accessibility despite the gateways' configuration you can add the following routes:&lt;br /&gt;
&lt;br /&gt;
 [HN]# ip route add 85.86.87.195 dev br0&lt;br /&gt;
 [HN]# vzctl exec 101 ip route add 10.0.0.2 dev eth0&lt;br /&gt;
&lt;br /&gt;
=== Resulting OpenVZ Node configuration ===&lt;br /&gt;
[[Image:PrivateIPs_fig2.gif|Resulting OpenVZ Node configuration]]&lt;br /&gt;
&lt;br /&gt;
=== Making the configuration persistent ===&lt;br /&gt;
&lt;br /&gt;
==== Set up a bridge on a HN ====&lt;br /&gt;
This can be done by configuring the &amp;lt;code&amp;gt;ifcfg-*&amp;lt;/code&amp;gt; files located in &amp;lt;code&amp;gt;/etc/sysconfig/network-scripts/&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Assuming you had a configuration file (e.g. &amp;lt;code&amp;gt;ifcfg-eth0&amp;lt;/code&amp;gt;) like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DEVICE=eth0&lt;br /&gt;
ONBOOT=yes&lt;br /&gt;
IPADDR=10.0.0.2&lt;br /&gt;
NETMASK=255.255.255.0&lt;br /&gt;
GATEWAY=10.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To automatically create bridge &amp;lt;code&amp;gt;br0&amp;lt;/code&amp;gt;  you can create &amp;lt;code&amp;gt;ifcfg-br0&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DEVICE=br0&lt;br /&gt;
TYPE=Bridge&lt;br /&gt;
ONBOOT=yes&lt;br /&gt;
IPADDR=10.0.0.2&lt;br /&gt;
NETMASK=255.255.255.0&lt;br /&gt;
GATEWAY=10.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and edit &amp;lt;code&amp;gt;ifcfg-eth0&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;eth0&amp;lt;/code&amp;gt; interface into the bridge &amp;lt;code&amp;gt;br0&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DEVICE=eth0&lt;br /&gt;
ONBOOT=yes&lt;br /&gt;
BRIDGE=br0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Edit the container's configuration ====&lt;br /&gt;
Add these parameters to the &amp;lt;code&amp;gt;/etc/vz/conf/$CTID.conf&amp;lt;/code&amp;gt; file which will be used during the network configuration:&lt;br /&gt;
* Add/change &amp;lt;code&amp;gt;CONFIG_CUSTOMIZED=&amp;quot;yes&amp;quot;&amp;lt;/code&amp;gt; (indicates that a custom&lt;br /&gt;
  script should be run on a container start)&lt;br /&gt;
* Add &amp;lt;code&amp;gt;VETH_IP_ADDRESS=&amp;quot;IP/MASK&amp;quot;&amp;lt;/code&amp;gt; (a container can have multiple&lt;br /&gt;
  IPs separated by spaces)&lt;br /&gt;
* Add &amp;lt;code&amp;gt;VE_DEFAULT_GATEWAY=&amp;quot;CT DEFAULT GATEWAY&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Add &amp;lt;code&amp;gt;BRIDGEDEV=&amp;quot;BRIDGE NAME&amp;quot;&amp;lt;/code&amp;gt; (a bridge name to which the&lt;br /&gt;
  container veth interface should be added)&lt;br /&gt;
&lt;br /&gt;
An example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Network customization section&lt;br /&gt;
CONFIG_CUSTOMIZED=&amp;quot;yes&amp;quot;&lt;br /&gt;
VETH_IP_ADDRESS=&amp;quot;85.86.87.195/26&amp;quot;&lt;br /&gt;
VE_DEFAULT_GATEWAY=&amp;quot;85.86.87.193&amp;quot;&lt;br /&gt;
BRIDGEDEV=&amp;quot;br0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create a custom network configuration script ====&lt;br /&gt;
which should be called each time a container is started (e.g. &amp;lt;code&amp;gt;/usr/sbin/vznetcfg.custom&amp;lt;/code&amp;gt;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# /usr/sbin/vznetcfg.custom&lt;br /&gt;
# a script to bring up bridged network interfaces (veth's) in a container&lt;br /&gt;
&lt;br /&gt;
GLOBALCONFIGFILE=/etc/vz/vz.conf&lt;br /&gt;
CTCONFIGFILE=/etc/vz/conf/$VEID.conf&lt;br /&gt;
vzctl=/usr/sbin/vzctl&lt;br /&gt;
brctl=/usr/sbin/brctl&lt;br /&gt;
ip=/sbin/ip&lt;br /&gt;
ifconfig=/sbin/ifconfig&lt;br /&gt;
. $GLOBALCONFIGFILE&lt;br /&gt;
. $CTCONFIGFILE&lt;br /&gt;
&lt;br /&gt;
NETIF_OPTIONS=`echo $NETIF | sed 's/,/\n/g'`&lt;br /&gt;
for str in $NETIF_OPTIONS; do \&lt;br /&gt;
        # getting 'ifname' parameter value&lt;br /&gt;
        if  echo &amp;quot;$str&amp;quot; | grep -o &amp;quot;^ifname=&amp;quot; ; then&lt;br /&gt;
                # remove the parameter name from the string (along with '=')&lt;br /&gt;
                CTIFNAME=${str#*=};&lt;br /&gt;
        fi&lt;br /&gt;
        # getting 'host_ifname' parameter value&lt;br /&gt;
        if  echo &amp;quot;$str&amp;quot; | grep -o &amp;quot;^host_ifname=&amp;quot; ; then&lt;br /&gt;
                # remove the parameter name from the string (along with '=')&lt;br /&gt;
                VZHOSTIF=${str#*=};&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ ! -n &amp;quot;$VETH_IP_ADDRESS&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;According to $CONFIGFILE CT$VEID has no veth IPs configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ ! -n &amp;quot;$VZHOSTIF&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;According to $CONFIGFILE CT$VEID has no veth interface configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ ! -n &amp;quot;$CTIFNAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Corrupted $CONFIGFILE: no 'ifname' defined for host_ifname $VZHOSTIF.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Initializing interface $VZHOSTIF for CT$VEID.&amp;quot;&lt;br /&gt;
$ifconfig $VZHOSTIF 0&lt;br /&gt;
&lt;br /&gt;
CTROUTEDEV=$VZHOSTIF&lt;br /&gt;
&lt;br /&gt;
if [ -n &amp;quot;$BRIDGEDEV&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Adding interface $VZHOSTIF to the bridge $BRIDGEDEV.&amp;quot;&lt;br /&gt;
   CTROUTEDEV=$BRIDGEDEV&lt;br /&gt;
   $brctl addif $BRIDGEDEV $VZHOSTIF&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Up the interface $CTIFNAME link in CT$VEID&lt;br /&gt;
$vzctl exec $VEID $ip link set $CTIFNAME up&lt;br /&gt;
&lt;br /&gt;
for IP in $VETH_IP_ADDRESS; do&lt;br /&gt;
   echo &amp;quot;Adding an IP $IP to the $CTIFNAME for CT$VEID.&amp;quot;&lt;br /&gt;
   $vzctl exec $VEID $ip address add $IP dev $CTIFNAME&lt;br /&gt;
&lt;br /&gt;
   # removing the netmask&lt;br /&gt;
   IP_STRIP=${IP%%/*};&lt;br /&gt;
&lt;br /&gt;
   echo &amp;quot;Adding a route from CT0 to CT$VEID using $IP_STRIP.&amp;quot;&lt;br /&gt;
   $ip route add $IP_STRIP dev $CTROUTEDEV&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -n &amp;quot;$CT0_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Adding a route from CT$VEID to CT0.&amp;quot;&lt;br /&gt;
   $vzctl exec $VEID $ip route add $CT0_IP dev $CTIFNAME&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ -n &amp;quot;$VE_DEFAULT_GATEWAY&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Setting $VE_DEFAULT_GATEWAY as a default gateway for CT$VEID.&amp;quot;&lt;br /&gt;
   $vzctl exec $VEID \&lt;br /&gt;
        $ip route add default via $VE_DEFAULT_GATEWAY dev $CTIFNAME&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;small&amp;gt;Note: this script can be easily extended to work for multiple triples &amp;amp;lt;bridge, ip address, veth device&amp;amp;gt;, see http://vireso.blogspot.com/2008/02/2-veth-with-2-brindges-on-openvz-at.html &amp;lt;/small&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Make the script to be run on a container start ====&lt;br /&gt;
In order to run above script on a container start create the file&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/vz/vznet.conf&amp;lt;/code&amp;gt; with the following contents:&lt;br /&gt;
&lt;br /&gt;
 EXTERNAL_SCRIPT=&amp;quot;/usr/sbin/vznetcfg.custom&amp;quot;&lt;br /&gt;
&lt;br /&gt;
{{Note|&amp;lt;code&amp;gt;/usr/sbin/vznetcfg.custom&amp;lt;/code&amp;gt; should be executable (chmod +x /usr/sbin/vznetcfg.custom)}}&lt;br /&gt;
&lt;br /&gt;
{{Note|When CT is stoped there are HW → CT route(s) still present in route table. We can use On-umount script for solve this.}}&lt;br /&gt;
&lt;br /&gt;
==== Create On-umount script for remove HW → CT route(s) ====&lt;br /&gt;
which should be called each time a container with VEID (&amp;lt;code&amp;gt;/etc/sysconfig/vz/$VEID.umount&amp;lt;/code&amp;gt;), or any container (&amp;lt;code&amp;gt;/etc/sysconfig/vz/vps.umount&amp;lt;/code&amp;gt;) is stoped.&lt;br /&gt;
&lt;br /&gt;
On a Debian system you can have per VE mount/umount scripts /etc/vz/conf/${VEID}.{mount|umount}&lt;br /&gt;
or mount/umount scripts which all VEs will run /etc/vz/conf/vps.{mount|umount}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# /etc/sysconfig/vz/$VEID.umount or /etc/sysconfig/vz/vps.umount&lt;br /&gt;
# a script to remove routes to container with veth-bridge from bridge &lt;br /&gt;
&lt;br /&gt;
CTCONFIGFILE=/etc/vz/conf/$VEID.conf&lt;br /&gt;
ip=/sbin/ip&lt;br /&gt;
. $CTCONFIGFILE&lt;br /&gt;
&lt;br /&gt;
if [ ! -n &amp;quot;$VETH_IP_ADDRESS&amp;quot; ]; then&lt;br /&gt;
   exit 0&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ ! -n &amp;quot;$BRIDGEDEV&amp;quot; ]; then&lt;br /&gt;
   exit 0&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
for IP in $VETH_IP_ADDRESS; do&lt;br /&gt;
   # removing the netmask&lt;br /&gt;
   IP_STRIP=${IP%%/*};&lt;br /&gt;
   &lt;br /&gt;
   echo &amp;quot;Remove a route from CT0 to CT$VEID using $IP_STRIP.&amp;quot;&lt;br /&gt;
   $ip route del $IP_STRIP dev $BRIDGEDEV&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|The script should be executable (chmod +x /etc/sysconfig/vz/vps.umount)}}&lt;br /&gt;
&lt;br /&gt;
==== Setting the route CT → HN ====&lt;br /&gt;
To set up a route from the CT to the HN, the custom script has to get a HN IP (the $CT0_IP variable in the script). There are several ways to specify it:&lt;br /&gt;
&lt;br /&gt;
# Add an entry CT0_IP=&amp;quot;CT0 IP&amp;quot; to the &amp;lt;code&amp;gt;$VEID.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add an entry CT0_IP=&amp;quot;CT0 IP&amp;quot; to the &amp;lt;code&amp;gt;/etc/vz/vz.conf&amp;lt;/code&amp;gt; (the global configuration config file)&lt;br /&gt;
# Implement some smart algorithm to determine the CT0 IP right in the custom network configuration script&lt;br /&gt;
&lt;br /&gt;
Each variant has its pros and cons, nevertheless for HN static IP configuration variant 2 seems to be acceptable (and the most simple).&lt;br /&gt;
&lt;br /&gt;
== An OpenVZ Hardware Node has two Ethernet interfaces ==&lt;br /&gt;
Assuming you have 2 interfaces eth0 and eth1 and want to separate local traffic (10.0.0.0/24) from  external traffic.&lt;br /&gt;
Let's assign eth0 for the external traffic and eth1 for the local one.&lt;br /&gt;
&lt;br /&gt;
If there is no need to make the container accessible from the HN and vice versa, it's enough to replace 'br0' with 'eth1' in the following steps of the above configuration:&lt;br /&gt;
* Hardware Node configuration → [[Using_private_IPs_for_Hardware_Nodes#Assign_the_IP_to_the_bridge|Assign the IP to the bridge]]&lt;br /&gt;
* Hardware Node configuration → [[Using_private_IPs_for_Hardware_Nodes#Resurrect_the_default_routing|Resurrect the default routing]]&lt;br /&gt;
&lt;br /&gt;
It is nesessary to set a local IP for 'br0' to ensure CT ↔ HN connection availability.&lt;br /&gt;
&lt;br /&gt;
== Putting containers to different subnetworks ==&lt;br /&gt;
It's enough to set up the correct $VETH_IP_ADDRESS and $VE_DEFAULT_GATEWAY values in the &lt;br /&gt;
[[Using_private_IPs_for_Hardware_Nodes#Edit_the_container.27s_configuration|above configuration]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Virtual network device]]&lt;br /&gt;
* [[Differences between venet and veth]]&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Networking]]&lt;/div&gt;</summary>
		<author><name>Ysidoro</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=User:Ysidoro&amp;diff=6761</id>
		<title>User:Ysidoro</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=User:Ysidoro&amp;diff=6761"/>
		<updated>2008-11-29T18:33:31Z</updated>

		<summary type="html">&lt;p&gt;Ysidoro: Helly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Ysidoro =&lt;br /&gt;
&lt;br /&gt;
Hello, I am Rodolfo Pilas, you can reach me at http://www.pilas.net/&lt;/div&gt;</summary>
		<author><name>Ysidoro</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6760</id>
		<title>Installation on Debian/old</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6760"/>
		<updated>2008-11-29T18:30:48Z</updated>

		<summary type="html">&lt;p&gt;Ysidoro: introduction how to partialy upgrade to lenny&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenVZ consists of a kernel, user-level tools, and container templates.&lt;br /&gt;
&lt;br /&gt;
This guide tells how to install the kernel and the tools on [http://www.debian.org Debian] stable. &lt;br /&gt;
&lt;br /&gt;
Additionally, this document explain how to partialy upgrade to Debian testing (lenny) and install from lenny repositories ('''use this options at your risk''').&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
=== Filesystems ===&lt;br /&gt;
It is recommended to use a separate partition for container private&lt;br /&gt;
directories (by default &amp;lt;code&amp;gt;/var/lib/vz/private/&amp;lt;CTID&amp;gt;&amp;lt;/code&amp;gt;). The reason why you should do so is that if you wish to use OpenVZ per-container disk quota, you won't be able to use usual Linux disk quotas on the same partition. Bear in mind that per-container quota in this context includes not only pure per-container quota but also usual Linux disk quota used in container, not on [[HN]].&lt;br /&gt;
&lt;br /&gt;
At least try to avoid using root partition for containers because the root user of container will be able to overcome the 5% disk space barrier in some situations. If the  HN root partition is completely filled, it will break the system.&lt;br /&gt;
&lt;br /&gt;
OpenVZ per-container disk quota is supported only for ext2/ext3 filesystems so use one of these filesystems (ext3 is recommended) if you need per-container disk quota.&lt;br /&gt;
&lt;br /&gt;
=== Repository setup ===&lt;br /&gt;
&lt;br /&gt;
==== 1. Using openvz.org repositories ====&lt;br /&gt;
&lt;br /&gt;
At the moment two different repositories are online at http://download.openvz.org:&lt;br /&gt;
&lt;br /&gt;
; by Ola Lundqvist &amp;lt;opal@debian.org&amp;gt;&lt;br /&gt;
: (OpenVZ kernels only)&lt;br /&gt;
: apt-uri http://download.openvz.org/debian&lt;br /&gt;
&lt;br /&gt;
; by Thorsten Schifferdecker &amp;lt;tsd@debian.systs.org&amp;gt;&lt;br /&gt;
: apt-uri http://download.openvz.org/debian-systs&lt;br /&gt;
: (Mirror of OpenVZ Repository from http://debian.systs.org/)&lt;br /&gt;
&lt;br /&gt;
{{Note|The next steps use the repository at http://download.openvz.org/debian-systs; the actual OpenVZ Tools for Debian exist only as unstable builds, see http://packages.debian.org/vzctl}}&lt;br /&gt;
&lt;br /&gt;
{{Note|By default, on Ubuntu systems root tasks are executed with [https://help.ubuntu.com/community/RootSudo sudo]}}&lt;br /&gt;
&lt;br /&gt;
This can be achieved by the following commands, as root or as privileged &amp;quot;sudo&amp;quot; user&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo -e &amp;quot;\ndeb http://download.openvz.org/debian-systs etch openvz&amp;quot; &amp;gt;&amp;gt; /etc/apt/sources.list&lt;br /&gt;
# wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add - &amp;amp;&amp;amp; apt-get update&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 2. Using Debian repositories (upgrade to lenny) ====&lt;br /&gt;
&lt;br /&gt;
There is even an '''lenny''' repository with kernel 2.6.28. '''Use it at your own risk!'''&lt;br /&gt;
&lt;br /&gt;
Add lenny repositories to your '''/etc/apt/sources.list'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian/ testing main&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian-security/ testing/updates main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enlarge apt-cache adding to '''/etc/apt/apt.conf''' this line:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
APT::Cache-Limit &amp;quot;100000000&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Give etch package priority over lenny packages. Edit '''/etc/apt/preferences''' and set like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=etch&lt;br /&gt;
Pin-Priority: 700&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=lenny&lt;br /&gt;
Pin-Priority: 650&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then '''apt-get update &amp;amp;&amp;amp; apt-get dist-upgrade''' to upgrade to lenny.&lt;br /&gt;
&lt;br /&gt;
== Kernel installation ==&lt;br /&gt;
&lt;br /&gt;
=== 1. Using openvz kernel repositories ===&lt;br /&gt;
&lt;br /&gt;
{{Note|In case you want to recompile the OpenVZ kernel yourself on Debian, see [[Compiling the OpenVZ kernel (the Debian way)]].}}&lt;br /&gt;
&lt;br /&gt;
First, you need to choose what kernel you want to install.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with kernel config from http://download.openvz.org'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18&lt;br /&gt;
| uniprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-smp&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 4 GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-enterprise&lt;br /&gt;
| SMP + PAE support + 4/4GB split&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386 only&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with official Debian kernel config and OpenVZ Settings'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686-bigmem&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-amd64&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| &lt;br /&gt;
| amd64&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # apt-get install &amp;lt;kernel&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configuring the bootloader ====&lt;br /&gt;
&lt;br /&gt;
In case GRUB is used as the boot loader, it will be configured automatically, or execute update-grub; lines similar to these will be added to the &amp;lt;tt&amp;gt;/boot/grub/menu.lst&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
  title           Debian GNU/Linux, kernel 2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  root            (hd0,1)&lt;br /&gt;
  kernel          /vmlinuz-2.6.18-ovz-028stab051.1-686 root=/dev/sda5 ro vga=791&lt;br /&gt;
  initrd          /initrd.img-2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  savedefault&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|per default on debian/ubuntu, a 2.6.22 kernel will boot before a 2.6.18, please check manually the grub boot order. See man update-grub for more details}}&lt;br /&gt;
&lt;br /&gt;
==== Installing the user-level tools ====&lt;br /&gt;
&lt;br /&gt;
OpenVZ needs some user-level tools installed. Those are:&lt;br /&gt;
&lt;br /&gt;
; vzctl&lt;br /&gt;
: A utility to control OpenVZ containers (create, destroy, start, stop, set parameters etc.)&lt;br /&gt;
; vzquota&lt;br /&gt;
: A utility to manage quotas for containers. Mostly used indirectly (by vzctl).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # [sudo] apt-get install vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2 Using Debian lenny repositories ===&lt;br /&gt;
&lt;br /&gt;
If you upgrade to lenny, you can search openvz kernel and can install with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt-get install linux-image-openvz-686&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
this command will install latest kernel and all required packages like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 iproute libatm1 linux-image-2.6.26-1-openvz-686 linux-image-openvz-686 rsync vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and will arrange grub bootloader propertly.&lt;br /&gt;
&lt;br /&gt;
=== Rebooting into OpenVZ kernel ===&lt;br /&gt;
&lt;br /&gt;
{{Warning|Before you restart your Server, keep in mind, that your system has all needed modules enabled; booting from your harddisk (e.g. hardware modules, raid system(s), lvm2 etc). May you need a INITRD (initramdisk) or compile needed kernel modules statically in.}}&lt;br /&gt;
&lt;br /&gt;
Now reboot the machine and choose the OpenVZ Linux Kernel on the boot loader menu. If the OpenVZ kernel has been booted successfully, proceed to installing the user-level tools for OpenVZ.&lt;br /&gt;
&lt;br /&gt;
=== Confirm proper installation ===&lt;br /&gt;
&lt;br /&gt;
1. Kernel:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # uname -r&lt;br /&gt;
 2.6.26-1-openvz-686&lt;br /&gt;
 #&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Openvz kernel facility:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps ax | grep vz&lt;br /&gt;
 2349 ?        S      0:00 [vzmond]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. A network interface for containers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ifconfig&lt;br /&gt;
 venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
           UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1&lt;br /&gt;
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
           collisions:0 txqueuelen:0 &lt;br /&gt;
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring ==&lt;br /&gt;
&lt;br /&gt;
=== sysctl ===&lt;br /&gt;
&lt;br /&gt;
There are a number of kernel parameters that should be set for OpenVZ to work correctly. These parameters are stored in &amp;lt;tt&amp;gt;/etc/sysctl.conf&amp;lt;/tt&amp;gt; file. Here is the relevant part of the file; please edit it accordingly.&lt;br /&gt;
&lt;br /&gt;
{{Note|vzctl version from debian-systs, automate changing sysctl options for openvz}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
# On Hardware Node we generally need&lt;br /&gt;
# packet forwarding enabled and proxy arp disabled&lt;br /&gt;
&lt;br /&gt;
net.ipv4.conf.default.forwarding=1&lt;br /&gt;
net.ipv4.conf.default.proxy_arp = 0&lt;br /&gt;
net.ipv4.ip_forward=1&lt;br /&gt;
&lt;br /&gt;
# Enables source route verification&lt;br /&gt;
net.ipv4.conf.all.rp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# Enables the magic-sysrq key&lt;br /&gt;
kernel.sysrq = 1&lt;br /&gt;
&lt;br /&gt;
# TCP Explict Congestion Notification&lt;br /&gt;
#net.ipv4.tcp_ecn = 0&lt;br /&gt;
&lt;br /&gt;
# we do not want all our interfaces to send redirects&lt;br /&gt;
net.ipv4.conf.default.send_redirects = 1&lt;br /&gt;
net.ipv4.conf.all.send_redirects = 0&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  # [sudo] sysctl -p&lt;br /&gt;
&lt;br /&gt;
{{Note|You can make a symlink from /var/lib/vz to /vz as backward&lt;br /&gt;
compatibility to OpenVZ as installed in other distributions&lt;br /&gt;
(Debian vz root directory is /var/lib/vz to be FHS-compliant.}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] ln -s /var/lib/vz /vz &lt;br /&gt;
&lt;br /&gt;
=== OS templates ===&lt;br /&gt;
&lt;br /&gt;
To install a container, you need OS template(s).&lt;br /&gt;
&lt;br /&gt;
Precreated templates can be found [http://download.openvz.org/contrib/template/precreated/ here].&lt;br /&gt;
&lt;br /&gt;
You can create your own templates, see &lt;br /&gt;
[[Debian template creation]], [[Ubuntu Gutsy template creation]] and [[:Category: Templates]].&lt;br /&gt;
&lt;br /&gt;
{{Note|Setup your prefered standard OS Template : edit the /etc/vz/vz.conf}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzctl-ostmpl-debian&lt;br /&gt;
&lt;br /&gt;
== Additional User Tools ==&lt;br /&gt;
&lt;br /&gt;
; vzprocps&lt;br /&gt;
:    A set of utilities to provide system information (vzps and vztop)&lt;br /&gt;
&lt;br /&gt;
; [[vzdump]]&lt;br /&gt;
:    A utility to backup and restore container. &lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzprocps vzdump&lt;br /&gt;
&lt;br /&gt;
== Secure it ==&lt;br /&gt;
&lt;br /&gt;
If you want to secure your container with individual firewall rules (instead or additionally to securing the host node) then you must run iptables inside the container. This works slightly different than on a physical server. So make sure that you check that iptables rules are indeed applied as expected inside the container.&lt;br /&gt;
&lt;br /&gt;
Iptables modules required by the container must be specified in the general vz.conf file or the vzXXX.conf file of the container.&lt;br /&gt;
&lt;br /&gt;
Add the following line into vz.conf to activate the respective iptables modules for all containers.&lt;br /&gt;
&lt;br /&gt;
 IPTABLES=&amp;quot;ip_tables ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_LOG ipt_conntrack ipt_helper ipt_state iptable_nat ip_nat_ftp ip_nat_irc ipt_TOS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[http://wiki.debian.org/DebianFirewall][Configure]] your iptable rules inside the container.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Note that iptables rules inside the container are not applied automatically as on a physical server by starting the iptables module! Follow the instructions below}}&lt;br /&gt;
&lt;br /&gt;
To make sure the iptables rules are applied on a startup/reboot we'll create a new file:&lt;br /&gt;
&lt;br /&gt;
 nano /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Add these lines to it:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 /sbin/iptables-restore &amp;lt; /etc/iptables.up.rules&lt;br /&gt;
&lt;br /&gt;
The file needs to be executable so change the permissions:&lt;br /&gt;
&lt;br /&gt;
 chmod +x /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Start iptables&lt;br /&gt;
&lt;br /&gt;
 /etc/init.d/iptables start&lt;br /&gt;
&lt;br /&gt;
If the startup shows errors then you have probably not activated the needed iptables modules. See above.&lt;br /&gt;
&lt;br /&gt;
Check inside the container that your iptables rules are indeed applied:&lt;br /&gt;
&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
If the rules do not show up as you would expect on a physical server then you might not have activated the needed iptables modules.&lt;br /&gt;
&lt;br /&gt;
== Start it! ==&lt;br /&gt;
&lt;br /&gt;
 # [sudo] /etc/init.d/vz start&lt;br /&gt;
&lt;br /&gt;
This does not make the vz system automatically start at boot time.  For automatic start:&lt;br /&gt;
&lt;br /&gt;
 # [sudo] update-rc.d vz defaults 98&lt;br /&gt;
&lt;br /&gt;
== Use it! ==&lt;br /&gt;
&lt;br /&gt;
After installing the OpenVZ kernel, user tools and a minimal OS template&lt;br /&gt;
to create a first container and do some&lt;br /&gt;
[[basic operations in OpenVZ environment]]. Read the [[download:doc/OpenVZ-Users-Guide.pdf]], browse this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Debian]]&lt;br /&gt;
[[Category: Installation]]&lt;/div&gt;</summary>
		<author><name>Ysidoro</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6759</id>
		<title>Installation on Debian/old</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6759"/>
		<updated>2008-11-29T18:27:17Z</updated>

		<summary type="html">&lt;p&gt;Ysidoro: /* Rebooting into OpenVZ kernel */  Confirm installation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenVZ consists of a kernel, user-level tools, and container templates.&lt;br /&gt;
&lt;br /&gt;
This guide tells how to install the kernel and the tools on [http://www.debian.org Debian] stable. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
=== Filesystems ===&lt;br /&gt;
It is recommended to use a separate partition for container private&lt;br /&gt;
directories (by default &amp;lt;code&amp;gt;/var/lib/vz/private/&amp;lt;CTID&amp;gt;&amp;lt;/code&amp;gt;). The reason why you should do so is that if you wish to use OpenVZ per-container disk quota, you won't be able to use usual Linux disk quotas on the same partition. Bear in mind that per-container quota in this context includes not only pure per-container quota but also usual Linux disk quota used in container, not on [[HN]].&lt;br /&gt;
&lt;br /&gt;
At least try to avoid using root partition for containers because the root user of container will be able to overcome the 5% disk space barrier in some situations. If the  HN root partition is completely filled, it will break the system.&lt;br /&gt;
&lt;br /&gt;
OpenVZ per-container disk quota is supported only for ext2/ext3 filesystems so use one of these filesystems (ext3 is recommended) if you need per-container disk quota.&lt;br /&gt;
&lt;br /&gt;
=== Repository setup ===&lt;br /&gt;
&lt;br /&gt;
==== 1. Using openvz.org repositories ====&lt;br /&gt;
&lt;br /&gt;
At the moment two different repositories are online at http://download.openvz.org:&lt;br /&gt;
&lt;br /&gt;
; by Ola Lundqvist &amp;lt;opal@debian.org&amp;gt;&lt;br /&gt;
: (OpenVZ kernels only)&lt;br /&gt;
: apt-uri http://download.openvz.org/debian&lt;br /&gt;
&lt;br /&gt;
; by Thorsten Schifferdecker &amp;lt;tsd@debian.systs.org&amp;gt;&lt;br /&gt;
: apt-uri http://download.openvz.org/debian-systs&lt;br /&gt;
: (Mirror of OpenVZ Repository from http://debian.systs.org/)&lt;br /&gt;
&lt;br /&gt;
{{Note|The next steps use the repository at http://download.openvz.org/debian-systs; the actual OpenVZ Tools for Debian exist only as unstable builds, see http://packages.debian.org/vzctl}}&lt;br /&gt;
&lt;br /&gt;
{{Note|By default, on Ubuntu systems root tasks are executed with [https://help.ubuntu.com/community/RootSudo sudo]}}&lt;br /&gt;
&lt;br /&gt;
This can be achieved by the following commands, as root or as privileged &amp;quot;sudo&amp;quot; user&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo -e &amp;quot;\ndeb http://download.openvz.org/debian-systs etch openvz&amp;quot; &amp;gt;&amp;gt; /etc/apt/sources.list&lt;br /&gt;
# wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add - &amp;amp;&amp;amp; apt-get update&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 2. Using Debian repositories (upgrade to lenny) ====&lt;br /&gt;
&lt;br /&gt;
There is even an '''lenny''' repository with kernel 2.6.28. '''Use it at your own risk!'''&lt;br /&gt;
&lt;br /&gt;
Add lenny repositories to your '''/etc/apt/sources.list'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian/ testing main&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian-security/ testing/updates main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enlarge apt-cache adding to '''/etc/apt/apt.conf''' this line:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
APT::Cache-Limit &amp;quot;100000000&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Give etch package priority over lenny packages. Edit '''/etc/apt/preferences''' and set like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=etch&lt;br /&gt;
Pin-Priority: 700&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=lenny&lt;br /&gt;
Pin-Priority: 650&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then '''apt-get update &amp;amp;&amp;amp; apt-get dist-upgrade''' to upgrade to lenny.&lt;br /&gt;
&lt;br /&gt;
== Kernel installation ==&lt;br /&gt;
&lt;br /&gt;
=== 1. Using openvz kernel repositories ===&lt;br /&gt;
&lt;br /&gt;
{{Note|In case you want to recompile the OpenVZ kernel yourself on Debian, see [[Compiling the OpenVZ kernel (the Debian way)]].}}&lt;br /&gt;
&lt;br /&gt;
First, you need to choose what kernel you want to install.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with kernel config from http://download.openvz.org'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18&lt;br /&gt;
| uniprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-smp&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 4 GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-enterprise&lt;br /&gt;
| SMP + PAE support + 4/4GB split&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386 only&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with official Debian kernel config and OpenVZ Settings'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686-bigmem&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-amd64&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| &lt;br /&gt;
| amd64&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # apt-get install &amp;lt;kernel&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configuring the bootloader ====&lt;br /&gt;
&lt;br /&gt;
In case GRUB is used as the boot loader, it will be configured automatically, or execute update-grub; lines similar to these will be added to the &amp;lt;tt&amp;gt;/boot/grub/menu.lst&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
  title           Debian GNU/Linux, kernel 2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  root            (hd0,1)&lt;br /&gt;
  kernel          /vmlinuz-2.6.18-ovz-028stab051.1-686 root=/dev/sda5 ro vga=791&lt;br /&gt;
  initrd          /initrd.img-2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  savedefault&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|per default on debian/ubuntu, a 2.6.22 kernel will boot before a 2.6.18, please check manually the grub boot order. See man update-grub for more details}}&lt;br /&gt;
&lt;br /&gt;
==== Installing the user-level tools ====&lt;br /&gt;
&lt;br /&gt;
OpenVZ needs some user-level tools installed. Those are:&lt;br /&gt;
&lt;br /&gt;
; vzctl&lt;br /&gt;
: A utility to control OpenVZ containers (create, destroy, start, stop, set parameters etc.)&lt;br /&gt;
; vzquota&lt;br /&gt;
: A utility to manage quotas for containers. Mostly used indirectly (by vzctl).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # [sudo] apt-get install vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2 Using Debian lenny repositories ===&lt;br /&gt;
&lt;br /&gt;
If you upgrade to lenny, you can search openvz kernel and can install with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt-get install linux-image-openvz-686&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
this command will install latest kernel and all required packages like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 iproute libatm1 linux-image-2.6.26-1-openvz-686 linux-image-openvz-686 rsync vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and will arrange grub bootloader propertly.&lt;br /&gt;
&lt;br /&gt;
=== Rebooting into OpenVZ kernel ===&lt;br /&gt;
&lt;br /&gt;
{{Warning|Before you restart your Server, keep in mind, that your system has all needed modules enabled; booting from your harddisk (e.g. hardware modules, raid system(s), lvm2 etc). May you need a INITRD (initramdisk) or compile needed kernel modules statically in.}}&lt;br /&gt;
&lt;br /&gt;
Now reboot the machine and choose the OpenVZ Linux Kernel on the boot loader menu. If the OpenVZ kernel has been booted successfully, proceed to installing the user-level tools for OpenVZ.&lt;br /&gt;
&lt;br /&gt;
=== Confirm proper installation ===&lt;br /&gt;
&lt;br /&gt;
1. Kernel:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # uname -r&lt;br /&gt;
 2.6.26-1-openvz-686&lt;br /&gt;
 #&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Openvz kernel facility:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps ax | grep vz&lt;br /&gt;
 2349 ?        S      0:00 [vzmond]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. A network interface for containers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ifconfig&lt;br /&gt;
 venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
           UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1&lt;br /&gt;
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
           collisions:0 txqueuelen:0 &lt;br /&gt;
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring ==&lt;br /&gt;
&lt;br /&gt;
=== sysctl ===&lt;br /&gt;
&lt;br /&gt;
There are a number of kernel parameters that should be set for OpenVZ to work correctly. These parameters are stored in &amp;lt;tt&amp;gt;/etc/sysctl.conf&amp;lt;/tt&amp;gt; file. Here is the relevant part of the file; please edit it accordingly.&lt;br /&gt;
&lt;br /&gt;
{{Note|vzctl version from debian-systs, automate changing sysctl options for openvz}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
# On Hardware Node we generally need&lt;br /&gt;
# packet forwarding enabled and proxy arp disabled&lt;br /&gt;
&lt;br /&gt;
net.ipv4.conf.default.forwarding=1&lt;br /&gt;
net.ipv4.conf.default.proxy_arp = 0&lt;br /&gt;
net.ipv4.ip_forward=1&lt;br /&gt;
&lt;br /&gt;
# Enables source route verification&lt;br /&gt;
net.ipv4.conf.all.rp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# Enables the magic-sysrq key&lt;br /&gt;
kernel.sysrq = 1&lt;br /&gt;
&lt;br /&gt;
# TCP Explict Congestion Notification&lt;br /&gt;
#net.ipv4.tcp_ecn = 0&lt;br /&gt;
&lt;br /&gt;
# we do not want all our interfaces to send redirects&lt;br /&gt;
net.ipv4.conf.default.send_redirects = 1&lt;br /&gt;
net.ipv4.conf.all.send_redirects = 0&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  # [sudo] sysctl -p&lt;br /&gt;
&lt;br /&gt;
{{Note|You can make a symlink from /var/lib/vz to /vz as backward&lt;br /&gt;
compatibility to OpenVZ as installed in other distributions&lt;br /&gt;
(Debian vz root directory is /var/lib/vz to be FHS-compliant.}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] ln -s /var/lib/vz /vz &lt;br /&gt;
&lt;br /&gt;
=== OS templates ===&lt;br /&gt;
&lt;br /&gt;
To install a container, you need OS template(s).&lt;br /&gt;
&lt;br /&gt;
Precreated templates can be found [http://download.openvz.org/contrib/template/precreated/ here].&lt;br /&gt;
&lt;br /&gt;
You can create your own templates, see &lt;br /&gt;
[[Debian template creation]], [[Ubuntu Gutsy template creation]] and [[:Category: Templates]].&lt;br /&gt;
&lt;br /&gt;
{{Note|Setup your prefered standard OS Template : edit the /etc/vz/vz.conf}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzctl-ostmpl-debian&lt;br /&gt;
&lt;br /&gt;
== Additional User Tools ==&lt;br /&gt;
&lt;br /&gt;
; vzprocps&lt;br /&gt;
:    A set of utilities to provide system information (vzps and vztop)&lt;br /&gt;
&lt;br /&gt;
; [[vzdump]]&lt;br /&gt;
:    A utility to backup and restore container. &lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzprocps vzdump&lt;br /&gt;
&lt;br /&gt;
== Secure it ==&lt;br /&gt;
&lt;br /&gt;
If you want to secure your container with individual firewall rules (instead or additionally to securing the host node) then you must run iptables inside the container. This works slightly different than on a physical server. So make sure that you check that iptables rules are indeed applied as expected inside the container.&lt;br /&gt;
&lt;br /&gt;
Iptables modules required by the container must be specified in the general vz.conf file or the vzXXX.conf file of the container.&lt;br /&gt;
&lt;br /&gt;
Add the following line into vz.conf to activate the respective iptables modules for all containers.&lt;br /&gt;
&lt;br /&gt;
 IPTABLES=&amp;quot;ip_tables ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_LOG ipt_conntrack ipt_helper ipt_state iptable_nat ip_nat_ftp ip_nat_irc ipt_TOS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[http://wiki.debian.org/DebianFirewall][Configure]] your iptable rules inside the container.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Note that iptables rules inside the container are not applied automatically as on a physical server by starting the iptables module! Follow the instructions below}}&lt;br /&gt;
&lt;br /&gt;
To make sure the iptables rules are applied on a startup/reboot we'll create a new file:&lt;br /&gt;
&lt;br /&gt;
 nano /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Add these lines to it:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 /sbin/iptables-restore &amp;lt; /etc/iptables.up.rules&lt;br /&gt;
&lt;br /&gt;
The file needs to be executable so change the permissions:&lt;br /&gt;
&lt;br /&gt;
 chmod +x /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Start iptables&lt;br /&gt;
&lt;br /&gt;
 /etc/init.d/iptables start&lt;br /&gt;
&lt;br /&gt;
If the startup shows errors then you have probably not activated the needed iptables modules. See above.&lt;br /&gt;
&lt;br /&gt;
Check inside the container that your iptables rules are indeed applied:&lt;br /&gt;
&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
If the rules do not show up as you would expect on a physical server then you might not have activated the needed iptables modules.&lt;br /&gt;
&lt;br /&gt;
== Start it! ==&lt;br /&gt;
&lt;br /&gt;
 # [sudo] /etc/init.d/vz start&lt;br /&gt;
&lt;br /&gt;
This does not make the vz system automatically start at boot time.  For automatic start:&lt;br /&gt;
&lt;br /&gt;
 # [sudo] update-rc.d vz defaults 98&lt;br /&gt;
&lt;br /&gt;
== Use it! ==&lt;br /&gt;
&lt;br /&gt;
After installing the OpenVZ kernel, user tools and a minimal OS template&lt;br /&gt;
to create a first container and do some&lt;br /&gt;
[[basic operations in OpenVZ environment]]. Read the [[download:doc/OpenVZ-Users-Guide.pdf]], browse this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Debian]]&lt;br /&gt;
[[Category: Installation]]&lt;/div&gt;</summary>
		<author><name>Ysidoro</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6758</id>
		<title>Installation on Debian/old</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6758"/>
		<updated>2008-11-29T18:24:35Z</updated>

		<summary type="html">&lt;p&gt;Ysidoro: /* Configuring the bootloader */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenVZ consists of a kernel, user-level tools, and container templates.&lt;br /&gt;
&lt;br /&gt;
This guide tells how to install the kernel and the tools on [http://www.debian.org Debian] stable. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
=== Filesystems ===&lt;br /&gt;
It is recommended to use a separate partition for container private&lt;br /&gt;
directories (by default &amp;lt;code&amp;gt;/var/lib/vz/private/&amp;lt;CTID&amp;gt;&amp;lt;/code&amp;gt;). The reason why you should do so is that if you wish to use OpenVZ per-container disk quota, you won't be able to use usual Linux disk quotas on the same partition. Bear in mind that per-container quota in this context includes not only pure per-container quota but also usual Linux disk quota used in container, not on [[HN]].&lt;br /&gt;
&lt;br /&gt;
At least try to avoid using root partition for containers because the root user of container will be able to overcome the 5% disk space barrier in some situations. If the  HN root partition is completely filled, it will break the system.&lt;br /&gt;
&lt;br /&gt;
OpenVZ per-container disk quota is supported only for ext2/ext3 filesystems so use one of these filesystems (ext3 is recommended) if you need per-container disk quota.&lt;br /&gt;
&lt;br /&gt;
=== Repository setup ===&lt;br /&gt;
&lt;br /&gt;
==== 1. Using openvz.org repositories ====&lt;br /&gt;
&lt;br /&gt;
At the moment two different repositories are online at http://download.openvz.org:&lt;br /&gt;
&lt;br /&gt;
; by Ola Lundqvist &amp;lt;opal@debian.org&amp;gt;&lt;br /&gt;
: (OpenVZ kernels only)&lt;br /&gt;
: apt-uri http://download.openvz.org/debian&lt;br /&gt;
&lt;br /&gt;
; by Thorsten Schifferdecker &amp;lt;tsd@debian.systs.org&amp;gt;&lt;br /&gt;
: apt-uri http://download.openvz.org/debian-systs&lt;br /&gt;
: (Mirror of OpenVZ Repository from http://debian.systs.org/)&lt;br /&gt;
&lt;br /&gt;
{{Note|The next steps use the repository at http://download.openvz.org/debian-systs; the actual OpenVZ Tools for Debian exist only as unstable builds, see http://packages.debian.org/vzctl}}&lt;br /&gt;
&lt;br /&gt;
{{Note|By default, on Ubuntu systems root tasks are executed with [https://help.ubuntu.com/community/RootSudo sudo]}}&lt;br /&gt;
&lt;br /&gt;
This can be achieved by the following commands, as root or as privileged &amp;quot;sudo&amp;quot; user&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo -e &amp;quot;\ndeb http://download.openvz.org/debian-systs etch openvz&amp;quot; &amp;gt;&amp;gt; /etc/apt/sources.list&lt;br /&gt;
# wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add - &amp;amp;&amp;amp; apt-get update&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 2. Using Debian repositories (upgrade to lenny) ====&lt;br /&gt;
&lt;br /&gt;
There is even an '''lenny''' repository with kernel 2.6.28. '''Use it at your own risk!'''&lt;br /&gt;
&lt;br /&gt;
Add lenny repositories to your '''/etc/apt/sources.list'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian/ testing main&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian-security/ testing/updates main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enlarge apt-cache adding to '''/etc/apt/apt.conf''' this line:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
APT::Cache-Limit &amp;quot;100000000&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Give etch package priority over lenny packages. Edit '''/etc/apt/preferences''' and set like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=etch&lt;br /&gt;
Pin-Priority: 700&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=lenny&lt;br /&gt;
Pin-Priority: 650&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then '''apt-get update &amp;amp;&amp;amp; apt-get dist-upgrade''' to upgrade to lenny.&lt;br /&gt;
&lt;br /&gt;
== Kernel installation ==&lt;br /&gt;
&lt;br /&gt;
=== 1. Using openvz kernel repositories ===&lt;br /&gt;
&lt;br /&gt;
{{Note|In case you want to recompile the OpenVZ kernel yourself on Debian, see [[Compiling the OpenVZ kernel (the Debian way)]].}}&lt;br /&gt;
&lt;br /&gt;
First, you need to choose what kernel you want to install.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with kernel config from http://download.openvz.org'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18&lt;br /&gt;
| uniprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-smp&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 4 GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-enterprise&lt;br /&gt;
| SMP + PAE support + 4/4GB split&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386 only&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with official Debian kernel config and OpenVZ Settings'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686-bigmem&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-amd64&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| &lt;br /&gt;
| amd64&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # apt-get install &amp;lt;kernel&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configuring the bootloader ====&lt;br /&gt;
&lt;br /&gt;
In case GRUB is used as the boot loader, it will be configured automatically, or execute update-grub; lines similar to these will be added to the &amp;lt;tt&amp;gt;/boot/grub/menu.lst&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
  title           Debian GNU/Linux, kernel 2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  root            (hd0,1)&lt;br /&gt;
  kernel          /vmlinuz-2.6.18-ovz-028stab051.1-686 root=/dev/sda5 ro vga=791&lt;br /&gt;
  initrd          /initrd.img-2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  savedefault&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|per default on debian/ubuntu, a 2.6.22 kernel will boot before a 2.6.18, please check manually the grub boot order. See man update-grub for more details}}&lt;br /&gt;
&lt;br /&gt;
==== Installing the user-level tools ====&lt;br /&gt;
&lt;br /&gt;
OpenVZ needs some user-level tools installed. Those are:&lt;br /&gt;
&lt;br /&gt;
; vzctl&lt;br /&gt;
: A utility to control OpenVZ containers (create, destroy, start, stop, set parameters etc.)&lt;br /&gt;
; vzquota&lt;br /&gt;
: A utility to manage quotas for containers. Mostly used indirectly (by vzctl).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # [sudo] apt-get install vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2 Using Debian lenny repositories ===&lt;br /&gt;
&lt;br /&gt;
If you upgrade to lenny, you can search openvz kernel and can install with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt-get install linux-image-openvz-686&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
this command will install latest kernel and all required packages like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 iproute libatm1 linux-image-2.6.26-1-openvz-686 linux-image-openvz-686 rsync vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and will arrange grub bootloader propertly.&lt;br /&gt;
&lt;br /&gt;
=== Rebooting into OpenVZ kernel ===&lt;br /&gt;
&lt;br /&gt;
{{Warning|Before you restart your Server, keep in mind, that your system has all needed modules enabled; booting from your harddisk (e.g. hardware modules, raid system(s), lvm2 etc). May you need a INITRD (initramdisk) or compile needed kernel modules statically in.}}&lt;br /&gt;
&lt;br /&gt;
Now reboot the machine and choose the OpenVZ Linux Kernel on the boot loader menu. If the OpenVZ kernel has been booted successfully, proceed to installing the user-level tools for OpenVZ.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Configuring ==&lt;br /&gt;
&lt;br /&gt;
=== sysctl ===&lt;br /&gt;
&lt;br /&gt;
There are a number of kernel parameters that should be set for OpenVZ to work correctly. These parameters are stored in &amp;lt;tt&amp;gt;/etc/sysctl.conf&amp;lt;/tt&amp;gt; file. Here is the relevant part of the file; please edit it accordingly.&lt;br /&gt;
&lt;br /&gt;
{{Note|vzctl version from debian-systs, automate changing sysctl options for openvz}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
# On Hardware Node we generally need&lt;br /&gt;
# packet forwarding enabled and proxy arp disabled&lt;br /&gt;
&lt;br /&gt;
net.ipv4.conf.default.forwarding=1&lt;br /&gt;
net.ipv4.conf.default.proxy_arp = 0&lt;br /&gt;
net.ipv4.ip_forward=1&lt;br /&gt;
&lt;br /&gt;
# Enables source route verification&lt;br /&gt;
net.ipv4.conf.all.rp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# Enables the magic-sysrq key&lt;br /&gt;
kernel.sysrq = 1&lt;br /&gt;
&lt;br /&gt;
# TCP Explict Congestion Notification&lt;br /&gt;
#net.ipv4.tcp_ecn = 0&lt;br /&gt;
&lt;br /&gt;
# we do not want all our interfaces to send redirects&lt;br /&gt;
net.ipv4.conf.default.send_redirects = 1&lt;br /&gt;
net.ipv4.conf.all.send_redirects = 0&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  # [sudo] sysctl -p&lt;br /&gt;
&lt;br /&gt;
{{Note|You can make a symlink from /var/lib/vz to /vz as backward&lt;br /&gt;
compatibility to OpenVZ as installed in other distributions&lt;br /&gt;
(Debian vz root directory is /var/lib/vz to be FHS-compliant.}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] ln -s /var/lib/vz /vz &lt;br /&gt;
&lt;br /&gt;
=== OS templates ===&lt;br /&gt;
&lt;br /&gt;
To install a container, you need OS template(s).&lt;br /&gt;
&lt;br /&gt;
Precreated templates can be found [http://download.openvz.org/contrib/template/precreated/ here].&lt;br /&gt;
&lt;br /&gt;
You can create your own templates, see &lt;br /&gt;
[[Debian template creation]], [[Ubuntu Gutsy template creation]] and [[:Category: Templates]].&lt;br /&gt;
&lt;br /&gt;
{{Note|Setup your prefered standard OS Template : edit the /etc/vz/vz.conf}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzctl-ostmpl-debian&lt;br /&gt;
&lt;br /&gt;
== Additional User Tools ==&lt;br /&gt;
&lt;br /&gt;
; vzprocps&lt;br /&gt;
:    A set of utilities to provide system information (vzps and vztop)&lt;br /&gt;
&lt;br /&gt;
; [[vzdump]]&lt;br /&gt;
:    A utility to backup and restore container. &lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzprocps vzdump&lt;br /&gt;
&lt;br /&gt;
== Secure it ==&lt;br /&gt;
&lt;br /&gt;
If you want to secure your container with individual firewall rules (instead or additionally to securing the host node) then you must run iptables inside the container. This works slightly different than on a physical server. So make sure that you check that iptables rules are indeed applied as expected inside the container.&lt;br /&gt;
&lt;br /&gt;
Iptables modules required by the container must be specified in the general vz.conf file or the vzXXX.conf file of the container.&lt;br /&gt;
&lt;br /&gt;
Add the following line into vz.conf to activate the respective iptables modules for all containers.&lt;br /&gt;
&lt;br /&gt;
 IPTABLES=&amp;quot;ip_tables ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_LOG ipt_conntrack ipt_helper ipt_state iptable_nat ip_nat_ftp ip_nat_irc ipt_TOS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[http://wiki.debian.org/DebianFirewall][Configure]] your iptable rules inside the container.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Note that iptables rules inside the container are not applied automatically as on a physical server by starting the iptables module! Follow the instructions below}}&lt;br /&gt;
&lt;br /&gt;
To make sure the iptables rules are applied on a startup/reboot we'll create a new file:&lt;br /&gt;
&lt;br /&gt;
 nano /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Add these lines to it:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 /sbin/iptables-restore &amp;lt; /etc/iptables.up.rules&lt;br /&gt;
&lt;br /&gt;
The file needs to be executable so change the permissions:&lt;br /&gt;
&lt;br /&gt;
 chmod +x /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Start iptables&lt;br /&gt;
&lt;br /&gt;
 /etc/init.d/iptables start&lt;br /&gt;
&lt;br /&gt;
If the startup shows errors then you have probably not activated the needed iptables modules. See above.&lt;br /&gt;
&lt;br /&gt;
Check inside the container that your iptables rules are indeed applied:&lt;br /&gt;
&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
If the rules do not show up as you would expect on a physical server then you might not have activated the needed iptables modules.&lt;br /&gt;
&lt;br /&gt;
== Start it! ==&lt;br /&gt;
&lt;br /&gt;
 # [sudo] /etc/init.d/vz start&lt;br /&gt;
&lt;br /&gt;
This does not make the vz system automatically start at boot time.  For automatic start:&lt;br /&gt;
&lt;br /&gt;
 # [sudo] update-rc.d vz defaults 98&lt;br /&gt;
&lt;br /&gt;
== Use it! ==&lt;br /&gt;
&lt;br /&gt;
After installing the OpenVZ kernel, user tools and a minimal OS template&lt;br /&gt;
to create a first container and do some&lt;br /&gt;
[[basic operations in OpenVZ environment]]. Read the [[download:doc/OpenVZ-Users-Guide.pdf]], browse this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Debian]]&lt;br /&gt;
[[Category: Installation]]&lt;/div&gt;</summary>
		<author><name>Ysidoro</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6757</id>
		<title>Installation on Debian/old</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6757"/>
		<updated>2008-11-29T18:24:01Z</updated>

		<summary type="html">&lt;p&gt;Ysidoro: /* Installing the user-level tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenVZ consists of a kernel, user-level tools, and container templates.&lt;br /&gt;
&lt;br /&gt;
This guide tells how to install the kernel and the tools on [http://www.debian.org Debian] stable. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
=== Filesystems ===&lt;br /&gt;
It is recommended to use a separate partition for container private&lt;br /&gt;
directories (by default &amp;lt;code&amp;gt;/var/lib/vz/private/&amp;lt;CTID&amp;gt;&amp;lt;/code&amp;gt;). The reason why you should do so is that if you wish to use OpenVZ per-container disk quota, you won't be able to use usual Linux disk quotas on the same partition. Bear in mind that per-container quota in this context includes not only pure per-container quota but also usual Linux disk quota used in container, not on [[HN]].&lt;br /&gt;
&lt;br /&gt;
At least try to avoid using root partition for containers because the root user of container will be able to overcome the 5% disk space barrier in some situations. If the  HN root partition is completely filled, it will break the system.&lt;br /&gt;
&lt;br /&gt;
OpenVZ per-container disk quota is supported only for ext2/ext3 filesystems so use one of these filesystems (ext3 is recommended) if you need per-container disk quota.&lt;br /&gt;
&lt;br /&gt;
=== Repository setup ===&lt;br /&gt;
&lt;br /&gt;
==== 1. Using openvz.org repositories ====&lt;br /&gt;
&lt;br /&gt;
At the moment two different repositories are online at http://download.openvz.org:&lt;br /&gt;
&lt;br /&gt;
; by Ola Lundqvist &amp;lt;opal@debian.org&amp;gt;&lt;br /&gt;
: (OpenVZ kernels only)&lt;br /&gt;
: apt-uri http://download.openvz.org/debian&lt;br /&gt;
&lt;br /&gt;
; by Thorsten Schifferdecker &amp;lt;tsd@debian.systs.org&amp;gt;&lt;br /&gt;
: apt-uri http://download.openvz.org/debian-systs&lt;br /&gt;
: (Mirror of OpenVZ Repository from http://debian.systs.org/)&lt;br /&gt;
&lt;br /&gt;
{{Note|The next steps use the repository at http://download.openvz.org/debian-systs; the actual OpenVZ Tools for Debian exist only as unstable builds, see http://packages.debian.org/vzctl}}&lt;br /&gt;
&lt;br /&gt;
{{Note|By default, on Ubuntu systems root tasks are executed with [https://help.ubuntu.com/community/RootSudo sudo]}}&lt;br /&gt;
&lt;br /&gt;
This can be achieved by the following commands, as root or as privileged &amp;quot;sudo&amp;quot; user&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo -e &amp;quot;\ndeb http://download.openvz.org/debian-systs etch openvz&amp;quot; &amp;gt;&amp;gt; /etc/apt/sources.list&lt;br /&gt;
# wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add - &amp;amp;&amp;amp; apt-get update&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 2. Using Debian repositories (upgrade to lenny) ====&lt;br /&gt;
&lt;br /&gt;
There is even an '''lenny''' repository with kernel 2.6.28. '''Use it at your own risk!'''&lt;br /&gt;
&lt;br /&gt;
Add lenny repositories to your '''/etc/apt/sources.list'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian/ testing main&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian-security/ testing/updates main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enlarge apt-cache adding to '''/etc/apt/apt.conf''' this line:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
APT::Cache-Limit &amp;quot;100000000&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Give etch package priority over lenny packages. Edit '''/etc/apt/preferences''' and set like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=etch&lt;br /&gt;
Pin-Priority: 700&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=lenny&lt;br /&gt;
Pin-Priority: 650&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then '''apt-get update &amp;amp;&amp;amp; apt-get dist-upgrade''' to upgrade to lenny.&lt;br /&gt;
&lt;br /&gt;
== Kernel installation ==&lt;br /&gt;
&lt;br /&gt;
=== 1. Using openvz kernel repositories ===&lt;br /&gt;
&lt;br /&gt;
{{Note|In case you want to recompile the OpenVZ kernel yourself on Debian, see [[Compiling the OpenVZ kernel (the Debian way)]].}}&lt;br /&gt;
&lt;br /&gt;
First, you need to choose what kernel you want to install.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with kernel config from http://download.openvz.org'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18&lt;br /&gt;
| uniprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-smp&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 4 GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-enterprise&lt;br /&gt;
| SMP + PAE support + 4/4GB split&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386 only&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with official Debian kernel config and OpenVZ Settings'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686-bigmem&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-amd64&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| &lt;br /&gt;
| amd64&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # apt-get install &amp;lt;kernel&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configuring the bootloader ====&lt;br /&gt;
&lt;br /&gt;
In case GRUB is used as the boot loader, it will be configured automatically, or execute update-grub; lines similar to these will be added to the &amp;lt;tt&amp;gt;/boot/grub/menu.lst&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
  title           Debian GNU/Linux, kernel 2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  root            (hd0,1)&lt;br /&gt;
  kernel          /vmlinuz-2.6.18-ovz-028stab051.1-686 root=/dev/sda5 ro vga=791&lt;br /&gt;
  initrd          /initrd.img-2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  savedefault&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|per default on debian/ubuntu, a 2.6.22 kernel will boot before a 2.6.18, please check manually the grub boot order. See man update-grub for more details}}&lt;br /&gt;
&lt;br /&gt;
=== 2 Using Debian lenny repositories ===&lt;br /&gt;
&lt;br /&gt;
If you upgrade to lenny, you can search openvz kernel and can install with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt-get install linux-image-openvz-686&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
this command will install latest kernel and all required packages like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 iproute libatm1 linux-image-2.6.26-1-openvz-686 linux-image-openvz-686 rsync vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and will arrange grub bootloader propertly.&lt;br /&gt;
&lt;br /&gt;
=== Rebooting into OpenVZ kernel ===&lt;br /&gt;
&lt;br /&gt;
{{Warning|Before you restart your Server, keep in mind, that your system has all needed modules enabled; booting from your harddisk (e.g. hardware modules, raid system(s), lvm2 etc). May you need a INITRD (initramdisk) or compile needed kernel modules statically in.}}&lt;br /&gt;
&lt;br /&gt;
Now reboot the machine and choose the OpenVZ Linux Kernel on the boot loader menu. If the OpenVZ kernel has been booted successfully, proceed to installing the user-level tools for OpenVZ.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Configuring ==&lt;br /&gt;
&lt;br /&gt;
=== sysctl ===&lt;br /&gt;
&lt;br /&gt;
There are a number of kernel parameters that should be set for OpenVZ to work correctly. These parameters are stored in &amp;lt;tt&amp;gt;/etc/sysctl.conf&amp;lt;/tt&amp;gt; file. Here is the relevant part of the file; please edit it accordingly.&lt;br /&gt;
&lt;br /&gt;
{{Note|vzctl version from debian-systs, automate changing sysctl options for openvz}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
# On Hardware Node we generally need&lt;br /&gt;
# packet forwarding enabled and proxy arp disabled&lt;br /&gt;
&lt;br /&gt;
net.ipv4.conf.default.forwarding=1&lt;br /&gt;
net.ipv4.conf.default.proxy_arp = 0&lt;br /&gt;
net.ipv4.ip_forward=1&lt;br /&gt;
&lt;br /&gt;
# Enables source route verification&lt;br /&gt;
net.ipv4.conf.all.rp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# Enables the magic-sysrq key&lt;br /&gt;
kernel.sysrq = 1&lt;br /&gt;
&lt;br /&gt;
# TCP Explict Congestion Notification&lt;br /&gt;
#net.ipv4.tcp_ecn = 0&lt;br /&gt;
&lt;br /&gt;
# we do not want all our interfaces to send redirects&lt;br /&gt;
net.ipv4.conf.default.send_redirects = 1&lt;br /&gt;
net.ipv4.conf.all.send_redirects = 0&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  # [sudo] sysctl -p&lt;br /&gt;
&lt;br /&gt;
{{Note|You can make a symlink from /var/lib/vz to /vz as backward&lt;br /&gt;
compatibility to OpenVZ as installed in other distributions&lt;br /&gt;
(Debian vz root directory is /var/lib/vz to be FHS-compliant.}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] ln -s /var/lib/vz /vz &lt;br /&gt;
&lt;br /&gt;
=== OS templates ===&lt;br /&gt;
&lt;br /&gt;
To install a container, you need OS template(s).&lt;br /&gt;
&lt;br /&gt;
Precreated templates can be found [http://download.openvz.org/contrib/template/precreated/ here].&lt;br /&gt;
&lt;br /&gt;
You can create your own templates, see &lt;br /&gt;
[[Debian template creation]], [[Ubuntu Gutsy template creation]] and [[:Category: Templates]].&lt;br /&gt;
&lt;br /&gt;
{{Note|Setup your prefered standard OS Template : edit the /etc/vz/vz.conf}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzctl-ostmpl-debian&lt;br /&gt;
&lt;br /&gt;
== Additional User Tools ==&lt;br /&gt;
&lt;br /&gt;
; vzprocps&lt;br /&gt;
:    A set of utilities to provide system information (vzps and vztop)&lt;br /&gt;
&lt;br /&gt;
; [[vzdump]]&lt;br /&gt;
:    A utility to backup and restore container. &lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzprocps vzdump&lt;br /&gt;
&lt;br /&gt;
== Secure it ==&lt;br /&gt;
&lt;br /&gt;
If you want to secure your container with individual firewall rules (instead or additionally to securing the host node) then you must run iptables inside the container. This works slightly different than on a physical server. So make sure that you check that iptables rules are indeed applied as expected inside the container.&lt;br /&gt;
&lt;br /&gt;
Iptables modules required by the container must be specified in the general vz.conf file or the vzXXX.conf file of the container.&lt;br /&gt;
&lt;br /&gt;
Add the following line into vz.conf to activate the respective iptables modules for all containers.&lt;br /&gt;
&lt;br /&gt;
 IPTABLES=&amp;quot;ip_tables ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_LOG ipt_conntrack ipt_helper ipt_state iptable_nat ip_nat_ftp ip_nat_irc ipt_TOS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[http://wiki.debian.org/DebianFirewall][Configure]] your iptable rules inside the container.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Note that iptables rules inside the container are not applied automatically as on a physical server by starting the iptables module! Follow the instructions below}}&lt;br /&gt;
&lt;br /&gt;
To make sure the iptables rules are applied on a startup/reboot we'll create a new file:&lt;br /&gt;
&lt;br /&gt;
 nano /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Add these lines to it:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 /sbin/iptables-restore &amp;lt; /etc/iptables.up.rules&lt;br /&gt;
&lt;br /&gt;
The file needs to be executable so change the permissions:&lt;br /&gt;
&lt;br /&gt;
 chmod +x /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Start iptables&lt;br /&gt;
&lt;br /&gt;
 /etc/init.d/iptables start&lt;br /&gt;
&lt;br /&gt;
If the startup shows errors then you have probably not activated the needed iptables modules. See above.&lt;br /&gt;
&lt;br /&gt;
Check inside the container that your iptables rules are indeed applied:&lt;br /&gt;
&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
If the rules do not show up as you would expect on a physical server then you might not have activated the needed iptables modules.&lt;br /&gt;
&lt;br /&gt;
== Start it! ==&lt;br /&gt;
&lt;br /&gt;
 # [sudo] /etc/init.d/vz start&lt;br /&gt;
&lt;br /&gt;
This does not make the vz system automatically start at boot time.  For automatic start:&lt;br /&gt;
&lt;br /&gt;
 # [sudo] update-rc.d vz defaults 98&lt;br /&gt;
&lt;br /&gt;
== Use it! ==&lt;br /&gt;
&lt;br /&gt;
After installing the OpenVZ kernel, user tools and a minimal OS template&lt;br /&gt;
to create a first container and do some&lt;br /&gt;
[[basic operations in OpenVZ environment]]. Read the [[download:doc/OpenVZ-Users-Guide.pdf]], browse this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Debian]]&lt;br /&gt;
[[Category: Installation]]&lt;/div&gt;</summary>
		<author><name>Ysidoro</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6756</id>
		<title>Installation on Debian/old</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6756"/>
		<updated>2008-11-29T18:22:59Z</updated>

		<summary type="html">&lt;p&gt;Ysidoro: /* Kernel installation */  with lenny repositories&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenVZ consists of a kernel, user-level tools, and container templates.&lt;br /&gt;
&lt;br /&gt;
This guide tells how to install the kernel and the tools on [http://www.debian.org Debian] stable. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
=== Filesystems ===&lt;br /&gt;
It is recommended to use a separate partition for container private&lt;br /&gt;
directories (by default &amp;lt;code&amp;gt;/var/lib/vz/private/&amp;lt;CTID&amp;gt;&amp;lt;/code&amp;gt;). The reason why you should do so is that if you wish to use OpenVZ per-container disk quota, you won't be able to use usual Linux disk quotas on the same partition. Bear in mind that per-container quota in this context includes not only pure per-container quota but also usual Linux disk quota used in container, not on [[HN]].&lt;br /&gt;
&lt;br /&gt;
At least try to avoid using root partition for containers because the root user of container will be able to overcome the 5% disk space barrier in some situations. If the  HN root partition is completely filled, it will break the system.&lt;br /&gt;
&lt;br /&gt;
OpenVZ per-container disk quota is supported only for ext2/ext3 filesystems so use one of these filesystems (ext3 is recommended) if you need per-container disk quota.&lt;br /&gt;
&lt;br /&gt;
=== Repository setup ===&lt;br /&gt;
&lt;br /&gt;
==== 1. Using openvz.org repositories ====&lt;br /&gt;
&lt;br /&gt;
At the moment two different repositories are online at http://download.openvz.org:&lt;br /&gt;
&lt;br /&gt;
; by Ola Lundqvist &amp;lt;opal@debian.org&amp;gt;&lt;br /&gt;
: (OpenVZ kernels only)&lt;br /&gt;
: apt-uri http://download.openvz.org/debian&lt;br /&gt;
&lt;br /&gt;
; by Thorsten Schifferdecker &amp;lt;tsd@debian.systs.org&amp;gt;&lt;br /&gt;
: apt-uri http://download.openvz.org/debian-systs&lt;br /&gt;
: (Mirror of OpenVZ Repository from http://debian.systs.org/)&lt;br /&gt;
&lt;br /&gt;
{{Note|The next steps use the repository at http://download.openvz.org/debian-systs; the actual OpenVZ Tools for Debian exist only as unstable builds, see http://packages.debian.org/vzctl}}&lt;br /&gt;
&lt;br /&gt;
{{Note|By default, on Ubuntu systems root tasks are executed with [https://help.ubuntu.com/community/RootSudo sudo]}}&lt;br /&gt;
&lt;br /&gt;
This can be achieved by the following commands, as root or as privileged &amp;quot;sudo&amp;quot; user&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo -e &amp;quot;\ndeb http://download.openvz.org/debian-systs etch openvz&amp;quot; &amp;gt;&amp;gt; /etc/apt/sources.list&lt;br /&gt;
# wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add - &amp;amp;&amp;amp; apt-get update&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 2. Using Debian repositories (upgrade to lenny) ====&lt;br /&gt;
&lt;br /&gt;
There is even an '''lenny''' repository with kernel 2.6.28. '''Use it at your own risk!'''&lt;br /&gt;
&lt;br /&gt;
Add lenny repositories to your '''/etc/apt/sources.list'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian/ testing main&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian-security/ testing/updates main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enlarge apt-cache adding to '''/etc/apt/apt.conf''' this line:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
APT::Cache-Limit &amp;quot;100000000&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Give etch package priority over lenny packages. Edit '''/etc/apt/preferences''' and set like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=etch&lt;br /&gt;
Pin-Priority: 700&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=lenny&lt;br /&gt;
Pin-Priority: 650&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then '''apt-get update &amp;amp;&amp;amp; apt-get dist-upgrade''' to upgrade to lenny.&lt;br /&gt;
&lt;br /&gt;
== Kernel installation ==&lt;br /&gt;
&lt;br /&gt;
=== 1. Using openvz kernel repositories ===&lt;br /&gt;
&lt;br /&gt;
{{Note|In case you want to recompile the OpenVZ kernel yourself on Debian, see [[Compiling the OpenVZ kernel (the Debian way)]].}}&lt;br /&gt;
&lt;br /&gt;
First, you need to choose what kernel you want to install.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with kernel config from http://download.openvz.org'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18&lt;br /&gt;
| uniprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-smp&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 4 GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-enterprise&lt;br /&gt;
| SMP + PAE support + 4/4GB split&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386 only&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with official Debian kernel config and OpenVZ Settings'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686-bigmem&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-amd64&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| &lt;br /&gt;
| amd64&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # apt-get install &amp;lt;kernel&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configuring the bootloader ====&lt;br /&gt;
&lt;br /&gt;
In case GRUB is used as the boot loader, it will be configured automatically, or execute update-grub; lines similar to these will be added to the &amp;lt;tt&amp;gt;/boot/grub/menu.lst&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
  title           Debian GNU/Linux, kernel 2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  root            (hd0,1)&lt;br /&gt;
  kernel          /vmlinuz-2.6.18-ovz-028stab051.1-686 root=/dev/sda5 ro vga=791&lt;br /&gt;
  initrd          /initrd.img-2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  savedefault&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|per default on debian/ubuntu, a 2.6.22 kernel will boot before a 2.6.18, please check manually the grub boot order. See man update-grub for more details}}&lt;br /&gt;
&lt;br /&gt;
=== 2 Using Debian lenny repositories ===&lt;br /&gt;
&lt;br /&gt;
If you upgrade to lenny, you can search openvz kernel and can install with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt-get install linux-image-openvz-686&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
this command will install latest kernel and all required packages like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 iproute libatm1 linux-image-2.6.26-1-openvz-686 linux-image-openvz-686 rsync vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and will arrange grub bootloader propertly.&lt;br /&gt;
&lt;br /&gt;
=== Rebooting into OpenVZ kernel ===&lt;br /&gt;
&lt;br /&gt;
{{Warning|Before you restart your Server, keep in mind, that your system has all needed modules enabled; booting from your harddisk (e.g. hardware modules, raid system(s), lvm2 etc). May you need a INITRD (initramdisk) or compile needed kernel modules statically in.}}&lt;br /&gt;
&lt;br /&gt;
Now reboot the machine and choose the OpenVZ Linux Kernel on the boot loader menu. If the OpenVZ kernel has been booted successfully, proceed to installing the user-level tools for OpenVZ.&lt;br /&gt;
&lt;br /&gt;
== Installing the user-level tools ==&lt;br /&gt;
&lt;br /&gt;
OpenVZ needs some user-level tools installed. Those are:&lt;br /&gt;
&lt;br /&gt;
; vzctl&lt;br /&gt;
: A utility to control OpenVZ containers (create, destroy, start, stop, set parameters etc.)&lt;br /&gt;
; vzquota&lt;br /&gt;
: A utility to manage quotas for containers. Mostly used indirectly (by vzctl).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # [sudo] apt-get install vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring ==&lt;br /&gt;
&lt;br /&gt;
=== sysctl ===&lt;br /&gt;
&lt;br /&gt;
There are a number of kernel parameters that should be set for OpenVZ to work correctly. These parameters are stored in &amp;lt;tt&amp;gt;/etc/sysctl.conf&amp;lt;/tt&amp;gt; file. Here is the relevant part of the file; please edit it accordingly.&lt;br /&gt;
&lt;br /&gt;
{{Note|vzctl version from debian-systs, automate changing sysctl options for openvz}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
# On Hardware Node we generally need&lt;br /&gt;
# packet forwarding enabled and proxy arp disabled&lt;br /&gt;
&lt;br /&gt;
net.ipv4.conf.default.forwarding=1&lt;br /&gt;
net.ipv4.conf.default.proxy_arp = 0&lt;br /&gt;
net.ipv4.ip_forward=1&lt;br /&gt;
&lt;br /&gt;
# Enables source route verification&lt;br /&gt;
net.ipv4.conf.all.rp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# Enables the magic-sysrq key&lt;br /&gt;
kernel.sysrq = 1&lt;br /&gt;
&lt;br /&gt;
# TCP Explict Congestion Notification&lt;br /&gt;
#net.ipv4.tcp_ecn = 0&lt;br /&gt;
&lt;br /&gt;
# we do not want all our interfaces to send redirects&lt;br /&gt;
net.ipv4.conf.default.send_redirects = 1&lt;br /&gt;
net.ipv4.conf.all.send_redirects = 0&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  # [sudo] sysctl -p&lt;br /&gt;
&lt;br /&gt;
{{Note|You can make a symlink from /var/lib/vz to /vz as backward&lt;br /&gt;
compatibility to OpenVZ as installed in other distributions&lt;br /&gt;
(Debian vz root directory is /var/lib/vz to be FHS-compliant.}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] ln -s /var/lib/vz /vz &lt;br /&gt;
&lt;br /&gt;
=== OS templates ===&lt;br /&gt;
&lt;br /&gt;
To install a container, you need OS template(s).&lt;br /&gt;
&lt;br /&gt;
Precreated templates can be found [http://download.openvz.org/contrib/template/precreated/ here].&lt;br /&gt;
&lt;br /&gt;
You can create your own templates, see &lt;br /&gt;
[[Debian template creation]], [[Ubuntu Gutsy template creation]] and [[:Category: Templates]].&lt;br /&gt;
&lt;br /&gt;
{{Note|Setup your prefered standard OS Template : edit the /etc/vz/vz.conf}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzctl-ostmpl-debian&lt;br /&gt;
&lt;br /&gt;
== Additional User Tools ==&lt;br /&gt;
&lt;br /&gt;
; vzprocps&lt;br /&gt;
:    A set of utilities to provide system information (vzps and vztop)&lt;br /&gt;
&lt;br /&gt;
; [[vzdump]]&lt;br /&gt;
:    A utility to backup and restore container. &lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzprocps vzdump&lt;br /&gt;
&lt;br /&gt;
== Secure it ==&lt;br /&gt;
&lt;br /&gt;
If you want to secure your container with individual firewall rules (instead or additionally to securing the host node) then you must run iptables inside the container. This works slightly different than on a physical server. So make sure that you check that iptables rules are indeed applied as expected inside the container.&lt;br /&gt;
&lt;br /&gt;
Iptables modules required by the container must be specified in the general vz.conf file or the vzXXX.conf file of the container.&lt;br /&gt;
&lt;br /&gt;
Add the following line into vz.conf to activate the respective iptables modules for all containers.&lt;br /&gt;
&lt;br /&gt;
 IPTABLES=&amp;quot;ip_tables ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_LOG ipt_conntrack ipt_helper ipt_state iptable_nat ip_nat_ftp ip_nat_irc ipt_TOS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[http://wiki.debian.org/DebianFirewall][Configure]] your iptable rules inside the container.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Note that iptables rules inside the container are not applied automatically as on a physical server by starting the iptables module! Follow the instructions below}}&lt;br /&gt;
&lt;br /&gt;
To make sure the iptables rules are applied on a startup/reboot we'll create a new file:&lt;br /&gt;
&lt;br /&gt;
 nano /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Add these lines to it:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 /sbin/iptables-restore &amp;lt; /etc/iptables.up.rules&lt;br /&gt;
&lt;br /&gt;
The file needs to be executable so change the permissions:&lt;br /&gt;
&lt;br /&gt;
 chmod +x /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Start iptables&lt;br /&gt;
&lt;br /&gt;
 /etc/init.d/iptables start&lt;br /&gt;
&lt;br /&gt;
If the startup shows errors then you have probably not activated the needed iptables modules. See above.&lt;br /&gt;
&lt;br /&gt;
Check inside the container that your iptables rules are indeed applied:&lt;br /&gt;
&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
If the rules do not show up as you would expect on a physical server then you might not have activated the needed iptables modules.&lt;br /&gt;
&lt;br /&gt;
== Start it! ==&lt;br /&gt;
&lt;br /&gt;
 # [sudo] /etc/init.d/vz start&lt;br /&gt;
&lt;br /&gt;
This does not make the vz system automatically start at boot time.  For automatic start:&lt;br /&gt;
&lt;br /&gt;
 # [sudo] update-rc.d vz defaults 98&lt;br /&gt;
&lt;br /&gt;
== Use it! ==&lt;br /&gt;
&lt;br /&gt;
After installing the OpenVZ kernel, user tools and a minimal OS template&lt;br /&gt;
to create a first container and do some&lt;br /&gt;
[[basic operations in OpenVZ environment]]. Read the [[download:doc/OpenVZ-Users-Guide.pdf]], browse this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Debian]]&lt;br /&gt;
[[Category: Installation]]&lt;/div&gt;</summary>
		<author><name>Ysidoro</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6755</id>
		<title>Installation on Debian/old</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Installation_on_Debian/old&amp;diff=6755"/>
		<updated>2008-11-29T18:13:32Z</updated>

		<summary type="html">&lt;p&gt;Ysidoro: /* Repository setup */  lenny repository to installation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenVZ consists of a kernel, user-level tools, and container templates.&lt;br /&gt;
&lt;br /&gt;
This guide tells how to install the kernel and the tools on [http://www.debian.org Debian] stable. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
=== Filesystems ===&lt;br /&gt;
It is recommended to use a separate partition for container private&lt;br /&gt;
directories (by default &amp;lt;code&amp;gt;/var/lib/vz/private/&amp;lt;CTID&amp;gt;&amp;lt;/code&amp;gt;). The reason why you should do so is that if you wish to use OpenVZ per-container disk quota, you won't be able to use usual Linux disk quotas on the same partition. Bear in mind that per-container quota in this context includes not only pure per-container quota but also usual Linux disk quota used in container, not on [[HN]].&lt;br /&gt;
&lt;br /&gt;
At least try to avoid using root partition for containers because the root user of container will be able to overcome the 5% disk space barrier in some situations. If the  HN root partition is completely filled, it will break the system.&lt;br /&gt;
&lt;br /&gt;
OpenVZ per-container disk quota is supported only for ext2/ext3 filesystems so use one of these filesystems (ext3 is recommended) if you need per-container disk quota.&lt;br /&gt;
&lt;br /&gt;
=== Repository setup ===&lt;br /&gt;
&lt;br /&gt;
==== 1. Using openvz.org repositories ====&lt;br /&gt;
&lt;br /&gt;
At the moment two different repositories are online at http://download.openvz.org:&lt;br /&gt;
&lt;br /&gt;
; by Ola Lundqvist &amp;lt;opal@debian.org&amp;gt;&lt;br /&gt;
: (OpenVZ kernels only)&lt;br /&gt;
: apt-uri http://download.openvz.org/debian&lt;br /&gt;
&lt;br /&gt;
; by Thorsten Schifferdecker &amp;lt;tsd@debian.systs.org&amp;gt;&lt;br /&gt;
: apt-uri http://download.openvz.org/debian-systs&lt;br /&gt;
: (Mirror of OpenVZ Repository from http://debian.systs.org/)&lt;br /&gt;
&lt;br /&gt;
{{Note|The next steps use the repository at http://download.openvz.org/debian-systs; the actual OpenVZ Tools for Debian exist only as unstable builds, see http://packages.debian.org/vzctl}}&lt;br /&gt;
&lt;br /&gt;
{{Note|By default, on Ubuntu systems root tasks are executed with [https://help.ubuntu.com/community/RootSudo sudo]}}&lt;br /&gt;
&lt;br /&gt;
This can be achieved by the following commands, as root or as privileged &amp;quot;sudo&amp;quot; user&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo -e &amp;quot;\ndeb http://download.openvz.org/debian-systs etch openvz&amp;quot; &amp;gt;&amp;gt; /etc/apt/sources.list&lt;br /&gt;
# wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add - &amp;amp;&amp;amp; apt-get update&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 2. Using Debian repositories (upgrade to lenny) ====&lt;br /&gt;
&lt;br /&gt;
There is even an '''lenny''' repository with kernel 2.6.28. '''Use it at your own risk!'''&lt;br /&gt;
&lt;br /&gt;
Add lenny repositories to your '''/etc/apt/sources.list'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian/ testing main&lt;br /&gt;
deb http://DEBIAN-MIRROR/debian-security/ testing/updates main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enlarge apt-cache adding to '''/etc/apt/apt.conf''' this line:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
APT::Cache-Limit &amp;quot;100000000&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Give etch package priority over lenny packages. Edit '''/etc/apt/preferences''' and set like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=etch&lt;br /&gt;
Pin-Priority: 700&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=lenny&lt;br /&gt;
Pin-Priority: 650&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then '''apt-get update &amp;amp;&amp;amp; apt-get dist-upgrade''' to upgrade to lenny.&lt;br /&gt;
&lt;br /&gt;
== Kernel installation ==&lt;br /&gt;
&lt;br /&gt;
{{Note|In case you want to recompile the OpenVZ kernel yourself on Debian, see [[Compiling the OpenVZ kernel (the Debian way)]].}}&lt;br /&gt;
&lt;br /&gt;
First, you need to choose what kernel you want to install.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with kernel config from http://download.openvz.org'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18&lt;br /&gt;
| uniprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-smp&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 4 GB of RAM&lt;br /&gt;
| i386 and amd64&lt;br /&gt;
|-&lt;br /&gt;
! ovzkernel-2.6.18-enterprise&lt;br /&gt;
| SMP + PAE support + 4/4GB split&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386 only&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+'''OpenVZ Kernel list built with official Debian kernel config and OpenVZ Settings'''&lt;br /&gt;
! Kernel !! Description !! Hardware !! Debian Architecture&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| up to 4GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-686-bigmem&lt;br /&gt;
| symmetric multiprocessor&lt;br /&gt;
| up to 64 GB of RAM&lt;br /&gt;
| i386&lt;br /&gt;
|-&lt;br /&gt;
! fzakernel-2.6.18-amd64&lt;br /&gt;
| uni- and multiprocessor&lt;br /&gt;
| &lt;br /&gt;
| amd64&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # apt-get install &amp;lt;kernel&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configuring the bootloader ===&lt;br /&gt;
&lt;br /&gt;
In case GRUB is used as the boot loader, it will be configured automatically, or execute update-grub; lines similar to these will be added to the &amp;lt;tt&amp;gt;/boot/grub/menu.lst&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
  title           Debian GNU/Linux, kernel 2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  root            (hd0,1)&lt;br /&gt;
  kernel          /vmlinuz-2.6.18-ovz-028stab051.1-686 root=/dev/sda5 ro vga=791&lt;br /&gt;
  initrd          /initrd.img-2.6.18-ovz-028stab051.1-686&lt;br /&gt;
  savedefault&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|per default on debian/ubuntu, a 2.6.22 kernel will boot before a 2.6.18, please check manually the grub boot order. See man update-grub for more details}}&lt;br /&gt;
&lt;br /&gt;
=== Rebooting into OpenVZ kernel ===&lt;br /&gt;
&lt;br /&gt;
{{Warning|Before you restart your Server, keep in mind, that your system has all needed modules enabled; booting from your harddisk (e.g. hardware modules, raid system(s), lvm2 etc). May you need a INITRD (initramdisk) or compile needed kernel modules statically in.}}&lt;br /&gt;
&lt;br /&gt;
Now reboot the machine and choose the OpenVZ Linux Kernel on the boot loader menu. If the OpenVZ kernel has been booted successfully, proceed to installing the user-level tools for OpenVZ.&lt;br /&gt;
&lt;br /&gt;
== Installing the user-level tools ==&lt;br /&gt;
&lt;br /&gt;
OpenVZ needs some user-level tools installed. Those are:&lt;br /&gt;
&lt;br /&gt;
; vzctl&lt;br /&gt;
: A utility to control OpenVZ containers (create, destroy, start, stop, set parameters etc.)&lt;br /&gt;
; vzquota&lt;br /&gt;
: A utility to manage quotas for containers. Mostly used indirectly (by vzctl).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # [sudo] apt-get install vzctl vzquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring ==&lt;br /&gt;
&lt;br /&gt;
=== sysctl ===&lt;br /&gt;
&lt;br /&gt;
There are a number of kernel parameters that should be set for OpenVZ to work correctly. These parameters are stored in &amp;lt;tt&amp;gt;/etc/sysctl.conf&amp;lt;/tt&amp;gt; file. Here is the relevant part of the file; please edit it accordingly.&lt;br /&gt;
&lt;br /&gt;
{{Note|vzctl version from debian-systs, automate changing sysctl options for openvz}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
# On Hardware Node we generally need&lt;br /&gt;
# packet forwarding enabled and proxy arp disabled&lt;br /&gt;
&lt;br /&gt;
net.ipv4.conf.default.forwarding=1&lt;br /&gt;
net.ipv4.conf.default.proxy_arp = 0&lt;br /&gt;
net.ipv4.ip_forward=1&lt;br /&gt;
&lt;br /&gt;
# Enables source route verification&lt;br /&gt;
net.ipv4.conf.all.rp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# Enables the magic-sysrq key&lt;br /&gt;
kernel.sysrq = 1&lt;br /&gt;
&lt;br /&gt;
# TCP Explict Congestion Notification&lt;br /&gt;
#net.ipv4.tcp_ecn = 0&lt;br /&gt;
&lt;br /&gt;
# we do not want all our interfaces to send redirects&lt;br /&gt;
net.ipv4.conf.default.send_redirects = 1&lt;br /&gt;
net.ipv4.conf.all.send_redirects = 0&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  # [sudo] sysctl -p&lt;br /&gt;
&lt;br /&gt;
{{Note|You can make a symlink from /var/lib/vz to /vz as backward&lt;br /&gt;
compatibility to OpenVZ as installed in other distributions&lt;br /&gt;
(Debian vz root directory is /var/lib/vz to be FHS-compliant.}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] ln -s /var/lib/vz /vz &lt;br /&gt;
&lt;br /&gt;
=== OS templates ===&lt;br /&gt;
&lt;br /&gt;
To install a container, you need OS template(s).&lt;br /&gt;
&lt;br /&gt;
Precreated templates can be found [http://download.openvz.org/contrib/template/precreated/ here].&lt;br /&gt;
&lt;br /&gt;
You can create your own templates, see &lt;br /&gt;
[[Debian template creation]], [[Ubuntu Gutsy template creation]] and [[:Category: Templates]].&lt;br /&gt;
&lt;br /&gt;
{{Note|Setup your prefered standard OS Template : edit the /etc/vz/vz.conf}}&lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzctl-ostmpl-debian&lt;br /&gt;
&lt;br /&gt;
== Additional User Tools ==&lt;br /&gt;
&lt;br /&gt;
; vzprocps&lt;br /&gt;
:    A set of utilities to provide system information (vzps and vztop)&lt;br /&gt;
&lt;br /&gt;
; [[vzdump]]&lt;br /&gt;
:    A utility to backup and restore container. &lt;br /&gt;
&lt;br /&gt;
  # [sudo] apt-get install vzprocps vzdump&lt;br /&gt;
&lt;br /&gt;
== Secure it ==&lt;br /&gt;
&lt;br /&gt;
If you want to secure your container with individual firewall rules (instead or additionally to securing the host node) then you must run iptables inside the container. This works slightly different than on a physical server. So make sure that you check that iptables rules are indeed applied as expected inside the container.&lt;br /&gt;
&lt;br /&gt;
Iptables modules required by the container must be specified in the general vz.conf file or the vzXXX.conf file of the container.&lt;br /&gt;
&lt;br /&gt;
Add the following line into vz.conf to activate the respective iptables modules for all containers.&lt;br /&gt;
&lt;br /&gt;
 IPTABLES=&amp;quot;ip_tables ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_LOG ipt_conntrack ipt_helper ipt_state iptable_nat ip_nat_ftp ip_nat_irc ipt_TOS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[http://wiki.debian.org/DebianFirewall][Configure]] your iptable rules inside the container.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Note that iptables rules inside the container are not applied automatically as on a physical server by starting the iptables module! Follow the instructions below}}&lt;br /&gt;
&lt;br /&gt;
To make sure the iptables rules are applied on a startup/reboot we'll create a new file:&lt;br /&gt;
&lt;br /&gt;
 nano /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Add these lines to it:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 /sbin/iptables-restore &amp;lt; /etc/iptables.up.rules&lt;br /&gt;
&lt;br /&gt;
The file needs to be executable so change the permissions:&lt;br /&gt;
&lt;br /&gt;
 chmod +x /etc/network/if-pre-up.d/iptables&lt;br /&gt;
&lt;br /&gt;
Start iptables&lt;br /&gt;
&lt;br /&gt;
 /etc/init.d/iptables start&lt;br /&gt;
&lt;br /&gt;
If the startup shows errors then you have probably not activated the needed iptables modules. See above.&lt;br /&gt;
&lt;br /&gt;
Check inside the container that your iptables rules are indeed applied:&lt;br /&gt;
&lt;br /&gt;
 iptables -L&lt;br /&gt;
&lt;br /&gt;
If the rules do not show up as you would expect on a physical server then you might not have activated the needed iptables modules.&lt;br /&gt;
&lt;br /&gt;
== Start it! ==&lt;br /&gt;
&lt;br /&gt;
 # [sudo] /etc/init.d/vz start&lt;br /&gt;
&lt;br /&gt;
This does not make the vz system automatically start at boot time.  For automatic start:&lt;br /&gt;
&lt;br /&gt;
 # [sudo] update-rc.d vz defaults 98&lt;br /&gt;
&lt;br /&gt;
== Use it! ==&lt;br /&gt;
&lt;br /&gt;
After installing the OpenVZ kernel, user tools and a minimal OS template&lt;br /&gt;
to create a first container and do some&lt;br /&gt;
[[basic operations in OpenVZ environment]]. Read the [[download:doc/OpenVZ-Users-Guide.pdf]], browse this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Debian]]&lt;br /&gt;
[[Category: Installation]]&lt;/div&gt;</summary>
		<author><name>Ysidoro</name></author>
		
	</entry>
</feed>