Is there an easier way to chroot than bind-mounting?

tur*_*rbo 7 chroot

Most of the time I use chroot to rescue an existing installation from usb.

When I chroot into another system I have to manually bind-mount proc, sys, dev and dev/pts by issuing for example:

mount --bind /proc proc/
Run Code Online (Sandbox Code Playgroud)

Is there an easy way already implemented in a standard Ubuntu install?

psu*_*usi 10

See the schroot package. Man Page

As an alternative, you can shorthand the bind mounting with:

for f in proc sys dev ; do mount --bind /$f /mnt/$f ; done
Run Code Online (Sandbox Code Playgroud)

  • @turbo, @psusi `--bind` 只挂载特定命名的文件系统;它不会包含`pts` 或`shm`。但是,如果您使用 [`mount --rbind`](http://manpages.ubuntu.com/manpages/natty/en/man2/mount.2.html),它将起作用。 (4认同)