linaro-media-create doesn't detach loop devices when it's done

Bug #616385 reported by Peter Maydell
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro Image Tools
Fix Released
Undecided
Unassigned
linaro-image-tools (Ubuntu)
Fix Released
Undecided
Unassigned
Maverick
Fix Released
Undecided
Unassigned
Natty
Fix Released
Undecided
Unassigned

Bug Description

If you use the linaro-media-create script's --image_file option to create the image to a file, the script uses losetup -f to set up two loopback mounts into the image file. However, it never cleans them up again, so they hang around indefinitely:

cam-vm-266:linaro-image-tools$ sudo losetup -a
/dev/loop0: [0801]:18049630 (/tmp/linaro-alpha3-2.bin), offset 32256, sizelimit 73995264
/dev/loop1: [0801]:18049630 (/tmp/linaro-alpha3-2.bin), offset 74027520, sizelimit 4219568128
/dev/loop2: [0801]:18049627 (/tmp/beagle_plus_kern.img), offset 32256, sizelimit 73995264
/dev/loop3: [0801]:18049627 (/tmp/beagle_plus_kern.img), offset 74027520, sizelimit 4219568128
/dev/loop4: [0801]:18049641 (/tmp/beagle_new_kern.img), offset 32256, sizelimit 73995264
/dev/loop5: [0801]:18049641 (/tmp/beagle_new_kern.img), offset 74027520, sizelimit 4219568128
/dev/loop6: [0801]:18049641 (/tmp/beagle_new_kern.img), offset 32256, sizelimit 73995264
/dev/loop7: [0801]:18049641 (/tmp/beagle_new_kern.img), offset 74027520, sizelimit 4219568128

and eventually if you run linaro-media-create often enough it will fail with "losetup: could not find any free loop device" because it's used them all up.

I think "losetup -d "$MMC1" $MMC2" somewhere suitable would fix this.

Revision history for this message
Peter Maydell (pmaydell) wrote :

I'm attaching a patch which fixes this by making the script detach the loopback devices if it is using them.

Revision history for this message
Peter Maydell (pmaydell) wrote :

Whoops, that was a slightly stale version of the patch. This one's better...

tags: added: linaro patch
Steve Langasek (vorlon)
Changed in linaro-image-tools (Ubuntu Maverick):
status: New → Fix Committed
Changed in linaro-image-tools (Ubuntu Natty):
status: New → Fix Committed
Changed in linaro-image-tools:
status: New → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted linaro-image-tools into maverick-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

tags: added: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package linaro-image-tools - 0.3

---------------
linaro-image-tools (0.3) maverick-proposed; urgency=low

  [ Steve Langasek ]
  * no longer using the 'omap' uboot flavor support in live-helper; instead,
    run the mkimage commands directly for omap.
  * fix the paths used for looking up x-loader and u-boot binaries in the
    tarball; these don't belong in /boot at all, pull them from /usr/lib.
  * only enforce the presence of commands we're actually using; this lets
    us automatically pull in btrfs-tools when btrfs is specified.
  * add sudo to a couple more commands in linaro-media-create, so the script
    itself can run as non-root as intended.

  [ James Westby ]
  * Add a linaro-hwpack-create script for the creation of hardware packs.

  [ Steve Langasek ]
  * Fix lookup of linaro-hwpack-install to work correctly when l-m-c is on
    the path. Closes: #652669.

  [ Loïc Minier ]
  * Drop spurious single quote character in boot_args_options for beagle|igep;
    thanks Peter Maydell; LP: #667400.
  * Set LC_ALL=C when entering the chroot as it has no locales. LP: #651905.

  [ Tom Gall ]
  * Use --numeric-owner argument to tar when unpacking, so that files get
    the right owner on boot of the image. LP: #652121.

  [ Dave Martin ]
  * Implement proper cleanup handling on signal / exit, so that we don't
    leave clutter behind on error. This also fixes the message at the end of
    a successful install about being unable to unmount proc. LP: #616385,
    #660196, #667394, #643601, #627383.
 -- Steve Langasek <email address hidden> Tue, 09 Nov 2010 12:50:26 -0800

Changed in linaro-image-tools (Ubuntu Maverick):
status: Fix Committed → Fix Released
Steve Langasek (vorlon)
Changed in linaro-image-tools (Ubuntu Maverick):
status: Fix Released → Fix Committed
Changed in linaro-image-tools (Ubuntu Natty):
status: Fix Committed → Fix Released
Changed in linaro-image-tools (Ubuntu Maverick):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.