From a4d2682238cd2e2d70d06640e9fa80f44c13c16d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 3 Nov 2011 02:15:33 +0000 Subject: [PATCH] * Remove loopback devices during shutdown, since they may prevent filesystems from being unmounted. svn path=/nixos/trunk/; revision=30203 --- modules/system/upstart-events/shutdown.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/system/upstart-events/shutdown.nix b/modules/system/upstart-events/shutdown.nix index cf06ba10d08b..32966f03cdba 100644 --- a/modules/system/upstart-events/shutdown.nix +++ b/modules/system/upstart-events/shutdown.nix @@ -88,6 +88,13 @@ with pkgs.lib; tryAgain= failed= # list of mount points that couldn't be unmounted/remounted + # Get rid of loopback devices. + loDevices=$(losetup -a | sed 's#^\(/dev/loop[0-9]\+\).*#\1#') + if [ -n "$loDevices" ]; then + echo "removing loopback devices $loDevices..." + losetup -d $loDevices + fi + cp /proc/mounts /dev/.mounts # don't read /proc/mounts while it's changing exec 4< /dev/.mounts while read -u 4 device mp fstype options rest; do