Can't exit chroot properly

112 views
Skip to first unread message

Anton Vayvod

unread,
Apr 7, 2010, 9:08:08 AM4/7/10
to Chromium OS dev
Hi.

I synced and replaced chroot with make_chroot --replace. Then I set up x86-generic board, built packages, built chromium, unmasked login manager 9999, built packages again and built image.
When I exit from chroot I get the following output:

Unmounting chroot environment.
[sudo] password for avayvod:
umount: /usr/local/home/avayvod/chromeos/chromeos/chroot/home/avayvod/trunk: device is busy
umount: /usr/local/home/avayvod/chromeos/chromeos/chroot/home/avayvod/trunk: device is busy
ERROR  : Failed to umount /usr/local/home/avayvod/chromeos/chromeos/chroot/home/avayvod/trunk
ERROR  : teardown_env failed

Looking up who's using the dir gave me the following:

avayvod@avayvod-z600:~/chromeos/src/scripts$ fuser -m /usr/local/home/avayvod/chromeos/chromeos/chroot/home/avayvod/trunk
/usr/local/home/avayvod/chromeos/chromeos/chroot/home/avayvod/trunk: 11113 11151 11228c 11490c 11519c

This pids belong to ssl-agent, loas and bash. Reboot surely helps for one time.
This usually didn't happen.

If anyone could give me a clue what is happening, I'd appreciate that?

Thanks,
Anton.

Chris Sosa

unread,
Apr 7, 2010, 12:11:47 PM4/7/10
to ava...@chromium.org, Chromium OS dev
As another data point, I've seen this too recently. It may be
stateful partition or gpt-related.

> --
> Chromium OS Developers mailing list: chromiu...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-os-dev?hl=en
>

Bill Richardson

unread,
Apr 7, 2010, 1:29:34 PM4/7/10
to Chris Sosa, ava...@chromium.org, Chromium OS dev
Same here. I've seen it as well, and it's really annoying. There were some changes to enter_chroot made around the same time that the GPT stuff went in, so I'm not sure who's at fault. Or it could be something completely unrelated. :-(

Antoine Labour

unread,
Apr 7, 2010, 1:38:18 PM4/7/10
to chromiu...@chromium.org
On Wed, Apr 7, 2010 at 6:08 AM, Anton Vayvod <ava...@chromium.org> wrote:
I don't know why it would happen, but to avoid rebooting, you can lazy unmount using 'umount -l'. it'll succeed even if the partition is busy.

Antoine

Bill Richardson

unread,
Apr 7, 2010, 7:38:24 PM4/7/10
to Antoine Labour, chromiu...@chromium.org
I may have found the issue here. Inside the chroot, we have /etc/mtab as a symlink to /proc/mounts. In build_image, I use "mount -o loop ...". That doesn't unmount cleanly. I'm testing now...

Bill Richardson

unread,
Apr 9, 2010, 11:18:36 AM4/9/10
to Ken Mixter, Antoine Labour, chromiu...@chromium.org
Just committed. I tried yesterday, but the tree was closed.

To clean up any leftover loop devices, run "sudo losetup -a", then "sudo losetup -d /dev/loopN" for any that aren't really being used (check your mounts carefully to be sure you don't zap one that's valid). Once you sync, the problem shouldn't come back.

Just be sure that you never use "mount -o loop" from within the chroot. See the commit message at 


On Fri, Apr 9, 2010 at 12:55 AM, Ken Mixter <kmi...@google.com> wrote:
Any resolution?

ko...@codeaurora.org

unread,
Apr 9, 2010, 11:29:26 AM4/9/10
to Bill Richardson, Ken Mixter, Antoine Labour, chromiu...@chromium.org
> Just be sure that you never use "mount -o loop" from within the chroot.

What would be the right mount option if we do want to mount the already
built image to something like /mnt/rootfs and throw into that image some
stuff?

Thx,
Kobi

Antoine Labour

unread,
Apr 9, 2010, 11:35:29 AM4/9/10
to ko...@codeaurora.org, Bill Richardson, Ken Mixter, chromiu...@chromium.org
Does mount -n work ?

Antoine

ko...@codeaurora.org

unread,
Apr 9, 2010, 11:55:14 AM4/9/10
to Antoine Labour, Bill Richardson, Ken Mixter, chromiu...@chromium.org
> On Fri, Apr 9, 2010 at 8:29 AM, <ko...@codeaurora.org> wrote:
>
>> > Just be sure that you never use "mount -o loop" from within the
>> chroot.
>>
>> What would be the right mount option if we do want to mount the already
>> built image to something like /mnt/rootfs and throw into that image some
>> stuff?
>>
> Does mount -n work ?

I c. -n would just avoid updating mtab, but I still need to "-n -o loop" it.

Bill - was that your intention?

kobi

Bill Richardson

unread,
Apr 9, 2010, 12:31:42 PM4/9/10
to Antoine Labour, ko...@codeaurora.org, Ken Mixter, chromiu...@chromium.org
No, mount -n doesn't work either.

Here's how I'd like to mount/unmount the rootfs from the image:

  sudo mount -o loop,offset=$((1512880 * 512)) chromiumos_image.bin /mnt

and

  sudo umount /mnt

But doing it this way leaves a loop device still active.

Here's how I have to do it, so that I can keep track of the loop devices and clean them up afterwards:

  dev=$(sudo losetup -f)
  sudo losetup -o $((1512880 * 512)) $dev chromiumos_image.bin
  sudo mount $dev /mnt

and

  sudo umount /mnt
  sudo losetup -d $dev



BTW, 1512880 is the start of partition 3, which I found by looking in pack_partitions.sh.

Chris Sosa

unread,
Apr 9, 2010, 12:43:34 PM4/9/10
to Bill Richardson, Antoine Labour, ko...@codeaurora.org, Ken Mixter, chromiu...@chromium.org
I was just playing around in my chroot, and it seems if you pass the
'-d' flag to umount it will also clean up the loop device. Does that
work for anyone else?

Bill Richardson

unread,
Apr 9, 2010, 12:49:01 PM4/9/10
to Chris Sosa, Antoine Labour, ko...@codeaurora.org, Ken Mixter, chromiu...@chromium.org
D'oh!

Yeah, that should work. 

I wish I'd bothered to RTFM before doing all this work. 

/grumble...

Bill Richardson

unread,
Apr 9, 2010, 12:55:59 PM4/9/10
to Chris Sosa, Antoine Labour, ko...@codeaurora.org, Ken Mixter, chromiu...@chromium.org
So, yes, you can still use "mount -o loop" in the chroot. Just use "umount -d" with it.

I feel stupid.

Of course, no one else pointed this out before Chris... ;-)
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages