Thursday, May 5, 2022

[SOLVED] How to check if /tmp and /proc filesysystems are mounted in a chrooted environment?

Issue

I have already tried mounting the filesystems without checking like this:

sudo -- mount -t proc /proc $chroot_dir/proc
sudo -- mount --bind /tmp $chroot_dir/tmp

However, this would corrupt the parent OS session if already mounted, and I would have to restart the OS. I want to check if they're mounted beforehand.


Solution

You can see in /etc/mtab what's currently mounted:

if grep $chroot_dir/proc /etc/mtab; then
  echo already mounted
fi;

And analogously for tmp.



Answered By - Christian Fritz
Answer Checked By - Robin (WPSolving Admin)