It seems very strange. systemd-nspawn should have nothing to do with whether it is running in vm or what is the host of the vm. Try to see what systemd-detect-virt see's in each case anyway.

For debugging, you can enter the nspawn container --boot and see if cgroup fs is mounted the same in all cases. Also enter the failing container and attach debugger (with follow on exec) to the shell process (pid 1 inside container, attach from outside ofc) and exec systemd to see exactly where it is failing. Good that you have extremely similar systems with different results so you can do differential debigging here.

(in case --boot adds other magic like podman --systemd flag, you can drop a binary with sleep/shell at the systemd location in the debian rootfs. Sorry, I haven't seen nspawn code since ages so can't recall).

~ serene

On 5/7/25 19:09, An Liu wrote:

Hi,
I'm playing systemd-nspawn, and something interesting happens.
Try 1: host CentOS 8 Stream, systemd-nspawn to Debian Trixie
everything goes well.

Try 2: host CentOS 8 Stream , kvm guest CentOS 8 Stream
a: in guest systemd-nspawn to Debian Trixie , nspawn is OK to start without —boot b: in guest systemd-nspawn to Debian Trixie with --boot, nspawn failed nspawn failed due to failed to create /init.scope

Try 3: host Debian bookworm, kvm guest CenOS 8 Stream, nspawn to Trixie
nspawn OK for whatever --boot present or not

Can someone explain what lead to the different behavior, Can we manage to fix it to make
if so, what should we do. say, at the host side or at the kvm guest side?


Try 4: host centos 8 stream, kvm guest centos 8 stream, starts with the same rootfs above but in pod man, this time systemd could start as
 pid 1


Thanks

Liu An

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to