Bug 73935

Summary: systemd-nspawn: can't start a debian based container
Product: systemd Reporter: Nicolas Dechesne <ndec13>
Component: generalAssignee: systemd-bugs
Status: RESOLVED NOTOURBUG QA Contact: systemd-bugs
Severity: normal    
Priority: medium CC: ndec13
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Nicolas Dechesne 2014-01-22 15:52:26 UTC
hello,

i am trying to replace my chroot environment with system-nspawn, but i can't get a console login. it just hangs with the following log:

==
sudo systemd-nspawn -bD /work/chroot/debian-testing/ -M debian4

The kernel auditing subsystem is known to be incompatible with containers.
Please make sure to turn off auditing with 'audit=0' on the kernel command
line before using systemd-nspawn. Sleeping for 5s...
Spawning namespace container on /work/chroot/debian-testing (console is /dev/pts/8).
Init process in the container running as PID 15407.
INIT: version 2.88 booting
[info] Using makefile-style concurrent boot in runlevel S.
[warn] udev does not support containers, not started ... (warning).
[warn] Filesystem mounted on /dev/shm; setting up compatibility bind mount. ... (warning).
[warn] Please remove this mount from /etc/fstab; it is no longer needed, and it is preventing completion of the transition to /run/shm. ... (warning).
[info] Setting the system clock.
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.
[warn] Unable to set System Clock to: Wed Jan 22 15:41:04 UTC 2014 ... (warning).
[ ok ] Activating swap...done.
[warn] Creating compatibility symlink from /etc/mtab to /proc/mounts. ... (warning).
[ ok ] Activating lvm and md swap...done.
[....] Checking file systems...fsck from util-linux 2.20.1
done.
[ ok ] Cleaning up temporary files... /tmp.
[ ok ] Mounting local filesystems...done.
[ ok ] Activating swapfile swap...done.
[ ok ] Cleaning up temporary files....
[ ok ] Setting kernel variables ...done.
[ ok ] Configuring network interfaces...done.
[ ok ] Cleaning up temporary files....
INIT: Entering runlevel: 2
[info] Using makefile-style concurrent boot in runlevel 2.
[ ok ] Starting enhanced syslogd: rsyslogd.
[ ok ] Starting periodic command scheduler: cron.
INIT: Id "2" respawning too fast: disabled for 5 minutes
INIT: Id "1" respawning too fast: disabled for 5 minutes
INIT: Id "5" respawning too fast: disabled for 5 minutes
INIT: Id "6" respawning too fast: disabled for 5 minutes
INIT: Id "3" respawning too fast: disabled for 5 minutes
INIT: Id "4" respawning too fast: disabled for 5 minutes
INIT: no more processes left in this runlevel
==

I am running an up-to-date archlinux 64-bit system, and I used the following command to create the root fs

sudo debootstrap testing /work/chroot/debian-testing

I didn't make any change in the rootfs. I have tried with both wheezy and 'testing'. 

If I install systemd in the container (I can actually get a root shell with -D instead of -bD), then it works fine:

==

Spawning namespace container on /work/chroot/debian-testing (console is /dev/pts/8).
Init process in the container running as PID 17807.
systemd 204 running in system mode. (+PAM +LIBWRAP +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ)
Detected virtualization 'systemd-nspawn'.

Welcome to Debian GNU/Linux jessie/sid!

Set hostname to <nikaia>.
Failed to install release agent, ignoring: File exists
Cannot add dependency job for unit display-manager.service, ignoring: Unit display-manager.service failed to load: No such file or directory. See system logs and 'systemctl status display-manager.service' for details.
[  OK  ] Listening on Syslog Socket.
[  OK  ] Listening on Delayed Shutdown Socket.
[  OK  ] Listening on /dev/initctl Compatibility Named Pipe.
[  OK  ] Reached target Encrypted Volumes.
[  OK  ] Listening on Journal Socket.
[  OK  ] Reached target Syslog.
         Mounting Huge Pages File System...
         Mounting Debug File System...
         Mounting POSIX Message Queue File System...
         Starting Journal Service...
[  OK  ] Started Journal Service.
[  OK  ] Reached target Paths.
         Mounting Configuration File System...
         Mounting FUSE Control File System...
[  OK  ] Reached target Swap.
         Starting Remount Root and Kernel File Systems...
[  OK  ] Mounted Huge Pages File System.
[  OK  ] Mounted Debug File System.
[  OK  ] Mounted POSIX Message Queue File System.
[  OK  ] Mounted Configuration File System.
[  OK  ] Mounted FUSE Control File System.
[  OK  ] Started Remount Root and Kernel File Systems.
[  OK  ] Reached target Local File Systems (Pre).
         Mounting User Runtime Directory...
         Mounting Lock Directory...
         Starting Load Random Seed...
[  OK  ] Started Load Random Seed.
[  OK  ] Mounted Lock Directory.
[  OK  ] Mounted User Runtime Directory.
[  OK  ] Reached target Local File Systems.
         Starting LSB: Raise network interfaces....
         Starting Recreate Volatile Files and Directories...
[  OK  ] Reached target Remote File Systems.
         Starting Trigger Flushing of Journal to Persistent Storage...
[  OK  ] Started Recreate Volatile Files and Directories.
[  OK  ] Started Trigger Flushing of Journal to Persistent Storage.
[  OK  ] Started LSB: Raise network interfaces..
[  OK  ] Reached target System Initialization.
[  OK  ] Reached target Timers.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
         Starting LSB: Create dynamic part of /etc/motd...
         Starting LSB: Log file handling to be done during bootup....
         Starting LSB: Regular background program processing daemon...
         Starting /etc/rc.local Compatibility...
         Starting Login Service...
         Starting System Logging Service...
         Starting Permit User Sessions...
         Starting D-Bus System Message Bus...
[  OK  ] Started D-Bus System Message Bus.
[  OK  ] Started /etc/rc.local Compatibility.
         Starting Cleanup of Temporary Directories...
[  OK  ] Started Permit User Sessions.
         Starting Console Getty...
[  OK  ] Started Console Getty.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started LSB: Create dynamic part of /etc/motd.
[  OK  ] Started Cleanup of Temporary Directories.
[  OK  ] Started LSB: Regular background program processing daemon.
[  OK  ] Started Login Service.
[  OK  ] Started LSB: Log file handling to be done during bootup..
[  OK  ] Started System Logging Service.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.

Debian GNU/Linux jessie/sid nikaia console

nikaia login: 

==
Comment 1 Zbigniew Jedrzejewski-Szmek 2014-01-22 17:16:03 UTC
The container environment is not like a VM, and the init system must make certain adjustments.  Specifically, /dev/tty* (apart from /dev/tty) are not there. sysv init can be made to work, but manual adjustments are required.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.