0

Is there a way to automatically unmount a filesystem when doing 'exit' command from a chroot?

$ mount --bind /proc proc
$ chroot .
~ exit #now in chroot and call exit.
$ # back to main device.

I would like proc to be unmounted automatically at exit.

Thank you!

1 Answer 1

0

You could try to make an alias for chroot to run your umount command or script after it completes, such as:

alias chroot='chroot; umount my/drive'

Or maybe use a different name for it, such as mychroot.

Another option would be to have script running in the background watching for chroot processes and then umount the drive when the process is terminated.

1
  • 1
    Thank you! The running script in the background is the solution for the case when you have multiple terminals of the same chroot open. Commented Mar 22, 2019 at 14:40

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.