[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: unmount sys/fs/cgroup/systemd after chroot, without rebooting



On 03/05/2017, Sam Kuper <sam.kuper@uclmail.net> wrote:
> [...] I then exit the `chroot`, and my trouble begins. I find that I can
> unmount `/mnt/dev` and `/mnt/proc`, **but not `/mnt/sys`**. The latter
> refuses to unmount because it contains `/mnt/sys/fs/cgroup/systemd`,
> which the system for some reason thinks is "in use". [...]
>
> - How can I unmount `/mnt/sys` after the chroot, without rebooting?
> [...]
>
> VIRTUAL_FILESYSTEM_DIRS=(dev proc sys)
>
> for i in "${VIRTUAL_FILESYSTEM_DIRS[@]}"; do
>     # Make mountpoints for virtual filesystems on target drive
>     mkdir /mnt/"$i"
>     mount --rbind /"$i"  /mnt/"$i"
> done

Adding `mount --make-rslave /mnt/"$i"` after the `mount --rbind /"$i"
/mnt/"$i"` line does the trick. Thanks to @Mioriin at
https://unix.stackexchange.com for the suggestion :)


Reply to: