WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Conflict with tcvd and rc.shutdown  (Read 2539 times)

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Conflict with tcvd and rc.shutdown
« on: January 05, 2010, 08:11:33 AM »
The /etc/init.d/rc.shutdown has the line:
for loop in $(/bin/mount | awk '/\/dev\/loop/{print $1}'); do umount -d $loop 2>/dev/null; done

This will only process mounted loop devices and will not disassociate any unmounted loop devices. If the tcvd= boot parameter is used (without any others), a loop device is created but not mounted. This causes an "unable to remount" error during shutdown. If a tce= boot parameter is used and it refers to extensions within the tcvd image, then they are mounted after the tcvd loop. This means the loop device is in use by mounted extensions during shutdown and the "unable to remount" error still occurs.

This has been a problem for a while, and I finally got a chance to diagnose the error and investigate solutions. I am bringing this up with the hope it can be addressed for 2.8. Because losetup no longer has the "-a" switch, it cannot be used to create a list of loop devices. I see two solutions which will ensure any unmounted loop devices are dissociated: 1) use a for loop to dissociate all loop devices from 255 to 0 after the unmount script, or 2) use a script similar to the following to dissociate only the necessary loop devices:
# unmount twice for extensions mounted inside loop-mounted image
for loop in $(/bin/mount | awk '/\/dev\/loop/{print $1}'); do umount -d $loop 2>/dev/null; done
for loop in $(/bin/mount | awk '/\/dev\/loop/{print $1}'); do umount -d $loop 2>/dev/null; done

# dissociate remaining devices
for loop in $(cut -d\) -f1 /proc/*/stat|cut -d\( -f2|grep ^loop); do losetup -d /dev/$loop 2>/dev/null; done

This uses the fact that /proc/PID/stat contains the name. There are other ways to get it.

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Conflict with tcvd and rc.shutdown
« Reply #1 on: January 07, 2010, 02:52:02 PM »
I can see the logic when tcvd is deployed and a reverse un-mounting is preferable.
I have done such and tested on a tcvd, will be in 2.8rc2 for further field testing.
10+ Years Contributing to Linux Open Source Projects.