I have a Linux Arch system running on a VPS. The rootfs is installed on a LVM partition. I would like to overlay an encrypted container on this partition, then reinstall the rootfs on it and enable ssh unlock at boot via ssh. I am happy to discard all content of the existing rootfs and create a new one from scratch.I am proceeding as follows:create a new temporary rootfs in /tmp/newroot (I use the Linux Arch boostrappig image in the Arch wiki)chroot to it and set up pacman, install a few things define authorized_keys, enable but not start sshdexit back to the original rootswitch permanently to the new root: following recommendations in this great post, I run the code below.At this point I would like to restart sshd and all other services still hanging on to the old root, which is on the lvm partitioncreate an encrypted partition on the lvm partitioninstall arch Linux on it and modify intrafms appropriatelySteps 6 and 7 are well documented (for instance here).Here are the details of step 4, which works fine:# we start after step 2, so that /tmp/newroot contains a minimal temporary root fs # with network, sshd and pacman, and the command prompt is from the original root# move the new root fs to a newly create /tmproot, as per the referenced post# (perhaps this is redundant, I could have used newroot directly, but it should not harm)mkdir /tmp/tmprootmount -t tmpfs none /tmp/tmprootmv /tmp/newroot/* /tmp/tmproot# switch to new rootmount -amount --make-rprivate / # necessary for pivot_root to workpivot_root /tmp/tmproot /tmp/tmproot/oldroot# move some directories to newrootfor i in dev proc sys run; do mount --move /oldroot/$i /$i; doneI am stuck with step 5. Using fuser -vm /oldroot I can see there are lot of processes still hanging to the old root partition. If I try and restart them from the newroot using systemctl, I get an error:# systemctl restart sshdFailed to restart sshd service: Failed to activate service 'org.freedesktop.systemd1': timed outI can kill them manually, but then I am left with just the init process systemd, and there seems to be no way to kill that. systemctl daemon-reexec won't work.Perhaps I forgot to configure something in my newroot filesystem?Perhaps I should use switch_root instead of pivot_root?Any suggestion? Thanks
How to encrypt a live root fs remotely and unlock it via ssh
arch linux;systemd;encryption;root filesystem