1

Trying to use a chrooted system via

mount -B stage3 gentoo
mount -t sysfs none gentoo/sys
mount -t proc none gentoo/proc
mount -R /dev gentoo/dev
mount --make-rslave gentoo/dev
unshare --fork chroot gentoo
umount -R gentoo

After the last umount, dev, dev/pts, dev/shm, dev/mqueue, dev/hugepages were still mounted under stage3.

I have two questions,

  1. Why they were mounted to stage3?
  2. How could I unmount those? Every mountpoint is busy.

OS: Ubuntu Xenial. Kernel: 4.13.4, but I have got same issue with kernel like 4.10 and others.

1 Answer 1

1
  1. Why they were mounted to stage3?

    Because you bind-mounted stage3 onto gentoo and stage3 propagation flag is set to shared (verify this with: findmnt -o PROPAGATION stage3)

  2. How could I unmount those? Every mountpoint is busy.

    You've just spawned a chroot on the mounted tree. If you want to unmount the tree while the chroot command is running, make the mount namespace private to the chroot:

     unshare --mount --fork chroot gentoo
    
5
  • (and the default to shared propagation is probably due to systemd: unix.stackexchange.com/questions/269695/…)
    – sourcejedi
    Oct 7, 2017 at 17:52
  • Thanks for the explanation. Shared sub-tree is always confusing me. For question 2, I ran umount after exited the chroot jail. umount -R unmounted gentoo, sys, proc properly. But dev and its children did not get unmounted due to "busy".
    – Magicloud
    Oct 8, 2017 at 5:44
  • Sorry last comment was not editable. I mean dev and its children (on stage3) did not get unmounted due to "busy". Let me check the share part since dev on gentoo got unmounted.
    – Magicloud
    Oct 8, 2017 at 6:06
  • @Magicloud It did not get unmounted with the --mount option? Use lsof to find out what is using it.
    – xhienne
    Oct 8, 2017 at 9:40
  • Oh, --mount works here. And --make-private when binding stage3 to gentoo also works.
    – Magicloud
    Oct 9, 2017 at 2:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .