diff --git a/operation/configure_bootloader_cnf.sh b/operation/configure_bootloader_cnf.sh index 57de7e5..4c30d42 100755 --- a/operation/configure_bootloader_cnf.sh +++ b/operation/configure_bootloader_cnf.sh @@ -106,7 +106,7 @@ EOF if [[ "$devname" =~ ^md[0-9]*$ ]];then root_dev="$ROOT_PARTITION" else - by_uuid=$(get_disk_sym $devname "by-uuid") + by_uuid=$(get_disk_sym $ROOT_PARTITION "by-uuid") if [ -n "$by_uuid" ];then root_dev="UUID=$(echo $by_uuid|sed 's/.*\///')" else diff --git a/operation/configure_fstab.sh b/operation/configure_fstab.sh index 051ba79..b3ae686 100755 --- a/operation/configure_fstab.sh +++ b/operation/configure_fstab.sh @@ -48,7 +48,7 @@ configure_fstab () local fs_mntops="$4" local fs_freq="$5" local fs_passno="$6" - # store uuid of by-id + # store uuid or by-id local devname="" @@ -58,16 +58,15 @@ configure_fstab () # if partition not exist, or couldn't get partition information # set $devname as default - partition=$(echo $device|sed 's/.*\///') if [ "$mountpoint" == "swap" -a "$fs_type" == "swap" ];then - by_id=$(get_disk_sym $partition "by-id") + by_id=$(get_disk_sym $device "by-id") if [ -n "$by_id" ];then devname="/dev/$by_id" else devname="$device" fi else - by_uuid=$(get_disk_sym $partition "by-uuid") + by_uuid=$(get_disk_sym $device "by-uuid") if [ -n "$by_uuid" ];then devname="UUID=$(echo $by_uuid|sed 's/.*\///')" else diff --git a/operation/functions b/operation/functions index f008532..6ac755b 100644 --- a/operation/functions +++ b/operation/functions @@ -116,7 +116,7 @@ update_udev() # # get device uuid/by-id/by-path info # if not found return NULL -# ex: get_disk_sym sda1 by-uuid +# ex: get_disk_sym /dev/sda1 by-uuid # get_disk_sym () { @@ -129,17 +129,14 @@ get_disk_sym () local type="$2" local devname="" - # we find partition in /sys/block/, - # "*" in oder to c0d0p1 match cciss!c0d0p1 - local path=$(find /sys/block/ -maxdepth 2 -name *$partition) + local path=$(udevadm info -q path -n $partition) + # if not update udev, uuid or by-id may use old one. + update_udev # scsci's by-id may be have multi-links, we get first link - if [ -n "$path" -a -d "$path" ];then - # update hard disk informations. - # if not update udev, uuid or by-id may use old one. - update_udev - devname=$(udevinfo -q symlink -p $path|tr " " "\n"|grep "$type"|head -n 1) - fi + # update hard disk informations. + devname=$(udevinfo -q symlink -p $path|tr " " "\n"|grep "$type"|head -n 1) + echo "$devname" }