[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: trying to umount a chroot /dev



On Tue, 2012-08-21 at 20:21 -0600, Bob Proulx wrote:
> Ross Boylan wrote:
> > I setup a chroot on a snapshot.  Part of the setup was
> > mount --rbind /dev /mnt/chrtest/dev
> 
> Why did you choose "rbind" over "bind".  Just curious.  My reply is
> the one I would give if you had used bind.  I have never used rbind.
> The result may be wrong for rbind.  But it would be right for bind.
I started with nothing mounted under /dev (and maybe /proc and /sys too)
in the chroot and kept adding things that I needed to make screen and
aptitude, and the package installers (e.g., some needed df to work)
happy inside the chroot.  At first I just mounted /dev/pts, but found
that was not enough.  rbind picks up /dev/pts and /dev/shm.

It's certainly not something to take as a model; it's just what sort of
worked for me.
> 
> > I have exited the chroot and, I believe, ended the processes I started.
> > umount /mnt/chrtest/dev
> > gives umount: /mnt/chrtest/dev: device is busy
> > 
> > How can I get this to work?
> 
> Unmount that path.  Look at /proc/mounts for the path to anything
> mounted in that directory tree and unmount it.  You will see something
> like this bind mount.
> 
>   udev /srv/chroot/sid/dev devtmpfs rw,relatime,size=10240k,nr_inodes=493001,mode=755 0 0
my host system shows
udev /mnt/chrtest/dev tmpfs rw,size=10240k,mode=755 0 0
> 
> In which case the umount command would be:
> 
>   # umount /srv/chroot/sid/dev
The corresponding command is the one I tried.  That failed with "device
is busy".
> 
> > After reviewing the output of mount I umounted the mounts below /dev,
> > which seems to be the main advice on the net for undoing rbinds.
> 
> I think instead of unmounting below /dev you needed to unmount below
> /mnt/chartest/dev instead.
I was speaking loosely; I meant below /dev in the chroot,
i.e., /mnt/chrtest/dev/pts and the shm directory.  Those mounts are now
gone, as verified by /proc/mounts (/proc/mounts on the host system).

/dev/pts is still mounted on the host.
> 
> If you really get stuck then rebooting should restore things to a sane
> state since those mounts will not exist after a reboot.  But you
> should be able to recover without rebooting.
That's my hope.

It might be relevant that I began with a logical volume mounted
at /mnt/chroot, with various submounts including /mnt/chroot/dev.  I
created a snapshot of the first logical volume and mounted it
at /mnt/chrtest.  I mounted stuff under it, ran some tests, shut down
what I could in the /mnt/chrtest chroot, and umounted what I could.  But
I can't seem to umount /mnt/chrtest/dev or (as a result, I
think) /mnt/chrtest itseelf.

Ross



Reply to: