Package: os-prober Version: 1.14 Severity: wishlist linux-boot-prober unmounts mounted partitions unnecessarily when run with the '-mounted' parameter. I'd already spoken to someone on the d-i list(i can't find that thread now), and was asked to submit the patch through the BTS. I've attached the patch to 50mounted-tests. I've tested the patch and it works well on my system.
Thank You -- The Abattoir
--- 50mounted-tests.new 2007-02-04 21:06:31.000000000 +0800 +++ 50mounted-tests.orig 2006-12-19 21:35:56.000000000 +0800 @@ -19,73 +19,67 @@ done } -rootmounted="" +tmpmnt=/var/lib/os-prober/mount +if [ ! -d $tmpmnt ]; then + mkdir $tmpmnt +fi -# If DO_MOUNTED is set, process already mounted partitions from their current mountpoint -mnt=$(mount |grep "$partition "|cut -d' ' -f 3) -if [ -n "$DO_MOUNTED" ] && [ -n "$mnt" ]; then - rootmounted=1 -elif [ ! -n "$DO_MOUNTED" ]; then - mnt=/var/lib/os-prober/mount - if [ ! -d $mnt ]; then - mkdir $mnt - fi +# If DO_MOUNTED is set, also process already mounted partitions by temporarily +# unmounting them. +oldmnt=$(mount |grep "$partition "|cut -d' ' -f 3) +if [ -n "$DO_MOUNTED" ] && [ -n "$oldmnt" ]; then + oldopts=$(mount |grep "$partition "|sed 's/.*(\(.*\)).*/\1/') + umount $partition fi for type in $(grep -v nodev /proc/filesystems); do - if [ ! -n "$DO_MOUNTED" ]; then - if mount -o ro -t $type $partition $mnt 2>/dev/null; then - rootmounted=1 - else - error "failed to mount $partition" - fi - fi - if [ "$rootmounted" ]; then + if mount -o ro -t $type $partition $tmpmnt 2>/dev/null; then bootpart="" - if [ -e "$mnt/etc/fstab" ]; then + if [ -e "$tmpmnt/etc/fstab" ]; then # Try to mount any /boot partition. - bootmnt=$(parsefstab < $mnt/etc/fstab | grep " /boot ") || true + bootmnt=$(parsefstab < $tmpmnt/etc/fstab | grep " /boot ") || true if [ -n "$bootmnt" ]; then set -- $bootmnt boottomnt="" - bootmounted="" + mounted="" if [ -e "$1" ]; then bootpart="$1" boottomnt="$1" - elif [ -e "$mnt/$1" ]; then + elif [ -e "$tmpmnt/$1" ]; then bootpart="$1" - boottomnt="$mnt/$1" + boottomnt="$tmpmnt/$1" elif [ -e "/target/$1" ]; then bootpart="$1" boottomnt="/target/$1" elif echo "$1" | grep -q "LABEL="; then debug "mounting boot partition by label for linux system on $partition: $1" label=$(echo "$1" | cut -d = -f 2) - if /target/bin/mount -L "$label" -o ro $mnt/boot -t "$3"; then - bootmounted=1 - bootpart=$(mount | grep $mnt/boot | cut -d " " -f 1) + if /target/bin/mount -L "$label" -o ro $tmpmnt/boot -t "$3"; then + mounted=1 + bootpart=$(mount | grep $tmpmnt/boot | cut -d " " -f 1) else error "failed to mount by label" fi elif echo "$1" | grep -q "UUID="; then debug "mounting boot partition by UUID for linux system on $partition: $1" uuid=$(echo "$1" | cut -d = -f 2) - if /target/bin/mount -U "$uuid" -o ro $mnt/boot -t "$3"; then - bootmounted=1 - bootpart=$(mount | grep $mnt/boot | cut -d " " -f 1) + if /target/bin/mount -U "$uuid" -o ro $tmpmnt/boot -t "$3"; then + mounted=1 + bootpart=$(mount | grep $tmpmnt/boot | cut -d " " -f 1) else error "failed to mount by UUID" fi else bootpart="" fi - if [ ! "$bootmounted" ]; then + + if [ ! "$mounted" ]; then if [ -z "$bootpart" ]; then debug "found boot partition $1 for linux system on $partition, but cannot map to existing device" else debug "found boot partition $bootpart for linux system on $partition" - if ! mount -o ro "$boottomnt" $mnt/boot -t "$3"; then - error "failed to mount $boottomnt on $mnt/boot" + if ! mount -o ro "$boottomnt" $tmpmnt/boot -t "$3"; then + error "failed to mount $boottomnt on $tmpmnt/boot" fi fi fi @@ -94,31 +88,34 @@ if [ -z "$bootpart" ]; then bootpart="$partition" fi + for test in /usr/lib/linux-boot-probes/mounted/*; do if [ -f $test ] && [ -x $test ]; then - debug "running $test $partition $bootpart $mnt $type" - if $test $partition $bootpart $mnt $type; then + debug "running $test $partition $bootpart $tmpmnt $type" + if $test $partition $bootpart $tmpmnt $type; then debug "$test succeeded" - umount $mnt/boot 2>/dev/null || true - #umount $mnt - if [ ! -n "$DO_MOUNTED" ]; then - umount $mnt - rmdir $mnt + umount $tmpmnt/boot 2>/dev/null || true + umount $tmpmnt + if [ -n "$DO_MOUNTED" ] && [ -n "$oldmnt" ]; then + mount $partition $oldmnt -o $oldopts fi + rmdir $tmpmnt || true exit 0 fi fi done - - umount $mnt/boot 2>/dev/null || true - #umount $mnt - if [ ! -n "$DO_MOUNTED" ]; then - umount $mnt - rmdir $mnt || true + + umount $tmpmnt/boot 2>/dev/null || true + umount $tmpmnt + if [ -n "$DO_MOUNTED" ] && [ -n "$oldmnt" ]; then + mount $partition $oldmnt -o $oldopts fi + break fi done +rmdir $tmpmnt || true + # No tests found anything. -exit 1 \ No newline at end of file +exit 1

