summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-08-16 11:52:07 +0200
committerHarald Hoyer <harald@redhat.com>2013-08-16 11:52:07 +0200
commit324ea606da753d38408698518bfe6be1ff23750c (patch)
tree705daf7769fef92fa3f9cc46f1cbbfca502b72ed
parentdf478eee753770bde7d5393be62bc17e6bde5f77 (diff)
downloaddracut-324ea606da753d38408698518bfe6be1ff23750c.tar.gz
dracut-324ea606da753d38408698518bfe6be1ff23750c.tar.bz2
dracut-324ea606da753d38408698518bfe6be1ff23750c.zip
dracut.sh: add --persistent-policy option
--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"
-rw-r--r--dracut-bash-completion.sh5
-rwxr-xr-xdracut-functions.sh27
-rw-r--r--dracut.8.asc5
-rwxr-xr-xdracut.sh9
-rwxr-xr-xmodules.d/95rootfs-block/module-setup.sh6
5 files changed, 46 insertions, 6 deletions
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 <mountpoint>
# 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** _<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_ 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
}