Skip to content
Snippets Groups Projects
Unverified Commit 99e09bf5 authored by Caleb Connolly's avatar Caleb Connolly :recycle:
Browse files

postmarketos-initramfs: unify with minimal initramfs


We previously forked the initramfs into a minimal variant for highly
space constrained devices, to allow the normal variant to gain
additional functionality like the debug-shell (With OSK). Initially the
hope was that only a handful of devices would need the minimal variant,
but in practise this has not been the case.

Trying to maintain two diverging forks of the initramfs is absoutely
unsustainable and (to be frank) a bit silly.

Based on discussion with craftyguy and newbyte, let's re-architect the
initramfs to run in two stages, with the second stage being part of
initramfs-extra. By itself this doesn't make a lot of sense, since
requiring the boot partition be mounted for the debug-shell to be useful
is a major downgrade.

However this can be used in tandem with pending support for a new
deviceinfo_create_initfs_extra variable, this is default false in
mkinitfs which finally gets rid of initramfs-extra entirely for devices
that don't need it.

Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
parent a845f307
No related branches found
No related tags found
No related merge requests found
......@@ -4,19 +4,11 @@
/etc/deviceinfo
/etc/unudhcpd.conf
/sbin/blkid
/usr/bin/iskey
/sbin/modprobe
/usr/bin/unudhcpd
/usr/sbin/kpartx
/usr/share/deviceinfo/deviceinfo
/usr/share/initramfs/init.sh:/init
/usr/share/initramfs/init_functions.sh:/init_functions.sh
/usr/share/initramfs/init.sh:/init
/usr/share/initramfs/mdev.conf:/etc/mdev.conf
/usr/share/misc/source_deviceinfo
/usr/bin/buffyboard
/usr/share/consolefonts/ter-128n.psf.gz
/usr/share/libinput/*.quirks
/bin/udevadm
/sbin/udevd
/etc/udev/rules.d
/lib/udev/rules.d
/lib/udev/scsi_id
/usr/lib/libz.so.1
/bin/udevadm
/etc/udev/rules.d
/lib/udev/rules.d
/lib/udev/scsi_id
/sbin/btrfs
/sbin/dmsetup
/sbin/e2fsck
/sbin/fsck.vfat
/sbin/switch_root
/sbin/udevd
/usr/bin/buffyboard
/usr/bin/iskey
/usr/lib/libz.so.1
/usr/sbin/fsck.f2fs
/usr/sbin/parted
/usr/sbin/resize.f2fs
/usr/sbin/resize2fs
/usr/share/consolefonts/ter-128n.psf.gz
/usr/share/initramfs/init_2nd.sh:/init_2nd.sh
/usr/share/initramfs/init_functions_2nd.sh:/init_functions_2nd.sh
/usr/share/libinput/*.quirks
# Maintainer: Caleb Connolly <caleb@postmarketos.org>
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=postmarketos-initramfs
pkgver=3.3.4
pkgver=3.4.0
pkgrel=0
pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra"
url="https://postmarketos.org"
......@@ -42,6 +42,9 @@ source="
00-initramfs-extra-base.files
init.sh
init_functions.sh
init_2nd.sh
init_functions_2nd.sh
mdev.conf
unudhcpd.conf
"
arch="noarch"
......@@ -59,12 +62,22 @@ package() {
install -Dm644 "$srcdir/unudhcpd.conf" \
"$pkgdir/etc/unudhcpd.conf"
install -Dm644 "$srcdir"/mdev.conf \
-t "$pkgdir"/usr/share/initramfs/
install -Dm644 "$srcdir/init_functions.sh" \
"$pkgdir/usr/share/initramfs/init_functions.sh"
install -Dm644 "$srcdir/init_functions_2nd.sh" \
"$pkgdir/usr/share/initramfs/init_functions_2nd.sh"
install -Dm755 "$builddir/init.sh" \
"$pkgdir/usr/share/initramfs/init.sh"
install -Dm755 "$srcdir/init_2nd.sh" \
"$pkgdir/usr/share/initramfs/init_2nd.sh"
install -Dm644 "$srcdir"/00-initramfs-base.dirs \
-t "$pkgdir"/usr/share/mkinitfs/dirs/
mkdir -p "$pkgdir"/etc/mkinitfs/dirs
......@@ -90,9 +103,12 @@ package() {
sha512sums="
20bc7a21f4f59548b8179c5cb1fc2b3db64eb355988bce992db3bc4075d65b4135ff9dd7d754215d0402978811494449cce476a26cda6bb2f0f8b53ae8e36bd7 00-default.modules
9c0e8f6f61d5da191e03a1aa9d5d0ceb5baf1eae6dbb9bfb0af59817783525119ac8394b135f303f7b6434a3eab0b49185fb90379e06823db847a4999c75ce33 00-initramfs-base.dirs
929a8e6cca6b2b4ac6af89fc3912e80315f51c9bf6e9479124ccb7ebe9e99c6c1cafb98d3aa01b0a76a2f6e0071ba3eb86c7a2169a15c2e1788d69458bea3471 00-initramfs-base.files
bc51380728c50584794dfed7a6b2b22258b9a31fc0b1aee2e196277e9846336228e6b48ce7af5e213edcc772addaac2c9b2bb344dcbbdb72b9c548c268393c40 00-initramfs-extra-base.files
7ea2c318e3b63b84ba8eb09e31dd74cdd9c86f5f4d8970ab54bb9213930e913c09728b60d429828007ea2dbb0472fd50dc3daae2efbe307babf854e4d8ecb238 init.sh
12c4db4cde4a015d1e94dd9f1552023c0facf221d015ff7a0a807ef976c42d8e89bae6cbbf06f9d68b0aa1b78b2bf8a03a3710c2b0c4957af6d818f3e8820da5 init_functions.sh
b0cfe73ca8092bb9edefaf438c99e2c932edda2b6f90cf45c5edb1a3ef457fcb9ce3892e7d905a1341cd5d61c6f2cbb3ccb3e75f780789c47407983ba2024da4 00-initramfs-base.files
6ff971e29d7654baa23026aca04d1e97eb8e8f3cd24d5be59a6e89be45d2e893bd5498351aadfd5afddff5c2de59c07b67a53ec8273d121ecdc57b7fbe07a6c6 00-initramfs-extra-base.files
94d3008e8700184758997acb6dd5b9af079e17867c1434fcdaea467dd0cdfa80e1e0e92aae3a86abcda69a7ca36c916ff3faf1e07be7e75317240f007a8a1afc init.sh
586517bf1b9c30b77342ba388f0a46beac72bb63b1f79ea6e8b62a6745991d7bdf6551d5f93f8f62eddd102adc0752cef4fd427549e2bb0dd2a9f6c2d65d11d5 init_functions.sh
d7ef6bb60b5ae6834f3aad0611b910e405f751bb3e19c79bec23418a28629ce319df3557b0b3190f0c9f780a958fbe1493c2327381b07b8e6aacc39170aaebfc init_2nd.sh
d40d6472df8fd653b9fe2c8b9436fecd7dadf2f0d380c0931f97448bedb1f52c8872fe8fdb6aea45f8b52f5926ca20db97a0f2e99091422aedc1aa0a0b58bb03 init_functions_2nd.sh
675e7d5bee39b2df7d322117f8dcaccc274d61beaf4d50ead19bbf2109446d64b1c0aa0c5b4f9846eb6c1c403418f28f6364eff4537ba41120fbfcbc484b7da7 mdev.conf
ba3275a9af788c7c782322a22a0f144d5e50e3498ea6886486a29331f23ae89cd32d500a3635cfa7cab369afba92edc18aeca64ccbf0cd589061cce23d15b46c unudhcpd.conf
"
#!/bin/sh
# shellcheck disable=SC1091
# Export all variables so they're available in
# init_2nd.sh
set -a
IN_CI="false"
LOG_PREFIX="[pmOS-rd]"
......@@ -26,90 +30,41 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin
mount_proc_sys_dev
setup_log
setup_firmware_path
modprobe libcomposite
# Run udev early, before splash, to make sure any relevant display drivers are
# loaded in time
setup_udev
if [ "$IN_CI" = "false" ]; then
setup_framebuffer
show_splash "Loading..."
fi
setup_dynamic_partitions "${deviceinfo_super_partitions:=}"
run_hooks /hooks
if [ "$IN_CI" = "true" ]; then
echo "PMOS: CI tests done, disabling console and looping forever"
dmesg -n 1
fail_halt_boot
fi
setup_usb_network
start_unudhcpd
if grep -q "pmos.debug-shell" /proc/cmdline; then
debug_shell
# Jump straight to the 2nd stage init if available
# (no separate -extra) or no-op otherwise
jump_init_2nd
# We need mdev to find the boot partition
setup_mdev
if [ "$IN_CI" = "false" ]; then
setup_framebuffer
show_splash "Loading..."
fi
check_keys
load_modules /lib/modules/initramfs.load
# Discover the partitions if they're "subpartitions"
# (where the whole disk image is flashed to a partition)
mount_subpartitions
# Poll for the boot partition to become available or crash
wait_boot_partition
mount_boot_partition /boot
extract_initramfs_extra /boot/initramfs-extra
run_hooks /hooks-extra
wait_root_partition
delete_old_install_partition
resize_root_partition
unlock_root_partition
resize_root_filesystem
mount_root_partition
# Mount boot partition into sysroot, so we do not depend on /etc/fstab, as
# not all old installations have a proper /etc/fstab file. See #2800
umount /boot
mount_boot_partition /sysroot/boot "rw"
init="/sbin/init"
setup_bootchart2
# Switch root
run_hooks /hooks-cleanup
echo "Switching root"
# Restore stdout and stderr to their original values if they
# were stashed
if [ -e "/proc/1/fd/3" ]; then
exec 1>&3 2>&4
elif ! grep -q "pmos.debug-shell" /proc/cmdline; then
echo "$LOG_PREFIX Disabling console output again (use 'pmos.debug-shell' to keep it enabled)"
exec >/dev/null 2>&1
fi
# Make it clear that we're at the end of the initramfs
show_splash "Starting..."
# Re-enable kmsg ratelimiting (might have been disabled for logging)
echo ratelimit > /proc/sys/kernel/printk_devkmsg
killall mdev udevd syslogd 2>/dev/null
# Kill any getty shells that might be running
for pid in $(pidof sh); do
if ! [ "$pid" = "1" ]; then
kill -9 "$pid"
fi
done
# Kill mdev, since it's replaced by udev in the
# second stage init
kill mdev 2>/dev/null
# shellcheck disable=SC2093
exec switch_root /sysroot "$init"
# Now we can jump to the 2nd stage init
jump_init_2nd
echo "$LOG_PREFIX ERROR: switch_root failed!" > /dev/kmsg
echo "$LOG_PREFIX Looping forever. Install and use the debug-shell hook to debug this." > /dev/kmsg
echo "$LOG_PREFIX For more information, see <https://postmarketos.org/debug-shell>" > /dev/kmsg
# Somehow init_2nd.sh is missing
echo "$LOG_PREFIX ERROR: /init_2nd.sh not found!"
echo "$LOG_PREFIX For more information, see <https://postmarketos.org/debug-shell>"
fail_halt_boot
#!/bin/sh
# shellcheck disable=SC1091
# This is the "real" init.sh script, it's either jumped to immediately
# from init.sh, or loaded from initramfs-extra on the boot partition
# on space constrained devices with deviceinfo_create_initfs_extra="true".
# The set -a in init.sh only exports variables, not functions
. /init_functions.sh
. /init_functions_2nd.sh
# Run udev early, before splash, to make sure any relevant display drivers are
# loaded in time
setup_udev
# Splash is already running if we're loaded from initramfs-extra
if [ "$deviceinfo_create_initfs_extra" != "true" ] && [ "$IN_CI" = "false" ]; then
setup_framebuffer
show_splash "Loading..."
fi
setup_dynamic_partitions "${deviceinfo_super_partitions:=}"
run_hooks /hooks
if [ "$IN_CI" = "true" ]; then
echo "PMOS: CI tests done, disabling console and looping forever"
dmesg -n 1
fail_halt_boot
fi
if grep -q "pmos.debug-shell" /proc/cmdline; then
debug_shell
fi
check_keys
# If running from initramfs-extra this will be a no-op since it was
# called before to mount the boot partition
mount_subpartitions
run_hooks /hooks-extra
wait_root_partition
delete_old_install_partition
resize_root_partition
unlock_root_partition
resize_root_filesystem
mount_root_partition
# Mount boot partition into sysroot, so we do not depend on /etc/fstab, as
# not all old installations have a proper /etc/fstab file. See #2800
if cat /sysroot/etc/fstab | grep -v "#" | grep -q "/boot" ; then
wait_boot_partition
mount_boot_partition /sysroot/boot "rw"
fi
init="/sbin/init"
setup_bootchart2
# Switch root
run_hooks /hooks-cleanup
echo "Switching root"
# Restore stdout and stderr to their original values if they
# were stashed
if [ -e "/proc/1/fd/3" ]; then
exec 1>&3 2>&4
elif ! grep -q "pmos.debug-shell" /proc/cmdline; then
echo "$LOG_PREFIX Disabling console output again (use 'pmos.debug-shell' to keep it enabled)"
exec >/dev/null 2>&1
fi
# Make it clear that we're at the end of the initramfs
show_splash "Starting..."
# Re-enable kmsg ratelimiting (might have been disabled for logging)
echo ratelimit > /proc/sys/kernel/printk_devkmsg
killall mdev udevd syslogd 2>/dev/null
# Kill any getty shells that might be running
for pid in $(pidof sh); do
if ! [ "$pid" = "1" ]; then
kill -9 "$pid"
fi
done
# shellcheck disable=SC2093
exec switch_root /sysroot "$init"
echo "$LOG_PREFIX ERROR: switch_root failed!" > /dev/kmsg
echo "$LOG_PREFIX Looping forever. Install and use the debug-shell hook to debug this." > /dev/kmsg
echo "$LOG_PREFIX For more information, see <https://postmarketos.org/debug-shell>" > /dev/kmsg
fail_halt_boot
#!/bin/sh
# This file will be in /init_functions.sh inside the initramfs.
ROOT_PARTITION_UNLOCKED=0
ROOT_PARTITION_RESIZED=0
PMOS_BOOT=""
PMOS_ROOT=""
# NOTE!!! The file is sourced again in init_2nd.sh, avoid
# clobbering variables by not setting them if they have
# a value already!
PMOS_BOOT="${PMOS_BOOT:-}"
PMOS_ROOT="${PMOS_ROOT:-}"
CONFIGFS="/config/usb_gadget"
CONFIGFS_ACM_FUNCTION="acm.usb0"
HOST_IP="${unudhcpd_host_ip:-172.16.42.1}"
deviceinfo_getty=""
deviceinfo_name=""
deviceinfo_codename=""
deviceinfo_getty="${deviceinfo_getty:-}"
deviceinfo_name="${deviceinfo_name:-}"
deviceinfo_codename="${deviceinfo_codename:-}"
deviceinfo_create_initfs_extra="${deviceinfo_create_initfs_extra:-}"
# Redirect stdout and stderr to logfile
setup_log() {
......@@ -100,19 +104,32 @@ setup_firmware_path() {
echo -n /lib/firmware/postmarketos >$SYS
}
setup_udev() {
if ! command -v udevd > /dev/null || ! command -v udevadm > /dev/null; then
echo "ERROR: udev not found!"
# shellcheck disable=SC3043
load_modules() {
local file="$1"
local modules="$2"
[ -f "$file" ] && modules="$modules $(grep -v ^\# "$file")"
# shellcheck disable=SC2086
modprobe -a $modules
}
setup_mdev() {
# Start mdev daemon
mdev -d
}
jump_init_2nd() {
if ! [ -e /init_2nd.sh ]; then
return
fi
# This is the same series of steps performed by the udev,
# udev-trigger and udev-settle RC services. See also:
# - https://git.alpinelinux.org/aports/tree/main/eudev/setup-udev
# - https://git.alpinelinux.org/aports/tree/main/udev-init-scripts/APKBUILD
udevd -d --resolve-names=never
udevadm trigger --type=devices --action=add
udevadm settle
local _reason="(Second stage already loaded)"
if [ "$deviceinfo_create_initfs_extra" = "true" ]; then
_reason="(Loaded initramfs-extra)"
fi
echo "Jumping to /init_2nd.sh $_reason"
exec /init_2nd.sh
}
get_uptime_seconds() {
......@@ -141,6 +158,10 @@ setup_dynamic_partitions() {
}
mount_subpartitions() {
# skip if ran already (unmerged -extra)
if [ -n "$PMOS_ROOT" ] && [ -n "$PMOS_BOOT" ]; then
return
fi
try_parts="/dev/disk/by-partlabel/userdata /dev/disk/by-partlabel/system* /dev/mapper/system*"
android_parts=""
for x in $try_parts; do
......@@ -504,71 +525,6 @@ has_unallocated_space() {
head -n1 | grep -qi "free space"
}
resize_root_partition() {
partition=$(find_root_partition)
# Do not resize the installer partition
if [ "$(blkid --label pmOS_install)" = "$partition" ]; then
echo "Resize root partition: skipped (on-device installer)"
return
fi
# Only resize the partition if it's inside the device-mapper, which means
# that the partition is stored as a subpartition inside another one.
# In this case we want to resize it to use all the unused space of the
# external partition.
if [ -z "${partition##"/dev/mapper/"*}" ] || [ -z "${partition##"/dev/dm-"*}" ]; then
# Get physical device
partition_dev=$(dmsetup deps -o blkdevname "$partition" | \
awk -F "[()]" '{print "/dev/"$2}')
if has_unallocated_space "$partition_dev"; then
echo "Resize root partition ($partition)"
# unmount subpartition, resize and remount it
kpartx -d "$partition"
parted -f -s "$partition_dev" resizepart 2 100%
kpartx -afs "$partition_dev"
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
# Resize the root partition (non-subpartitions). Usually we do not want
# this, except for QEMU devices and non-android devices (e.g.
# PinePhone). For them, it is fine to use the whole storage device and
# so we pass PMOS_FORCE_PARTITION_RESIZE as kernel parameter.
elif grep -q PMOS_FORCE_PARTITION_RESIZE /proc/cmdline; then
partition_dev="$(echo "$partition" | sed -E 's/p?2$//')"
if has_unallocated_space "$partition_dev"; then
echo "Resize root partition ($partition)"
parted -f -s "$partition_dev" resizepart 2 100%
partprobe
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
# Resize the root partition (non-subpartitions) on Chrome OS devices.
# Match $deviceinfo_cgpt_kpart not being empty instead of cmdline
# because it does not make sense here as all these devices use the same
# partitioning methods. This also resizes third partition instead of
# second, because these devices have an additional kernel partition
# at the start.
elif [ -n "$deviceinfo_cgpt_kpart" ]; then
partition_dev="$(echo "$partition" | sed -E 's/p?3$//')"
if has_unallocated_space "$partition_dev"; then
echo "Resize root partition ($partition)"
parted -f -s "$partition_dev" resizepart 3 100%
partprobe
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
else
echo "Unable to resize root partition: failed to find qualifying partition"
fi
}
unlock_root_partition() {
command -v cryptsetup >/dev/null || return
partition="$(find_root_partition)"
......@@ -587,38 +543,6 @@ unlock_root_partition() {
fi
}
resize_root_filesystem() {
if [ "$ROOT_PARTITION_RESIZED" = 1 ]; then
show_splash "Resizing filesystem during initial boot..."
partition="$(find_root_partition)"
touch /etc/mtab # see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=673323
type="$(get_partition_type "$partition")"
case "$type" in
ext4)
echo "Resize 'ext4' root filesystem ($partition)"
modprobe ext4
resize2fs -f "$partition"
;;
f2fs)
echo "Resize 'f2fs' root filesystem ($partition)"
modprobe f2fs
resize.f2fs "$partition"
;;
btrfs)
echo "Resize 'btrfs' root filesystem ($partition)"
modprobe btrfs
resize_root_filesystem_tmp_btrfs="$(mktemp -d)"
mount -t btrfs "$partition" "$resize_root_filesystem_tmp_btrfs"
btrfs filesystem resize max "$resize_root_filesystem_tmp_btrfs"
umount "$resize_root_filesystem_tmp_btrfs"
unset resize_root_filesystem_tmp_btrfs
;;
*) echo "WARNING: Can not resize '$type' filesystem ($partition)." ;;
esac
show_splash "Loading..."
fi
}
mount_root_partition() {
# Don't mount root if it is already mounted
if mountpoint -q /sysroot; then
......@@ -794,6 +718,7 @@ setup_usb_network() {
[ -e "$_marker" ] && return
touch "$_marker"
echo "Setup usb network"
modprobe libcomposite
# Run all usb network setup functions (add more below!)
setup_usb_network_android
setup_usb_network_configfs
......@@ -924,6 +849,7 @@ debug_shell() {
initrd: $INITRAMFS_PKG_VERSION
Run 'pmos_continue_boot' to continue booting.
Read the initramfs log with 'cat /pmOS_init.log'.
EOF
# Add pmos_logdump message only if relevant
......@@ -998,7 +924,9 @@ debug_shell() {
# Getty on the display
hide_splash
# Spawn buffyboard if the device might not have a physical keyboard
if echo "handset tablet convertible" | grep "${deviceinfo_chassis:-handset}" >/dev/null; then
# buffyboard is only available with merged initramfs-extra!
if which buffyboard 2>/dev/null && \
echo "handset tablet convertible" | grep "${deviceinfo_chassis:-handset}" >/dev/null; then
modprobe uinput
# Set a large font for the framebuffer
setfont "/usr/share/consolefonts/ter-128n.psf.gz" -C "/dev/$active_console"
......
#!/bin/sh
# Additional functions that depend on initramfs-extra
# Functions are notated with the reason they're only in
# initramfs-extra
ROOT_PARTITION_RESIZED=0
# udevd is too big
setup_udev() {
if ! command -v udevd > /dev/null || ! command -v udevadm > /dev/null; then
echo "ERROR: udev not found!"
return
fi
# This is the same series of steps performed by the udev,
# udev-trigger and udev-settle RC services. See also:
# - https://git.alpinelinux.org/aports/tree/main/eudev/setup-udev
# - https://git.alpinelinux.org/aports/tree/main/udev-init-scripts/APKBUILD
udevd -d --resolve-names=never
udevadm trigger --type=devices --action=add
udevadm settle
}
# parted is too big
resize_root_partition() {
partition=$(find_root_partition)
# Do not resize the installer partition
if [ "$(blkid --label pmOS_install)" = "$partition" ]; then
echo "Resize root partition: skipped (on-device installer)"
return
fi
# Only resize the partition if it's inside the device-mapper, which means
# that the partition is stored as a subpartition inside another one.
# In this case we want to resize it to use all the unused space of the
# external partition.
if [ -z "${partition##"/dev/mapper/"*}" ] || [ -z "${partition##"/dev/dm-"*}" ]; then
# Get physical device
partition_dev=$(dmsetup deps -o blkdevname "$partition" | \
awk -F "[()]" '{print "/dev/"$2}')
if has_unallocated_space "$partition_dev"; then
echo "Resize root partition ($partition)"
# unmount subpartition, resize and remount it
kpartx -d "$partition"
parted -f -s "$partition_dev" resizepart 2 100%
kpartx -afs "$partition_dev"
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
# Resize the root partition (non-subpartitions). Usually we do not want
# this, except for QEMU devices and non-android devices (e.g.
# PinePhone). For them, it is fine to use the whole storage device and
# so we pass PMOS_FORCE_PARTITION_RESIZE as kernel parameter.
elif grep -q PMOS_FORCE_PARTITION_RESIZE /proc/cmdline; then
partition_dev="$(echo "$partition" | sed -E 's/p?2$//')"
if has_unallocated_space "$partition_dev"; then
echo "Resize root partition ($partition)"
parted -f -s "$partition_dev" resizepart 2 100%
partprobe
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
# Resize the root partition (non-subpartitions) on Chrome OS devices.
# Match $deviceinfo_cgpt_kpart not being empty instead of cmdline
# because it does not make sense here as all these devices use the same
# partitioning methods. This also resizes third partition instead of
# second, because these devices have an additional kernel partition
# at the start.
elif [ -n "$deviceinfo_cgpt_kpart" ]; then
partition_dev="$(echo "$partition" | sed -E 's/p?3$//')"
if has_unallocated_space "$partition_dev"; then
echo "Resize root partition ($partition)"
parted -f -s "$partition_dev" resizepart 3 100%
partprobe
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
else
echo "Unable to resize root partition: failed to find qualifying partition"
fi
}
# resize2fs and resize.f2fs are too big
resize_root_filesystem() {
if [ "$ROOT_PARTITION_RESIZED" = 1 ]; then
show_splash "Resizing filesystem during initial boot..."
partition="$(find_root_partition)"
touch /etc/mtab # see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=673323
type="$(get_partition_type "$partition")"
case "$type" in
ext4)
echo "Resize 'ext4' root filesystem ($partition)"
modprobe ext4
resize2fs -f "$partition"
;;
f2fs)
echo "Resize 'f2fs' root filesystem ($partition)"
modprobe f2fs
resize.f2fs "$partition"
;;
btrfs)
echo "Resize 'btrfs' root filesystem ($partition)"
modprobe btrfs
resize_root_filesystem_tmp_btrfs="$(mktemp -d)"
mount -t btrfs "$partition" "$resize_root_filesystem_tmp_btrfs"
btrfs filesystem resize max "$resize_root_filesystem_tmp_btrfs"
umount "$resize_root_filesystem_tmp_btrfs"
unset resize_root_filesystem_tmp_btrfs
;;
*) echo "WARNING: Can not resize '$type' filesystem ($partition)." ;;
esac
show_splash "Loading..."
fi
}
#
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment