Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trying to umount a chroot /dev

1,169 views
Skip to first unread message

Ross Boylan

unread,
Aug 21, 2012, 9:50:01 PM8/21/12
to
I setup a chroot on a snapshot. Part of the setup was
mount --rbind /dev /mnt/chrtest/dev

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?

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.

The net also mentions using lsof to see what is accessing the file
system. lsof isn't much help because it shows everything that is
touching /dev (I presume--it's a long list), and I can't shut all that
down without a reboot.

My ultimate goal is to destroy the snapshot, but neither lvremove nor
lvchange -an work with the volume "in use".

linux kernel 2.6.26-2-686.

Thanks.
Ross


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/1345599995.9...@corn.betterworld.us

Bob Proulx

unread,
Aug 21, 2012, 10:30:03 PM8/21/12
to
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 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

In which case the umount command would be:

# umount /srv/chroot/sid/dev

> 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.

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.

Bob
signature.asc

Ross Boylan

unread,
Aug 22, 2012, 1:10:02 AM8/22/12
to
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



--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/1345611934.9...@corn.betterworld.us

Bob Proulx

unread,
Aug 22, 2012, 1:30:02 AM8/22/12
to
Ross Boylan wrote:
> Bob Proulx wrote:
> > Why did you choose "rbind" over "bind". Just curious.
>
> It's certainly not something to take as a model; it's just what sort of
> worked for me.

Understood. We are all pragmatic when need be. :-)

> > # umount /srv/chroot/sid/dev
> The corresponding command is the one I tried. That failed with "device
> is busy".

Try using the umount -l option for a lazy unmount. Might work. Might
not work. If it doesn't then I think you need to reboot.

Bob
signature.asc

Ross Boylan

unread,
Aug 22, 2012, 3:30:02 AM8/22/12
to
On Tue, 2012-08-21 at 23:20 -0600, Bob Proulx wrote:
>
> Try using the umount -l option for a lazy unmount. Might work. Might
> not work. If it doesn't then I think you need to reboot.
Kind of works.
umount -l /mnt/chrtest/dev
no error messages. And it's no longer listed in /proc/mounts
Despite that,
umount /mnt/chrtest -> device is busy
umount -l /mnt/chrtest -> no complaints

But
# lvchange -an daisy/chrtest
Can't change snapshot logical volume "chrtest"
# lvremove daisy/chrtest; date
Can't remove open logical volume "chrtest"

Ross


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/1345620410.9...@corn.betterworld.us

Tom H

unread,
Aug 22, 2012, 3:40:01 AM8/22/12
to
On Tue, Aug 21, 2012 at 9:46 PM, Ross Boylan <ro...@biostat.ucsf.edu> wrote:
>
> I setup a chroot on a snapshot. Part of the setup was
> mount --rbind /dev /mnt/chrtest/dev
>
> 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?
>
> 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.
>
> The net also mentions using lsof to see what is accessing the file
> system. lsof isn't much help because it shows everything that is
> touching /dev (I presume--it's a long list), and I can't shut all that
> down without a reboot.
>
> My ultimate goal is to destroy the snapshot, but neither lvremove nor
> lvchange -an work with the volume "in use".

Since you used "rbind", you must also have mounted
submounts/subdirectories of "/dev" like "its" and "shm". Try
umount-ing "/dev" with "-l" or umount-ing all three.


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/CAOdo=Sx+nR4NeonXPHzEnVrZ4Pn...@mail.gmail.com

Roger Leigh

unread,
Aug 22, 2012, 3:50:01 AM8/22/12
to
On Tue, Aug 21, 2012 at 06:46:35PM -0700, Ross Boylan wrote:
> I setup a chroot on a snapshot. Part of the setup was
> mount --rbind /dev /mnt/chrtest/dev
>
> 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?

All the answers have been good ones.

I just wanted to mention that if you want to do this regularly,
the schroot program can automatically snapshot your chroot with
LVM and mount the /dev (and other) filesystems. It then
subsequently umounts the filesystems and deletes the snapshot.


Regards,
Roger

--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20120822074...@codelibre.net

Tom H

unread,
Aug 22, 2012, 3:50:02 AM8/22/12
to
On Tue, Aug 21, 2012 at 10:21 PM, Bob Proulx <b...@proulx.com> 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.

The advantage of using "rbind" is that you don't have to mount
"/dev/pts" and "/dev/shm" (or just "/dev/pts" on wheezy since
"/dev/shm" has been moved to "/run/shm") after mounting "/dev".


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/CAOdo=SzbMpFoUpGF=9feXVmzAbbP00dC9...@mail.gmail.com

Ross Boylan

unread,
Aug 22, 2012, 4:10:01 AM8/22/12
to
On Wed, 2012-08-22 at 08:40 +0100, Roger Leigh wrote:
> On Tue, Aug 21, 2012 at 06:46:35PM -0700, Ross Boylan wrote:
> > I setup a chroot on a snapshot. Part of the setup was
> > mount --rbind /dev /mnt/chrtest/dev
> >
> > 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?
>
> All the answers have been good ones.
>
> I just wanted to mention that if you want to do this regularly,
> the schroot program can automatically snapshot your chroot with
> LVM and mount the /dev (and other) filesystems. It then
> subsequently umounts the filesystems and deletes the snapshot.
>
That sounds a lot like what I'm trying to do, including the snapshot.
Does schroot do any special tricks to umount dev?

Ross



--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/1345622422.9...@corn.betterworld.us

Roger Leigh

unread,
Aug 22, 2012, 4:50:02 AM8/22/12
to
On Wed, Aug 22, 2012 at 01:00:22AM -0700, Ross Boylan wrote:
> On Wed, 2012-08-22 at 08:40 +0100, Roger Leigh wrote:
> > On Tue, Aug 21, 2012 at 06:46:35PM -0700, Ross Boylan wrote:
> > > I setup a chroot on a snapshot. Part of the setup was
> > > mount --rbind /dev /mnt/chrtest/dev
> > >
> > > 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?
> >
> > All the answers have been good ones.
> >
> > I just wanted to mention that if you want to do this regularly,
> > the schroot program can automatically snapshot your chroot with
> > LVM and mount the /dev (and other) filesystems. It then
> > subsequently umounts the filesystems and deletes the snapshot.
> >
> That sounds a lot like what I'm trying to do, including the snapshot.
> Does schroot do any special tricks to umount dev?

No. It just recursively umounts every filesystem in the chroot,
depth-first. For mounting, it just uses a regular fstab, so you
can mount whatever you like. The only difference is that the
mountpoint has the chroot path prefixed to it, so you can mount
filesystems outside the chroot (like /home) inside it.


Regards,
Roger

--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20120822084...@codelibre.net

Roger Leigh

unread,
Aug 22, 2012, 5:00:02 AM8/22/12
to
On Wed, Aug 22, 2012 at 03:41:50AM -0400, Tom H wrote:
> On Tue, Aug 21, 2012 at 10:21 PM, Bob Proulx <b...@proulx.com> 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.
>
> The advantage of using "rbind" is that you don't have to mount
> "/dev/pts" and "/dev/shm" (or just "/dev/pts" on wheezy since
> "/dev/shm" has been moved to "/run/shm") after mounting "/dev".

This approach is really nice, and schroot used to do this. There's
just one niggle:

If you use systemd, it will kill your system because autofs mounts
under /dev created by systemd can't be bind mounted; well, they can,
they are just broken and umountable, and all the processes in your
system will slowly enter D state!


Roger

--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20120822085...@codelibre.net

T o n g

unread,
Aug 27, 2012, 11:20:01 PM8/27/12
to
On Wed, 22 Aug 2012 09:54:09 +0100, Roger Leigh wrote:

>> > Why did you choose "rbind" over "bind". Just curious.
>>
>> The advantage of using "rbind" is that you don't have to mount
>> "/dev/pts" and "/dev/shm" (or just "/dev/pts" on wheezy since
>> "/dev/shm" has been moved to "/run/shm") after mounting "/dev".
>
> This approach is really nice, and schroot used to do this. There's just
> one niggle:
>
> If you use systemd, it will kill your system because autofs mounts under
> /dev created by systemd can't be bind mounted; well, they can, they are
> just broken and umountable, and all the processes in your system will
> slowly enter D state!

Interesting. What is systemd? (apt-cache search systemd shows me nothing)

How can I tell if I'm using systemd or not?

I ask because till now, I always use rbind for /dev under chroot, because
of the above advantage.

--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/k1hd03$nfv$3...@ger.gmane.org

Bob Proulx

unread,
Aug 28, 2012, 1:40:03 AM8/28/12
to
T o n g wrote:
> Interesting. What is systemd? (apt-cache search systemd shows me nothing)

'systemd' is an alternative 'sysvinit' system.

> How can I tell if I'm using systemd or not?

If you don't know then you are not using it. You are using sysvinit
if you haven't manually taken action to change from it.

dpkg -l sysvinit

Bob
signature.asc
0 new messages