Difference between revisions of "Installation on Debian 8"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(Install packages: Patch VarLock directory creation)
(Install packages: VarLock: it only was a Devuan issue)
Line 44: Line 44:
 
  VE_STOP_MODE=stop
 
  VE_STOP_MODE=stop
  
== Patch VarLock directory creation ==
+
* Only Devuan: link to be recognised as Debian
This is necessary to vzeventd works on boot, because it doesn't automatically create VARLOCK directory on startup:
+
  if [ -f /etc/devuan_version ] ; then sudo ln -s /etc/devuan_version /etc/debian_version ; fi
Lines="$(cat /etc/init.d/vzeventd | grep -e '#.*INIT INFO' -ie '# .*Provides:' -ie '^# .*-St')"
 
  Lines="$(echo "$Lines" | sed -e 's|vzeventd$|vzevent_pre|g' | sed -e 's| vz$| vzeventd|g')"
 
echo "$Lines" | sudo tee /etc/init.d/vzevent_pre
 
echo 'mkdir -p /var/lock/subsys' | sudo tee -a /etc/init.d/vzevent_pre
 
sudo chmod +x /etc/init.d/vzevent_pre
 
sudo insserv --default vzevent_pre
 
  
 
= '''Reboot into OpenVZ kernel''' =
 
= '''Reboot into OpenVZ kernel''' =

Revision as of 11:24, 7 October 2017

This is a guide to install OpenVZ 6 (legacy) on your Devuan 1 "Jessie" or Debian 8 "Jessie" machine (both amd64 or i386).

Current commercial version of OpenVZ (Virtuozzo 7) is not installable on Devuan or Debian because is developed as an independent GNU/Linux distribution

Volumes and file systems

  • It is recommended to use a separate partition for containers (by default /var/lib/vz) and format it to ext4.
  • btrfs mounted filesystems cannot be formatted with modern features as: mixed-bg, extref, skinny-metadata, no-holes (More details).

Change Systemd to SystemV

Only needed for Debian (Devuan already works with SystemV by default). Warning: This operation can make some desktop software to stop working.

sudo apt-get install sysvinit-core sysvinit-utils
# Must boot with SystemV to release Systemd
sudo reboot
sudo apt-get remove systemd
sudo apt-get autoremove
echo -e 'Package: *systemd*\nPin: release *\nPin-Priority: -1\n' | sudo tee /etc/apt/preferences.d/avoid-systemd

Register OVZ updated repository

RepoFile=/etc/apt/sources.list.d/openvz.list
RepoUrl=http://download.openvz.org/debian
echo "deb $RepoUrl jessie main" | sudo tee "$RepoFile"
echo "#deb $RepoUrl jessie-test main" | sudo tee -a "$RepoFile"
echo "deb $RepoUrl wheezy main" | sudo tee -a "$RepoFile"
wget -qO - http://ftp.openvz.org/debian/archive.key | sudo apt-key add -
sudo apt-get update
Yellowpin.svg Note: The second line with jessie-test is commented out. This is a testing repo with newer kernels and possibly tools. Enable it if you want to stay on a bleeding edge of technology.

For more info about Debian repositories, see http://download.openvz.org/debian

Install packages

KPackage="linux-image-openvz-$(dpkg --print-architecture)"
sudo apt-get --install-recommends install $KPackage vzdump ploop initramfs-tools
if [ ! -d /vz ] ; then sudo ln -s /var/lib/vz/ /vz ; fi
  • Create file /etc/vz/vznet.conf with the following line:
EXTERNAL_SCRIPT="/usr/sbin/vznetaddbr"
  • Optionally you can set containers completely stop when service stops at /etc/vz/vz.conf
VE_STOP_MODE=stop
  • Only Devuan: link to be recognised as Debian
if [ -f /etc/devuan_version ] ; then sudo ln -s /etc/devuan_version /etc/debian_version ; fi

Reboot into OpenVZ kernel

Yellowpin.svg Note: At boot manager, in "Advanced options for Devuan GNU+Linux", you will find kernels named "2.6.32-openvz". Select the first listed.
sudo reboot

Check the OpenVZ processes are running:

sudo ps ax | grep -v 'grep' | grep 'vzmond'

Set OpenVZ as default to boot

Because of GRUB2 default criteria, default kernel to boot can still be the one from Devuan's repository (non OVZ). Probably you don't want this behaviour; once you've booted fine into OpenVZ kernel, you can remove other unuseful kernels:

Packages="$(aptitude search ~i~nlinux-image- --display-format '%p' | grep -ve 'openvz')"
sudo apt-get remove $Packages
sudo apt-get autoremove

(requires aptitude)

Download OS templates

This step is optional, vzctl is able to download templates on demand.

An OS template is a GNU distribution for Linux, installed into a container and then packed into a gzipped tarball. Using such a cache, a new container can be created in a minute.

OpenvzKey="$(echo $(sudo gpg --batch --search-keys security@openvz.org 2>&1 | grep -ie ' key.*created' | sed -e 's|key|@|g' | cut -f 2 -d '@') | cut -f 1 -d ' ' | cut -f 1 -d ',')"
sudo gpg --recv-keys $OpenvzKey
sudo vztmpl-dl --gpg-check --list-remote
# Example:
sudo vztmpl-dl --gpg-check debian-8.0-x86_64-minimal

Alternatively, you can also download precreated template caches from Download » Template » Precreated, or from one of the mirrors. Put those tarballs as-is (no unpacking needed) to the /vz/template/cache/ directory.

Next steps

OpenVZ is now set up on your machine. Follow on to basic operations in OpenVZ environment document.

See also