main/postmarketos-initramfs: use mdev properly (MR 4204)
Drop in mdev.conf and the /lib/mdev/persistent-storage script, these cause /dev/disk/by-* to be populated in the ramdisk, making it possible to do look up partition by-label and by-partlabel for free, compared to findfs which can take some time. As a first optimisation based on this, check for some partitions using these paths and prioritise them when looking for subpartitions. Drop the first find_boot_partition call as it doesn't really save time over the call in the while loop. The mdev config also handles setting up /dev/null, /dev/random, etc, so these don't have to be done manually.
This commit is contained in:
parent
7c79667fe0
commit
e0fcfb74e2
5 changed files with 48 additions and 12 deletions
|
@ -3,8 +3,11 @@
|
|||
/bin/sh
|
||||
/etc/deviceinfo
|
||||
/etc/unudhcpd.conf
|
||||
/lib/mdev/persistent-storage
|
||||
/sbin/blkid
|
||||
/usr/share/misc/source_deviceinfo
|
||||
/usr/bin/unudhcpd
|
||||
/usr/sbin/kpartx
|
||||
/usr/share/initramfs/init.sh:/init
|
||||
/usr/share/initramfs/init_functions.sh:/init_functions.sh
|
||||
/usr/share/initramfs/mdev.conf:/etc/mdev.conf
|
||||
|
|
|
@ -33,6 +33,7 @@ source="
|
|||
init.sh
|
||||
init_functions.sh
|
||||
unudhcpd.conf
|
||||
mdev.conf
|
||||
"
|
||||
arch="noarch"
|
||||
license="GPL-2.0-or-later"
|
||||
|
@ -63,6 +64,9 @@ package() {
|
|||
-t "$pkgdir"/usr/share/mkinitfs/files-extra/
|
||||
mkdir -p "$pkgdir"/etc/mkinitfs/files-extra
|
||||
|
||||
install -Dm644 "$srcdir"/mdev.conf \
|
||||
-t "$pkgdir"/usr/share/initramfs/
|
||||
|
||||
mkdir -p "$pkgdir"/usr/share/mkinitfs/hooks
|
||||
mkdir -p "$pkgdir"/usr/share/mkinitfs/hooks-extra
|
||||
mkdir -p "$pkgdir"/etc/mkinitfs/hooks
|
||||
|
|
|
@ -13,7 +13,6 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
|||
|
||||
# Mount everything, set up logging, modules, mdev
|
||||
mount_proc_sys_dev
|
||||
create_device_nodes
|
||||
setup_log
|
||||
setup_firmware_path
|
||||
# shellcheck disable=SC2154
|
||||
|
|
|
@ -36,12 +36,6 @@ mount_proc_sys_dev() {
|
|||
mount -t devpts devpts /dev/pts
|
||||
}
|
||||
|
||||
create_device_nodes() {
|
||||
mknod -m 666 /dev/null c 1 3
|
||||
mknod -m 644 /dev/random c 1 8
|
||||
mknod -m 644 /dev/urandom c 1 9
|
||||
}
|
||||
|
||||
setup_firmware_path() {
|
||||
# Add the postmarketOS-specific path to the firmware search paths.
|
||||
# This should be sufficient on kernel 3.10+, before that we need
|
||||
|
@ -110,16 +104,19 @@ setup_dynamic_partitions() {
|
|||
}
|
||||
|
||||
mount_subpartitions() {
|
||||
# Do not create subpartition mappings if pmOS_boot
|
||||
# already exists (e.g. installed on an sdcard)
|
||||
[ -n "$(find_boot_partition)" ] && return
|
||||
try_parts="/dev/disk/by-partlabel/userdata /dev/disk/by-partlabel/system* /dev/mapper/system*"
|
||||
android_parts=""
|
||||
for x in $try_parts; do
|
||||
[ -e "$x" ] && android_parts="$android_parts $x"
|
||||
done
|
||||
|
||||
attempt_start=$(get_uptime_seconds)
|
||||
wait_seconds=10
|
||||
echo "Trying to mount subpartitions for $wait_seconds seconds..."
|
||||
while [ -z "$(find_boot_partition)" ]; do
|
||||
partitions="$(grep -v "loop\|ram" < /proc/diskstats |\
|
||||
partitions="$android_parts $(grep -v "loop\|ram" < /proc/diskstats |\
|
||||
sed 's/\(\s\+[0-9]\+\)\+\s\+//;s/ .*//;s/^/\/dev\//')"
|
||||
echo "$partitions" | while read -r partition; do
|
||||
for partition in $partitions; do
|
||||
case "$(kpartx -l "$partition" 2>/dev/null | wc -l)" in
|
||||
2)
|
||||
echo "Mount subpartitions of $partition"
|
||||
|
|
33
main/postmarketos-initramfs/mdev.conf
Normal file
33
main/postmarketos-initramfs/mdev.conf
Normal file
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# This is an mdev config for the postmarketOS initramfs
|
||||
#
|
||||
|
||||
# Devices:
|
||||
# Syntax: %s %d:%d %s
|
||||
# devices user:group mode
|
||||
|
||||
$MODALIAS=.* 0:0 0660 @modprobe -q -b "$MODALIAS"
|
||||
|
||||
# null does already exist; therefore ownership has to be changed with command
|
||||
null 0:0 0666 @chmod 666 $MDEV
|
||||
zero 0:0 0666
|
||||
full 0:0 0666
|
||||
|
||||
random 0:0 0666
|
||||
urandom 0:0 0444
|
||||
hwrandom 0:0 0660
|
||||
|
||||
console 0:0 0600
|
||||
|
||||
kmem 0:0 0640
|
||||
mem 0:0 0640
|
||||
|
||||
# Set up /dev/disk/by-* symlinks
|
||||
dasd.* 0:0 0660 */lib/mdev/persistent-storage
|
||||
mmcblk.* 0:0 0660 */lib/mdev/persistent-storage
|
||||
nbd.* 0:0 0660 */lib/mdev/persistent-storage
|
||||
nvme.* 0:0 0660 */lib/mdev/persistent-storage
|
||||
sd[a-z].* 0:0 0660 */lib/mdev/persistent-storage
|
||||
sr[0-9]+ 0:0 0660 */lib/mdev/persistent-storage
|
||||
vd[a-z].* 0:0 0660 */lib/mdev/persistent-storage
|
||||
xvd[a-z].* 0:0 0660 */lib/mdev/persistent-storage
|
Loading…
Reference in a new issue