mirror of
https://github.com/dracutdevs/dracut.git
synced 2024-10-26 16:25:20 +03:00
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"
This commit is contained in:
parent
df478eee75
commit
324ea606da
@ -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]*)
|
||||
;;
|
||||
|
@ -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.
|
||||
|
@ -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_.
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user