main/postmarketos-initramfs: fixup device-mapper paths (MR 4204)
findfs might produce a block device path like /dev/dm-3, these can change across boots and devices. Make things more readable and consistent by mapping from the /dev/dm-* path to the equivalent /dev/mapper/xyz path. Combined with invoking kpartx from a /dev/disk/by-partlabel/abc symlink, this results in the final block device having a name like /dev/mapper/userdata2 on an Android device. Whilst this is just nicer to work with, this will be especially useful for the upcoming ondev2 postmarketOS installer to make device-specific configuration and detection easier.
This commit is contained in:
parent
89fba12fbb
commit
6f44124c1b
1 changed files with 15 additions and 0 deletions
|
@ -145,6 +145,19 @@ mount_subpartitions() {
|
|||
done
|
||||
}
|
||||
|
||||
# Rewrite /dev/dm-X paths to /dev/mapper/...
|
||||
pretty_dm_path() {
|
||||
dm="$1"
|
||||
n="${dm#/dev/dm-}"
|
||||
|
||||
# If the substitution didn't do anything, then we're done
|
||||
[ "$n" = "$dm" ] && echo "$dm" && return
|
||||
|
||||
# Get the name of the device mapper device
|
||||
name="/dev/mapper/$(cat "/sys/class/block/dm-${n}/dm/name")"
|
||||
echo "$name"
|
||||
}
|
||||
|
||||
find_root_partition() {
|
||||
[ -n "$PMOS_ROOT" ] && echo "$PMOS_ROOT" && return
|
||||
|
||||
|
@ -213,6 +226,7 @@ find_root_partition() {
|
|||
PMOS_ROOT="$(blkid | grep "crypto_LUKS" | cut -d ":" -f 1 | head -n 1)"
|
||||
fi
|
||||
|
||||
PMOS_ROOT=$(pretty_dm_path "$PMOS_ROOT")
|
||||
echo "$PMOS_ROOT"
|
||||
}
|
||||
|
||||
|
@ -253,6 +267,7 @@ find_boot_partition() {
|
|||
done
|
||||
fi
|
||||
|
||||
PMOS_BOOT=$(pretty_dm_path "$PMOS_BOOT")
|
||||
echo "$PMOS_BOOT"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue