Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 52926 - loop device removal fails in certain setups
Summary: loop device removal fails in certain setups
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-03 16:33 UTC by Marc Ballarin
Modified: 2006-10-05 00:01 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Revised fix (dm_deactivate.sh,485 bytes, text/plain)
2004-06-04 12:44 UTC, Marc Ballarin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Ballarin 2004-06-03 16:33:04 UTC
I am using a rather complicated, yet likely (if dm-crypt becomes more widely used) setup.
/home is on a lvm2-volume (/dev/mapper/vgbase-home)
Inside this volume is a file which is attached to a loop device (/dev/loop7).
However, instead of directly mounting this file, I am accesing it through dm-crypt (/dev/mapper/crypt-home).

Since it isn't directly mounted, the loop-device handling in halt.sh fails to detect and detach this loop-device. As a consequence, /home can not be unmounted and vgbase-home and crypt-home cannot be deactivated.

Following is a fix I was able to create. It needs to be placed in halt.sh before regular unmounting.

# get a list of all dm-mappings on top of loop devices. Based on
# the  assumption that loop devices always use major number 7.
# umount filesystem, remove mapping and loop device
if [ -f "/sbin/dmsetup" ]
then
        for i in `/sbin/dmsetup deps | grep \(7\, | awk '{ print $1}'| sed s/\:/\/`
        do
		# get minor number of loop device
                LN=`/sbin/dmsetup deps $i | awk '{ print $5}' | sed s/\)/\/`
                umount /dev/mapper/${i}
                /sbin/dmsetup remove ${i}
                /sbin/losetup -d /dev/loop${LN}
                unset LN
        done
fi


Reproducible: Always
Steps to Reproduce:
1. Create a loop based device-mapping inside another device-mapping (encrpted or not should not matter)
2. mount it
3. shutdown or reboot
Actual Results:  
base device /home fails to umount, mapping and loop device are not detached
Comment 1 Marc Ballarin 2004-06-04 12:44:07 UTC
Created attachment 32655 [details]
Revised fix

This version avoids potentially dangerous sed replacements.
It still lacks a proper check to find out if actually mounted, but uses a hack
to prevent error.
Comment 2 Bruno 2005-04-30 01:33:31 UTC
For simple loop mounts (eg squashfs) mounted correctly by bootscripts, but with binds on them, the stopscript "forgets" to first unmount the binds before wanting to unmount the loop filesystem. Because of this it always says, it can't unmount the loop filesystems.

Here the relevant part of /etc/fstab
...
/home/squashfs.sqfs /mnt/myloopfs            squashfs loop 0 0
/mnt/otherfs        /mnt/myloopfs/somefolder bind     bind 0 0
...

My baselayout version: sys-apps/baselayout-1.9.4-r6
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2006-10-05 00:01:47 UTC
marc is this still a problem? please reopen if so.