0

Been trying to understand and play around with systemd-nspawn because I'd like to run a Debian Testing install for myself without enabling the testing repos on my main Debian stable system.

I wrote this shell script to help set up Debootstrap process:

#!/bin/sh

dirpath="$1"

if [ -z "$dirpath" ]; then
    dirpath="debian-testing-devel"
elif ! [ -d "$dirpath" ]; then
    mkdir -p "$dirpath"
fi

echo "NOTICE: You must run `debootstrap` as a root user! Requesting sudo privilage..."
sudo debootstrap --include="dbus,systemd-container" testing "$dirpath" "https://deb.debian.org/debian"

echo "Debootstrap has finished!"
echo "You may log in to your system by using: systemd-nspawn -D ${dirpath} -U --machine debian-testing-devel"
echo "Make sure to set a secure root password!"

Something like that, basically. I named it "debian-testing-devel". Then I quickly learned that machinectl can only access things in "/var/lib/machines/", so I moved my created directory there. Anyway...

Then I logged in with systemd-nspawn -D /var/lib/machines/debian-testing-devel/ -U --machine debian-testing-devel, and set up my password, and had to add "pts/0" and "pts/1" to "/etc/securetty" so I could login as root.

When I tried to login with machinectl login debian-testing-devel, I got "Failed to get login PTY: Protocol error"

So I logged into the container with systemd-nspawn again, found out that the package install was broken for some reason with dbus, so I ran apt -f install, which seemed to fix it... kinda. Another source Online claimed that I had to also install systemd in the container itself, not just DBus, to get rid of the protocol error, so I tried that!

And finally, when I try to run machinectl login debian-testing-devel again, I still get stuck at "Failed to get login PTY: ..." this time it says, Failed to get login PTY: Failed to activate service 'org.freedesktop.systemd1': timed out (service_start_timeout=25000ms).

So I'm really not sure what to do next. Trying to search for this problem Online isn't bringing up too many results, and I'm not sure what's going on. It's been getting a little frustrating to try to learn this stuff and get it working when... nothing I try to do seems to work...

Any help is appreciated!

1 Answer 1

0

Okay, so I finally got it to login again. After checking my directory, I realized that there were some files owned by root:root, and then others owned by (random id):(random id), but after rebuilding the debootstrap again, making absolutely sure it finished without any errors, then tried running systemd-nspawn command with the -U flag it let me log in just fine. I really just kind of wish for people who are new to containers that there would be better error messages that were plainly obvious what was wrong. Because I was stuck on this for a couple days, not knowing that my container directory/root was bad. So just... yeah, that all kinda sucks. I'll definitely make sure to snapshot and backup my container folders now, because apparently they can be corrupted VERY easily just by forgetting to use unprivileged user. Yikes. I still feel like container stability and ease of use still has a ways to go, IMO.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .