Discussion:
[arch-releng] HEADSUP: mkinitcpio and shutdown
Thomas Bächler
2013-12-15 23:59:10 UTC
Permalink
The new mkinitcpio 16 (yes, we bumped from 0.15 to 16) in testing
contains a new feature that automatically generates an "initramfs" on
shutdown. systemd will pivot to this image on shutdown. All it does is
re-run systemd-shutdown in a ramdisk, thus allowing a proper umount of /
and proper shutdown of ALL loop and device mapper devices.

This feature is enabled automatically if
* /run/initramfs exists (will be created on your next boot by tmpfiles),
* /run/initramfs/shutdown doesn't exist or is not an executable,
* The user hasn't masked mkinitcpio-generate-shutdown-ramfs.service.

This method should also be able to completely obsolete the custom
shutdown hook in archiso and the mkinitcpio shutdown hook (using any of
those will disable the new stuff).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-releng/attachments/20131216/6d48e2dd/attachment.asc>
Gerardo Exequiel Pozzi
2013-12-16 02:25:40 UTC
Permalink
Post by Thomas Bächler
The new mkinitcpio 16 (yes, we bumped from 0.15 to 16) in testing
contains a new feature that automatically generates an "initramfs" on
shutdown. systemd will pivot to this image on shutdown. All it does is
re-run systemd-shutdown in a ramdisk, thus allowing a proper umount of /
and proper shutdown of ALL loop and device mapper devices.
This feature is enabled automatically if
* /run/initramfs exists (will be created on your next boot by tmpfiles),
* /run/initramfs/shutdown doesn't exist or is not an executable,
* The user hasn't masked mkinitcpio-generate-shutdown-ramfs.service.
This method should also be able to completely obsolete the custom
shutdown hook in archiso and the mkinitcpio shutdown hook (using any of
those will disable the new stuff).
Nice, thanks for the work on making systemd working on
initramfs/de-initramfs.

But by nature of the archiso mount structure (/ mounted from
/run/archiso/...) of course this does not work, since systemd does not
know about this (in other words it needs to mount move /run/archiso
outside / before anything)

Remember that this is the first step, that I do on custom
archiso_shutdown script:

# /oldroot depends on things inside /oldroot/run/archiso...
mkdir /oldrun
mount -n --move /oldroot/run /oldrun


Just to test...

Successfully changed into root pivot.
Returning to initrd...
Sending SIGTERM to remaining processes...
Sending SIGKILL to remaining processes...
Unmounting file systems.
Unmounting /oldroot/sys/fs/cgroup/blkio.
Unmounting /oldroot/sys/fs/cgroup/net_cls.
Unmounting /oldroot/sys/fs/cgroup/freezer.
Unmounting /oldroot/sys/fs/cgroup/devices.
Unmounting /oldroot/sys/fs/cgroup/memory.
Unmounting /oldroot/sys/fs/cgroup/cpu,cpuacct.
Unmounting /oldroot/sys/fs/cgroup/cpuset.
Unmounting /oldroot/sys/fs/pstore.
[ 114.204122] cgroup: option or name mismatch, new: 0x0 "", old: 0x4
"systemd"
Unmounting /oldroot/sys/fs/cgroup/systemd.
Unmounting /oldroot/sys/fs/cgroup.
Unmounting /oldroot/dev/pts.
Unmounting /oldroot/dev/shm.
Unmounting /oldroot/sys/kernel/security.
Unmounting /oldroot.
Unmounting /oldroot/run/archiso/sfs/root-image.
Unmounting /oldroot/run/archiso/cowspace.
Unmounting /oldroot/run/archiso/bootmnt.
Unmounting /oldroot/run.
Unmounting /oldroot/dev.
Unmounting /oldroot/sys.
Unmounting /oldroot/proc.
Unmounting /oldroot.
Unmounting /oldroot/run/archiso/sfs/root-image.
Unmounting /oldroot/run/archiso/cowspace.
Unmounting /oldroot/run/archiso/bootmnt.
Unmounting /oldroot/run.
Unmounting /oldroot.
Could not unmount /oldroot: Device or resource busy
Unmounting /oldroot/run/archiso/sfs/root-image.
Could not unmount /oldroot/run/archiso/sfs/root-image: Device or
resource busy
Unmounting /oldroot/run/archiso/cowspace.
Could not unmount /oldroot/run/archiso/cowspace: Device or resource busy
Unmounting /oldroot/run/archiso/bootmnt.
Could not unmount /oldroot/run/archiso/bootmnt: Device or resource busy
Unmounting /oldroot/run.
Could not unmount /oldroot/run: Device or resource busy
Not all file systems unmounted, 5 left.
Deactivating swaps.
All swaps deactivated.
Detaching loop devices.
Detaching loopback /dev/loop2.
Detaching loopback /dev/loop1.
Detaching loopback /dev/loop0.
All loop devices detached.
Detaching DM devices.
Detaching DM 254:0.
Could not detach DM /dev/dm-0: Device or resource busy
Not all DM devices detached, 1 left.
Unmounting file systems.
Unmounting /oldroot.
Unmounting /oldroot/run/archiso/sfs/root-image.
Unmounting /oldroot/run/archiso/cowspace.
Unmounting /oldroot/run/archiso/bootmnt.
Unmounting /oldroot/run.
Unmounting /oldroot.
Could not unmount /oldroot: Device or resource busy
Unmounting /oldroot/run/archiso/sfs/root-image.
Could not unmount /oldroot/run/archiso/sfs/root-image: Device or
resource busy
Unmounting /oldroot/run/archiso/cowspace.
Could not unmount /oldroot/run/archiso/cowspace: Device or resource busy
Unmounting /oldroot/run/archiso/bootmnt.
Could not unmount /oldroot/run/archiso/bootmnt: Device or resource busy
Unmounting /oldroot/run.
Could not unmount /oldroot/run: Device or resource busy
Not all file systems unmounted, 5 left.
Detaching DM devices.
Detaching DM 254:0.
Could not detach DM /dev/dm-0: Device or resource busy
Not all DM devices detached, 1 left.
Cannot finalize remaining file systems and devices, giving up.
Storage is finalized.
[ 114.300170] reboot: Power down
--
Gerardo Exequiel Pozzi
\cos^2\alpha + \sin^2\alpha = 1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-releng/attachments/20131215/e13317c7/attachment.asc>
Thomas Bächler
2013-12-16 09:44:22 UTC
Permalink
Post by Gerardo Exequiel Pozzi
Post by Thomas Bächler
The new mkinitcpio 16 (yes, we bumped from 0.15 to 16) in testing
contains a new feature that automatically generates an "initramfs" on
shutdown. systemd will pivot to this image on shutdown. All it does is
re-run systemd-shutdown in a ramdisk, thus allowing a proper umount of /
and proper shutdown of ALL loop and device mapper devices.
This feature is enabled automatically if
* /run/initramfs exists (will be created on your next boot by tmpfiles),
* /run/initramfs/shutdown doesn't exist or is not an executable,
* The user hasn't masked mkinitcpio-generate-shutdown-ramfs.service.
This method should also be able to completely obsolete the custom
shutdown hook in archiso and the mkinitcpio shutdown hook (using any of
those will disable the new stuff).
Nice, thanks for the work on making systemd working on
initramfs/de-initramfs.
But by nature of the archiso mount structure (/ mounted from
/run/archiso/...) of course this does not work, since systemd does not
know about this (in other words it needs to mount move /run/archiso
outside / before anything)
Remember that this is the first step, that I do on custom
# /oldroot depends on things inside /oldroot/run/archiso...
mkdir /oldrun
mount -n --move /oldroot/run /oldrun
pivot_root semantics are seriously weird. Wouldn't it help if we moved
/run/archiso to /run/initramfs/archiso before switching back to initrd?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-releng/attachments/20131216/a294ee29/attachment.asc>
Gerardo Exequiel Pozzi
2013-12-16 16:20:49 UTC
Permalink
Post by Thomas Bächler
Post by Gerardo Exequiel Pozzi
Post by Thomas Bächler
The new mkinitcpio 16 (yes, we bumped from 0.15 to 16) in testing
contains a new feature that automatically generates an "initramfs" on
shutdown. systemd will pivot to this image on shutdown. All it does is
re-run systemd-shutdown in a ramdisk, thus allowing a proper umount of /
and proper shutdown of ALL loop and device mapper devices.
This feature is enabled automatically if
* /run/initramfs exists (will be created on your next boot by tmpfiles),
* /run/initramfs/shutdown doesn't exist or is not an executable,
* The user hasn't masked mkinitcpio-generate-shutdown-ramfs.service.
This method should also be able to completely obsolete the custom
shutdown hook in archiso and the mkinitcpio shutdown hook (using any of
those will disable the new stuff).
Nice, thanks for the work on making systemd working on
initramfs/de-initramfs.
But by nature of the archiso mount structure (/ mounted from
/run/archiso/...) of course this does not work, since systemd does not
know about this (in other words it needs to mount move /run/archiso
outside / before anything)
Remember that this is the first step, that I do on custom
# /oldroot depends on things inside /oldroot/run/archiso...
mkdir /oldrun
mount -n --move /oldroot/run /oldrun
pivot_root semantics are seriously weird. Wouldn't it help if we moved
/run/archiso to /run/initramfs/archiso before switching back to initrd?
/run/archiso is not a mountpoint, can not be moved.

Anyway from point of view of "de-initramfs", /oldroot depends on things
from /oldroot/run.

What I try is from archiso hook modify all paths
"s|run/archiso|run/initramfs/archiso|" but is the same scenario.
(/oldroot depends on things from /oldroot/run/initramfs/archiso instead).
--
Gerardo Exequiel Pozzi
\cos^2\alpha + \sin^2\alpha = 1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-releng/attachments/20131216/95d9148f/attachment.asc>
Loading...