Tag Archives: openvz

Upgrade from Debian 7 (wheezy) to Debian 9 (stretch) on OpenVZ

I wanted to upgrade a tiny OpenVZ based VPS (128MB of ram and 128MB vswap) from a 32 bits version of Debian 7 (wheezy) to the latest stable Debian 9 (stretch). The host of the VPS is running a 2.6.32-openvz-042stab120.18-amd64 Linux Kernel which is CentOS6 based distro I think, the provider is BuyVM/frantech.

Before embarking in this journey make sure to backup any important data you have on the system, if things goes wrong you have to reinstall your VPS which means all your data will be wiped out!, be warned

The base Debian 7 VPS uses upstart and devtmpfs with udev:

# ps xaf
    1 ?        Ss     0:00 init
    2 ?        S      0:00 [kthreadd/58079]
    3 ?        S      0:00  \_ [khelper/58079]
  121 ?        S      0:00 upstart-udev-bridge --daemon
  130 ?        Ss     0:00 /sbin/udevd --daemon
  314 ?        S      0:00 upstart-socket-bridge --daemon
 1637 ?        Sl     0:00 /usr/sbin/rsyslogd -c5
 1748 tty1     Ss+    0:00 /sbin/getty 38400 console
 1750 tty2     Ss+    0:00 /sbin/getty 38400 tty2
 3227 ?        Ss     0:00 /usr/sbin/sshd
 3921 ?        Ss     0:00 vzctl: pts/0               
 3922 pts/0    Ss     0:00  \_ -bash
 3926 pts/0    R+     0:00      \_ ps xaf

# mount
/dev/simfs on / type simfs (rw,relatime,usrquota,grpquota)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
none on /dev type devtmpfs (rw,nosuid,noexec,relatime,mode=755)
none on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
none on /run type tmpfs (rw,nosuid,noexec,relatime,size=13108k,mode=755)
none on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
none on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=52420k)
none on /run/user type tmpfs (rw,nosuid,nodev,noexec,relatime,size=102400k,mode=755)

# dpkg -l upstart udev 
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                          Version                     Architecture                Description
ii  udev                                          175-7.2                     i386                        /dev/ and hotplug management daemon
ii  upstart                                       1.6.1-1                     i386                        event-based init daemon

I want to replace upstart with systemd. At first I was planning to use sysvinit and replace devtmpfs and udev with static entries in /dev, but this was proven to be difficult since I don’t have admin control on the host system to umount /dev in order to create static entries with MAKEDEV on the live VPS, so I settled down with systemd

The following are the steps taken to achieve the objective:

  • fetch the latest updates from wheezy
    # cat /etc/apt/sources.list
    deb http://ftp.debian.org/debian wheezy main contrib non-free
    deb http://ftp.debian.org/debian wheezy-updates main contrib non-free
    deb http://security.debian.org wheezy/updates main contrib non-free
    # apt-get update
    # apt-get upgrade -y
  • install a text based dialog frontend to debconf (optional)
    # apt-get install -y whiptail
  • configure your locale (optional), for me I’ve chosen en_CA.UTF-8 UTF-8 from the locales to be generated and en_CA.UTF-8 for the Default locale for the system environment
    # dpkg-reconfigure locales
  • replace upstart with systemd
    # apt-get install -y systemd-sysv
  • upgrade to jessie
    # sed -i 's/wheezy/jessie/g' /etc/apt/sources.list
    # apt-get update
    # apt-get upgrade -y
  • dist upgrade to jessie
    # apt-get dist-upgrade -y # will take some time to complete, when done cat /etc/debian_version will return 8.x (e.g. 8.9)
  • reboot to jessie, systemd should be now the new init
    # reboot -f
  • purge leftover upstart configurations and get rid of non needed packages and cached packages under /var/cache/apt/archives
    # dpkg --purge upstart
    # apt-get autoremove -y
    # apt-get clean
  • upgrade to stretch
    # sed -i 's/jessie/stretch/g' /etc/apt/sources.list
    # apt-get update
    # apt-get upgrade -y
  • dist upgrade to stretch
    # apt-get dist-upgrade -y
  • reboot to stretch
    # reboot
  • cleanup non needed packages and cached packages under /var/cache/apt/archives
    # apt autoremove -y
    # apt-get clean
  • get rid of non needed services (optional)
    # systemctl stop getty@tty2.service
    # systemctl disable getty@tty2.service
    # systemctl stop systemd-logind.service
    # systemctl mask systemd-logind.service