<?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=Kingneutron</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=Kingneutron"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Kingneutron"/>
	<updated>2026-05-15T13:47:38Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3138</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3138"/>
		<updated>2007-05-27T21:55:54Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Starting VE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is indentified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; directory for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o Note: In the LiveCD environment, you may have to increase SHMPAGES for the VE or you will run out of &amp;quot;disk space&amp;quot; when trying to install software.  You can do this &amp;quot;on the fly&amp;quot; by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl set 101 --shmpages $((8192*8)):$((8192*8)) --save '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o This will give VE 101 64MB of shmpages; you may wish to give it more if you're planning on doing more than just basic openvz testing.&lt;br /&gt;
&lt;br /&gt;
o You can verify the change from the host by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl exec 101 cat /proc/user_beancounters '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the &amp;quot;vzlist&amp;quot; command you see that 5 processes are running inside VE 101. (The &amp;quot;NPROC&amp;quot; field indicates the number of Processes, or PIDs, that are active in the VE -- not the number of Processors, or CPUs.)  Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# useradd new-user&lt;br /&gt;
Knoppix:/# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
Knoppix:/# mkdir /home/new-user&lt;br /&gt;
Knoppix:/# chown new-user /home/new-user/&lt;br /&gt;
Knoppix:/# su new-user&lt;br /&gt;
Knoppix:/$ cd ~&lt;br /&gt;
Knoppix:~$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
root@Knoppix:~# ifconfig venet0 up&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need to&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual apt-get tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
Knoppix:/# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# cat /proc/bc/101/resources&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
root@Knoppix:~# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/ .&lt;br /&gt;
&lt;br /&gt;
If you experience some difficulties, contact us via http://forum.openvz.org/ . Templates and other tools are available from http://download.openvz.org/ .&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3137</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3137"/>
		<updated>2007-05-27T21:54:20Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Links */ spelling ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is indentified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; directory for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o Note: In the LiveCD environment, you may have to increase SHMPAGES for the VE or you will run out of &amp;quot;disk space&amp;quot; when trying to install software.  You can do this &amp;quot;on the fly&amp;quot; by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl set 101 --shmpages $((8192*8)):$((8192*8)) --save '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o This will give VE 101 64MB of shmpages; you may wish to give it more if you're planning on doing more than just basic openvz testing.&lt;br /&gt;
&lt;br /&gt;
o You can verify the change in-VE by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl exec 101 cat /proc/user_beancounters '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the &amp;quot;vzlist&amp;quot; command you see that 5 processes are running inside VE 101. (The &amp;quot;NPROC&amp;quot; field indicates the number of Processes, or PIDs, that are active in the VE -- not the number of Processors, or CPUs.)  Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# useradd new-user&lt;br /&gt;
Knoppix:/# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
Knoppix:/# mkdir /home/new-user&lt;br /&gt;
Knoppix:/# chown new-user /home/new-user/&lt;br /&gt;
Knoppix:/# su new-user&lt;br /&gt;
Knoppix:/$ cd ~&lt;br /&gt;
Knoppix:~$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
root@Knoppix:~# ifconfig venet0 up&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need to&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual apt-get tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
Knoppix:/# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# cat /proc/bc/101/resources&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
root@Knoppix:~# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/ .&lt;br /&gt;
&lt;br /&gt;
If you experience some difficulties, contact us via http://forum.openvz.org/ . Templates and other tools are available from http://download.openvz.org/ .&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3136</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3136"/>
		<updated>2007-05-27T21:51:05Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Executing commands in VE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is indentified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; directory for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o Note: In the LiveCD environment, you may have to increase SHMPAGES for the VE or you will run out of &amp;quot;disk space&amp;quot; when trying to install software.  You can do this &amp;quot;on the fly&amp;quot; by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl set 101 --shmpages $((8192*8)):$((8192*8)) --save '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o This will give VE 101 64MB of shmpages; you may wish to give it more if you're planning on doing more than just basic openvz testing.&lt;br /&gt;
&lt;br /&gt;
o You can verify the change in-VE by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl exec 101 cat /proc/user_beancounters '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the &amp;quot;vzlist&amp;quot; command you see that 5 processes are running inside VE 101. (The &amp;quot;NPROC&amp;quot; field indicates the number of Processes, or PIDs, that are active in the VE -- not the number of Processors, or CPUs.)  Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# useradd new-user&lt;br /&gt;
Knoppix:/# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
Knoppix:/# mkdir /home/new-user&lt;br /&gt;
Knoppix:/# chown new-user /home/new-user/&lt;br /&gt;
Knoppix:/# su new-user&lt;br /&gt;
Knoppix:/$ cd ~&lt;br /&gt;
Knoppix:~$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
root@Knoppix:~# ifconfig venet0 up&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need to&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual apt-get tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
Knoppix:/# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# cat /proc/bc/101/resources&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
root@Knoppix:~# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/.&lt;br /&gt;
&lt;br /&gt;
If you expirience some difficulties, contact us via http://forum.openvz.org/. Templates and other tools are available from http://download.openvz.org/.&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3135</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3135"/>
		<updated>2007-05-27T21:50:18Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Executing commands in VE */ Explained diff btwn nproc and # of cpu's ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is indentified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; directory for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o Note: In the LiveCD environment, you may have to increase SHMPAGES for the VE or you will run out of &amp;quot;disk space&amp;quot; when trying to install software.  You can do this &amp;quot;on the fly&amp;quot; by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl set 101 --shmpages $((8192*8)):$((8192*8)) --save '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o This will give VE 101 64MB of shmpages; you may wish to give it more if you're planning on doing more than just basic openvz testing.&lt;br /&gt;
&lt;br /&gt;
o You can verify the change in-VE by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl exec 101 cat /proc/user_beancounters '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the previous command you see that 5 processes are running inside VE 101. (The &amp;quot;NPROC&amp;quot; field indicates the number of Processes, or PIDs, that are active in the VE -- not the number of Processors, or CPUs.)  Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# useradd new-user&lt;br /&gt;
Knoppix:/# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
Knoppix:/# mkdir /home/new-user&lt;br /&gt;
Knoppix:/# chown new-user /home/new-user/&lt;br /&gt;
Knoppix:/# su new-user&lt;br /&gt;
Knoppix:/$ cd ~&lt;br /&gt;
Knoppix:~$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
root@Knoppix:~# ifconfig venet0 up&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need to&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual apt-get tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
Knoppix:/# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# cat /proc/bc/101/resources&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
root@Knoppix:~# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/.&lt;br /&gt;
&lt;br /&gt;
If you expirience some difficulties, contact us via http://forum.openvz.org/. Templates and other tools are available from http://download.openvz.org/.&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3134</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3134"/>
		<updated>2007-05-27T21:46:39Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Starting VE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is indentified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; directory for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o Note: In the LiveCD environment, you may have to increase SHMPAGES for the VE or you will run out of &amp;quot;disk space&amp;quot; when trying to install software.  You can do this &amp;quot;on the fly&amp;quot; by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl set 101 --shmpages $((8192*8)):$((8192*8)) --save '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o This will give VE 101 64MB of shmpages; you may wish to give it more if you're planning on doing more than just basic openvz testing.&lt;br /&gt;
&lt;br /&gt;
o You can verify the change in-VE by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl exec 101 cat /proc/user_beancounters '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the previous command you see that 5 processes are running inside VE 101. Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# useradd new-user&lt;br /&gt;
Knoppix:/# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
Knoppix:/# mkdir /home/new-user&lt;br /&gt;
Knoppix:/# chown new-user /home/new-user/&lt;br /&gt;
Knoppix:/# su new-user&lt;br /&gt;
Knoppix:/$ cd ~&lt;br /&gt;
Knoppix:~$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
root@Knoppix:~# ifconfig venet0 up&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need to&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual apt-get tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
Knoppix:/# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# cat /proc/bc/101/resources&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
root@Knoppix:~# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/.&lt;br /&gt;
&lt;br /&gt;
If you expirience some difficulties, contact us via http://forum.openvz.org/. Templates and other tools are available from http://download.openvz.org/.&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3133</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3133"/>
		<updated>2007-05-27T21:45:36Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Starting VE */ Added shmpages fix for livecd ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is indentified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; directory for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o Note: In the LiveCD environment, you may have to increase SHMPAGES for the VE or you will run out of &amp;quot;disk space&amp;quot; when trying to install software.  You can do this &amp;quot;on the fly&amp;quot; by issuing:&lt;br /&gt;
&lt;br /&gt;
' vzctl set 101 --shmpages $((8192*8)):$((8192*8)) --save '&lt;br /&gt;
&lt;br /&gt;
o This will give VE 101 64MB of shmpages; you may wish to give it more if you're planning on doing more than just basic openvz testing.&lt;br /&gt;
&lt;br /&gt;
o You can verify the change in-VE by issuing:&lt;br /&gt;
&lt;br /&gt;
' vzctl exec 101 cat /proc/user_beancounters '&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the previous command you see that 5 processes are running inside VE 101. Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# useradd new-user&lt;br /&gt;
Knoppix:/# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
Knoppix:/# mkdir /home/new-user&lt;br /&gt;
Knoppix:/# chown new-user /home/new-user/&lt;br /&gt;
Knoppix:/# su new-user&lt;br /&gt;
Knoppix:/$ cd ~&lt;br /&gt;
Knoppix:~$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
root@Knoppix:~# ifconfig venet0 up&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
root@Knoppix:~# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need to&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
root@Knoppix:~# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
root@Knoppix:~# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual apt-get tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
Knoppix:/#&lt;br /&gt;
Knoppix:/# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
Knoppix:/# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# cat /proc/bc/101/resources&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@Knoppix:~# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
root@Knoppix:~# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
root@Knoppix:~#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/.&lt;br /&gt;
&lt;br /&gt;
If you expirience some difficulties, contact us via http://forum.openvz.org/. Templates and other tools are available from http://download.openvz.org/.&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=X_inside_VE&amp;diff=3130</id>
		<title>X inside VE</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=X_inside_VE&amp;diff=3130"/>
		<updated>2007-05-26T08:23:18Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* X forwarding */ Added -2 -c blowfish for speed ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are several ways to run X applications inside your [[VE]].&lt;br /&gt;
&lt;br /&gt;
== X forwarding ==&lt;br /&gt;
&lt;br /&gt;
To run an X application inside a [[VE]], one need simply to connect to a VE with '''ssh -X''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
host# ssh -2 -c blowfish -X user@address&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After login to VE check that &amp;lt;code&amp;gt;$DISPLAY&amp;lt;/code&amp;gt; variable is set and X11 forwarding is enabled:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ve# echo $DISPLAY&lt;br /&gt;
localhost:10.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case &amp;lt;code&amp;gt;$DISPLAY&amp;lt;/code&amp;gt; is not set, make sure that X forwarding is enabled in &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; config inside VE. In most Linux distros sshd configuration is stored in &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;. You should set parameter &amp;lt;code&amp;gt;X11Forwarding&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt;. Also VE should contain &amp;lt;code&amp;gt;xauth&amp;lt;/code&amp;gt; package, thus install &amp;lt;code&amp;gt;xauth&amp;lt;/code&amp;gt; if it is missing. After that, restart your sshd daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ve# /etc/init.d/sshd restart&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Don't forget to reconnect after this}}&lt;br /&gt;
&lt;br /&gt;
Now you can run X applications from your VE:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ve# firefox&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, that if you want to run complete X window environment (including window manager), you should kill local window manager and run only pure X server. Secondly you shoud use  '''-Y''' option when invoking ssh. And if you want to run gnome/kde/..., don't forget to increase [[UBC]] limits, 'cause default values are certainly too small for these monsters. ;)&lt;br /&gt;
&lt;br /&gt;
== VNC for X desktop ==&lt;br /&gt;
First, one need to run '''Xvnc''' server inside VE. The easiest way for this is to run&lt;br /&gt;
'''vncserver''' script. This scripts starts all the required services&lt;br /&gt;
and small http daemon which provides graphical web access to your desktop (via Java applet).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ve# vncserver -name mydesktop&lt;br /&gt;
New 'mydekstop' desktop is ve:1&lt;br /&gt;
&lt;br /&gt;
Starting applications specified in ~/.vnc/xstartup&lt;br /&gt;
Log file is ~/.vnc/ve:1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now when your desktop is up and running you can connect to it&lt;br /&gt;
using '''vncviewer''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
host# vncviewer &amp;lt;VE_IP&amp;gt;:1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the VNC desktop is the same size or larger than your X desktop, you will see scroll bars on the bottom and the side.  This is often inconvenient. You may reduce your VNC desktop to a more reasonable size like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;vncserver -geometry 1000x650&amp;lt;/pre&amp;gt;&lt;br /&gt;
This setting works quite well for a 1024 by 768 X desktop setting.&lt;br /&gt;
&lt;br /&gt;
=== Starting KDE desktop with VNC ===&lt;br /&gt;
To start KDE desktop instead of default twm one replace &amp;lt;code&amp;gt;twm &amp;amp;&amp;lt;/code&amp;gt; line with &amp;lt;code&amp;gt;startkde &amp;amp;&amp;lt;/code&amp;gt; in user's&lt;br /&gt;
&amp;lt;code&amp;gt;~/.vnc/xstartup&amp;lt;/code&amp;gt; file on the VE.&lt;br /&gt;
&lt;br /&gt;
=== Connecting with VNC from firewalled network ===&lt;br /&gt;
VNC uses 590x TCP ports for its connections. These ports can be firewalled in&lt;br /&gt;
many networks so in order to be able to connect to remote side one need to tunnel VNC connections somehow.&lt;br /&gt;
A usuall '''ssh''' can be used for tunneling VNC connections as described below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
localhost# ssh -L 5900:localhost:5900 &amp;lt;remote host&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;remote host&amp;gt; is the name of the system you want to connect to. When you are asked for a username and password enter your normal username and password. Then start the VNC session to localhost, i.e.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
localhost# vncviewer localhost&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using xdm ==&lt;br /&gt;
It should be also possible to do remote X by running '''xdm''' inside VE and&lt;br /&gt;
X -query &amp;lt;remote IP&amp;gt; :1&lt;br /&gt;
&lt;br /&gt;
However VNC approach is much easier.&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;th=235&amp;amp;mid=1115&amp;amp;&amp;amp;rev=&amp;amp;reveal=&lt;br /&gt;
* http://ait.web.psi.ch/services/linux/kde-desktop-sharing.htm&lt;br /&gt;
* http://ait.web.psi.ch/services/ssh/vnc-ssh.html&lt;br /&gt;
* http://www.vnc.com/pipermail/vnc-list/2002-July/031831.html&lt;br /&gt;
* http://www.linuxjournal.com/article/5499&lt;br /&gt;
* http://www.realvnc.com/pipermail/vnc-list/2002-March/029502.html&lt;br /&gt;
* http://www.redhat.com/archives/rhl-list/2003-December/msg01859.html&lt;br /&gt;
* http://faq.gotomyvnc.com/fom-serve/cache/56.html&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Networking]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3129</id>
		<title>Virtual Ethernet device</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3129"/>
		<updated>2007-05-26T08:21:08Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* syntax vzctl version &amp;gt;= 3.0.14 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Virtual ethernet device''' is an ethernet-like device which can be used inside a [[VE]]. Unlike&lt;br /&gt;
[[venet]] network device, veth device has a MAC address. Due to this, it can be used in configurations, when veth is bridged to ethX or other device and VE user fully sets up his networking himself, &lt;br /&gt;
including IPs, gateways etc.&lt;br /&gt;
&lt;br /&gt;
Virtual ethernet device consist of two ethernet devices - one in [[VE0]] and another one &lt;br /&gt;
in VE. These devices are connected to each other, so if a packet goes to one&lt;br /&gt;
device it will come out from the other device.&lt;br /&gt;
&lt;br /&gt;
== Virtual ethernet device usage ==&lt;br /&gt;
&lt;br /&gt;
=== Kernel module ===&lt;br /&gt;
First of all, make sure the &amp;lt;code&amp;gt;vzethdev&amp;lt;/code&amp;gt; module is loaded:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# lsmod | grep vzeth&lt;br /&gt;
vzethdev                8224  0&lt;br /&gt;
vzmon                  35164  5 vzethdev,vznetdev,vzrst,vzcpt&lt;br /&gt;
vzdev                   3080  4 vzethdev,vznetdev,vzmon,vzdquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case it is not loaded, load it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# modprobe vzethdev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might want to add the module to &amp;lt;code&amp;gt;/etc/init.d/vz script&amp;lt;/code&amp;gt;, so it will be loaded during startup.&lt;br /&gt;
&lt;br /&gt;
{{Note|since vzctl version 3.0.11, vzethdev is loaded by /etc/init.d/vz}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Adding veth to a VE ===&lt;br /&gt;
&lt;br /&gt;
{{Note|Use random MAC addresses. Do not use MAC addresses of real eth devices, because this can lead to collisions and MAC addresses must be entered in XX:XX:XX:XX:XX:XX format.}}&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_add &amp;lt;dev_name&amp;gt;,&amp;lt;dev_addr&amp;gt;,&amp;lt;ve_dev_name&amp;gt;,&amp;lt;ve_dev_addr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name that you are creating on the [[VE0|host system]]&lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_name&amp;lt;/tt&amp;gt; is the corresponding ethernet device name you are creating on the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
&lt;br /&gt;
{{Note| that this option is incremental, so devices are added to already existing ones.}}&lt;br /&gt;
&lt;br /&gt;
NB there are no spaces after the commas&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command &amp;lt;tt&amp;gt;veth&amp;lt;/tt&amp;gt; device will be created for VE 101 and veth configuration will be saved to a VE configuration file.&lt;br /&gt;
Host-side ethernet device will have &amp;lt;tt&amp;gt;veth101.0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9A&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
VE-side ethernet device will have &amp;lt;tt&amp;gt;eth0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9B&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
Read Update infos about [http://openvz.org/news/updates/vzctl-3.0.14-1 vzctl 3.0.14]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_add &amp;lt;ifname&amp;gt;[,&amp;lt;mac&amp;gt;,&amp;lt;host_ifname&amp;gt;,&amp;lt;host_mac]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;tt&amp;gt;ifname&amp;lt;/tt&amp;gt; is the ethernet device name in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;mac&amp;lt;/tt&amp;gt; is its MAC address in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_ifname&amp;lt;/tt&amp;gt;  is the ethernet device name on the host ([[VE0]])&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_mac&amp;lt;/tt&amp;gt; is its MAC address on the host ([[VE0]])&lt;br /&gt;
&lt;br /&gt;
{{Note|All parameters except ifname are optional and are automatically generated if not specified.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_add eth0,00:12:34:56:78:9A,veth101.0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
o There is a utility script available for generating MAC addresses: &lt;br /&gt;
&lt;br /&gt;
http://www.easyvmx.com/software/easymac.sh&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
o Recommended Usage: &lt;br /&gt;
&lt;br /&gt;
' chmod +x easymac.sh '&lt;br /&gt;
&lt;br /&gt;
' ./easymac.sh -R '&lt;br /&gt;
&lt;br /&gt;
=== Removing veth from a VE ===&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_del &amp;lt;dev_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name in the [[VE0|host system]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_del veth101.0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command veth device with host-side ethernet name veth101.0 will be removed from VE 101 and veth configuration will be updated in VE config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_del &amp;lt;dev_name&amp;gt;|all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;code&amp;gt;dev_name&amp;lt;/code&amp;gt; is the ethernet device name in the [[VE]].&lt;br /&gt;
&lt;br /&gt;
{{Note|If you want to remove all ethernet devices in VE, use &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_del eth0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Common configurations with virtual ethernet devices ==&lt;br /&gt;
Module &amp;lt;tt&amp;gt;vzethdev&amp;lt;/tt&amp;gt; must be loaded to operate with veth devices.&lt;br /&gt;
&lt;br /&gt;
=== Simple configuration with virtual ethernet device ===&lt;br /&gt;
&lt;br /&gt;
==== Start a VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in VE0 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/proxy_arp&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
[ve-101]# /sbin/ip addr add 192.168.0.101 dev eth0&lt;br /&gt;
[ve-101]# /sbin/ip route add default dev eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add route in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.0.101 dev veth101.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet device with IPv6 ===&lt;br /&gt;
&lt;br /&gt;
==== Start [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/all/forwarding&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start router advertisement daemon (radvd) for IPv6 in VE0 ====&lt;br /&gt;
First you need to edit radvd configuration file. Here is a simple example of &amp;lt;tt&amp;gt;/etc/radv.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interface veth101.0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:2400:0:0::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
interface eth0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:0302:0011:0002::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start radvd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# /etc/init.d/radvd start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add IPv6 addresses to devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip addr add dev veth101.0 3ffe:2400::212:34ff:fe56:789a/64&lt;br /&gt;
[host-node]# ip addr add dev eth0 3ffe:0302:0011:0002:211:22ff:fe33:4455/64&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices can be joined in one bridge ===&lt;br /&gt;
Perform steps 1 - 4 from Simple configuration chapter for several VEs and/or veth devices&lt;br /&gt;
&lt;br /&gt;
==== Create bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addbr vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth devices to bridge ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.n&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth102.0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 vethXXX.N&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig vzbr0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add routes in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.101.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.101.n dev vzbr0&lt;br /&gt;
[host-node]# ip route add 192.168.102.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.XXX.N dev vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus you'll have more convinient configuration, i.e. all routes to VEs will be through this bridge and VEs can communicate with each other even without these routes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Making a veth-device persistent ===&lt;br /&gt;
&lt;br /&gt;
At the moment, it is not possible to have the commands needed for a persistent veth being made automatically be vzctl. A  bugreport ( http://bugzilla.openvz.org/show_bug.cgi?id=301 ) has already been made. Until then, here's a way to make the above steps persistent.&lt;br /&gt;
&lt;br /&gt;
1. First, edit the VE's configuration to specify what the veth's IP address(es) should be, and to indicate that a custom script should be run when starting up a VE.&lt;br /&gt;
 * Open up /etc/vz/conf/VEID.conf&lt;br /&gt;
 * Comment out any IP_ADDRESS entries to prevent a VENET-device from being created in the VE&lt;br /&gt;
 * Add or change the entry CONFIG_CUSTOMIZED=&amp;quot;yes&amp;quot;&lt;br /&gt;
 * Add an entry VETH_IP_ADDRESS=&amp;quot;&amp;lt;VE IP&amp;gt;&amp;quot; The VE IP can have multiple IPs, separated by spaces&lt;br /&gt;
&lt;br /&gt;
2. Now to create that &amp;quot;custom script&amp;quot;. The following helper script will check the configuration file for IP addresses and for the veth interface, and configure the IP routing accordingly. Create the script /usr/sbin/vznetaddroute to have the following, and then &amp;lt;code&amp;gt;chmod 0500 /usr/sbin/vznetaddroute&amp;lt;/code&amp;gt; to make it executable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# /usr/sbin/vznetaddroute&lt;br /&gt;
# a script to bring up bridged network interfaces (veth's) in a VE&lt;br /&gt;
&lt;br /&gt;
CONFIGFILE=/etc/vz/conf/$VEID.conf&lt;br /&gt;
. $CONFIGFILE&lt;br /&gt;
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`&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 VE$VEIDI 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 VE$VEIDI has no veth interface configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
for IP in $VETH_IP_ADDRESS; do&lt;br /&gt;
   echo &amp;quot;Adding interface $VZHOSTIF and route $IP for VE$VEID to VE0&amp;quot;&lt;br /&gt;
   /sbin/ifconfig $VZHOSTIF 0&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/proxy_arp&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/forwarding&lt;br /&gt;
   /sbin/ip route add $IP dev $VZHOSTIF&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;
3. Now create /etc/vz/vznet.conf containing the following. This is what defines the &amp;quot;custom script&amp;quot; as being the vznetaddroute which you just created.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
EXTERNAL_SCRIPT=&amp;quot;/usr/sbin/vznetaddroute&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Of course, the VE's operating system will need to be configured with those IP address(es) as well. Consult the manual for your VE's OS for details.&lt;br /&gt;
&lt;br /&gt;
That's it! At this point, when you restart the VE you should see a new line in the output, indicating that the interface is being configured and a new route being added. And you should be able to ping the host, and to enter the VE and use the network.&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices + VLAN ===&lt;br /&gt;
This configuration can be done by adding vlan device to the previous 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;
== External links ==&lt;br /&gt;
* [http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/hints-daemons-radvd.html Linux IPv6 HOWTO, a chapter about radvd]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Networking]]&lt;br /&gt;
[[Category: HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3128</id>
		<title>Virtual Ethernet device</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3128"/>
		<updated>2007-05-26T08:16:51Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* syntax vzctl version &amp;gt;= 3.0.14 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Virtual ethernet device''' is an ethernet-like device which can be used inside a [[VE]]. Unlike&lt;br /&gt;
[[venet]] network device, veth device has a MAC address. Due to this, it can be used in configurations, when veth is bridged to ethX or other device and VE user fully sets up his networking himself, &lt;br /&gt;
including IPs, gateways etc.&lt;br /&gt;
&lt;br /&gt;
Virtual ethernet device consist of two ethernet devices - one in [[VE0]] and another one &lt;br /&gt;
in VE. These devices are connected to each other, so if a packet goes to one&lt;br /&gt;
device it will come out from the other device.&lt;br /&gt;
&lt;br /&gt;
== Virtual ethernet device usage ==&lt;br /&gt;
&lt;br /&gt;
=== Kernel module ===&lt;br /&gt;
First of all, make sure the &amp;lt;code&amp;gt;vzethdev&amp;lt;/code&amp;gt; module is loaded:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# lsmod | grep vzeth&lt;br /&gt;
vzethdev                8224  0&lt;br /&gt;
vzmon                  35164  5 vzethdev,vznetdev,vzrst,vzcpt&lt;br /&gt;
vzdev                   3080  4 vzethdev,vznetdev,vzmon,vzdquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case it is not loaded, load it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# modprobe vzethdev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might want to add the module to &amp;lt;code&amp;gt;/etc/init.d/vz script&amp;lt;/code&amp;gt;, so it will be loaded during startup.&lt;br /&gt;
&lt;br /&gt;
{{Note|since vzctl version 3.0.11, vzethdev is loaded by /etc/init.d/vz}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Adding veth to a VE ===&lt;br /&gt;
&lt;br /&gt;
{{Note|Use random MAC addresses. Do not use MAC addresses of real eth devices, because this can lead to collisions and MAC addresses must be entered in XX:XX:XX:XX:XX:XX format.}}&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_add &amp;lt;dev_name&amp;gt;,&amp;lt;dev_addr&amp;gt;,&amp;lt;ve_dev_name&amp;gt;,&amp;lt;ve_dev_addr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name that you are creating on the [[VE0|host system]]&lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_name&amp;lt;/tt&amp;gt; is the corresponding ethernet device name you are creating on the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
&lt;br /&gt;
{{Note| that this option is incremental, so devices are added to already existing ones.}}&lt;br /&gt;
&lt;br /&gt;
NB there are no spaces after the commas&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command &amp;lt;tt&amp;gt;veth&amp;lt;/tt&amp;gt; device will be created for VE 101 and veth configuration will be saved to a VE configuration file.&lt;br /&gt;
Host-side ethernet device will have &amp;lt;tt&amp;gt;veth101.0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9A&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
VE-side ethernet device will have &amp;lt;tt&amp;gt;eth0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9B&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
Read Update infos about [http://openvz.org/news/updates/vzctl-3.0.14-1 vzctl 3.0.14]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_add &amp;lt;ifname&amp;gt;[,&amp;lt;mac&amp;gt;,&amp;lt;host_ifname&amp;gt;,&amp;lt;host_mac]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;tt&amp;gt;ifname&amp;lt;/tt&amp;gt; is the ethernet device name in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;mac&amp;lt;/tt&amp;gt; is its MAC address in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_ifname&amp;lt;/tt&amp;gt;  is the ethernet device name on the host ([[VE0]])&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_mac&amp;lt;/tt&amp;gt; is its MAC address on the host ([[VE0]])&lt;br /&gt;
&lt;br /&gt;
{{Note|All parameters except ifname are optional and are automatically generated if not specified.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_add eth0,00:12:34:56:78:9A,veth101.0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
o There is a utility script available for generating MAC addresses: &lt;br /&gt;
&lt;br /&gt;
http://www.easyvmx.com/software/easymac.sh&lt;br /&gt;
&lt;br /&gt;
o Recommended Usage: &lt;br /&gt;
&lt;br /&gt;
' chmod +x easymac.sh '&lt;br /&gt;
&lt;br /&gt;
' ./easymac.sh -R '&lt;br /&gt;
&lt;br /&gt;
=== Removing veth from a VE ===&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_del &amp;lt;dev_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name in the [[VE0|host system]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_del veth101.0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command veth device with host-side ethernet name veth101.0 will be removed from VE 101 and veth configuration will be updated in VE config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_del &amp;lt;dev_name&amp;gt;|all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;code&amp;gt;dev_name&amp;lt;/code&amp;gt; is the ethernet device name in the [[VE]].&lt;br /&gt;
&lt;br /&gt;
{{Note|If you want to remove all ethernet devices in VE, use &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_del eth0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Common configurations with virtual ethernet devices ==&lt;br /&gt;
Module &amp;lt;tt&amp;gt;vzethdev&amp;lt;/tt&amp;gt; must be loaded to operate with veth devices.&lt;br /&gt;
&lt;br /&gt;
=== Simple configuration with virtual ethernet device ===&lt;br /&gt;
&lt;br /&gt;
==== Start a VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in VE0 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/proxy_arp&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
[ve-101]# /sbin/ip addr add 192.168.0.101 dev eth0&lt;br /&gt;
[ve-101]# /sbin/ip route add default dev eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add route in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.0.101 dev veth101.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet device with IPv6 ===&lt;br /&gt;
&lt;br /&gt;
==== Start [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/all/forwarding&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start router advertisement daemon (radvd) for IPv6 in VE0 ====&lt;br /&gt;
First you need to edit radvd configuration file. Here is a simple example of &amp;lt;tt&amp;gt;/etc/radv.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interface veth101.0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:2400:0:0::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
interface eth0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:0302:0011:0002::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start radvd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# /etc/init.d/radvd start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add IPv6 addresses to devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip addr add dev veth101.0 3ffe:2400::212:34ff:fe56:789a/64&lt;br /&gt;
[host-node]# ip addr add dev eth0 3ffe:0302:0011:0002:211:22ff:fe33:4455/64&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices can be joined in one bridge ===&lt;br /&gt;
Perform steps 1 - 4 from Simple configuration chapter for several VEs and/or veth devices&lt;br /&gt;
&lt;br /&gt;
==== Create bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addbr vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth devices to bridge ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.n&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth102.0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 vethXXX.N&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig vzbr0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add routes in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.101.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.101.n dev vzbr0&lt;br /&gt;
[host-node]# ip route add 192.168.102.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.XXX.N dev vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus you'll have more convinient configuration, i.e. all routes to VEs will be through this bridge and VEs can communicate with each other even without these routes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Making a veth-device persistent ===&lt;br /&gt;
&lt;br /&gt;
At the moment, it is not possible to have the commands needed for a persistent veth being made automatically be vzctl. A  bugreport ( http://bugzilla.openvz.org/show_bug.cgi?id=301 ) has already been made. Until then, here's a way to make the above steps persistent.&lt;br /&gt;
&lt;br /&gt;
1. First, edit the VE's configuration to specify what the veth's IP address(es) should be, and to indicate that a custom script should be run when starting up a VE.&lt;br /&gt;
 * Open up /etc/vz/conf/VEID.conf&lt;br /&gt;
 * Comment out any IP_ADDRESS entries to prevent a VENET-device from being created in the VE&lt;br /&gt;
 * Add or change the entry CONFIG_CUSTOMIZED=&amp;quot;yes&amp;quot;&lt;br /&gt;
 * Add an entry VETH_IP_ADDRESS=&amp;quot;&amp;lt;VE IP&amp;gt;&amp;quot; The VE IP can have multiple IPs, separated by spaces&lt;br /&gt;
&lt;br /&gt;
2. Now to create that &amp;quot;custom script&amp;quot;. The following helper script will check the configuration file for IP addresses and for the veth interface, and configure the IP routing accordingly. Create the script /usr/sbin/vznetaddroute to have the following, and then &amp;lt;code&amp;gt;chmod 0500 /usr/sbin/vznetaddroute&amp;lt;/code&amp;gt; to make it executable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# /usr/sbin/vznetaddroute&lt;br /&gt;
# a script to bring up bridged network interfaces (veth's) in a VE&lt;br /&gt;
&lt;br /&gt;
CONFIGFILE=/etc/vz/conf/$VEID.conf&lt;br /&gt;
. $CONFIGFILE&lt;br /&gt;
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`&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 VE$VEIDI 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 VE$VEIDI has no veth interface configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
for IP in $VETH_IP_ADDRESS; do&lt;br /&gt;
   echo &amp;quot;Adding interface $VZHOSTIF and route $IP for VE$VEID to VE0&amp;quot;&lt;br /&gt;
   /sbin/ifconfig $VZHOSTIF 0&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/proxy_arp&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/forwarding&lt;br /&gt;
   /sbin/ip route add $IP dev $VZHOSTIF&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;
3. Now create /etc/vz/vznet.conf containing the following. This is what defines the &amp;quot;custom script&amp;quot; as being the vznetaddroute which you just created.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
EXTERNAL_SCRIPT=&amp;quot;/usr/sbin/vznetaddroute&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Of course, the VE's operating system will need to be configured with those IP address(es) as well. Consult the manual for your VE's OS for details.&lt;br /&gt;
&lt;br /&gt;
That's it! At this point, when you restart the VE you should see a new line in the output, indicating that the interface is being configured and a new route being added. And you should be able to ping the host, and to enter the VE and use the network.&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices + VLAN ===&lt;br /&gt;
This configuration can be done by adding vlan device to the previous 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;
== External links ==&lt;br /&gt;
* [http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/hints-daemons-radvd.html Linux IPv6 HOWTO, a chapter about radvd]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Networking]]&lt;br /&gt;
[[Category: HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3127</id>
		<title>Virtual Ethernet device</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3127"/>
		<updated>2007-05-26T08:16:33Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* syntax vzctl version &amp;gt;= 3.0.14 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Virtual ethernet device''' is an ethernet-like device which can be used inside a [[VE]]. Unlike&lt;br /&gt;
[[venet]] network device, veth device has a MAC address. Due to this, it can be used in configurations, when veth is bridged to ethX or other device and VE user fully sets up his networking himself, &lt;br /&gt;
including IPs, gateways etc.&lt;br /&gt;
&lt;br /&gt;
Virtual ethernet device consist of two ethernet devices - one in [[VE0]] and another one &lt;br /&gt;
in VE. These devices are connected to each other, so if a packet goes to one&lt;br /&gt;
device it will come out from the other device.&lt;br /&gt;
&lt;br /&gt;
== Virtual ethernet device usage ==&lt;br /&gt;
&lt;br /&gt;
=== Kernel module ===&lt;br /&gt;
First of all, make sure the &amp;lt;code&amp;gt;vzethdev&amp;lt;/code&amp;gt; module is loaded:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# lsmod | grep vzeth&lt;br /&gt;
vzethdev                8224  0&lt;br /&gt;
vzmon                  35164  5 vzethdev,vznetdev,vzrst,vzcpt&lt;br /&gt;
vzdev                   3080  4 vzethdev,vznetdev,vzmon,vzdquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case it is not loaded, load it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# modprobe vzethdev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might want to add the module to &amp;lt;code&amp;gt;/etc/init.d/vz script&amp;lt;/code&amp;gt;, so it will be loaded during startup.&lt;br /&gt;
&lt;br /&gt;
{{Note|since vzctl version 3.0.11, vzethdev is loaded by /etc/init.d/vz}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Adding veth to a VE ===&lt;br /&gt;
&lt;br /&gt;
{{Note|Use random MAC addresses. Do not use MAC addresses of real eth devices, because this can lead to collisions and MAC addresses must be entered in XX:XX:XX:XX:XX:XX format.}}&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_add &amp;lt;dev_name&amp;gt;,&amp;lt;dev_addr&amp;gt;,&amp;lt;ve_dev_name&amp;gt;,&amp;lt;ve_dev_addr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name that you are creating on the [[VE0|host system]]&lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_name&amp;lt;/tt&amp;gt; is the corresponding ethernet device name you are creating on the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
&lt;br /&gt;
{{Note| that this option is incremental, so devices are added to already existing ones.}}&lt;br /&gt;
&lt;br /&gt;
NB there are no spaces after the commas&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command &amp;lt;tt&amp;gt;veth&amp;lt;/tt&amp;gt; device will be created for VE 101 and veth configuration will be saved to a VE configuration file.&lt;br /&gt;
Host-side ethernet device will have &amp;lt;tt&amp;gt;veth101.0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9A&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
VE-side ethernet device will have &amp;lt;tt&amp;gt;eth0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9B&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
Read Update infos about [http://openvz.org/news/updates/vzctl-3.0.14-1 vzctl 3.0.14]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_add &amp;lt;ifname&amp;gt;[,&amp;lt;mac&amp;gt;,&amp;lt;host_ifname&amp;gt;,&amp;lt;host_mac]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;tt&amp;gt;ifname&amp;lt;/tt&amp;gt; is the ethernet device name in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;mac&amp;lt;/tt&amp;gt; is its MAC address in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_ifname&amp;lt;/tt&amp;gt;  is the ethernet device name on the host ([[VE0]])&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_mac&amp;lt;/tt&amp;gt; is its MAC address on the host ([[VE0]])&lt;br /&gt;
&lt;br /&gt;
{{Note|All parameters except ifname are optional and are automatically generated if not specified.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_add eth0,00:12:34:56:78:9A,veth101.0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
o There is a utility script available for generating MAC addresses: &lt;br /&gt;
&lt;br /&gt;
http://www.easyvmx.com/software/easymac.sh&lt;br /&gt;
&lt;br /&gt;
o Recommended Usage: &lt;br /&gt;
' chmod +x easymac.sh '&lt;br /&gt;
&lt;br /&gt;
' ./easymac.sh -R '&lt;br /&gt;
&lt;br /&gt;
=== Removing veth from a VE ===&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_del &amp;lt;dev_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name in the [[VE0|host system]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_del veth101.0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command veth device with host-side ethernet name veth101.0 will be removed from VE 101 and veth configuration will be updated in VE config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_del &amp;lt;dev_name&amp;gt;|all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;code&amp;gt;dev_name&amp;lt;/code&amp;gt; is the ethernet device name in the [[VE]].&lt;br /&gt;
&lt;br /&gt;
{{Note|If you want to remove all ethernet devices in VE, use &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_del eth0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Common configurations with virtual ethernet devices ==&lt;br /&gt;
Module &amp;lt;tt&amp;gt;vzethdev&amp;lt;/tt&amp;gt; must be loaded to operate with veth devices.&lt;br /&gt;
&lt;br /&gt;
=== Simple configuration with virtual ethernet device ===&lt;br /&gt;
&lt;br /&gt;
==== Start a VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in VE0 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/proxy_arp&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
[ve-101]# /sbin/ip addr add 192.168.0.101 dev eth0&lt;br /&gt;
[ve-101]# /sbin/ip route add default dev eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add route in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.0.101 dev veth101.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet device with IPv6 ===&lt;br /&gt;
&lt;br /&gt;
==== Start [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/all/forwarding&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start router advertisement daemon (radvd) for IPv6 in VE0 ====&lt;br /&gt;
First you need to edit radvd configuration file. Here is a simple example of &amp;lt;tt&amp;gt;/etc/radv.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interface veth101.0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:2400:0:0::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
interface eth0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:0302:0011:0002::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start radvd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# /etc/init.d/radvd start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add IPv6 addresses to devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip addr add dev veth101.0 3ffe:2400::212:34ff:fe56:789a/64&lt;br /&gt;
[host-node]# ip addr add dev eth0 3ffe:0302:0011:0002:211:22ff:fe33:4455/64&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices can be joined in one bridge ===&lt;br /&gt;
Perform steps 1 - 4 from Simple configuration chapter for several VEs and/or veth devices&lt;br /&gt;
&lt;br /&gt;
==== Create bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addbr vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth devices to bridge ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.n&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth102.0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 vethXXX.N&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig vzbr0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add routes in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.101.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.101.n dev vzbr0&lt;br /&gt;
[host-node]# ip route add 192.168.102.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.XXX.N dev vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus you'll have more convinient configuration, i.e. all routes to VEs will be through this bridge and VEs can communicate with each other even without these routes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Making a veth-device persistent ===&lt;br /&gt;
&lt;br /&gt;
At the moment, it is not possible to have the commands needed for a persistent veth being made automatically be vzctl. A  bugreport ( http://bugzilla.openvz.org/show_bug.cgi?id=301 ) has already been made. Until then, here's a way to make the above steps persistent.&lt;br /&gt;
&lt;br /&gt;
1. First, edit the VE's configuration to specify what the veth's IP address(es) should be, and to indicate that a custom script should be run when starting up a VE.&lt;br /&gt;
 * Open up /etc/vz/conf/VEID.conf&lt;br /&gt;
 * Comment out any IP_ADDRESS entries to prevent a VENET-device from being created in the VE&lt;br /&gt;
 * Add or change the entry CONFIG_CUSTOMIZED=&amp;quot;yes&amp;quot;&lt;br /&gt;
 * Add an entry VETH_IP_ADDRESS=&amp;quot;&amp;lt;VE IP&amp;gt;&amp;quot; The VE IP can have multiple IPs, separated by spaces&lt;br /&gt;
&lt;br /&gt;
2. Now to create that &amp;quot;custom script&amp;quot;. The following helper script will check the configuration file for IP addresses and for the veth interface, and configure the IP routing accordingly. Create the script /usr/sbin/vznetaddroute to have the following, and then &amp;lt;code&amp;gt;chmod 0500 /usr/sbin/vznetaddroute&amp;lt;/code&amp;gt; to make it executable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# /usr/sbin/vznetaddroute&lt;br /&gt;
# a script to bring up bridged network interfaces (veth's) in a VE&lt;br /&gt;
&lt;br /&gt;
CONFIGFILE=/etc/vz/conf/$VEID.conf&lt;br /&gt;
. $CONFIGFILE&lt;br /&gt;
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`&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 VE$VEIDI 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 VE$VEIDI has no veth interface configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
for IP in $VETH_IP_ADDRESS; do&lt;br /&gt;
   echo &amp;quot;Adding interface $VZHOSTIF and route $IP for VE$VEID to VE0&amp;quot;&lt;br /&gt;
   /sbin/ifconfig $VZHOSTIF 0&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/proxy_arp&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/forwarding&lt;br /&gt;
   /sbin/ip route add $IP dev $VZHOSTIF&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;
3. Now create /etc/vz/vznet.conf containing the following. This is what defines the &amp;quot;custom script&amp;quot; as being the vznetaddroute which you just created.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
EXTERNAL_SCRIPT=&amp;quot;/usr/sbin/vznetaddroute&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Of course, the VE's operating system will need to be configured with those IP address(es) as well. Consult the manual for your VE's OS for details.&lt;br /&gt;
&lt;br /&gt;
That's it! At this point, when you restart the VE you should see a new line in the output, indicating that the interface is being configured and a new route being added. And you should be able to ping the host, and to enter the VE and use the network.&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices + VLAN ===&lt;br /&gt;
This configuration can be done by adding vlan device to the previous 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;
== External links ==&lt;br /&gt;
* [http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/hints-daemons-radvd.html Linux IPv6 HOWTO, a chapter about radvd]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Networking]]&lt;br /&gt;
[[Category: HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3126</id>
		<title>Virtual Ethernet device</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3126"/>
		<updated>2007-05-26T08:16:08Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* syntax vzctl version &amp;gt;= 3.0.14 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Virtual ethernet device''' is an ethernet-like device which can be used inside a [[VE]]. Unlike&lt;br /&gt;
[[venet]] network device, veth device has a MAC address. Due to this, it can be used in configurations, when veth is bridged to ethX or other device and VE user fully sets up his networking himself, &lt;br /&gt;
including IPs, gateways etc.&lt;br /&gt;
&lt;br /&gt;
Virtual ethernet device consist of two ethernet devices - one in [[VE0]] and another one &lt;br /&gt;
in VE. These devices are connected to each other, so if a packet goes to one&lt;br /&gt;
device it will come out from the other device.&lt;br /&gt;
&lt;br /&gt;
== Virtual ethernet device usage ==&lt;br /&gt;
&lt;br /&gt;
=== Kernel module ===&lt;br /&gt;
First of all, make sure the &amp;lt;code&amp;gt;vzethdev&amp;lt;/code&amp;gt; module is loaded:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# lsmod | grep vzeth&lt;br /&gt;
vzethdev                8224  0&lt;br /&gt;
vzmon                  35164  5 vzethdev,vznetdev,vzrst,vzcpt&lt;br /&gt;
vzdev                   3080  4 vzethdev,vznetdev,vzmon,vzdquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case it is not loaded, load it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# modprobe vzethdev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might want to add the module to &amp;lt;code&amp;gt;/etc/init.d/vz script&amp;lt;/code&amp;gt;, so it will be loaded during startup.&lt;br /&gt;
&lt;br /&gt;
{{Note|since vzctl version 3.0.11, vzethdev is loaded by /etc/init.d/vz}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Adding veth to a VE ===&lt;br /&gt;
&lt;br /&gt;
{{Note|Use random MAC addresses. Do not use MAC addresses of real eth devices, because this can lead to collisions and MAC addresses must be entered in XX:XX:XX:XX:XX:XX format.}}&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_add &amp;lt;dev_name&amp;gt;,&amp;lt;dev_addr&amp;gt;,&amp;lt;ve_dev_name&amp;gt;,&amp;lt;ve_dev_addr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name that you are creating on the [[VE0|host system]]&lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_name&amp;lt;/tt&amp;gt; is the corresponding ethernet device name you are creating on the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
&lt;br /&gt;
{{Note| that this option is incremental, so devices are added to already existing ones.}}&lt;br /&gt;
&lt;br /&gt;
NB there are no spaces after the commas&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command &amp;lt;tt&amp;gt;veth&amp;lt;/tt&amp;gt; device will be created for VE 101 and veth configuration will be saved to a VE configuration file.&lt;br /&gt;
Host-side ethernet device will have &amp;lt;tt&amp;gt;veth101.0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9A&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
VE-side ethernet device will have &amp;lt;tt&amp;gt;eth0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9B&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
Read Update infos about [http://openvz.org/news/updates/vzctl-3.0.14-1 vzctl 3.0.14]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_add &amp;lt;ifname&amp;gt;[,&amp;lt;mac&amp;gt;,&amp;lt;host_ifname&amp;gt;,&amp;lt;host_mac]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;tt&amp;gt;ifname&amp;lt;/tt&amp;gt; is the ethernet device name in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;mac&amp;lt;/tt&amp;gt; is its MAC address in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_ifname&amp;lt;/tt&amp;gt;  is the ethernet device name on the host ([[VE0]])&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_mac&amp;lt;/tt&amp;gt; is its MAC address on the host ([[VE0]])&lt;br /&gt;
&lt;br /&gt;
{{Note|All parameters except ifname are optional and are automatically generated if not specified.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_add eth0,00:12:34:56:78:9A,veth101.0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
o There is a utility script available for generating MAC addresses: &lt;br /&gt;
&lt;br /&gt;
http://www.easyvmx.com/software/easymac.sh&lt;br /&gt;
&lt;br /&gt;
o Recommended Usage: &lt;br /&gt;
' chmod +x easymac.sh '&lt;br /&gt;
' ./easymac.sh -R '&lt;br /&gt;
&lt;br /&gt;
=== Removing veth from a VE ===&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_del &amp;lt;dev_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name in the [[VE0|host system]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_del veth101.0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command veth device with host-side ethernet name veth101.0 will be removed from VE 101 and veth configuration will be updated in VE config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_del &amp;lt;dev_name&amp;gt;|all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;code&amp;gt;dev_name&amp;lt;/code&amp;gt; is the ethernet device name in the [[VE]].&lt;br /&gt;
&lt;br /&gt;
{{Note|If you want to remove all ethernet devices in VE, use &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_del eth0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Common configurations with virtual ethernet devices ==&lt;br /&gt;
Module &amp;lt;tt&amp;gt;vzethdev&amp;lt;/tt&amp;gt; must be loaded to operate with veth devices.&lt;br /&gt;
&lt;br /&gt;
=== Simple configuration with virtual ethernet device ===&lt;br /&gt;
&lt;br /&gt;
==== Start a VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in VE0 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/proxy_arp&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
[ve-101]# /sbin/ip addr add 192.168.0.101 dev eth0&lt;br /&gt;
[ve-101]# /sbin/ip route add default dev eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add route in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.0.101 dev veth101.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet device with IPv6 ===&lt;br /&gt;
&lt;br /&gt;
==== Start [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/all/forwarding&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start router advertisement daemon (radvd) for IPv6 in VE0 ====&lt;br /&gt;
First you need to edit radvd configuration file. Here is a simple example of &amp;lt;tt&amp;gt;/etc/radv.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interface veth101.0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:2400:0:0::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
interface eth0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:0302:0011:0002::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start radvd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# /etc/init.d/radvd start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add IPv6 addresses to devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip addr add dev veth101.0 3ffe:2400::212:34ff:fe56:789a/64&lt;br /&gt;
[host-node]# ip addr add dev eth0 3ffe:0302:0011:0002:211:22ff:fe33:4455/64&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices can be joined in one bridge ===&lt;br /&gt;
Perform steps 1 - 4 from Simple configuration chapter for several VEs and/or veth devices&lt;br /&gt;
&lt;br /&gt;
==== Create bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addbr vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth devices to bridge ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.n&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth102.0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 vethXXX.N&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig vzbr0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add routes in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.101.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.101.n dev vzbr0&lt;br /&gt;
[host-node]# ip route add 192.168.102.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.XXX.N dev vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus you'll have more convinient configuration, i.e. all routes to VEs will be through this bridge and VEs can communicate with each other even without these routes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Making a veth-device persistent ===&lt;br /&gt;
&lt;br /&gt;
At the moment, it is not possible to have the commands needed for a persistent veth being made automatically be vzctl. A  bugreport ( http://bugzilla.openvz.org/show_bug.cgi?id=301 ) has already been made. Until then, here's a way to make the above steps persistent.&lt;br /&gt;
&lt;br /&gt;
1. First, edit the VE's configuration to specify what the veth's IP address(es) should be, and to indicate that a custom script should be run when starting up a VE.&lt;br /&gt;
 * Open up /etc/vz/conf/VEID.conf&lt;br /&gt;
 * Comment out any IP_ADDRESS entries to prevent a VENET-device from being created in the VE&lt;br /&gt;
 * Add or change the entry CONFIG_CUSTOMIZED=&amp;quot;yes&amp;quot;&lt;br /&gt;
 * Add an entry VETH_IP_ADDRESS=&amp;quot;&amp;lt;VE IP&amp;gt;&amp;quot; The VE IP can have multiple IPs, separated by spaces&lt;br /&gt;
&lt;br /&gt;
2. Now to create that &amp;quot;custom script&amp;quot;. The following helper script will check the configuration file for IP addresses and for the veth interface, and configure the IP routing accordingly. Create the script /usr/sbin/vznetaddroute to have the following, and then &amp;lt;code&amp;gt;chmod 0500 /usr/sbin/vznetaddroute&amp;lt;/code&amp;gt; to make it executable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# /usr/sbin/vznetaddroute&lt;br /&gt;
# a script to bring up bridged network interfaces (veth's) in a VE&lt;br /&gt;
&lt;br /&gt;
CONFIGFILE=/etc/vz/conf/$VEID.conf&lt;br /&gt;
. $CONFIGFILE&lt;br /&gt;
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`&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 VE$VEIDI 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 VE$VEIDI has no veth interface configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
for IP in $VETH_IP_ADDRESS; do&lt;br /&gt;
   echo &amp;quot;Adding interface $VZHOSTIF and route $IP for VE$VEID to VE0&amp;quot;&lt;br /&gt;
   /sbin/ifconfig $VZHOSTIF 0&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/proxy_arp&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/forwarding&lt;br /&gt;
   /sbin/ip route add $IP dev $VZHOSTIF&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;
3. Now create /etc/vz/vznet.conf containing the following. This is what defines the &amp;quot;custom script&amp;quot; as being the vznetaddroute which you just created.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
EXTERNAL_SCRIPT=&amp;quot;/usr/sbin/vznetaddroute&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Of course, the VE's operating system will need to be configured with those IP address(es) as well. Consult the manual for your VE's OS for details.&lt;br /&gt;
&lt;br /&gt;
That's it! At this point, when you restart the VE you should see a new line in the output, indicating that the interface is being configured and a new route being added. And you should be able to ping the host, and to enter the VE and use the network.&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices + VLAN ===&lt;br /&gt;
This configuration can be done by adding vlan device to the previous 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;
== External links ==&lt;br /&gt;
* [http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/hints-daemons-radvd.html Linux IPv6 HOWTO, a chapter about radvd]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Networking]]&lt;br /&gt;
[[Category: HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3125</id>
		<title>Virtual Ethernet device</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=3125"/>
		<updated>2007-05-26T08:07:41Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* syntax vzctl version &amp;gt;= 3.0.14 */ + Added easymac script link + usage ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Virtual ethernet device''' is an ethernet-like device which can be used inside a [[VE]]. Unlike&lt;br /&gt;
[[venet]] network device, veth device has a MAC address. Due to this, it can be used in configurations, when veth is bridged to ethX or other device and VE user fully sets up his networking himself, &lt;br /&gt;
including IPs, gateways etc.&lt;br /&gt;
&lt;br /&gt;
Virtual ethernet device consist of two ethernet devices - one in [[VE0]] and another one &lt;br /&gt;
in VE. These devices are connected to each other, so if a packet goes to one&lt;br /&gt;
device it will come out from the other device.&lt;br /&gt;
&lt;br /&gt;
== Virtual ethernet device usage ==&lt;br /&gt;
&lt;br /&gt;
=== Kernel module ===&lt;br /&gt;
First of all, make sure the &amp;lt;code&amp;gt;vzethdev&amp;lt;/code&amp;gt; module is loaded:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# lsmod | grep vzeth&lt;br /&gt;
vzethdev                8224  0&lt;br /&gt;
vzmon                  35164  5 vzethdev,vznetdev,vzrst,vzcpt&lt;br /&gt;
vzdev                   3080  4 vzethdev,vznetdev,vzmon,vzdquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case it is not loaded, load it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# modprobe vzethdev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might want to add the module to &amp;lt;code&amp;gt;/etc/init.d/vz script&amp;lt;/code&amp;gt;, so it will be loaded during startup.&lt;br /&gt;
&lt;br /&gt;
{{Note|since vzctl version 3.0.11, vzethdev is loaded by /etc/init.d/vz}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Adding veth to a VE ===&lt;br /&gt;
&lt;br /&gt;
{{Note|Use random MAC addresses. Do not use MAC addresses of real eth devices, because this can lead to collisions and MAC addresses must be entered in XX:XX:XX:XX:XX:XX format.}}&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_add &amp;lt;dev_name&amp;gt;,&amp;lt;dev_addr&amp;gt;,&amp;lt;ve_dev_name&amp;gt;,&amp;lt;ve_dev_addr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name that you are creating on the [[VE0|host system]]&lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_name&amp;lt;/tt&amp;gt; is the corresponding ethernet device name you are creating on the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
&lt;br /&gt;
{{Note| that this option is incremental, so devices are added to already existing ones.}}&lt;br /&gt;
&lt;br /&gt;
NB there are no spaces after the commas&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command &amp;lt;tt&amp;gt;veth&amp;lt;/tt&amp;gt; device will be created for VE 101 and veth configuration will be saved to a VE configuration file.&lt;br /&gt;
Host-side ethernet device will have &amp;lt;tt&amp;gt;veth101.0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9A&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
VE-side ethernet device will have &amp;lt;tt&amp;gt;eth0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9B&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
Read Update infos about [http://openvz.org/news/updates/vzctl-3.0.14-1 vzctl 3.0.14]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_add &amp;lt;ifname&amp;gt;[,&amp;lt;mac&amp;gt;,&amp;lt;host_ifname&amp;gt;,&amp;lt;host_mac]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;tt&amp;gt;ifname&amp;lt;/tt&amp;gt; is the ethernet device name in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;mac&amp;lt;/tt&amp;gt; is its MAC address in the VE&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_ifname&amp;lt;/tt&amp;gt;  is the ethernet device name on the host ([[VE0]])&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_mac&amp;lt;/tt&amp;gt; is its MAC address on the host ([[VE0]])&lt;br /&gt;
&lt;br /&gt;
{{Note|All parameters except ifname are optional and are automatically generated if not specified.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_add eth0,00:12:34:56:78:9A,veth101.0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o There is a utility script available for generating MAC addresses: &lt;br /&gt;
http://www.easyvmx.com/software/easymac.sh&lt;br /&gt;
&lt;br /&gt;
o Recommended Usage: ' chmod +x easymac.sh; ./easymac.sh -R '&lt;br /&gt;
&lt;br /&gt;
=== Removing veth from a VE ===&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --veth_del &amp;lt;dev_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the ethernet device name in the [[VE0|host system]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --veth_del veth101.0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After executing this command veth device with host-side ethernet name veth101.0 will be removed from VE 101 and veth configuration will be updated in VE config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set &amp;lt;VEID&amp;gt; --netif_del &amp;lt;dev_name&amp;gt;|all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;code&amp;gt;dev_name&amp;lt;/code&amp;gt; is the ethernet device name in the [[VE]].&lt;br /&gt;
&lt;br /&gt;
{{Note|If you want to remove all ethernet devices in VE, use &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --netif_del eth0 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Common configurations with virtual ethernet devices ==&lt;br /&gt;
Module &amp;lt;tt&amp;gt;vzethdev&amp;lt;/tt&amp;gt; must be loaded to operate with veth devices.&lt;br /&gt;
&lt;br /&gt;
=== Simple configuration with virtual ethernet device ===&lt;br /&gt;
&lt;br /&gt;
==== Start a VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in VE0 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/proxy_arp&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in VE ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
[ve-101]# /sbin/ip addr add 192.168.0.101 dev eth0&lt;br /&gt;
[ve-101]# /sbin/ip route add default dev eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add route in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.0.101 dev veth101.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet device with IPv6 ===&lt;br /&gt;
&lt;br /&gt;
==== Start [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl start 101&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/all/forwarding&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure device in [[VE]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start router advertisement daemon (radvd) for IPv6 in VE0 ====&lt;br /&gt;
First you need to edit radvd configuration file. Here is a simple example of &amp;lt;tt&amp;gt;/etc/radv.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interface veth101.0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:2400:0:0::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
interface eth0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:0302:0011:0002::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start radvd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# /etc/init.d/radvd start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add IPv6 addresses to devices in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip addr add dev veth101.0 3ffe:2400::212:34ff:fe56:789a/64&lt;br /&gt;
[host-node]# ip addr add dev eth0 3ffe:0302:0011:0002:211:22ff:fe33:4455/64&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices can be joined in one bridge ===&lt;br /&gt;
Perform steps 1 - 4 from Simple configuration chapter for several VEs and/or veth devices&lt;br /&gt;
&lt;br /&gt;
==== Create bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addbr vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth devices to bridge ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.n&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth102.0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 vethXXX.N&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig vzbr0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add routes in [[VE0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.101.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.101.n dev vzbr0&lt;br /&gt;
[host-node]# ip route add 192.168.102.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.XXX.N dev vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus you'll have more convinient configuration, i.e. all routes to VEs will be through this bridge and VEs can communicate with each other even without these routes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Making a veth-device persistent ===&lt;br /&gt;
&lt;br /&gt;
At the moment, it is not possible to have the commands needed for a persistent veth being made automatically be vzctl. A  bugreport ( http://bugzilla.openvz.org/show_bug.cgi?id=301 ) has already been made. Until then, here's a way to make the above steps persistent.&lt;br /&gt;
&lt;br /&gt;
1. First, edit the VE's configuration to specify what the veth's IP address(es) should be, and to indicate that a custom script should be run when starting up a VE.&lt;br /&gt;
 * Open up /etc/vz/conf/VEID.conf&lt;br /&gt;
 * Comment out any IP_ADDRESS entries to prevent a VENET-device from being created in the VE&lt;br /&gt;
 * Add or change the entry CONFIG_CUSTOMIZED=&amp;quot;yes&amp;quot;&lt;br /&gt;
 * Add an entry VETH_IP_ADDRESS=&amp;quot;&amp;lt;VE IP&amp;gt;&amp;quot; The VE IP can have multiple IPs, separated by spaces&lt;br /&gt;
&lt;br /&gt;
2. Now to create that &amp;quot;custom script&amp;quot;. The following helper script will check the configuration file for IP addresses and for the veth interface, and configure the IP routing accordingly. Create the script /usr/sbin/vznetaddroute to have the following, and then &amp;lt;code&amp;gt;chmod 0500 /usr/sbin/vznetaddroute&amp;lt;/code&amp;gt; to make it executable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# /usr/sbin/vznetaddroute&lt;br /&gt;
# a script to bring up bridged network interfaces (veth's) in a VE&lt;br /&gt;
&lt;br /&gt;
CONFIGFILE=/etc/vz/conf/$VEID.conf&lt;br /&gt;
. $CONFIGFILE&lt;br /&gt;
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`&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 VE$VEIDI 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 VE$VEIDI has no veth interface configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
for IP in $VETH_IP_ADDRESS; do&lt;br /&gt;
   echo &amp;quot;Adding interface $VZHOSTIF and route $IP for VE$VEID to VE0&amp;quot;&lt;br /&gt;
   /sbin/ifconfig $VZHOSTIF 0&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/proxy_arp&lt;br /&gt;
   echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/forwarding&lt;br /&gt;
   /sbin/ip route add $IP dev $VZHOSTIF&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;
3. Now create /etc/vz/vznet.conf containing the following. This is what defines the &amp;quot;custom script&amp;quot; as being the vznetaddroute which you just created.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
EXTERNAL_SCRIPT=&amp;quot;/usr/sbin/vznetaddroute&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Of course, the VE's operating system will need to be configured with those IP address(es) as well. Consult the manual for your VE's OS for details.&lt;br /&gt;
&lt;br /&gt;
That's it! At this point, when you restart the VE you should see a new line in the output, indicating that the interface is being configured and a new route being added. And you should be able to ping the host, and to enter the VE and use the network.&lt;br /&gt;
&lt;br /&gt;
=== Virtual ethernet devices + VLAN ===&lt;br /&gt;
This configuration can be done by adding vlan device to the previous 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;
== External links ==&lt;br /&gt;
* [http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/hints-daemons-radvd.html Linux IPv6 HOWTO, a chapter about radvd]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Networking]]&lt;br /&gt;
[[Category: HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Timezone&amp;diff=3124</id>
		<title>Timezone</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Timezone&amp;diff=3124"/>
		<updated>2007-05-26T07:51:27Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Time difference between Hardware Node and VPS&lt;br /&gt;
&lt;br /&gt;
During the distribution (redhat/centos) installer, you choose the timezone for your HN. The VE template has its own preconfigured timezone. So, its very possible for the zones to differ.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To resolve the problem, You should configure your VE to have the same timezone as the HN. For example, if EST is your preferred timezone:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;rm -rf /etc/localtime 2&amp;gt;/dev/null; unlink /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
ln -s /usr/share/zoneinfo/EST /etc/localtime&lt;br /&gt;
vzctl exec 1041 rm -rf /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
vzctl exec 1041 unlink /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
vzctl exec 1041 ln -s /usr/share/zoneinfo/EST /etc/localtime&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Debian:&lt;br /&gt;
&lt;br /&gt;
o ' tzconf ' (as root) for interactive timezone change (it asks questions.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can find many more exciting timezones with:&lt;br /&gt;
&lt;br /&gt;
find /usr/share/zoneinfo/ | more&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Or, here is a shell script that will let you change the timezones in ALL of your VPS's:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#! /bin/bash&lt;br /&gt;
for f in `ls /vz/private`&lt;br /&gt;
do&lt;br /&gt;
vzctl exec $f rm -rf /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
vzctl exec $f unlink /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
vzctl exec $f ln -s /usr/share/zoneinfo/CST6CDT /etc/localtime&lt;br /&gt;
done&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Timezone&amp;diff=3123</id>
		<title>Timezone</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Timezone&amp;diff=3123"/>
		<updated>2007-05-26T07:50:22Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: Added debian tzconf info ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Time difference between Hardware Node and VPS&lt;br /&gt;
&lt;br /&gt;
During the distribution (redhat/centos) installer, you choose the timezone for your HN. The VE template has its own preconfigured timezone. So, its very possible for the zones to differ.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To resolve the problem, You should configure your VE to have the same timezone as the HN. For example, if EST is your preferred timezone:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;rm -rf /etc/localtime 2&amp;gt;/dev/null; unlink /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
ln -s /usr/share/zoneinfo/EST /etc/localtime&lt;br /&gt;
vzctl exec 1041 rm -rf /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
vzctl exec 1041 unlink /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
vzctl exec 1041 ln -s /usr/share/zoneinfo/EST /etc/localtime&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Debian:&lt;br /&gt;
&lt;br /&gt;
o ' tzconf ' for interactive timezone change (it asks questions.)&lt;br /&gt;
&lt;br /&gt;
You can find many more exciting timezones with:&lt;br /&gt;
&lt;br /&gt;
find /usr/share/zoneinfo/ | more&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Or, here is a shell script that will let you change the timezones in ALL of your VPS's:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#! /bin/bash&lt;br /&gt;
for f in `ls /vz/private`&lt;br /&gt;
do&lt;br /&gt;
vzctl exec $f rm -rf /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
vzctl exec $f unlink /etc/localtime 2&amp;gt;/dev/null&lt;br /&gt;
vzctl exec $f ln -s /usr/share/zoneinfo/CST6CDT /etc/localtime&lt;br /&gt;
done&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Plesk_in_VE&amp;diff=3122</id>
		<title>Plesk in VE</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Plesk_in_VE&amp;diff=3122"/>
		<updated>2007-05-26T07:39:40Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: Added Plesk &amp;quot;about&amp;quot; link ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Below is an example transcript of installing Plesk into an OpenVZ VE (VE#11):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl create 11 --ostemplate centos-4-i386-default&lt;br /&gt;
Creating VPS private area: /vz/private/11&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VPS private area was created&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --quotaugidlimit 150 --save&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --numproc 400:400 --save&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --kmemsize 16384000:18022400 --save&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --privvmpages 262144:292912 --save&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --hostname=plesk.example.com --save&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --diskspace 2000000:2000000 --save&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --shmpages 16384:16384 --save&lt;br /&gt;
UB limits were set successefully&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --ipadd 127.1.2.3 --save&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --userpasswd root:pass&lt;br /&gt;
Changing password for user root.&lt;br /&gt;
passwd: all authentication tokens updated successfully.&lt;br /&gt;
&lt;br /&gt;
# vzctl set 11 --iptables &amp;quot;iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state ipt_helper iptable_nat ip_nat_ftp ip_nat_irc&amp;quot; --save&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
&lt;br /&gt;
# vzctl start 11&lt;br /&gt;
Starting VPS ...&lt;br /&gt;
VPS is mounted&lt;br /&gt;
Adding IP address(es): 192.168.51.55&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
Set hostname: plesk.local&lt;br /&gt;
Setting quota ugidlimit: 150&lt;br /&gt;
VPS start in progress...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to run a VPN server inside the VE you need to [[VPN via the TUN/TAP device|TUN/TAP module]]. The following commands consolidate what needs to be done: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# modprobe tun&lt;br /&gt;
# lsmod | grep tun&lt;br /&gt;
tun                     6624  0 &lt;br /&gt;
# vzctl set 11 --devices c:10:200:rw --save&lt;br /&gt;
Setting devices&lt;br /&gt;
Saved parameters for VPS 11&lt;br /&gt;
# vzctl exec 11 mkdir -p /dev/net&lt;br /&gt;
# vzctl exec 11 mknod /dev/net/tun c 10 200&lt;br /&gt;
# vzctl exec 11 chmod 600 /dev/net/tun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that the VE's hostname (plesk.example.com) is resolving correctly to the VE's IP address (127.1.2.3). You can also add the corresponding record to /etc/hosts as a workaround.&lt;br /&gt;
&lt;br /&gt;
Then, go to http://www.swsoft.com/download/plesk8/ and download the appropriate autoinstaller or the appropriate RPM. In this case, [[http://download1.swsoft.com/Plesk/Plesk8.1/CentOS4.3/psa_installer_v3.1.0_build061201.02_os_CentOS_4.3_i386|CentOS]] 4.3.&lt;br /&gt;
&lt;br /&gt;
If you want to download the autoinstaller all you need to do is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -f /etc/resolv.conf /vz/private/11/etc/resolv.conf &lt;br /&gt;
# vzctl enter 11&lt;br /&gt;
entered into VE 11&lt;br /&gt;
# cd&lt;br /&gt;
# wget http://download1.swsoft.com/Plesk/Plesk8.1/CentOS4.3/psa_installer_v3.1.0_build061201.02_os_CentOS_4.3_i386&lt;br /&gt;
# chmod a+x psa*&lt;br /&gt;
# ./psa_installer_v3.1.0_build061201.02_os_CentOS_4.3_i386&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Proceed as you would if you were installing Plesk without OpenVZ.&lt;br /&gt;
&lt;br /&gt;
When the installation over you will see something along the lines of:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
                             Congratulations!&lt;br /&gt;
        Plesk has been successfully installed on your server.&lt;br /&gt;
        To complete the system configuration, please proceed to URL:&lt;br /&gt;
        https://plesk.local:8443/ or&lt;br /&gt;
        https://127.0.0.1:8443/&lt;br /&gt;
        Use the login name 'admin' and password 'setup'.&lt;br /&gt;
&lt;br /&gt;
        Further, use the following commands to start and stop Plesk:&lt;br /&gt;
        &amp;quot;/etc/init.d/psa start&amp;quot; and&lt;br /&gt;
        &amp;quot;/etc/init.d/psa stop&amp;quot; respectively.&lt;br /&gt;
&lt;br /&gt;
        All Plesk control panel documentation is available at&lt;br /&gt;
        http://www.swsoft.com/en/products/plesk80/docs&lt;br /&gt;
&lt;br /&gt;
 *****************************************************************************&lt;br /&gt;
 *                                                                           *&lt;br /&gt;
 *      NOTE:   You have a default key file with limited functionality       *&lt;br /&gt;
 *              currently installed for Plesk, which allows                  *&lt;br /&gt;
 *              creating one client account, one domain, one mail name and   *&lt;br /&gt;
 *              one web user.                                                *&lt;br /&gt;
 *              To extend the limits of your license key and enable          *&lt;br /&gt;
 *              additional features, please contact the SWsoft, Inc. sales   *&lt;br /&gt;
 *              department: sales@swsoft.com                                *&lt;br /&gt;
 *                                                                           *&lt;br /&gt;
 *      Thank you for choosing our products!                                 *&lt;br /&gt;
 *****************************************************************************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Plesk install full output]]&lt;br /&gt;
&lt;br /&gt;
o Plesk &amp;quot;about&amp;quot; webpage:&lt;br /&gt;
http://www.swsoft.com/en/products/plesk/&lt;br /&gt;
http://www.swsoft.com/en/products/plesk/docs/&lt;br /&gt;
&lt;br /&gt;
Done. You can create a [[Debian_template_creation#Preparing_for_and_packing_template_cache|prepackaged template]] from this VE for future installations.&lt;br /&gt;
&lt;br /&gt;
[[category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3121</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3121"/>
		<updated>2007-05-26T07:29:52Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Disable Old Physical Interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&lt;br /&gt;
( See: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html )&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;' update-rc.d -f hdparm remove '&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Centos 5:&lt;br /&gt;
&lt;br /&gt;
o ' system-config-network-gui ' from X is the best interface as of May 2007; the commandline variant is not as useful.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Debian and related (Ubuntu, etc):&lt;br /&gt;
&lt;br /&gt;
o Edit /etc/network/interfaces&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# /etc/network/interfaces -- configuration file for ifup(8),  ifdown(8)&lt;br /&gt;
&lt;br /&gt;
# The loopback interface&lt;br /&gt;
# automatically added when upgrading&lt;br /&gt;
auto lo eth0 eth0:1 eth0:2&lt;br /&gt;
# eth0:2 eth0:3&lt;br /&gt;
iface lo inet loopback&lt;br /&gt;
&lt;br /&gt;
iface eth0 inet dhcp&lt;br /&gt;
#       address 10.0.0.4&lt;br /&gt;
#       netmask 255.0.0.0&lt;br /&gt;
#       network 10.0.0.0&lt;br /&gt;
#       broadcast 10.0.0.255&lt;br /&gt;
&lt;br /&gt;
iface eth0:1 inet static&lt;br /&gt;
        address 10.0.0.4&lt;br /&gt;
        netmask 255.0.0.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
iface eth0:2 inet static&lt;br /&gt;
        address 192.168.2.250&lt;br /&gt;
        netmask 255.255.255.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
#iface eth0:3 inet static&lt;br /&gt;
#       address 10.0.81.4&lt;br /&gt;
#       netmask 255.255.255.0&lt;br /&gt;
#       broadcast 255.255.255.255&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o You can either comment out the interface stanza(s), or take it out of the &amp;quot;auto&amp;quot; line(s).&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Suse *Fixme if inaccurate*&lt;br /&gt;
&lt;br /&gt;
o Use Yast&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3120</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3120"/>
		<updated>2007-05-26T07:27:32Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Disable Old Physical Interface */ Fixed &amp;lt;code&amp;gt; ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&lt;br /&gt;
( See: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html )&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;' update-rc.d -f hdparm remove '&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Centos 5:&lt;br /&gt;
&lt;br /&gt;
o ' system-config-network-gui ' from X is the best interface as of May 2007; the commandline variant is not as useful.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Debian and related (Ubuntu, etc):&lt;br /&gt;
&lt;br /&gt;
o Edit /etc/network/interfaces&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# /etc/network/interfaces -- configuration file for ifup(8),  ifdown(8)&lt;br /&gt;
&lt;br /&gt;
# The loopback interface&lt;br /&gt;
# automatically added when upgrading&lt;br /&gt;
auto lo eth0 eth0:1 eth0:2&lt;br /&gt;
# eth0:2 eth0:3&lt;br /&gt;
iface lo inet loopback&lt;br /&gt;
&lt;br /&gt;
iface eth0 inet dhcp&lt;br /&gt;
#       address 10.0.0.4&lt;br /&gt;
#       netmask 255.0.0.0&lt;br /&gt;
#       network 10.0.0.0&lt;br /&gt;
#       broadcast 10.0.0.255&lt;br /&gt;
&lt;br /&gt;
iface eth0:1 inet static&lt;br /&gt;
        address 10.0.0.4&lt;br /&gt;
        netmask 255.0.0.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
iface eth0:2 inet static&lt;br /&gt;
        address 192.168.2.250&lt;br /&gt;
        netmask 255.255.255.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
#iface eth0:3 inet static&lt;br /&gt;
#       address 10.0.81.4&lt;br /&gt;
#       netmask 255.255.255.0&lt;br /&gt;
#       broadcast 255.255.255.255&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o You can either comment out the interface stanza(s), or take it out of the &amp;quot;auto&amp;quot; line(s).&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Suse *Fixme if inaccurate*&lt;br /&gt;
&lt;br /&gt;
o Use Yast&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3119</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3119"/>
		<updated>2007-05-26T07:26:19Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Disable Old Physical Interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&lt;br /&gt;
( See: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html )&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;' update-rc.d -f hdparm remove '&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Centos 5:&lt;br /&gt;
&lt;br /&gt;
o ' system-config-network-gui ' from X is the best interface as of May 2007; the commandline variant is not as useful.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Debian and related (Ubuntu, etc):&lt;br /&gt;
&lt;br /&gt;
o Edit /etc/network/interfaces&lt;br /&gt;
&lt;br /&gt;
[code]&lt;br /&gt;
# /etc/network/interfaces -- configuration file for ifup(8),  ifdown(8)&lt;br /&gt;
&lt;br /&gt;
# The loopback interface&lt;br /&gt;
# automatically added when upgrading&lt;br /&gt;
 auto lo eth0 eth0:1 eth0:2&lt;br /&gt;
# eth0:2 eth0:3&lt;br /&gt;
 iface lo inet loopback&lt;br /&gt;
&lt;br /&gt;
 iface eth0 inet dhcp&lt;br /&gt;
#       address 10.0.0.4&lt;br /&gt;
#       netmask 255.0.0.0&lt;br /&gt;
#       network 10.0.0.0&lt;br /&gt;
#       broadcast 10.0.0.255&lt;br /&gt;
&lt;br /&gt;
 iface eth0:1 inet static&lt;br /&gt;
        address 10.0.0.4&lt;br /&gt;
        netmask 255.0.0.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
 iface eth0:2 inet static&lt;br /&gt;
        address 192.168.2.250&lt;br /&gt;
        netmask 255.255.255.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
#iface eth0:3 inet static&lt;br /&gt;
#       address 10.0.81.4&lt;br /&gt;
#       netmask 255.255.255.0&lt;br /&gt;
#       broadcast 255.255.255.255&lt;br /&gt;
[/code]&lt;br /&gt;
&lt;br /&gt;
o You can either comment out the interface stanza(s), or take it out of the &amp;quot;auto&amp;quot; line(s).&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Suse *Fixme if inaccurate*&lt;br /&gt;
&lt;br /&gt;
o Use Yast&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3118</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3118"/>
		<updated>2007-05-26T07:25:11Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Disable Old Physical Interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&lt;br /&gt;
( See: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html )&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;' update-rc.d -f hdparm remove '&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Centos 5:&lt;br /&gt;
&lt;br /&gt;
o ' system-config-network-gui ' from X is the best interface as of May 2007; the commandline variant is not as useful.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Debian and related (Ubuntu, etc):&lt;br /&gt;
&lt;br /&gt;
o Edit /etc/network/interfaces&lt;br /&gt;
&lt;br /&gt;
[code]&lt;br /&gt;
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)&lt;br /&gt;
&lt;br /&gt;
# The loopback interface&lt;br /&gt;
# automatically added when upgrading&lt;br /&gt;
auto lo eth0 eth0:1 eth0:2&lt;br /&gt;
# eth0:2 eth0:3&lt;br /&gt;
iface lo inet loopback&lt;br /&gt;
&lt;br /&gt;
iface eth0 inet dhcp&lt;br /&gt;
#       address 10.0.0.4&lt;br /&gt;
#       netmask 255.0.0.0&lt;br /&gt;
#       network 10.0.0.0&lt;br /&gt;
#       broadcast 10.0.0.255&lt;br /&gt;
&lt;br /&gt;
iface eth0:1 inet static&lt;br /&gt;
        address 10.0.0.4&lt;br /&gt;
        netmask 255.0.0.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
iface eth0:2 inet static&lt;br /&gt;
        address 192.168.2.250&lt;br /&gt;
        netmask 255.255.255.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
#iface eth0:3 inet static&lt;br /&gt;
#       address 10.0.81.4&lt;br /&gt;
#       netmask 255.255.255.0&lt;br /&gt;
#       broadcast 255.255.255.255&lt;br /&gt;
[/code]&lt;br /&gt;
&lt;br /&gt;
o You can either comment out the interface stanza(s), or take it out of the &amp;quot;auto&amp;quot; line(s).&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Suse *Fixme if inaccurate*&lt;br /&gt;
&lt;br /&gt;
o Use Yast&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3117</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3117"/>
		<updated>2007-05-26T07:23:40Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Disable Old Physical Interface */ Added Centos 5, Debian, Suse ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&lt;br /&gt;
( See: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html )&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;' update-rc.d -f hdparm remove '&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Centos 5:&lt;br /&gt;
&lt;br /&gt;
o ' system-config-network-gui ' from X is the best interface as of May 2007; the commandline variant is not as useful.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Debian and related (Ubuntu, etc):&lt;br /&gt;
&lt;br /&gt;
o Edit /etc/network/interfaces&lt;br /&gt;
&lt;br /&gt;
[code]&lt;br /&gt;
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)&lt;br /&gt;
&lt;br /&gt;
# The loopback interface&lt;br /&gt;
# automatically added when upgrading&lt;br /&gt;
auto lo eth0 eth0:1 eth0:2&lt;br /&gt;
# eth0:2 eth0:3&lt;br /&gt;
iface lo inet loopback&lt;br /&gt;
&lt;br /&gt;
iface eth0 inet dhcp&lt;br /&gt;
#       address 10.0.0.4&lt;br /&gt;
#       netmask 255.0.0.0&lt;br /&gt;
#       network 10.0.0.0&lt;br /&gt;
#       broadcast 10.0.0.255&lt;br /&gt;
&lt;br /&gt;
iface eth0:1 inet static&lt;br /&gt;
        address 10.0.0.4&lt;br /&gt;
        netmask 255.0.0.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
iface eth0:2 inet static&lt;br /&gt;
        address 192.168.2.250&lt;br /&gt;
        netmask 255.255.255.0&lt;br /&gt;
        broadcast 255.255.255.255&lt;br /&gt;
&lt;br /&gt;
#iface eth0:3 inet static&lt;br /&gt;
#       address 10.0.81.4&lt;br /&gt;
#       netmask 255.255.255.0&lt;br /&gt;
#       broadcast 255.255.255.255&lt;br /&gt;
[/code]&lt;br /&gt;
&lt;br /&gt;
o You can comment out the interface, or take it out of the &amp;quot;auto&amp;quot; line(s).&lt;br /&gt;
&lt;br /&gt;
--&amp;gt; Suse *Fixme if inaccurate*&lt;br /&gt;
&lt;br /&gt;
o Use Yast&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3116</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3116"/>
		<updated>2007-05-26T07:18:43Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* Disable Old Physical Interface */ Added Debian ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&lt;br /&gt;
( See: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html )&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;' update-rc.d -f hdparm remove '&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
Debian and related (Ubuntu, etc):&lt;br /&gt;
&lt;br /&gt;
o Edit /etc/network/interfaces&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3115</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3115"/>
		<updated>2007-05-26T07:17:16Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* /etc/init.d services */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&lt;br /&gt;
( See: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html )&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;' update-rc.d -f hdparm remove '&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3114</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3114"/>
		<updated>2007-05-26T07:15:15Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* /etc/init.d services */ Fixed Debian ==db&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&lt;br /&gt;
( See: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html )&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;' update-rc.d -f samba remove '&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3113</id>
		<title>Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Physical_to_container&amp;diff=3113"/>
		<updated>2007-05-26T07:12:13Z</updated>

		<summary type="html">&lt;p&gt;Kingneutron: /* /etc/init.d services */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A rough description of how to migrate existing physical server into a [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Prepare a new “empty” VE ==&lt;br /&gt;
For OpenVZ this would mean the following (assume you chose VE ID of 123):&lt;br /&gt;
&lt;br /&gt;
 mkdir /vz/root/123 /vz/private/123&lt;br /&gt;
 cat /etc/vz/conf/ve-vps.basic.conf-sample &amp;gt; /etc/vz/conf/123.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Preparing to migrate ==&lt;br /&gt;
&lt;br /&gt;
Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh daemon).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copying the data ==&lt;br /&gt;
&lt;br /&gt;
Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to &amp;lt;code&amp;gt;/vz/private/123/&amp;lt;/code&amp;gt; directory (so there will be directories such as &amp;lt;code&amp;gt;/vz/private/123/bin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;etc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and so on). This could be done in several ways:&lt;br /&gt;
&lt;br /&gt;
=== rsync ===&lt;br /&gt;
rsync example (run from the new HN):&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' Your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
=== Live CD ===&lt;br /&gt;
Another way to do is using a live cd, booting up and use tar to dump the complete disk in a tar you save over the network or on a USB device.&lt;br /&gt;
&lt;br /&gt;
=== Tar ===&lt;br /&gt;
Another approach is using tar and excluding some dirs, you could do it like this:&lt;br /&gt;
&lt;br /&gt;
Create a file /tmp/excludes.excl with these contents:&lt;br /&gt;
 .bash_history&lt;br /&gt;
 /dev/*&lt;br /&gt;
 /mnt/*&lt;br /&gt;
 /tmp/*&lt;br /&gt;
 /proc/*&lt;br /&gt;
 /sys/*&lt;br /&gt;
 /usr/src/*&lt;br /&gt;
&lt;br /&gt;
Then create the tar. But remember, when the system is 'not' using udev, you have to look into /proc/ after creating your VE because some devices might not exist. (/dev/ptmx or others)&lt;br /&gt;
&lt;br /&gt;
 # tar cjpf /tmp/mysystem.tar.bz2 / -X /tmp/excludes.excl&lt;br /&gt;
&lt;br /&gt;
Naturally, you can only do this when the critical services (MySQL, apache, ..) are stopped and your /tmp filesystem is big enough to contain your tar.&lt;br /&gt;
&lt;br /&gt;
'''Advantage:''' You don't need to boot from a livecd, so your system doesn't really go down.&lt;br /&gt;
&lt;br /&gt;
== Setting VE parameters ==&lt;br /&gt;
&lt;br /&gt;
=== OSTEMPLATE ===&lt;br /&gt;
You have to add &amp;lt;code&amp;gt;OSTEMPLATE=xxx&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;/etc/vz/conf/123.conf&amp;lt;/code&amp;gt; file, where &amp;lt;code&amp;gt;xxx&amp;lt;/code&amp;gt; would be distribution name (like &amp;lt;code&amp;gt;debian-3.0&amp;lt;/code&amp;gt;) for vzctl to be able to make changes specific for this distribution.&lt;br /&gt;
&lt;br /&gt;
=== IP address(es) ===&lt;br /&gt;
Also, you have to supply an IP for a new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl set 123 --ipadd x.x.x.x --save&lt;br /&gt;
&lt;br /&gt;
=== venet vs. veth ===&lt;br /&gt;
You may use veth interface instead of venet if you need just bring old server up for seamless migration of services.&lt;br /&gt;
It may be nessessary if server you are migrating is badly configured and it is hard to find all hard-coded net interfaces settings and so on.&lt;br /&gt;
&lt;br /&gt;
veth inteface may me included into bridge to allow seamless old installation access.&lt;br /&gt;
&lt;br /&gt;
== Making adjustments ==&lt;br /&gt;
Since VE is a bit different than a real physical server, you have to edit some files inside your new VE.&lt;br /&gt;
&lt;br /&gt;
=== /etc/inittab ===&lt;br /&gt;
A VE does not have real ttys, so you have to disable getty in &amp;lt;code&amp;gt;/etc/inittab&amp;lt;/code&amp;gt; (i. e. &amp;lt;code&amp;gt;/vz/private/123/etc/inittab&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 sed -i -e '/getty/d' /vz/private/123/etc/inittab&lt;br /&gt;
&lt;br /&gt;
=== /etc/mtab ===&lt;br /&gt;
Link &amp;lt;code&amp;gt;/etc/mtab&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/proc/mounts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 rm -f /vz/private/123/etc/mtab&lt;br /&gt;
 ln -s /proc/mounts /vz/private/123/etc/mtab &lt;br /&gt;
&lt;br /&gt;
=== /etc/fstab ===&lt;br /&gt;
Since you do not have any real disk partitions in a VE, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the line for /dev/pts):&lt;br /&gt;
&lt;br /&gt;
 cp /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old&lt;br /&gt;
 grep devpts /vz/private/123/etc/fstab.old &amp;gt; /vz/private/123/etc/fstab&lt;br /&gt;
&lt;br /&gt;
You can also mount a devpts in a running (but not fully functional) VE:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
=== /dev TTY devices ===&lt;br /&gt;
In order for vzctl enter to work, a VE need to have some entries in /dev. This can either be /dev/ttyp* and /dev/ptyp*, or /dev/ptmx and mounted /dev/pts.&lt;br /&gt;
&lt;br /&gt;
==== /dev/ptmx ====&lt;br /&gt;
Check that /dev/ptmx exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/ptmx c 5 2&lt;br /&gt;
&lt;br /&gt;
==== /dev/pts/ ====&lt;br /&gt;
Check that /dev/pts exists. It's a directory, if it does not exist, create with:&lt;br /&gt;
 mkdir /vz/private/123/dev/pts&lt;br /&gt;
&lt;br /&gt;
==== /dev/ttyp* and /dev/ptyp* ====&lt;br /&gt;
Check that /dev/ttyp* and /dev/ptyp* files are there. If not, you have to create those, either by using /sbin/MAKEDEV, or by copying them from the host system.&lt;br /&gt;
&lt;br /&gt;
To copy:&lt;br /&gt;
 cp -a /dev/ttyp* /dev/ptyp* /vz/private/123/dev/&lt;br /&gt;
&lt;br /&gt;
To recreate with MAKEDEV, either&lt;br /&gt;
 /sbin/MAKEDEV -d /vz/private/123/dev ttyp ptyp&lt;br /&gt;
or&lt;br /&gt;
 cd /vz/private/123/dev &amp;amp;&amp;amp; /sbin/MAKEDEV ttyp&lt;br /&gt;
====/dev/null====&lt;br /&gt;
Make sure sure /dev/null is not a file or directory, if unsure remove and recreate, If this is not correct sshd will not start correctly&lt;br /&gt;
 rm -f /vz/private/123/dev/null&lt;br /&gt;
 mknod /vz/private/123/dev/null c 1 3&lt;br /&gt;
=== Other devices ===&lt;br /&gt;
===/proc===&lt;br /&gt;
Make sure the /proc directory exists&lt;br /&gt;
 ls -la /vz/private/123/ | grep proc&lt;br /&gt;
If it does'nt exist, Make it&lt;br /&gt;
 mkdir /vz/private/123/proc&lt;br /&gt;
&lt;br /&gt;
==== /dev/urandom ====&lt;br /&gt;
Check that /dev/urandom exists. If it does not, create with:&lt;br /&gt;
 mknod /vz/private/123/dev/urandom c 1 9&lt;br /&gt;
&lt;br /&gt;
=== /etc/init.d services ===&lt;br /&gt;
&lt;br /&gt;
Some system services can (or in some cases should) be disabled. A few good candidates are:&lt;br /&gt;
&lt;br /&gt;
* acpid, amd (not needed)&lt;br /&gt;
* checkfs, checkroot (no filesystem checking is required in VE)&lt;br /&gt;
* clock (no clock setting is required/allowed in VE)&lt;br /&gt;
* consolefont (VE does not have a console)&lt;br /&gt;
* hdparm (VE does not have real hard drives)&lt;br /&gt;
* klogd (unless you use iptables to LOG some packets)&lt;br /&gt;
* keymaps (VE does not have a real keyboard)&lt;br /&gt;
* kudzu (VE does not have real hardware)&lt;br /&gt;
* lm_sensors (VE does not have access to hardware sensors)&lt;br /&gt;
* microcodectl (VE can not update CPU microcode)&lt;br /&gt;
* netplugd (VE does not have real Ethernet device) &lt;br /&gt;
&lt;br /&gt;
To see which services are enabled:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --list&amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;Use ' rcconf ' (ncurses) or update-rc.d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To disable the service:&lt;br /&gt;
* RedHat/Fedora/SUSE: &amp;lt;code&amp;gt;/sbin/chkconfig --del SERVICENAME  &amp;lt;/code&amp;gt;&lt;br /&gt;
* Debian: &amp;lt;code&amp;gt;*FIXME*&amp;lt;/code&amp;gt;&lt;br /&gt;
* Gentoo: &amp;lt;code&amp;gt;/sbin/rc-update del SERVICENAME&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
There might be other adjustments needed. Please add those here if you have more info.&lt;br /&gt;
==== Disable Old Physical Interface ====&lt;br /&gt;
You should disable your old physical interface from starting at boot time&lt;br /&gt;
&lt;br /&gt;
In Fedora, edit /vz/private/{VEID}/etc/sysconfig/network-scripts/ifcfg-eth''x''&lt;br /&gt;
&lt;br /&gt;
Make the following look like this:&lt;br /&gt;
 onboot=no&lt;br /&gt;
&lt;br /&gt;
Other Distros: *FIXME*&lt;br /&gt;
&lt;br /&gt;
== Starting a new VE ==&lt;br /&gt;
&lt;br /&gt;
Try to start your new VE:&lt;br /&gt;
 &lt;br /&gt;
 vzctl start 123&lt;br /&gt;
&lt;br /&gt;
Now check that everything works fine. If not, see [[#Troubleshooting]] below.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Can't enter VE ===&lt;br /&gt;
&lt;br /&gt;
If you can not enter your VE (using &amp;lt;code&amp;gt;vzctl enter&amp;lt;/code&amp;gt;), you should be able to at least execute commands in it.&lt;br /&gt;
&lt;br /&gt;
First, see the [[#/dev TTY devices]] section above.&lt;br /&gt;
&lt;br /&gt;
Next, check if devpts is mounted:&lt;br /&gt;
 vzctl exec 123 mount | grep pts&lt;br /&gt;
&lt;br /&gt;
If it is not mounted, mount it:&lt;br /&gt;
 vzctl exec 123 mount -t devpts none /dev/pts&lt;br /&gt;
&lt;br /&gt;
Then, add the appropriate mount command to VE's startup scripts. On some distros, you need to have the appropriate line in VE's /etc/fstab.&lt;br /&gt;
&lt;br /&gt;
In Fedora, try commenting out any '''udev''' entries in /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
 vi /vz/private/{VEID}/etc/rc.sysinit&lt;br /&gt;
Locate the '''udev''' entry from within vim&lt;br /&gt;
 /udev&lt;br /&gt;
Then comment the line similar to this:&lt;br /&gt;
 #[ -x /sbin/start_udev ] &amp;amp;&amp;amp; /sbin/start_udev&lt;br /&gt;
&lt;br /&gt;
=== Other problems ===&lt;br /&gt;
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. Also check out IRC and please report back on this page.&lt;br /&gt;
&lt;br /&gt;
== Success Stories ==&lt;br /&gt;
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS&lt;br /&gt;
--[[User:Stoffell|stoffell]] 08:41, 8 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Red Hat 7.2 with MySQL 3.23, apache, Chilisoft --[[User:Stoffell|stoffell]] 13:26, 9 February 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- Gentoo with Courier, Postfix, MySQL, Apache2&lt;br /&gt;
--[[User:bfrackie|bfrackie]] 19:00, 18 March 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
- AltLinux Master with qmail, MySQL, Apache, etc - to Debian/testing with OpenVZ --[[User:alexkuklin|alexkuklin]] &lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Kingneutron</name></author>
		
	</entry>
</feed>