systemd-shutdown / initrd에서 루프를 디버깅하는 방법은 무엇입니까? (아치 리눅스)

systemd-shutdown / initrd에서 루프를 디버깅하는 방법은 무엇입니까? (아치 리눅스)

최근 ZFS의 루트에 대한 사용자 정의 구성에 따라 가상 디스크에 Arch Linux를 설치했습니다. 이는 별도의 부팅 및 루트 풀이 있는 멀티부팅 구성을 관리하기 위해 제가 함께 구성한 일부 스크립팅을 사용하는 것이었습니다. 각각은 Arch와 FreeBSD에 모두 사용됩니다. 현재 ZFS 풀 구성은 VM 아래에서 FreeBSD로 생성되었습니다. 그런 다음 Arch Linux 설치는 Arch가 Ext4 파티션에 설치된 다른 VM에서 생성되었습니다. 부팅/루트 ZFS 구성에 Arch가 설치되어 있고 Grub에 대한 일부 구성 후에 이제 ZFS의 Arch 설치가 성공적으로 부팅됩니다.

현재 ZFS 풀이 있는 가상 디스크는 별도의 가상 머신에서 실행되고 있습니다. Arch Linux는 현재 해당 머신의 가상 디스크에 설치된 유일한 OS입니다. 이제 해당 Grub2 구성으로 성공적으로 부팅됩니다. 그러나 종료 중에 루프가 발생하는 것을 발견했습니다.

[ 1561.324253] systemd-shutdown[1]: Sending SIGKILL to remaining processes...
[ 1561.336930] systemd-shutdown[1]: Unmounting file systems.
[ 1561.341650] [563]: Remounting '/var' read-only in with options 'noxattr,noacl'.
[ 1561.783555] [564]: Unmounting '/var'.
[ 1561.790194] [565]: Remounting '/usr' read-only in with options 'noxattr,noacl'.
[ 1561.796853] [566]: Remounting '/' read-only in with options 'noxattr,noacl'.
[ 1561.803420] systemd-shutdown[1]: All filesystems unmounted.
[ 1561.809423] systemd-shutdown[1]: Deactivating swaps.
[ 1561.813672] systemd-shutdown[1]: All swaps deactivated.
[ 1561.818688] systemd-shutdown[1]: Detaching loop devices.
[ 1561.824354] systemd-shutdown[1]: All loop devices detached.
[ 1561.829085] systemd-shutdown[1]: Stopping MD devices.
[ 1561.833346] systemd-shutdown[1]: All MD devices stopped.
[ 1561.837982] systemd-shutdown[1]: Detaching DM devices.
[ 1561.842299] systemd-shutdown[1]: All DM devices detached.
[ 1561.847501] systemd-shutdown[1]: All filesystems, swaps, loop devices, MD devices and DM devices detached.
[ 1561.856852] systemd-shutdown[1]: Successfully changed into root pivot.
[ 1561.863478] systemd-shutdown[1]: Returning to initrd...
[ 1562.306958] shutdown[1]: Syncing filesystems and block devices.
[ 1562.311377] shutdown[1]: Sending SIGTERM to remaining processes...
[ 1562.316903] shutdown[1]: Sending SIGKILL to remaining processes...
[ 1562.329374] shutdown[1]: Unmounting file systems.
[ 1562.334319] sd-remou[569]: Remounting '/' read-only in with options 'noxattr,noacl'.
[ 1562.346902] sd-umoun[570]: Unmounting '/oldroot/sys/kernel/config'.
[ 1562.354595] sd-umoun[571]: Unmounting '/oldroot/sys/fs/fuse/connections'.
[ 1562.361525] sd-umoun[572]: Unmounting '/oldroot/sys/kernel/tracing'.
[ 1562.368232] sd-umoun[573]: Unmounting '/oldroot/sys/kernel/debug'.
[ 1562.373715] sd-umoun[574]: Unmounting '/oldroot/dev/mqueue'.
[ 1562.380105] sd-umoun[575]: Unmounting '/oldroot/dev/hugepages'.
[ 1562.386843] sd-umoun[576]: Unmounting '/oldroot/sys/fs/bpf'.
[ 1562.391984] sd-umoun[577]: Unmounting '/oldroot/sys/fs/pstore'.
[ 1562.397417] sd-umoun[578]: Unmounting '/oldroot/sys/fs/cgroup'.
[ 1562.404234] audit: type=1334 audit(1635363440.667:81): prog-id=8 op=UNLOAD
[ 1562.410100] sd-umoun[579]: Unmounting '/oldroot/dev/pts'.
[ 1562.414579] audit: type=1334 audit(1635363440.667:82): prog-id=6 op=UNLOAD
[ 1562.420101] sd-umoun[580]: Unmounting '/oldroot/dev/shm'.
[ 1562.426852] sd-umoun[581]: Unmounting '/oldroot/sys/kernel/security'.
[ 1562.432165] sd-umoun[582]: Unmounting '/oldroot/usr'.
[ 1562.443869] sd-remou[583]: Remounting '/oldroot/run' read-only in with options 'noxattr,noacl'.
[ 1562.456905] sd-umoun[584]: Unmounting '/oldroot/run'.
[ 1562.461323] sd-umoun[585]: Unmounting '/oldroot'.
[ 1562.466800] sd-umoun[585]: Failed to unmount /oldroot: Device or resource busy
[ 1562.473458] sd-umoun[586]: Unmounting '/oldroot/dev'.
[ 1562.478395] sd-umoun[587]: Unmounting '/oldroot/sys'.
[ 1562.483288] sd-umoun[588]: Unmounting '/oldroot/proc'.
[ 1562.488082] sd-umoun[589]: Unmounting '/oldroot'.
[ 1562.493279] shutdown[1]: All filesystems unmounted.
[ 1562.498851] shutdown[1]: Deactivating swaps.
[ 1562.502456] shutdown[1]: All swaps deactivated.
[ 1562.506839] shutdown[1]: Detaching loop devices.
[ 1562.511505] shutdown[1]: All loop devices detached.
[ 1562.515404] shutdown[1]: Stopping MD devices.
[ 1562.520083] shutdown[1]: All MD devices stopped.
[ 1562.523666] shutdown[1]: Detaching DM devices.
[ 1562.527617] shutdown[1]: All DM devices detached.
[ 1562.531822] shutdown[1]: All filesystems, swaps, loop devices, MD devices and DM devices detached.
[ 1562.540145] shutdown[1]: Successfully changed into root pivot.
[ 1562.544940] shutdown[1]: Returning to initrd...

ZFS에 Arch Linux를 설치할 때만 이 문제가 발생했습니다. Ext4 파티션에 Arch가 있는 다른 VM 설치에서 동일한 systemd, mkinitcpio, linux 및 zfs-linux 버전을 사용하면 해당 시스템을 종료하는 동안 그러한 루프가 발생하지 않습니다. ZFS 구성의 루트 때문일 수 있습니까?

이 루프를 더 이상 디버깅하는 방법을 알아내려고 노력하다 보니 당황스럽습니다.

내 추측으로는 이는 2013년에 도입된 mkinticpio의 systemd-shutdown 스크립트와 관련이 있을 수 있습니다.베흘러2013).

mkinitcpio-generate-shutdown-ramfs당시 소개된 서비스 의 주요 코드로 보이는 것 - 발췌/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service

[Service]
Type=oneshot
# /tmp could be umounted at this point
# use /run as temporary directory
Environment=TMPDIR=/run
ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -k none -c /dev/null -d /run/initramfs

게다가 파일의 내용은/usr/lib/initcpio/install/sd-shutdown

#!/bin/bash

build() {
    add_binary /usr/lib/systemd/systemd-shutdown /shutdown

    if type -P kexec >/dev/null; then
        add_binary kexec
    fi
}

help() {
    cat <<HELPEOF
This hook adds systemd-shutdown to the initramfs. This is only
if the image is extracted to /run/initramfs before shutdown.
HELPEOF
}

# vim: set ft=sh ts=4 sw=4 et:

VM에서 실제로 종료 프로세스가 진행되는지는 확실하지 않습니다. 시스템이 명시된 전제 조건을 그만큼 충족하지 못할 수도 있습니다.

mkinitcpio-generate-shutdown-ramfssystemd에서 서비스를 마스킹 한 다음 mkinitcpio -P다시 실행하고 재부팅해 보았지만 시스템 종료 중에도 여전히 해당 루프에 들어갑니다.

시스템은 VM 설치 하에서 계속 사용할 수 있습니다. 적어도 시스템이 무한정 루프를 시작하는 종료 시 해당 이벤트 시점까지는 사용할 수 있습니다. 이상적으로는 Arch 옆에 무엇인가를 설치하거나 이것을 기계의 내부 하드 디스크에 넣기 전에 구성에서 이 매듭을 작업할 수 있기를 바랍니다.

메시지의 결과가 무엇인지 확실하지 않습니다 Failed to unmount /oldroot: Device or resource busy. ZFS 설치의 루트와 관련된 것일 수 있습니까? 하지만 그것은 단지 추측일 뿐입니다.

내 관점에서는 systemd-shutdown 프로세스가 콘솔 출력에 표시된 대로 initrd에서 실행되고 있습니까? 나는 이 시점에서 디버깅하는 것이 중요하지 않다고 생각합니다.

VM의 가상 디스크 아래 ZFS 풀 구성에서 Arch 옆에 FreeBSD를 설치한 후 Grub 구성을 최신 상태로 유지하기 위해 Arch를 계속 사용할 수 있다고 확신합니다. 그러나 Arch의 종료 루프로 이 문제를 해결할 수 있다면 Arch 설치를 VM 설치 또는 최종적으로 PC 하드 디스크에서 작동하는 데스크탑 시스템으로 유지할 수 있기를 바랍니다.

이 루프를 더 이상 디버깅하는 방법을 찾으려고 노력하는 동안 종료 중 해당 루프에 대해 아직 찾지 못한 패치가 있을 수 있습니까?

업데이트

내가 발견했다소스 코드systemd-shutdown의 경우 Arch Linux에서 사용되는 버전입니다. 제 생각에는 상당히 간단한 코드인 것 같습니다. 'oldroot' 마운트 지점이나 systemd-shutdown에서 어떻게 마운트 해제할 수 있는지에 대한 정보가 많지 않을 수 있습니다.

로깅으로 인한 것은 아닌 것 같습니다. 부팅 후 실행되는 일회성 시스템 서비스를 설정 Storage=volatile하고 만들었습니다. 이제 파일 시스템 이 성공적으로 마운트 해제되었으며 재부팅 시 모든 로그 데이터가 손실될 것이라고는 생각하지 않습니다./etc/systemd/journald.conf/usr/bin/journalctl --flush/var/

Failed to unmount /oldroot...그러나 systemd-shutdown의 메시지와 함께 종료 중에 루프가 계속 발생합니다 . 부작용으로 뭔가 걸려있는 것이 있습니까?

관련 정보