11 | | 2. Before getting started make sure the machine is up to date.[[br]] |
12 | | `sudo apt-get update`[[br]] |
13 | | `sudo apt-get upgrade` |
14 | | |
15 | | 3. Reconfigure dash. When the "Configuring dash" screen appears select NO.[[br]] |
16 | | `sudo dpkg-reconfigure dash` |
17 | | |
18 | | 4. Install required packages to compile the kernel. This will be needed when the OpenVZ kernel is compiled.[[br]] |
19 | | `sudo apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 module-assistant debhelper build-essential bridge-utils` |
20 | | |
21 | | 5. Set the following variables that will be used.[[br]] |
22 | | `Variant="linux-image-generic"`[[br]] |
23 | | `VersionAppendix="-openvz"`[[br]] |
24 | | `MyConfigFile="kernel-2.6.32-i686.config.ovz"`[[br]] |
25 | | |
26 | | 6. Set the build dependencies for OpenVZ[[br]] |
27 | | `Package="$(apt-cache showpkg $Variant | grep "^2\.6\.32" | grep "linux-image")"`[[br]] |
28 | | `Package=$(ReturnWord () { echo $3; }; ReturnWord $Package)`[[br]] |
29 | | `sudo apt-get build-dep --no-install-recommends $Package`[[br]] |
30 | | |
31 | | 7. Prepare the linux headers before compiling, and create the configuration for the kernel.[[br]] |
32 | | `sudo m-a prepare`[[br]] |
33 | | `sudo kernel-packageconfig` |
34 | | |
35 | | 9. Set up multi-core support. This step may not be necessary if your VM is only using one core, but it does not hurt to execute this line anyway.[[br]] |
36 | | `Cores=$(Nr () { echo $#; }; Nr $(grep "processor" /proc/cpuinfo | cut -f2 -d":"))`[[br]] |
37 | | `echo "CONCURRENCY_LEVEL := $(($Cores + 1))" | sudo tee -a /etc/kernel-pkg.conf`[[br]] |
38 | | |
39 | | 10. Download the linux kernel source code.[[br]] |
40 | | `cd /usr/src`[[br]] |
41 | | `sudo wget http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux_2.6.32.orig.tar.gz` |
42 | | |
43 | | 11. Get the OpenVZ patch for the linux kernel, and the OpenVZ kernel itself.[[br]] |
44 | | `sudo wget http://download.openvz.org/kernel/branches/2.6.32/current/patches/patch-feoktistov.1-combined.gz`[[br]] |
45 | | `sudo wget http://download.openvz.org/kernel/branches/2.6.32/current/configs/$MyConfigFile` |
46 | | |
47 | | 12. Unpack the source code.[[br]] |
48 | | `sudo rm -fR linux-2.6.32`[[br]] |
49 | | `sudo tar -xpf linux_2.6.32.orig.tar.gz`[[br]] |
50 | | `sudo rm -fR "linux-2.6.32$VersionAppendix"`[[br]] |
51 | | `sudo mv linux-2.6.32 "linux-2.6.32$VersionAppendix"`[[br]] |
52 | | `sudo rm linux`[[br]] |
53 | | `sudo ln -s "linux-2.6.32$VersionAppendix" linux` |
54 | | |
55 | | 13. Apply the OpenVZ patch to the kernel.[[br]] |
56 | | `cd /usr/src/linux`[[br]] |
57 | | `sudo gunzip -dc /usr/src/patch-feoktistov.1-combined.gz | sudo patch -p1 --batch`[[br]] |
58 | | `sudo cp -f "/usr/src/$MyConfigFile" .config`[[br]] |
59 | | `sudo make oldconfig` |
60 | | |
61 | | 14. One of the make files has a bug in it that needs to be fixed.[[br]] |
62 | | `sudo gedit Documentation/lguest/Makefile` |
| 11 | 2. Before getting started make sure the machine is up to date. |
| 12 | {{{ |
| 13 | sudo apt-get update |
| 14 | sudo apt-get upgrade |
| 15 | }}} |
| 16 | |
| 17 | 3. Reconfigure dash. When the "Configuring dash" screen appears select NO. |
| 18 | {{{ |
| 19 | sudo dpkg-reconfigure dash |
| 20 | }}} |
| 21 | |
| 22 | 4. Install required packages to compile the kernel. This will be needed when the OpenVZ kernel is compiled. |
| 23 | {{{ |
| 24 | sudo apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 module-assistant debhelper build-essential bridge-utils |
| 25 | }}} |
| 26 | |
| 27 | 5. Set the following variables that will be used. |
| 28 | {{{ |
| 29 | Variant="linux-image-generic" |
| 30 | VersionAppendix="-openvz" |
| 31 | MyConfigFile="kernel-2.6.32-i686.config.ovz" |
| 32 | }}} |
| 33 | |
| 34 | 6. Set the build dependencies for OpenVZ. |
| 35 | {{{ |
| 36 | Package="$(apt-cache showpkg $Variant | grep "^2\.6\.32" | grep "linux-image")" |
| 37 | Package=$(ReturnWord () { echo $3; }; ReturnWord $Package) |
| 38 | sudo apt-get build-dep --no-install-recommends $Package |
| 39 | }}} |
| 40 | |
| 41 | 7. Prepare the linux headers before compiling, and create the configuration for the kernel. |
| 42 | {{{ |
| 43 | sudo m-a prepare |
| 44 | sudo kernel-packageconfig |
| 45 | }}} |
| 46 | |
| 47 | 9. Set up multi-core support. This step may not be necessary if your VM is only using one core, but it does not hurt to execute this line anyway. |
| 48 | {{{ |
| 49 | Cores=$(Nr () { echo $#; }; Nr $(grep "processor" /proc/cpuinfo | cut -f2 -d":")) |
| 50 | echo "CONCURRENCY_LEVEL := $(($Cores + 1))" | sudo tee -a /etc/kernel-pkg.conf |
| 51 | }}} |
| 52 | |
| 53 | 10. Download the linux kernel source code. |
| 54 | {{{ |
| 55 | cd /usr/src |
| 56 | sudo wget http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux_2.6.32.orig.tar.gz |
| 57 | }}} |
| 58 | |
| 59 | 11. Get the OpenVZ patch for the linux kernel, and the OpenVZ kernel itself. |
| 60 | {{{ |
| 61 | sudo wget http://download.openvz.org/kernel/branches/2.6.32/current/patches/patch-feoktistov.1-combined.gz |
| 62 | sudo wget http://download.openvz.org/kernel/branches/2.6.32/current/configs/$MyConfigFile |
| 63 | }}} |
| 64 | |
| 65 | 12. Unpack the source code. |
| 66 | {{{ |
| 67 | sudo rm -fR linux-2.6.32 |
| 68 | sudo tar -xpf linux_2.6.32.orig.tar.gz |
| 69 | sudo rm -fR "linux-2.6.32$VersionAppendix" |
| 70 | sudo mv linux-2.6.32 "linux-2.6.32$VersionAppendix" |
| 71 | sudo rm linux |
| 72 | sudo ln -s "linux-2.6.32$VersionAppendix" linux |
| 73 | }}} |
| 74 | |
| 75 | 13. Apply the OpenVZ patch to the kernel. |
| 76 | {{{ |
| 77 | cd /usr/src/linux |
| 78 | sudo gunzip -dc /usr/src/patch-feoktistov.1-combined.gz | sudo patch -p1 --batch |
| 79 | sudo cp -f "/usr/src/$MyConfigFile" .config |
| 80 | sudo make oldconfig |
| 81 | }}} |
| 82 | |
| 83 | 14. One of the make files has a bug in it that needs to be fixed. |
| 84 | {{{ |
| 85 | sudo gedit Documentation/lguest/Makefile |
| 86 | }}} |
71 | | `all:`[[br]] |
72 | | |
73 | | `clean:`[[br]] |
74 | | `rm -f lguest` |
75 | | |
76 | | 15. Now build the OpenVZ kernel. '''WARNING''': This may take some time, upwards of 1 or 2 hours.[[br]] |
77 | | `cd /usr/src/linux`[[br]] |
78 | | `sudo make-kpkg --initrd --append-to-version=$VersionAppendix --revision=1 kernel_image kernel_headers`[[br]] |
79 | | |
80 | | 16. Install the OpenVZ kernels that were just built.[[br]] |
81 | | `cd /usr/src`[[br]] |
82 | | `sudo dpkg -i linux-image-2.6.32.28-openvz_1_i386.deb`[[br]] |
83 | | `sudo dpkg -i linux-headers-2.6.32.28-openvz_1_i386.deb`[[br]] |
84 | | |
85 | | 17. Setup the grub menu to load the OpenVZ kernel at boot.[[br]] |
86 | | `sudo mkinitramfs -k 2.6.32.28-openvz -o /boot/initrd.img-2.6.32.28-openvz`[[br]] |
87 | | `sudo update-grub`[[br]] |
88 | | |
89 | | 18. Create a new internet configuration.[[br]] |
90 | | `sudo gedit /etc/sysctl.d/10-openvz.conf`[[br]] |
| 97 | {{{ |
| 98 | all: |
| 99 | |
| 100 | clean: |
| 101 | rm -f lguest |
| 102 | }}} |
| 103 | |
| 104 | 15. Now build the OpenVZ kernel. '''WARNING''': This may take some time, upwards of 1 or 2 hours. |
| 105 | {{{ |
| 106 | cd /usr/src/linux |
| 107 | sudo make-kpkg --initrd --append-to-version=$VersionAppendix --revision=1 kernel_image kernel_headers |
| 108 | }}} |
| 109 | |
| 110 | 16. Install the OpenVZ kernels that were just built. |
| 111 | {{{ |
| 112 | cd /usr/src |
| 113 | sudo dpkg -i linux-image-2.6.32.28-openvz_1_i386.deb |
| 114 | sudo dpkg -i linux-headers-2.6.32.28-openvz_1_i386.deb |
| 115 | }}} |
| 116 | |
| 117 | 17. Setup the grub menu to load the OpenVZ kernel at boot. |
| 118 | {{{ |
| 119 | sudo mkinitramfs -k 2.6.32.28-openvz -o /boot/initrd.img-2.6.32.28-openvz |
| 120 | sudo update-grub |
| 121 | }}} |
| 122 | |
| 123 | 18. Create a new internet configuration. |
| 124 | {{{ |
| 125 | sudo gedit /etc/sysctl.d/10-openvz.conf |
| 126 | }}} |
93 | | |
94 | | `### Optimized for Ubuntu 10.04`[[br]] |
95 | | `# vim:ft=sysctl`[[br]] |
96 | | `# sysctl config for OpenVZ`[[br]] |
97 | | `#net.ipv4.ip_forward=1`[[br]] |
98 | | |
99 | | `net.ipv4.conf.default.forwarding = 1`[[br]] |
100 | | `net.ipv4.conf.default.proxy_arp = 1`[[br]] |
101 | | `net.ipv4.ip_forward = 1`[[br]] |
102 | | |
103 | | `# Enables source route verification`[[br]] |
104 | | `net.ipv4.conf.all.rp_filter = 1`[[br]] |
105 | | |
106 | | `# Enables the magic-sysrq key`[[br]] |
107 | | `kernel.sysrq = 1`[[br]] |
108 | | |
109 | | `# TCP Explict Congestion Notification`[[br]] |
110 | | `#net.ipv4.tcp_ecn = 0`[[br]] |
111 | | |
112 | | `# we do not want all our interfaces to send redirects`[[br]] |
113 | | `net.ipv4.conf.default.send_redirects = 0`[[br]] |
114 | | |
115 | | |
116 | | 19. Apply the changes to the network configuration.[[br]] |
117 | | `sudo sysctl -p /etc/sysctl.d/10-openvz.conf`[[br]] |
118 | | |
119 | | 20. Install the tools used by OpenVZ for managing containers.[[br]] |
120 | | `sudo apt-get install --no-install-recommends vzctl vzquota vzdump` |
121 | | |
122 | | 21. Create a symlink to be FHS-compliant and then reboot.[[br]] |
123 | | `sudo ln -s /var/lib/vz /vz`[[br]] |
124 | | `sudo reboot` |
| 129 | {{{ |
| 130 | ### Optimized for Ubuntu 10.04 |
| 131 | # vim:ft=sysctl |
| 132 | # sysctl config for OpenVZ |
| 133 | #net.ipv4.ip_forward=1 |
| 134 | |
| 135 | net.ipv4.conf.default.forwarding = 1 |
| 136 | net.ipv4.conf.default.proxy_arp = 1 |
| 137 | net.ipv4.ip_forward = 1 |
| 138 | |
| 139 | # Enables source route verification |
| 140 | net.ipv4.conf.all.rp_filter = 1 |
| 141 | |
| 142 | # Enables the magic-sysrq key |
| 143 | kernel.sysrq = 1 |
| 144 | |
| 145 | # TCP Explict Congestion Notification |
| 146 | #net.ipv4.tcp_ecn = 0 |
| 147 | |
| 148 | # we do not want all our interfaces to send redirects |
| 149 | net.ipv4.conf.default.send_redirects = 0 |
| 150 | }}} |
| 151 | |
| 152 | |
| 153 | 19. Apply the changes to the network configuration. |
| 154 | {{{ |
| 155 | sudo sysctl -p /etc/sysctl.d/10-openvz.conf |
| 156 | }}} |
| 157 | |
| 158 | 20. Install the tools used by OpenVZ for managing containers. |
| 159 | {{{ |
| 160 | sudo apt-get install --no-install-recommends vzctl vzquota vzdump |
| 161 | }}} |
| 162 | |
| 163 | 21. Create a symlink to be FHS-compliant and then reboot. |
| 164 | {{{ |
| 165 | sudo ln -s /var/lib/vz /vz |
| 166 | sudo reboot |
| 167 | }}} |