mirror of
https://github.com/kairos-io/packages.git
synced 2025-08-04 17:50:14 +00:00
Several improvements for alpine initramfs (#484)
This commit is contained in:
parent
d705476a02
commit
030e223bef
@ -10,10 +10,17 @@ copy:
|
|||||||
version: ">=0"
|
version: ">=0"
|
||||||
source: "/usr/bin/immucore"
|
source: "/usr/bin/immucore"
|
||||||
destination: "/usr/bin/immucore"
|
destination: "/usr/bin/immucore"
|
||||||
|
- package:
|
||||||
|
category: "system"
|
||||||
|
name: "kairos-agent"
|
||||||
|
version: ">=0"
|
||||||
|
source: "/usr/bin/kairos-agent"
|
||||||
|
destination: "/usr/bin/kairos-agent"
|
||||||
package_dir: "/package"
|
package_dir: "/package"
|
||||||
prelude:
|
prelude:
|
||||||
- apk update
|
- apk update
|
||||||
- apk add linux-rpi4 mkinitfs linux-firmware-none udev lvm2 findmnt rsync parted cryptsetup
|
# multipath-tools and cryptsetup is needed to bring modules and udev rules
|
||||||
|
- apk add linux-rpi4 linux-firmware-none mkinitfs eudev eudev-hwids mdadm-udev device-mapper-udev lvm2 findmnt rsync parted cryptsetup multipath-tools openrc blkid
|
||||||
steps:
|
steps:
|
||||||
- kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}"
|
- kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}"
|
||||||
- mkdir -p /package/boot
|
- mkdir -p /package/boot
|
||||||
@ -45,7 +52,8 @@ copy:
|
|||||||
package_dir: "/package"
|
package_dir: "/package"
|
||||||
prelude:
|
prelude:
|
||||||
- apk update
|
- apk update
|
||||||
- apk add linux-lts linux-firmware-none mkinitfs udev lvm2 findmnt rsync parted cryptsetup
|
# multipath-tools and cryptsetup is needed to bring modules and udev rules
|
||||||
|
- apk add linux-lts linux-firmware-none mkinitfs eudev eudev-hwids mdadm-udev device-mapper-udev lvm2 findmnt rsync parted cryptsetup multipath-tools openrc blkid
|
||||||
steps:
|
steps:
|
||||||
- kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}"
|
- kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}"
|
||||||
- mkdir -p /package/boot
|
- mkdir -p /package/boot
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
packages:
|
packages:
|
||||||
- name: "alpine"
|
- name: "alpine"
|
||||||
category: "distro-kernel"
|
category: "distro-kernel"
|
||||||
version: "6.1.56-1"
|
version: "6.1.56-2"
|
||||||
description: "Provides kernel and custom initrd for alpine"
|
description: "Provides kernel and custom initrd for alpine"
|
||||||
labels:
|
labels:
|
||||||
autobump.strategy: "custom"
|
autobump.strategy: "custom"
|
||||||
@ -14,7 +14,7 @@ packages:
|
|||||||
package.version: "6.1.56"
|
package.version: "6.1.56"
|
||||||
- name: "alpine-rpi"
|
- name: "alpine-rpi"
|
||||||
category: "distro-kernel"
|
category: "distro-kernel"
|
||||||
version: "6.1.55-1"
|
version: "6.1.55-2"
|
||||||
description: "Provides kernel and custom initrd for alpine"
|
description: "Provides kernel and custom initrd for alpine"
|
||||||
labels:
|
labels:
|
||||||
autobump.strategy: "custom"
|
autobump.strategy: "custom"
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
/usr/bin/immucore
|
/usr/bin/immucore
|
||||||
/usr/bin/kairos-agent
|
/usr/bin/kairos-agent
|
||||||
/sbin/lvm
|
/sbin/lvm
|
||||||
/sbin/cryptsetup
|
/sbin/blkid
|
||||||
/bin/findmnt
|
/bin/findmnt
|
||||||
/bin/udevadm
|
/bin/udevadm
|
||||||
/sbin/udevadm
|
/sbin/udevadm
|
||||||
/sbin/udevd
|
/sbin/udevd
|
||||||
|
/sbin/dmsetup
|
||||||
/etc/udev/*
|
/etc/udev/*
|
||||||
/lib/udev/*
|
/lib/udev/*
|
||||||
|
/usr/lib/udev/*
|
||||||
/usr/lib/libudev*
|
/usr/lib/libudev*
|
||||||
/usr/bin/rsync
|
/usr/bin/rsync
|
||||||
/usr/sbin/parted
|
/usr/sbin/parted
|
||||||
|
/sbin/openrc
|
||||||
|
/sbin/openrc-run
|
@ -160,6 +160,8 @@ eudev_start()
|
|||||||
cat "$file" >> /etc/udev/rules.d/"$dest" && rm -f "$file"
|
cat "$file" >> /etc/udev/rules.d/"$dest" && rm -f "$file"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
udevadm hwdb --update
|
||||||
|
|
||||||
# Populating /dev with existing devices through uevents
|
# Populating /dev with existing devices through uevents
|
||||||
udevadm trigger --type=subsystems --action=add
|
udevadm trigger --type=subsystems --action=add
|
||||||
udevadm trigger --type=devices --action=add
|
udevadm trigger --type=devices --action=add
|
||||||
@ -238,6 +240,14 @@ is_url() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rd_break() {
|
||||||
|
if grep -q "rd.break=$1" /proc/cmdline; then
|
||||||
|
echo "initramfs emergency recovery shell launched" > "$ROOT"/dev/kmsg
|
||||||
|
echo "initramfs emergency recovery shell launched"
|
||||||
|
exec /bin/busybox sh
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
/bin/busybox mkdir -p "$ROOT"/usr/bin \
|
/bin/busybox mkdir -p "$ROOT"/usr/bin \
|
||||||
"$ROOT"/usr/sbin \
|
"$ROOT"/usr/sbin \
|
||||||
"$ROOT"/proc \
|
"$ROOT"/proc \
|
||||||
@ -299,9 +309,10 @@ done
|
|||||||
|
|
||||||
# hide kernel messages
|
# hide kernel messages
|
||||||
# dmesg -n 1
|
# dmesg -n 1
|
||||||
|
rd_break pre-modprobe
|
||||||
# load available drivers to get access to media
|
# load available drivers to get access to media
|
||||||
ebegin "Loading boot drivers"
|
ebegin "Loading boot drivers"
|
||||||
modprobe -a ahci virtio_blk virtio_net virtio_console virtio_pci nvme overlay usb_storage libata cdrom sr_mod iso9660 loop squashfs simpledrm ext4 tpm dm_mod 2> /dev/null
|
modprobe -a ahci virtio_blk virtio_net virtio_console virtio_pci nvme overlay usb_storage libata cdrom sr_mod iso9660 loop squashfs simpledrm ext4 tpm dm_mod dm_crypt 2> /dev/null
|
||||||
if [ -f "$ROOT"/etc/modules ] ; then
|
if [ -f "$ROOT"/etc/modules ] ; then
|
||||||
sed 's/\#.*//g' < /etc/modules |
|
sed 's/\#.*//g' < /etc/modules |
|
||||||
while read module args; do
|
while read module args; do
|
||||||
@ -315,17 +326,24 @@ fi
|
|||||||
|
|
||||||
eend
|
eend
|
||||||
|
|
||||||
|
rd_break post-modprobe
|
||||||
|
|
||||||
|
rd_break pre-udev
|
||||||
# persistent device names from eudev in order for immucore to mount stuff
|
# persistent device names from eudev in order for immucore to mount stuff
|
||||||
[ -x "/sbin/udevadm" ] && eudev_start
|
[ -x "/sbin/udevadm" ] && eudev_start
|
||||||
|
rd_break post-udev
|
||||||
|
|
||||||
|
rd_break pre-network
|
||||||
# Mount network if we got rd.neednet=1 or netboot
|
# Mount network if we got rd.neednet=1 or netboot
|
||||||
if grep -q "rd.neednet=1" /proc/cmdline || grep -q netboot /proc/cmdline ;then
|
if grep -q "rd.neednet=1" /proc/cmdline || grep -q netboot /proc/cmdline ;then
|
||||||
configure_ip
|
configure_ip
|
||||||
fi
|
fi
|
||||||
|
rd_break post-network
|
||||||
|
|
||||||
# Path for booting from netboot
|
# Path for booting from netboot
|
||||||
if grep -q netboot /proc/cmdline; then
|
if grep -q netboot /proc/cmdline; then
|
||||||
echo "Netbooting"
|
echo "Netbooting"
|
||||||
|
rd_break pre-netboot
|
||||||
|
|
||||||
for x in $(cat /proc/cmdline); do
|
for x in $(cat /proc/cmdline); do
|
||||||
# shellcheck disable=SC2039
|
# shellcheck disable=SC2039
|
||||||
@ -353,10 +371,12 @@ if grep -q netboot /proc/cmdline; then
|
|||||||
retry 5 losetup /dev/loop0 /tmp/rootfs.squashfs
|
retry 5 losetup /dev/loop0 /tmp/rootfs.squashfs
|
||||||
eend $?
|
eend $?
|
||||||
sync
|
sync
|
||||||
|
rd_break post-netboot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Path for booting from livecd
|
# Path for booting from livecd
|
||||||
if grep -q cdroot /proc/cmdline ;then
|
if grep -q cdroot /proc/cmdline ;then
|
||||||
|
rd_break pre-livecd
|
||||||
echo "Mounting LiveCD"
|
echo "Mounting LiveCD"
|
||||||
sync
|
sync
|
||||||
# Create mountpoints
|
# Create mountpoints
|
||||||
@ -377,10 +397,12 @@ if grep -q cdroot /proc/cmdline ;then
|
|||||||
retry 5 losetup /dev/loop0 /media/root-ro/rootfs.squashfs
|
retry 5 losetup /dev/loop0 /media/root-ro/rootfs.squashfs
|
||||||
eend $?
|
eend $?
|
||||||
sync
|
sync
|
||||||
|
rd_break post-livecd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# shared path for netboot and livecd, we expect the rootfs to be already in /dev/loop0
|
# shared path for netboot and livecd, we expect the rootfs to be already in /dev/loop0
|
||||||
if grep -q cdroot /proc/cmdline || grep -q netboot /proc/cmdline;then
|
if grep -q cdroot /proc/cmdline || grep -q netboot /proc/cmdline;then
|
||||||
|
rd_break pre-mounts
|
||||||
# Mount loop device into the rootfsbase
|
# Mount loop device into the rootfsbase
|
||||||
ebegin "Mount loop device into rootfsbase"
|
ebegin "Mount loop device into rootfsbase"
|
||||||
retry 5 mount /dev/loop0 /run/rootfsbase
|
retry 5 mount /dev/loop0 /run/rootfsbase
|
||||||
@ -412,17 +434,24 @@ if grep -q cdroot /proc/cmdline || grep -q netboot /proc/cmdline;then
|
|||||||
eend $?
|
eend $?
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
rd_break post-mounts
|
||||||
|
# stop udevd, will be relaunched by openrc
|
||||||
|
udevadm control --exit
|
||||||
|
|
||||||
# shellcheck disable=SC2093
|
# shellcheck disable=SC2093
|
||||||
exec switch_root "$sysroot" "$INIT"
|
exec switch_root "$sysroot" "$INIT"
|
||||||
echo "initramfs emergency recovery shell launched"
|
echo "initramfs emergency recovery shell launched"
|
||||||
exec /bin/busybox sh
|
exec /bin/busybox sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rd_break pre-immucore
|
||||||
# Path for booting active/passive/recovery
|
# Path for booting active/passive/recovery
|
||||||
ebegin "Run immucore"
|
ebegin "Run immucore"
|
||||||
immucore
|
immucore
|
||||||
eend $?
|
eend $?
|
||||||
|
|
||||||
|
rd_break post-immucore
|
||||||
|
|
||||||
# by now the system should be mounted in /sysroot
|
# by now the system should be mounted in /sysroot
|
||||||
if [ -f "$sysroot/etc/.default_boot_services" ]; then
|
if [ -f "$sysroot/etc/.default_boot_services" ]; then
|
||||||
# add some boot services by default
|
# add some boot services by default
|
||||||
@ -474,21 +503,24 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
rd_break pre-binds
|
||||||
# Mount bind system mounts to sysroot to keep them going
|
# Mount bind system mounts to sysroot to keep them going
|
||||||
mkdir -p $sysroot/sys $sysroot/proc $sysroot/dev $sysroot/run
|
mkdir -p $sysroot/sys $sysroot/proc $sysroot/dev $sysroot/run
|
||||||
mount -o bind /sys $sysroot/sys
|
mount -o bind /sys $sysroot/sys
|
||||||
mount -o bind /proc $sysroot/proc
|
mount -o bind /proc $sysroot/proc
|
||||||
mount -o bind /dev $sysroot/dev
|
mount -o bind /dev $sysroot/dev
|
||||||
mount -o bind /run $sysroot/run
|
mount -o bind /run $sysroot/run
|
||||||
|
rd_break post-binds
|
||||||
|
|
||||||
# remount according default fstab from package
|
# remount according default fstab from package
|
||||||
if [ -z "$has_fstab" ] && [ -f "$sysroot"/etc/fstab ]; then
|
if [ -z "$has_fstab" ] && [ -f "$sysroot"/etc/fstab ]; then
|
||||||
remount_fstab_entry "$sysroot"/etc/fstab
|
remount_fstab_entry "$sysroot"/etc/fstab
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rd_break pre-console
|
||||||
# fix inittab if alternative console
|
# fix inittab if alternative console
|
||||||
setup_inittab_console
|
setup_inittab_console
|
||||||
|
rd_break post-console
|
||||||
|
|
||||||
! [ -f "$sysroot"/etc/resolv.conf ] && [ -f /etc/resolv.conf ] && \
|
! [ -f "$sysroot"/etc/resolv.conf ] && [ -f /etc/resolv.conf ] && \
|
||||||
cp /etc/resolv.conf "$sysroot"/etc
|
cp /etc/resolv.conf "$sysroot"/etc
|
||||||
@ -499,6 +531,10 @@ if [ ! -x "${sysroot}${INIT}" ]; then
|
|||||||
/bin/busybox sh
|
/bin/busybox sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rd_break pre-switch
|
||||||
|
# stop udevd, will be relaunched by openrc
|
||||||
|
udevadm control --exit
|
||||||
|
|
||||||
# switch over to new root
|
# switch over to new root
|
||||||
echo ""
|
echo ""
|
||||||
# shellcheck disable=SC2093
|
# shellcheck disable=SC2093
|
||||||
|
@ -1 +1 @@
|
|||||||
features="ata base cdrom ext4 ext2 keymap kms mmc lvm nvme raid scsi usb network dhcp virtio zfs squashfs immucore tpm"
|
features="ata base cdrom ext4 ext2 keymap kms mmc lvm nvme raid scsi usb network dhcp virtio zfs squashfs immucore tpm cryptsetup kms mmc xfs"
|
||||||
|
Loading…
Reference in New Issue
Block a user