Changeset 510 for branches/stable


Ignore:
Timestamp:
Apr 30, 2006, 1:42:26 PM (14 years ago)
Author:
bcornec
Message:

Patch to fix problems with stupid systems using a LABEL for swap partitions
(Many thanks to Michel Loiseleur <mloiseleur_at_linagora.com> for tracking the bug and providing the patch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi/mindi

    r492 r510  
    13821382    [ "`echo "$c_p" | grep -x "/dev/cdroms.*"`" ] && continue
    13831383    if [ -h "$c_p" ] && [ "`echo "$c_p" | fgrep "/dev/hd"`" = "" ] && [ "`echo "$c_p" | fgrep "/dev/sd"`" = "" ] && [ "`echo "$c_p" | fgrep "/dev/md"`" = "" ] ; then
    1384             current_partition=`ResolveSoftlink $c_p`
     1384        current_partition=`ResolveSoftlink $c_p`
    13851385        [ "`echo "$current_partition" | fgrep "/dev/mapper"`" != "" ] && current_partition="$c_p"
    1386             [ "`echo "/dev/scd0 /dev/scd1 /dev/sr0 /dev/sr1 /dev/cdrom /dev/cdrom1" | fgrep "$current_partition"`" ] && continue
     1386        [ "`echo "/dev/scd0 /dev/scd1 /dev/sr0 /dev/sr1 /dev/cdrom /dev/cdrom1" | fgrep "$current_partition"`" ] && continue
    13871387    else
    13881388        current_partition="$c_p"
    13891389    fi
    13901390    [ "$c_p" = "none" ] && continue
    1391         absolute_partition=`ResolveSoftlink $c_p`
     1391    absolute_partition=`ResolveSoftlink $c_p`
    13921392    partition_mountpt=`tr -s '\t' ' ' < $MY_FSTAB | grep -w "$current_partition" | grep -vx " *#.*" | $AWK '{print $2}' | head -n1`
     1393
     1394    # This part tries to retrieve the correct device from a LABEL line in /etc/fstab
     1395    # current_partition contains only first column of /etc/fstab
    13931396    redhat_label=""
    1394     if [ "`echo "$current_partition" | fgrep -i "LABEL=SWAP"`" != "" ] ; then
    1395             redhat_label=`echo "$current_partition" | cut -d'=' -f2`
    1396             actual_dev="/dev/`echo "$redhat_label" | cut -d '-' -f2`"
    1397             current_partition=$actual_dev
    1398     elif [ "`echo "$current_partition" | fgrep -i "LABEL="`" != "" ] ; then
     1397    if [ "`echo "$current_partition" | /bin/grep -f -i "LABEL="`" != "" ] ; then
    13991398        str_to_find_fmt_with=$current_partition
    1400         redhat_label=`echo "$current_partition" | cut -d'=' -f2`
    1401         actual_dev=`mount -l | fgrep " [$redhat_label]" | cut -d' ' -f1`
    1402 #       partition_mountpt=$redhat_label
    1403         current_partition=$actual_dev
     1399        redhat_label=`echo "$current_partition" | /bin/cut -d'=' -f2`
     1400        actual_dev=""
     1401
     1402        # 1st try : blkid, the good way
     1403        if [ -x "/sbin/blkid" ] ; then
     1404            actual_dev=`/sbin/blkid | grep "$current_partition" | /bin/cut -d':' -f1`
     1405        fi
     1406        # 2nd try, which works on a standard partition (ext2/3), but not on swap
     1407        if [ $actual_dev="" ] ; then
     1408            actual_dev=`/bin/mount -l | /bin/grep " [$redhat_label]" | /bin/cut -d' ' -f1`
     1409        fi
     1410        # 3rd try, with vol_id (which works with swap)
     1411        if [ $actual_dev="" -a -x "/sbin/vol_id" ] ; then
     1412                list_swaps=`cat /proc/swaps | /bin/grep "/dev/" | /bin/awk '{ print $1 }' `
     1413                for dev_swap in $list_swaps ; do
     1414                    dev_exists=`/sbin/vol_id $dev_swap | /bin/grep -f "$redhat_label"`
     1415                    if [ -n "$dev_exists" ] ; then
     1416                        actual_dev=$dev_swap
     1417                        break;
     1418                    fi
     1419                done
     1420        fi
     1421        # 4th try : pre-formated LABEL. Format is : LABEL=SWAP-mydevice. e.g. : LABEL=SWAP-hda5
     1422        if [ $actual_dev="" -a  "`echo "$current_partition" | /bin/grep -f -i "LABEL=SWAP"`" != ""] ; then
     1423                actual_dev="/dev/`echo "$redhat_label" | /bin/cut -d '-' -f2`"
     1424        fi
     1425        # Check if one of all those tries has known success
     1426        if [  $actual_dev != "" ] ; then
     1427                current_partition=$actual_dev
     1428        else
     1429            Die "Your system uses a labelled swap partition, but you lack the tool to su
     1430pport it.\nPlease replace swap labels with their correct devices in /etc/fstab\n"
     1431        fi
    14041432    else
    14051433        str_to_find_fmt_with=$current_partition
    14061434    fi
     1435
    14071436    partition_format=`$AWK '$1 == "'"$str_to_find_fmt_with"'" {print $3}' $MY_FSTAB`
    14081437    if [ -d "/proc/lvm" ] && [ "`lvdisplay $current_partition 2> /dev/null`" ] ; then
Note: See TracChangeset for help on using the changeset viewer.