Open lz-lunzi opened 8 months ago
There is also a systemd issue - https://github.com/systemd/systemd/issues/31690 that you did not linked to
Who knows how to protect specific processes during switch switching https://mirrors.edge.kernel.org/pub/linux/utils/boot/dracut/dracut.html#_cleanup_and_switch_root
hCorrelation of similar problems https://github.com/dracutdevs/dracut/issues/1032
This is some of my handling, although not successful. However, some information can be provided to facilitate understanding { echo "[Unit]" echo "Before=initrd-root-fs.target" echo "[Mount]" echo "Where=/sysroot" echo "What=/dev/nbd0p2" echo "Type=ext4" echo "Options=rw" } > /etc/systemd/system/sysroot.mount
{
echo "[Unit]"
echo "Description=Qemu NBD Server"
echo "After=network.target"
echo "[Service]"
echo "ExecStart=qemu-nbd -c /dev/nbd0 /host$QEMUNBD"
echo "Restart=always"
echo "RootService=true"
echo "SurviveFinalKillSignal=yes"
echo "[Install]"
echo "WantedBy=multi-user.target"
} > /etc/systemd/system/qemu-nbd.service
Reference: https://systemd.io/ROOT_STORAGE_DAEMONS/
logs: [ 24.890490] fedora systemctl[976]: Bus n/a: changing state UNSET → OPENING [ 24.890784] fedora systemctl[976]: sd-bus: starting bus by connecting to /run/systemd/private... [ 24.891276] fedora systemctl[976]: Bus n/a: changing state OPENING → AUTHENTICATING [ 24.891560] fedora systemctl[976]: Executing dbus call org.freedesktop.systemd1.Manager StartUnit(initrd-switch-root.target, isolate) [ 24.893117] fedora systemctl[976]: Bus n/a: changing state AUTHENTICATING → RUNNING [ 24.893464] fedora systemctl[976]: Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=StartUnit cookie=1 reply_cookie=0 signature=ss error-name=n/a error-message=n/a [ 24.894369] fedora systemctl[976]: Got message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=3 reply_cookie=1 signature=o error-name=n/a error-message=n/a [ 24.894893] fedora systemctl[976]: Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=GetUnit cookie=2 reply_cookie=0 signature=s error-name=n/a error-message=n/a [ 24.896499] fedora systemctl[976]: Got message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=114 reply_cookie=2 signature=o error-name=n/a error-message=n/a [ 24.898173] fedora systemctl[976]: Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1/unit/initrd_2dswitch_2droot_2etarget interface=org.freedesktop.DBus.Properties member=Get cookie=3 reply_cookie=0 signature=ss error-name=n/a error-message=n/a [ 24.955170] fedora systemctl[976]: Got message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=288 reply_cookie=3 signature=v error-name=n/a error-message=n/a [ 24.955987] fedora systemctl[976]: Bus n/a: changing state RUNNING → CLOSED [ 25.003636] fedora systemd-journald[393]: Successfully sent stream file descriptor to service manager. [ 25.001777] fedora udevadm[979]: Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy [ 25.001777] fedora udevadm[979]: Found container virtualization none. [ 25.009743] fedora udevadm[979]: SELinux enabled state cached to: disabled [ 25.034886] fedora systemd-journald[393]: Successfully sent stream file descriptor to service manager. [ 25.041328] fedora @ystemctl[981]: Bus n/a: changing state UNSET → OPENING [ 25.042086] fedora @ystemctl[981]: sd-bus: starting bus by connecting to /run/systemd/private... [ 25.042595] fedora @ystemctl[981]: Bus n/a: changing state OPENING → AUTHENTICATING [ 25.042985] fedora @ystemctl[981]: Switching root - root: /sysroot; init: n/a [ 25.044560] fedora @ystemctl[981]: Bus n/a: changing state AUTHENTICATING → RUNNING [ 25.045388] fedora @ystemctl[981]: Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=SwitchRoot cookie=1 reply_cookie=0 signature=ss error-name=n/a error-message=n/a [ 25.055008] fedora @ystemctl[981]: Got message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=n/a error-name=n/a error-message=n/a [ 25.056204] fedora @ystemctl[981]: Bus n/a: changing state RUNNING → CLOSED [ 25.182251] fedora kernel: block nbd0: shutting down sockets
Describe the bug A clear and concise description of what the error is.
Distribution used Which distribution was this behaviour seen in?
Dracut version Version: 059-16.fc39
Init system /sbin/init -> ../lib/systemd/systemd To Reproduce `QEMUNBD=$(getarg qemunbd=)
export QEMUNBD echo "test:$QEMUNBD"
if [ -n "$QEMUNBD" ]; then modprobe nbd modprobe nvme modprobe ntfs3 if ismounted "$NEWROOT"; then umount "$NEWROOT" else echo "Directory $NEWROOT is not mounted." fi
fi`
sudo dracut -i ./kloop/10-vhdmount-kloop.sh /lib/dracut/hooks/pre-mount/10-vhdmount-kloop.sh --no-hostonly --install " vi /etc/virc ps grep cat rm blkid losetup kpartx partx mount.fuse mount.ntfs-3g ntfs-3g shutdown qemu-nbd " --add-drivers "fuse dm-mod nbd nvme " -o " plymouth btrfs crypt cifs fcoe fcoe-uefi iscsi nfs" ./kloop/initramfs.img
`menuentry 'niumao ' --class fedora { insmod gzio insmod part_msdos insmod part_gpt insmod ext2 insmod ntfs insmod probe insmod search set vhdfile="/Blackup/kloop_dracut/kloop_dracut.vhd" set root=(hd1,gpt2) search --no-floppy -f --set=aabbcc $vhdfile set root=${aabbcc} probe -u --set=ddeeff ${aabbcc} linux /Blackup/kloop_dracut/vmlinuz rw root=UUID=${ddeeff} qemunbd=$vhdfile selinux=0 rd.debug rd.shell rd.break=dracut-pre-mount rd.break=dracut-pre-trigger rd.break=dracut-initqueue rd.break=initqueue rd.break=pre-pivot rd.memlunit=2048M rd.ip=auto nbd.max_part=16}` Expected behavior A clear and concise description of what you expected to happen.
Additional context logs:https://gist.github.com/lz-lunzi/0570a44040270fb676cac4dcbd5c0a96