8

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/

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

Zanna
  • 69,223
  • 56
  • 216
  • 327
turbo
  • 4,572
  • 4
  • 28
  • 46

1 Answers1

11

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
psusi
  • 37,033
  • 2
  • 68
  • 106
  • 1
    You could add references to the [manual page](http://manpages.ubuntu.com/manpages/maverick/en/man1/schroot.1.html) and provide examples. – Lekensteyn Mar 28 '11 at 17:42
  • well... that's kindof why I asked about the _standard_ Ubuntu install. Of course there exist tools that do that. But is it as simple as sudo apt-get install schroot && schroot /dest ? – turbo Mar 28 '11 at 17:54
  • 1
    @turbo in that case, no. One thing that can help save some typing though is rather than issue 3 separate bind mount commands, you can just do "for f in /sys /proc /dev ; do mount --bind $f /mnt/$f ; done" – psusi Mar 28 '11 at 19:16
  • yeah that's a good one. I knew and forgot about one line bash 'scripts'. I just seems kind of obvious from Ubuntu's point of view to include something like this in their rescue menu. – turbo Mar 28 '11 at 19:52
  • psusi if you change your answer to "for i in bla" I'm gonna accept this answer since that is what comes closest to answering my question, albeit being ... not 100% satisfying. Oh and don't forget /dev/pts please! – turbo Apr 11 '11 at 22:31
  • @Lenensteyn neat, good idea. – psusi Apr 12 '11 at 00:44
  • @turbo /dev/pts is part of /dev, so you don't need to treat it separately. – psusi Apr 12 '11 at 00:47
  • 4
    @turbo, @psusi `--bind` only mounts the specific named filesystem; it won't include `pts` or for that matter `shm`. However if you use [`mount --rbind`](http://manpages.ubuntu.com/manpages/natty/en/man2/mount.2.html) it will work. – poolie Apr 12 '11 at 02:33
  • ah cool! good one! It's funny that every how-to on earth suggests mount --bind ;) – turbo Apr 12 '11 at 12:50
  • @poolie I'll be damned... I guess you should use rbind then – psusi Apr 12 '11 at 13:23
  • @poolie actually it looks like --rbind is still a little buggy; you can't umount the rbind point. I also have never run into anything that needed pts or shm, so... – psusi Apr 12 '11 at 13:30
  • 1
    @psusi, you'll probably need to manually umount the things inside it before you can unmount /dev. If that doesn't work, yes, it's a bug. `screen` would be an example of something that needs a pseudoterminal from `/dev/pts`, though it might fall back to putting them just under `/dev/`. – poolie Apr 13 '11 at 00:18