Dobrica Pavlinušić's random unstructured stuff
systemd: Revision 5

running old distributions under systemd-nspawn



install on host

apt install systemd-container

setup old distribution

os-release

root@saturn4:~# cat /saturn/etc/os-release
PRETTY_NAME="Debian GNU/Linux 4 (etch)"
NAME="Debian GNU/Linux"
VERSION_ID="4"
VERSION="4 (etch)"
VERSION_CODENAME=etch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

console

root@saturn4:/saturn/etc# machinectl shell saturn /usr/bin/uptime
Failed to get shell PTY: Protocol error

fix it by adding console to inittab

dpavlin@saturn:~$ grep console /etc/inittab
0:2345:respawn:/sbin/getty 38400 console

network config

full access to host network, services are configured to listen to localhost

root@saturn4:/etc/systemd# mkdir nspawn

root@saturn4:/etc/systemd# cat > nspawn/saturn.nspawn
[Network]
VirtualEthernet=no

start it

root@saturn4:~# mv /saturn/ /var/lib/machines/
root@saturn4:~# machinectl enable saturn
Created symlink /etc/systemd/system/machines.target.wants/systemd-nspawn@saturn.service �/lib/systemd/system/systemd-nspawn@.service.
root@saturn4:~# machinectl start saturn

alternative

it seems that I'm unable to get console to work with systemd-nspawn and Debian etch. So alternative approach is just to run services from systemd service file using chroot

root@saturn4:/etc/systemd/system# cat saturn\@.service
[Unit]
Description=SocialText saturn services

[Service]
User=root
Type=forking
ExecStart=/etc/systemd/system/saturn.sh /etc/init.d/%i start
ExecStop=/etc/systemd/system/saturn.sh /etc/init.d/%i stop
Restart=on-failure

[Install]
WantedBy=multi-user.target

root@saturn4:/etc/systemd/system# systemctl start saturn@postgresql-8.1
root@saturn4:/etc/systemd/system# systemctl start saturn@ceqlotron
root@saturn4:/etc/systemd/system# systemctl start saturn@st-apache
root@saturn4:/etc/systemd/system# systemctl start saturn@apache2