From: Harald Hoyer Date: Fri, 16 Aug 2013 09:52:07 +0000 (+0200) Subject: dracut.sh: add --persistent-policy option X-Git-Tag: 032~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=324ea606da753d38408698518bfe6be1ff23750c;p=platform%2Fupstream%2Fdracut.git dracut.sh: add --persistent-policy option --persistent-policy : Use to address disks and partitions. can be any directory name found in /dev/disk. E.g. "by-uuid", "by-label" --- diff --git a/dracut-bash-completion.sh b/dracut-bash-completion.sh index 66b9bc9f..f822058d 100644 --- a/dracut-bash-completion.sh +++ b/dracut-bash-completion.sh @@ -40,7 +40,7 @@ _dracut() { --omit-drivers --modules --omit --drivers --filesystems --install --fwdir --libdirs --fscks --add-fstab --mount --device --nofscks --kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix - --kernel-cmdline --sshkey' + --kernel-cmdline --sshkey --persistent-policy' ) if __contains_word "$prev" ${OPTS[ARG]}; then @@ -56,6 +56,9 @@ _dracut() { -a|-m|-o|--add|--modules|--omit) comps=$(dracut --list-modules 2>/dev/null) ;; + --persistent-policy) + comps=$(cd /dev/disk/; echo *) + ;; --kver) comps=$(cd /lib/modules; echo [0-9]*) ;; diff --git a/dracut-functions.sh b/dracut-functions.sh index 1a73e603..68b0a56a 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -303,7 +303,16 @@ get_persistent_dev() { _dev=$(get_maj_min "$1") [ -z "$_dev" ] && return - for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do + for i in \ + /dev/mapper/* \ + /dev/disk/$persistent_policy/* \ + /dev/disk/by-uuid/* \ + /dev/disk/by-label/* \ + /dev/disk/by-partuuid/* \ + /dev/disk/by-partlabel/* \ + /dev/disk/by-id/* \ + /dev/disk/by-path/* \ + ; do [[ $i == /dev/mapper/control ]] && continue [[ $i == /dev/mapper/mpath* ]] && continue _tmp=$(get_maj_min "$i") @@ -314,6 +323,22 @@ get_persistent_dev() { done } +shorten_persistent_dev() { + local dev="$1" + case "$dev" in + /dev/disk/by-uuid/*) + printf "%s" "UUID=${dev##*/}";; + /dev/disk/by-label/*) + printf "%s" "LABEL=${dev##*/}";; + /dev/disk/by-partuuid/*) + printf "%s" "PARTUUID=${dev##*/}";; + /dev/disk/by-partlabel/*) + printf "%s" "PARTLABEL=${dev##*/}";; + *) + printf "%s" "$dev";; + esac +} + # find_block_device # Prints the major and minor number of the block device # for a given mountpoint. diff --git a/dracut.8.asc b/dracut.8.asc index 08af94ef..714ba858 100644 --- a/dracut.8.asc +++ b/dracut.8.asc @@ -325,6 +325,11 @@ provide a valid _/etc/fstab_. **-N, --no-hostonly**:: Disable Host-Only mode +**--persistent-policy** __:: + Use __ to address disks and partitions. + __ can be any directory name found in /dev/disk. + E.g. "by-uuid", "by-label" + **--fstab**:: Use _/etc/fstab_ instead of _/proc/self/mountinfo_. diff --git a/dracut.sh b/dracut.sh index d3e750bb..d0d1c118 100755 --- a/dracut.sh +++ b/dracut.sh @@ -132,8 +132,12 @@ Creates initial ramdisk images for preloading modules /usr/lib/dracut/modules.d. Useful when running dracut from a git checkout. -H, --hostonly Host-Only mode: Install only what is needed for - booting the local host instead of a generic host. + booting the local host instead of a generic host. -N, --no-hostonly Disables Host-Only mode + --persistent-policy [POLICY] + Use [POLICY] to address disks and partitions. + POLICY can be any directory name found in /dev/disk. + E.g. "by-uuid", "by-label" --fstab Use /etc/fstab to determine the root device. --add-fstab [FILE] Add file to the initramfs fstab --mount "[DEV] [MP] [FSTYPE] [FSOPTS]" @@ -328,6 +332,7 @@ TEMP=$(unset POSIXLY_CORRECT; getopt \ --long host-only \ --long no-hostonly \ --long no-host-only \ + --long persistent-policy: \ --long fstab \ --long help \ --long bzip2 \ @@ -408,6 +413,8 @@ while :; do hostonly_l="yes" ;; -N|--no-hostonly|--no-host-only) hostonly_l="no" ;; + --persistent-policy) + persistent_policy="$2"; shift;; --fstab) use_fstab_l="yes" ;; -h|--help) long_usage; exit 1 ;; -i|--include) push include_src "$2" diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh index 6792f1d3..6654b981 100755 --- a/modules.d/95rootfs-block/module-setup.sh +++ b/modules.d/95rootfs-block/module-setup.sh @@ -13,9 +13,9 @@ depends() { cmdline() { local dev=/dev/block/$(find_root_block_device) if [ -e $dev ]; then - printf " root=%s" $(get_persistent_dev "$dev") - printf " rootflags=%s" $(find_mp_fsopts /) - printf " rootfstype=%s" $(find_mp_fstype /) + printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$dev")")" + printf " rootflags=%s" "$(find_mp_fsopts /)" + printf " rootfstype=%s" "$(find_mp_fstype /)" fi }