diff options
author | Aaron Ball <nullspoon@oper.io> | 2023-03-04 22:53:43 -0700 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2023-03-04 22:53:43 -0700 |
commit | 6a4cfe33c524fc8653f8bf50554e8b31e96c8bf4 (patch) | |
tree | d22a0f3891abb0f5838972a3a756042bf720e4dd | |
parent | 2edd418c12164fbd5b854e9cf24c43ace94b9fb9 (diff) | |
download | mkinitramfs-6a4cfe33c524fc8653f8bf50554e8b31e96c8bf4.tar.gz mkinitramfs-6a4cfe33c524fc8653f8bf50554e8b31e96c8bf4.tar.xz |
Remove requirement for blkid and cut commands
With the `/dev/disk` directory tree now filled out, we no longer need
blkid and cut to determine device paths based on aliases such as
partlabel or uuid. This also simplifies the code, using bash-native
parameter expansion to cut substrings.
-rwxr-xr-x | init | 16 | ||||
-rwxr-xr-x | mkinitramfs | 3 |
2 files changed, 7 insertions, 12 deletions
@@ -69,29 +69,25 @@ parse_cmdline() { root=*) if [ "${i:5:4}" == 'UUID' ]; then # mount by uuid - local uuid=$(echo ${i} | cut -d '=' -f 3) - ROOTDEV="$(blkid -U ${uuid})" + ROOTDEV="/dev/disk/by-uuid/${i##*=}" elif [ "${i:5:5}" == 'LABEL' ]; then # mount by label - local label=$(echo ${i} | cut -d '=' -f 3) - ROOTDEV="$(blkid -L ${label})" + ROOTDEV=/dev/disk/by-partlabel/${i##*=} else # mount by dev - ROOTDEV="$(echo ${i} | cut -d '=' -f 2)" + ROOTDEV="${i##*=}" fi ;; cryptroot=*) if [ "${i:10:4}" == 'UUID' ]; then # mount by uuid - local uuid=$(echo ${i} | cut -d '=' -f 3) - CRYPTROOT="$(blkid -U ${uuid})" + CRYPTROOT="/dev/disk/by-uuid/${i##*=}" elif [ "${i:10:5}" == 'LABEL' ]; then # mount by label - local label=$(echo ${i} | cut -d '=' -f 3) - CRYPTROOT="$(blkid -L ${label})" + CRYPTROOT=/dev/disk/by-partlabel/${i##*=} else # mount by dev - CRYPTROOT="$(echo ${i} | cut -d '=' -f 2)" + CRYPTROOT="${i##*=}" fi ;; subvol=*) diff --git a/mkinitramfs b/mkinitramfs index 5d35386..676c770 100755 --- a/mkinitramfs +++ b/mkinitramfs @@ -19,7 +19,6 @@ # Hash of fully-qualified binaries declare -a fqbins - # # Searches PATH for all binaries listed as function arguments. Each found # binary is then put into the global "bins" array. @@ -204,7 +203,7 @@ function main { # List of binaries to exist in the new initramfs # Standard shell binaries - resolve_bins bash cat pidof ps ls clear cut grep less blkid switch_root kill + resolve_bins bash cat pidof ps ls clear grep less switch_root kill # Module management resolve_bins udevadm udevd modprobe rmmod # For encrypted and block device support |