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 sshd
- exit back to the original root
- switch 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 partition
- create an encrypted partition on the lvm partition
- install arch Linux on it and modify intrafms appropriately
Steps 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/tmproot mount -t tmpfs none /tmp/tmproot mv /tmp/newroot/* /tmp/tmproot # switch to new root mount -a mount --make-rprivate / # necessary for pivot_root to work pivot_root /tmp/tmproot /tmp/tmproot/oldroot # move some directories to newroot for i in dev proc sys run; do mount --move /oldroot/$i /$i; done
I 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 sshd Failed to restart sshd service: Failed to activate service 'org.freedesktop.systemd1': timed out
I 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
Perhaps I should use
switch_root instead of
Any suggestion? Thanks