diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2010-03-24 16:25:19 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2010-03-24 16:25:19 +0100 |
commit | 0e60088d33ae1fc2552fc904dc3ecb0072dc3c0a (patch) | |
tree | 7c6d1c180b796d39d4d5383901aafe49a1fd0db7 /src/core/libs | |
parent | 9525c62d5f6fc9e23f7571b26d6b1deaec685789 (diff) | |
parent | b2b3b8592d2cec202af80b19fa81fd948e2c191d (diff) |
Merge remote branch 'aif-new/label'
Diffstat (limited to 'src/core/libs')
-rw-r--r-- | src/core/libs/lib-blockdevices-filesystems.sh | 35 | ||||
-rw-r--r-- | src/core/libs/lib-ui-interactive.sh | 26 |
2 files changed, 48 insertions, 13 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 8346385..be4c270 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -183,6 +183,17 @@ getuuid() } +# parameters: device file +# outputs: LABEL on success +# nothing on failure +# returns: nothing +getlabel() +{ + [ -z "$1" ] && die_error "getlabel needs an argument" + [ "${1%%/[hs]d?[0-9]}" != "${1}" ] && echo "$(blkid -s LABEL -o value ${1})" +} + + # taken from setup script, slightly optimized and modified for separator control # $1 set to 1 to echo a newline after partition instead of a space (optional) # $2 extra things to echo for each partition (optional) @@ -757,15 +768,23 @@ process_filesystem () # Add to temp fstab, if not already there. if [ -n "$fs_mountpoint" -a "$fs_mount" = target ] then - local _uuid="$(getuuid $part)" - if [ -n "${_uuid}" ]; then - _device="UUID=${_uuid}" - else - _device=$part - fi - if ! grep -q "$_device $fs_mountpoint $fs_type defaults 0 " $TMP_FSTAB 2>/dev/null #$TMP_FSTAB may not exist yet + case "$PART_ACCESS" in + label) + local _label="$(getlabel $part)" + if [ -n "${_label}" ]; then + part="LABEL=${_label}" + fi + ;; + uuid) + local _uuid="$(getuuid $part)" + if [ -n "${_uuid}" ]; then + part="UUID=${_uuid}" + fi + ;; + esac + if ! grep -q "$part $fs_mountpoint $fs_type defaults 0 " $TMP_FSTAB 2>/dev/null #$TMP_FSTAB may not exist yet then - echo -n "$_device $fs_mountpoint $fs_type defaults 0 " >> $TMP_FSTAB + echo -n "$part $fs_mountpoint $fs_type defaults 0 " >> $TMP_FSTAB if [ "$fs_type" = "swap" ]; then echo "0" >>$TMP_FSTAB else diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 23e8c4e..4be0625 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -185,6 +185,12 @@ interactive_prepare_disks () NEXTITEM= DISK_CONFIG_TYPE= [ "$BLOCK_ROLLBACK_USELESS" = "0" ] && show_warning "Rollback may be needed" "It seems you already went here. You should probably rollback previous changes before reformatting, otherwise stuff will probably fail" + [ -z "$PART_ACCESS" ] && PART_ACCESS=dev + ask_option $PART_ACCESS 'Disk Access Method' 'How do you want your partitions to be accessed?' '' \ + "dev" "directly by /dev/sd??" \ + "label" "by Disk-Label" \ + "uuid" "by Universally Unique Identifier" || return 1 + PART_ACCESS=$ANSWER_OPTION while [ "$DONE" = "0" ] do rollbackstr=" (you don't need to do this)" @@ -1088,11 +1094,21 @@ generate_grub_menulst() { # remove default entries by truncating file at our little tag (#-*) sed -i -e '/#-\*/q' $grubmenu - # attempt to use a UUID if the root device has one - local _uuid="$(getuuid ${_rootpart})" - if [ -n "${_uuid}" ]; then - _rootpart="/dev/disk/by-uuid/${_uuid}" - fi + # find label or uuid of the root partition + case $PART_ACCESS in + label) + local _label="$(getlabel $_rootpart)" + if [ -n "${_label}" ]; then + _rootpart="/dev/disk/by-label/${_label}" + fi + ;; + uuid) + local _uuid="$(getuuid $_rootpart)" + if [ -n "${_uuid}" ]; then + _rootpart="/dev/disk/by-uuid/${_uuid}" + fi + ;; + esac # handle dmraid/mdadm,lvm,dm_crypt etc. replace entries where needed automatically kernel="kernel $subdir/vmlinuz26 root=${_rootpart} ro" |