From 4aa6efead74dd3b91bcd507f3e990d975d0bce9d Mon Sep 17 00:00:00 2001 From: Tomas M Date: Fri, 12 Oct 2012 20:18:54 -0500 Subject: [PATCH] free attached loop devices --- initramfs/cleanup | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/initramfs/cleanup b/initramfs/cleanup index 858196c..148dccd 100644 --- a/initramfs/cleanup +++ b/initramfs/cleanup @@ -64,6 +64,10 @@ if [ "$1" = "--init" ]; then setsid sh -c 'exec sh < /dev/tty1 >/dev/tty1 2>&1' fi + # make sure to detach loop devices which can be detached at this moment, + # else they would block unmounting later. + losetup | cut -d : -f 1 | xargs -n 1 losetup -d + # next, unmount everything from union, backwards tac /proc/mounts | grep union | cut -d " " -f 2 | while read LINE; do umount $LINE >/dev/console 2>&1