Bug 45826

Summary: loopback devices are not detached at shutdown
Product: [Retired] Red Hat Linux Reporter: chris
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-06-25 15:53:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to detach loopback devices at shutdown none

Description chris 2001-06-25 15:48:02 UTC
At system shutdown, /etc/rc.d/init.d/halt unmounts any loopback devices
which are currently mounted, but it doesn't then detach those devices. 
This means that the filesystem on which the file resides which is being
loopback mounted cannot itself be unmounted.

It's easy to reproduce this by doing, for example:

  losetup /dev/loop1 /root/some/data/file
  mount /dev/loop1 /tmp/mountpoint
  /sbin/shutdown -r now

The loop device stays attached to /root/some/data/file.

Patch attached to fix this (though it's probably not the best way of doing
it).

Comment 1 chris 2001-06-25 15:53:18 UTC
Created attachment 21746 [details]
Patch to detach loopback devices at shutdown

Comment 2 Bill Nottingham 2001-08-07 06:58:00 UTC
Will be fixed in initscripts-6.12-1.

Comment 3 chris 2001-09-25 23:08:36 UTC
Thanks.  The code in the current rawhide initscripts-6.39-1 still doesn't quite
work correctly, though.  It's OK if the loopback devices are mounted, but it
doesn't work for attached but not mounted loopback devices.

My patch above does work in these circumstances.

Comment 4 Petko Alov 2002-07-25 09:40:24 UTC
The patch 21746 is not properly included in /etc/rc.d/init.d/halt from 
initscripts-5.84.1-1; because of typo in variable name in line 144 ($device 
instead of $dev) loopback devices can't be detached:

142:	for dev in $devremaining ; do
143:	losetup $dev > /dev/null 2>&1 && \
144:	runcmd $"Detaching loopback device $dev: " losetup -d $device
145:	done

should be:

142:	for dev in $devremaining ; do
143:	losetup $dev > /dev/null 2>&1 && \
144:	runcmd $"Detaching loopback device $dev: " losetup -d $dev
145:	done