diff --git a/etc/archboot/init.conf b/etc/archboot/init.conf new file mode 100644 index 000000000..2355fe8c3 --- /dev/null +++ b/etc/archboot/init.conf @@ -0,0 +1,29 @@ +# Created by Tobias Powalowski +# SPDX-License-Identifier: GPL-2.0-only +# For more information on how using mkinitcpio please refer to the main config file +# or check the wiki. +MODULES=() +BINARIES=() +FILES=() + +# SETUP +# +# Please change the hooks only if you know what you are doing. +HOOKS=(archboot_init) + +# COMPRESSION +# Use this to compress the initramfs image. By default, gzip compression +# is used. Use 'cat' to create an uncompressed image. +COMPRESSION="zstd" +#COMPRESSION="gzip" +#COMPRESSION="bzip2" +#COMPRESSION="lzma" +#COMPRESSION="xz" +#COMPRESSION="lzop" +#COMPRESSION="lz4" + +# COMPRESSION_OPTIONS +# Additional options for the compressor +COMPRESSION_OPTIONS=(-19) +MODULES_DECOMPRESS="no" +# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/aarch64 b/etc/archboot/presets/aarch64 deleted file mode 100644 index 0d4842672..000000000 --- a/etc/archboot/presets/aarch64 +++ /dev/null @@ -1,9 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/aarch64.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/Image.gz" - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/aarch64-latest b/etc/archboot/presets/aarch64-latest deleted file mode 100644 index 1e7193767..000000000 --- a/etc/archboot/presets/aarch64-latest +++ /dev/null @@ -1,9 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/aarch64-latest.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/Image.gz" - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/aarch64-local b/etc/archboot/presets/aarch64-local deleted file mode 100644 index ca797aca0..000000000 --- a/etc/archboot/presets/aarch64-local +++ /dev/null @@ -1,9 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/aarch64-local.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/Image.gz" - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/riscv64 b/etc/archboot/presets/riscv64 deleted file mode 100644 index 803ffc67f..000000000 --- a/etc/archboot/presets/riscv64 +++ /dev/null @@ -1,9 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/riscv64.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/vmlinuz-linux" - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/riscv64-latest b/etc/archboot/presets/riscv64-latest deleted file mode 100644 index 30b37824b..000000000 --- a/etc/archboot/presets/riscv64-latest +++ /dev/null @@ -1,9 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/riscv64-latest.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/vmlinuz-linux" - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/riscv64-local b/etc/archboot/presets/riscv64-local deleted file mode 100644 index 8639d5759..000000000 --- a/etc/archboot/presets/riscv64-local +++ /dev/null @@ -1,9 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/riscv64-local.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/vmlinuz-linux" - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/x86_64 b/etc/archboot/presets/x86_64 deleted file mode 100644 index 148bc8c79..000000000 --- a/etc/archboot/presets/x86_64 +++ /dev/null @@ -1,8 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/x86_64.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/vmlinuz-linux" -# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/x86_64-latest b/etc/archboot/presets/x86_64-latest deleted file mode 100644 index 07860b14d..000000000 --- a/etc/archboot/presets/x86_64-latest +++ /dev/null @@ -1,8 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/x86_64-latest.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/vmlinuz-linux" -# vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/presets/x86_64-local b/etc/archboot/presets/x86_64-local deleted file mode 100644 index 7099ef8a0..000000000 --- a/etc/archboot/presets/x86_64-local +++ /dev/null @@ -1,8 +0,0 @@ -# Created by Tobias Powalowski -# SPDX-License-Identifier: GPL-2.0-only -# mkinitcpio config file, defaulted to stock config file -MKINITCPIO_CONFIG="/etc/archboot/x86_64-local.conf" - -# kernel version, defaulted to build for runtime kernel -ALL_kver="/boot/vmlinuz-linux" -# vim: set ft=sh ts=4 sw=4 et: diff --git a/usr/lib/archboot/iso.sh b/usr/lib/archboot/iso.sh index 93e8cc91e..33d339f3e 100644 --- a/usr/lib/archboot/iso.sh +++ b/usr/lib/archboot/iso.sh @@ -45,7 +45,7 @@ _prepare_kernel_initramfs_files() { source "${_PRESET}" mkdir -p "${_ISODIR}"/EFI/{BOOT,TOOLS} mkdir -p "${_ISODIR}/boot" - + mkinitcpio -c "/etc/archboot/init.conf" -k "${ALL_kver}" -g "${_ISODIR}/boot/initramfs.img" || exit 1 #shellcheck disable=SC2154 mkinitcpio -c "${MKINITCPIO_CONFIG}" -k "${ALL_kver}" -g "${_ISODIR}/boot/initramfs-${_ARCH}.img" || exit 1 # delete cachedir on archboot environment @@ -76,6 +76,7 @@ _prepare_kernel_initramfs_files_RISCV64() { source "${_PRESET}" mkdir -p "${_ISODIR}"/boot install -m644 "${ALL_kver}" "${_ISODIR}/boot/vmlinuz-${_ARCH}" + mkinitcpio -c "/etc/archboot/init.conf" -k "${ALL_kver}" -g "${_ISODIR}/boot/initramfs.img" || exit 1 mkinitcpio -c "${MKINITCPIO_CONFIG}" -k "${ALL_kver}" -g "${_ISODIR}/boot/initramfs-${_ARCH}.img" || exit 1 } @@ -191,7 +192,7 @@ default linux label linux menu label Boot System (automatic boot in 10 seconds...) kernel /boot/vmlinuz-${_ARCH} - initrd /boot/initramfs-${_ARCH}.img + initrd /boot/initramfs.img append rootfstype=ramfs console=ttyS0,115200 console=tty0 audit=0 ${_SMP} EOF } diff --git a/usr/lib/initcpio/install/archboot_init b/usr/lib/initcpio/install/archboot_init new file mode 100644 index 000000000..13a6772eb --- /dev/null +++ b/usr/lib/initcpio/install/archboot_init @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0-only +# created by Tobias Powalowski + +build() { + map add_module sd_mod? sr_mod? usb_storage? mmc_block? virtio_blk? vfat btrfs + # pata, sata, scsi, nvme + for filter in 'scsi/.*ata' '/(block|scsi|fusion|nvme)/' 'ata/[ps]ata_' \ + 'ata/(ahci|pdc_adma|ata_piix|ata_generic)'; do + add_checked_modules "$filter" + done + # usb + add_checked_modules -f '(_cs|sl811_hcd|isp116x_hcd)' '/usb/host' + add_checked_modules '/drivers/usb/storage/' + # mmc + add_checked_modules '/(drivers/mmc|tifm_)' + # spi (mmc in spi mode) + add_checked_modules '/drivers/spi/' + # virtio + add_checked_modules 'virtio' + add_binary /usr/lib/initcpio/busybox /bin/busybox + for applet in $(/usr/lib/initcpio/busybox --list); do + add_symlink "/usr/bin/$applet" busybox + done + # add kmod with applet symlinks + add_binary kmod + for applet in {dep,ins,rm,ls}mod mod{probe,info}; do + add_symlink "/usr/bin/$applet" kmod + done + map add_binary blkid mount switch_root bsdcpio mkfs.btrfs \ + /usr/lib/systemd/systemd-udevd udevadm systemd-tmpfiles + + map add_udev_rule '50-udev-default.rules' '60-persistent-storage.rules' \ + '64-btrfs.rules' '80-drivers.rules' + + map add_file '/usr/lib/udev/ata_id' '/usr/lib/udev/scsi_id' + add_dir /mnt + add_file "/usr/share/archboot/base/init" "/init" +} + +help() { + cat < +mount -t proc proc /proc -o nosuid,noexec,nodev +mount -t sysfs sys /sys -o nosuid,noexec,nodev +mount -t devtmpfs dev /dev -o mode=0755,nosuid +mount -t tmpfs run /run -o nosuid,nodev,mode=0755 +mkdir -m755 /run/initramfs +if [ -e /sys/firmware/efi ]; then + mount -t efivarfs efivarfs /sys/firmware/efi/efivars -o nosuid,nodev,noexec +fi +kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf +systemd-tmpfiles --prefix=/dev --create --boot +echo "Initializing Archboot Environment:" +echo "Step 1/3: Initializing udev..." +/usr/lib/systemd/systemd-udevd --daemon --resolve-names=never &>/dev/null +udevadm trigger --action=add --type=subsystems +udevadm trigger --action=add --type=devices +udevadm settle +udevadm control --exit +udevadm info --cleanup-db +echo "Step 2/3: Initializing /dev/zram0..." +modprobe zram +echo "zstd" >/sys/block/zram0/comp_algorithm +echo "3500M" > /sys/block/zram0/disksize +mkfs.btrfs /dev/zram0 &>/dev/null +mount /dev/zram0 /new_root &>/dev/null +mount UUID=1234-ABCD /mnt +cd new_root +echo "Step 3/3: Initializing /new_root..." +bsdcpio -i /dev/null +exec switch_root /new_root /init "$@" + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/usr/share/archboot/grub/archboot-main-grub.cfg b/usr/share/archboot/grub/archboot-main-grub.cfg index f7e4370d7..fb703f47c 100644 --- a/usr/share/archboot/grub/archboot-main-grub.cfg +++ b/usr/share/archboot/grub/archboot-main-grub.cfg @@ -65,7 +65,7 @@ if [ ${grub_platform} == "pc" ]; then menuentry "Archboot Arch Linux x86_64 - BIOS Mode" { _menu_running linux /boot/vmlinuz-x86_64 rootfstype=ramfs console=ttyS0,115200 console=tty0 audit=0 - initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-x86_64.img + initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs.img } menuentry "Memory Tester (memtest86+)" { _menu_running @@ -79,7 +79,7 @@ if [ ${grub_platform} == "efi" ]; then menuentry "Archboot Arch Linux x86_64" { _menu_running linux /boot/vmlinuz-x86_64 rootfstype=ramfs console=ttyS0,115200 console=tty0 audit=0 - initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-x86_64.img + initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs.img } _efi_shell elif [ ${grub_cpu} == "arm64" ]; then @@ -87,14 +87,14 @@ if [ ${grub_platform} == "efi" ]; then menuentry "Archboot Arch Linux AA64" { _menu_running linux /boot/Image-aarch64.gz rootfstype=ramfs nr_cpus=1 console=ttyAMA0,115200 console=tty0 loglevel=4 audit=0 - initrd /boot/amd-ucode.img /boot/initramfs-aarch64.img + initrd /boot/amd-ucode.img /boot/initramfs.img } elif [ ${grub_cpu} == "i386" ]; then set default="Archboot Arch Linux x86_64 - EFI MIXED MODE" menuentry "Archboot Arch Linux x86_64 - EFI MIXED MODE" { _menu_running linux /boot/vmlinuz-x86_64 rootfstype=ramfs _IA32_UEFI=1 console=ttyS0,115200 console=tty0 audit=0 - initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-x86_64.img + initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs.img } _efi_shell fi