systemd service cleanup
parent
43bac63e33
commit
792b189317
|
@ -13,22 +13,22 @@ if [ "${root%%:*}" = "block" ]; then
|
|||
printf '[ -e "%s" ] && { ln -s "%s" /dev/root 2>/dev/null; rm "$job"; }\n' \
|
||||
"${root#block:}" "${root#block:}" > $hookdir/initqueue/settled/blocksymlink.sh
|
||||
|
||||
if [ -d /lib/systemd/system/ ]; then
|
||||
echo "${root#block:} $NEWROOT ${fstype:-auto} ${rflags:-defaults} 1 1" >> /etc/fstab
|
||||
{
|
||||
echo '[Unit]'
|
||||
echo 'Description=New Root File System'
|
||||
echo 'DefaultDependencies=no'
|
||||
echo 'Before=switch-root.service'
|
||||
echo '[Mount]'
|
||||
echo "What=${root#block:}"
|
||||
echo "Where=$NEWROOT"
|
||||
# if [ -d /lib/systemd/system/ ]; then
|
||||
# echo "${root#block:} $NEWROOT ${fstype:-auto} ${rflags:-defaults} 1 1" >> /etc/fstab
|
||||
# {
|
||||
# echo '[Unit]'
|
||||
# echo 'Description=New Root File System'
|
||||
# echo 'DefaultDependencies=no'
|
||||
# echo 'Before=initrd-switch-root.service'
|
||||
# echo '[Mount]'
|
||||
# echo "What=${root#block:}"
|
||||
# echo "Where=$NEWROOT"
|
||||
|
||||
} >/lib/systemd/system/${NEWROOT#/}.mount
|
||||
# } >/lib/systemd/system/${NEWROOT#/}.mount
|
||||
|
||||
mkdir -p /lib/systemd/system/switch-root.target.wants
|
||||
ln -s ../${NEWROOT#/}.mount /lib/systemd/system/switch-root.target.wants/${NEWROOT#/}.mount
|
||||
fi
|
||||
# mkdir -p /lib/systemd/system/initrd-switch-root.target.requires
|
||||
# ln -s ../${NEWROOT#/}.mount /lib/systemd/system/initrd-switch-root.target.requires/${NEWROOT#/}.mount
|
||||
# fi
|
||||
|
||||
wait_for_dev "${root#block:}"
|
||||
fi
|
||||
|
|
|
@ -16,10 +16,8 @@ Wants=systemd-journald.socket
|
|||
ConditionPathExists=/etc/initrd-release
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/
|
||||
WorkingDirectory=/
|
||||
ExecStart=-/bin/dracut-cmdline
|
||||
Type=oneshot
|
||||
ExecStart=-/bin/dracut-cmdline
|
||||
StandardInput=null
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog+console
|
||||
|
|
|
@ -15,10 +15,8 @@ Wants=systemd-udev-trigger.service
|
|||
ConditionPathExists=/etc/initrd-release
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/
|
||||
WorkingDirectory=/
|
||||
Type=oneshot
|
||||
ExecStart=-/bin/dracut-initqueue
|
||||
Type=simple
|
||||
StandardInput=null
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog+console
|
||||
|
|
|
@ -106,5 +106,4 @@ done
|
|||
|
||||
export -p > /dracut-state.sh
|
||||
|
||||
systemctl isolate initrd-switch-root.target
|
||||
exit 0
|
||||
|
|
|
@ -10,14 +10,13 @@
|
|||
[Unit]
|
||||
Description=Dracut pre-pivot and cleanup hook
|
||||
DefaultDependencies=no
|
||||
Before=initrd-switch-root.service
|
||||
After=dracut-initqueue.service
|
||||
ConditionPathExists=/etc/initrd-release
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/
|
||||
WorkingDirectory=/
|
||||
ExecStart=-/bin/dracut-pre-pivot
|
||||
Type=oneshot
|
||||
ExecStart=-/bin/dracut-pre-pivot
|
||||
ExecStopPost=-/usr/bin/systemctl isolate initrd-switch-root.target
|
||||
StandardInput=null
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog+console
|
||||
|
|
|
@ -34,20 +34,9 @@ done
|
|||
|
||||
echo "NEWROOT=\"$NEWROOT\"" >> /run/initramfs/switch-root.conf
|
||||
|
||||
udevadm control --stop-exec-queue
|
||||
|
||||
for i in systemd-udevd.service; do
|
||||
systemctl is-active $i >/dev/null 2>&1 && systemctl stop $i
|
||||
done
|
||||
|
||||
udevadm info --cleanup-db
|
||||
|
||||
# remove helper symlink
|
||||
[ -h /dev/root ] && rm -f /dev/root
|
||||
|
||||
getarg rd.break rdbreak && emergency_shell -n switch_root "Break before switch_root"
|
||||
|
||||
cp -avr /lib/systemd/system/dracut*.service /run/systemd/system/
|
||||
|
||||
export -p > /dracut-state.sh
|
||||
exit 0
|
||||
|
|
|
@ -16,10 +16,8 @@ Wants=dracut-pre-udev.service systemd-udevd.service
|
|||
ConditionPathExists=/etc/initrd-release
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/
|
||||
WorkingDirectory=/
|
||||
ExecStart=-/bin/dracut-pre-trigger
|
||||
Type=oneshot
|
||||
ExecStart=-/bin/dracut-pre-trigger
|
||||
StandardInput=null
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog+console
|
||||
|
|
|
@ -16,10 +16,8 @@ Wants=dracut-cmdline.service
|
|||
ConditionPathExists=/etc/initrd-release
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/
|
||||
WorkingDirectory=/
|
||||
ExecStart=-/bin/dracut-pre-udev
|
||||
Type=oneshot
|
||||
ExecStart=-/bin/dracut-pre-udev
|
||||
StandardInput=null
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog+console
|
||||
|
|
|
@ -9,9 +9,13 @@
|
|||
Description=Switch Root
|
||||
DefaultDependencies=no
|
||||
ConditionPathExists=/etc/initrd-release
|
||||
OnFailure=emergency.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
EnvironmentFile=/run/initramfs/switch-root.conf
|
||||
ExecStart=/usr/bin/systemctl --force switch-root ${NEWROOT} ${NEWINIT}
|
||||
ExecStopPost=-/usr/bin/systemctl isolate default.target
|
||||
ExecStopPost=-/usr/bin/systemctl restart systemd-journald.service
|
||||
StandardInput=null
|
||||
StandardOutput=null
|
||||
StandardError=null
|
||||
|
|
|
@ -13,4 +13,4 @@ DefaultDependencies=no
|
|||
Requires=initrd-switch-root.service
|
||||
Before=initrd-switch-root.service
|
||||
AllowIsolate=yes
|
||||
|
||||
Wants=systemd-journald.service
|
||||
|
|
|
@ -63,7 +63,7 @@ install() {
|
|||
$systemdsystemunitdir/systemd-ask-password-console.service \
|
||||
$systemdsystemunitdir/halt.service \
|
||||
$systemdsystemunitdir/poweroff.service \
|
||||
$systemdsystemunitdir/reboot.service \
|
||||
$systemdsystemunitdir/systemd-reboot.service \
|
||||
$systemdsystemunitdir/kexec.service \
|
||||
$systemdsystemunitdir/fsck@.service \
|
||||
$systemdsystemunitdir/systemd-udevd.service \
|
||||
|
@ -142,8 +142,12 @@ install() {
|
|||
|
||||
inst_script "$moddir/dracut-pre-pivot.sh" /bin/dracut-pre-pivot
|
||||
inst_simple "$moddir/dracut-pre-pivot.service" ${systemdsystemunitdir}/dracut-pre-pivot.service
|
||||
mkdir -p "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.wants"
|
||||
ln -fs ../dracut-pre-pivot.service "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.wants/dracut-pre-pivot.service"
|
||||
ln -fs ../dracut-pre-pivot.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-pre-pivot.service"
|
||||
|
||||
inst_simple "$moddir/udevadm-cleanup-db.service" ${systemdsystemunitdir}/udevadm-cleanup-db.service
|
||||
mkdir -p "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.requires"
|
||||
ln -fs ../udevadm-cleanup-db.service "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.requires/udevadm-cleanup-db.service"
|
||||
|
||||
inst_script "$moddir/service-to-run.sh" $systemdutildir/system-generators/service-to-run
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
cp -a /lib/systemd/system/dracut*.service /run/systemd/system/
|
||||
cp -a /lib/systemd/system/initrd-* /run/systemd/system/
|
||||
cp -a /lib/systemd/system/udevadm*.service /run/systemd/system/
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
[Unit]
|
||||
Description=Cleanup udevd DB
|
||||
DefaultDependencies=no
|
||||
ConditionPathExists=/etc/initrd-release
|
||||
Conflicts=systemd-udevd.service systemd-udevd-control.socket systemd-udevd-kernel.socket
|
||||
Before=initrd-switch-root.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/usr/bin/udevadm info --cleanup-db
|
||||
StandardInput=null
|
||||
StandardOutput=null
|
||||
StandardError=null
|
Loading…
Reference in New Issue