1

as we know chroot needs some fs to be mounted inside chroot directory like the following :

chroot_dir=/some/where
cd $chroot_dir/
mount -t proc proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/

what i want is to mount theses directories with their absolute path
for sys and dev it's very clear to me ! it can be like that :

chroot_dir=/some/where
mount --rbind /sys $chroot_dir/sys/
mount --rbind /dev $chroot_dir/dev/

but i don't know how to deal with proc
i don't know if it should be like that :
mount -t $chroot_dir/proc $chroot_dir/proc $chroot_dir/proc/
or any !

anyone knows how to deal with this please?

2 Answers 2

3

The "absolute path" would be as seen inside the chroot. However, you can mount these filesystems in preparing the chroot, and need not be concerned about making them absolute pathnames.

These questions can be helpful in comparing against your examples

In particular, the answer in the second question citing the Arch Wiki (on Change root) is the simplest one, since it uses only the filesystem types (no special devices from the non-chrooted filesystem). The other answers use the --bind option of mount.

2

From man mount:

       -t, --types vfstype
              The  argument following the -t is used to indicate the
              filesystem type.  The filesystem types which are  cur‐
              rently  supported  include:  adfs, affs, autofs, cifs,
              [ . . . ]

And proc, among others. Therefore, the -t argument takes one of a number of filesystem types, rather than a /a/directory/name. Mount as usual will take the name of the system you want to mount followed by the directory to which the system is mounted. So your command would look like this:

mount --rbind /sys $chroot_dir/sys/
mount --rbind /dev $chroot_dir/dev/
mount -t proc /proc $chroot_dir/proc/

I second Thomas's mention you can read more about this subject in places such as the Arch Wiki article he pointed to (though some logistics could conceivably vary by system, depending on what it is you want to do).

2
  • that means the proc can be mounted either from outside or inside chroot_dir ? Commented Nov 21, 2015 at 18:01
  • You can mount from inside or outside chroot_dir, but if you're outside of the directory, you might need to type your path differently. Commented Nov 21, 2015 at 18:07

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.