[systemd-devel] systemd shutdown: switch-root after remounting root fs ro

Radoslaw Kamil Ejsmont radoslaw at ejsmont.net
Tue Dec 8 02:04:18 PST 2015


Hi,

I am new to systemd. I am currently running Ubuntu 15.04 with ZFS. I would like to switch root filesystem to a tmpfs during system shutdown to reset root ZFS mount point (to dual boot FreeBSD). I have used /lib/systemd/system-shutdown/foo script. I have tried using systemctl switch-root, but the dbus daemon is already killed at this point. Starting dbus manually did not help much (getting "input/output error" on systemctl status and "launch helper exited with unknown return code 1” on systemctl switch-root). I have also tried using pivot_root after moving mounts to the new fs (except where temps is mounted), but this resulted in “device or resource busy” error.

Could you please advise how should I perform the root switch? Should I use systemctl switch-root or pivot_root - and what are prerequisites?

— FILE /lib/systemd/system-shutdown/foo —

mount -o remount,rw / > /dev/console 2>&1
/etc/init.d/dbus start > /dev/console 2>&1
mount none /tmp -t tmpfs > /dev/console 2>&1
cd /tmp > /dev/console 2>&1
mkdir dev proc sys run > /dev/console 2>&1
ls -la > /dev/console 2>&1
mount | grep tmp > /dev/console 2>&1
zcat /boot/initrd.img-3.19.0-15-generic | cpio -id > /dev/console 2>&1
cp /root/shutdown /tmp > /dev/console 2>&1
systemctl status > /dev/console 2>&1
systemctl switch-root --force /tmp /shutdown > /dev/console 2>&1

— END FILE —


Thanks in advance for advice!


Best,

Radek

-- 
Radoslaw Kamil Ejsmont, Ph.D.
http://radoslaw.ejsmont.net <http://radoslaw.ejsmont.net/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20151208/b507c9b3/attachment.html>


More information about the systemd-devel mailing list