diff options
| author | Shulhan <ms@kilabit.info> | 2022-07-03 02:31:59 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-07-03 03:10:02 +0700 |
| commit | a90c8025b24350bcfb987a45589845e2738acc7e (patch) | |
| tree | 1ac73ffc46c6d2c34b6d7708c1f5b5c4c3b7afd3 | |
| parent | 1b0aa63a8af32bf9e8a86a2dc028c38d751bad91 (diff) | |
| download | compute-archlinux-image-builder-systemd-boot.tar.xz | |
all: replace grub with systemd-bootsystemd-boot
Now that we use UEFI based partition, we can replace the grub with
systemd-boot.
This option have several advantages,
- minimize installed package and dependencies
- allow future customization (e.g. automounting, secure boot)
The pacman hook 00-systemd-boot is required to re-install the systemd
boot loader automatically when package systemd updated.
| -rw-r--r-- | README.md | 2 | ||||
| -rwxr-xr-x | build-arch-gce | 42 |
2 files changed, 30 insertions, 14 deletions
@@ -9,7 +9,7 @@ installation, while still allowing it to be fully functional and optimized for Compute Engine. Notable choices made and differences compared to a standard Arch Linux installation are the following: -- GRUB is used with a UEFI-based boot and a GPT partition table. +- systemd-boot is used with UEFI-based boot and a GPT partition table. - Serial console logging is enabled from kernel command line and journald is configured to forward to it. - Block multiqueue is configured from the kernel command line to optimize diff --git a/build-arch-gce b/build-arch-gce index d92bdcf..6884880 100755 --- a/build-arch-gce +++ b/build-arch-gce @@ -59,8 +59,8 @@ mkdir -- "$mount_dir" mount -- "$root_dev" "$mount_dir" echo '- Mounting the EFI partition.' -mkdir -- "$mount_dir/efi" -mount -- "$efi_dev" "$mount_dir/efi" +mkdir -- "$mount_dir/boot" +mount -- "$efi_dev" "$mount_dir/boot" echo '- Installing Arch Linux.' append_gce_repo() { @@ -76,7 +76,7 @@ append_gce_repo() { cp /etc/pacman.conf "$work_dir" append_gce_repo "$work_dir/pacman.conf" pacstrap -G -M -C "$work_dir/pacman.conf" -- "$mount_dir" \ - base linux grub dosfstools e2fsprogs dhclient openssh sudo google-compute-engine + base linux dosfstools e2fsprogs dhclient openssh sudo google-compute-engine append_gce_repo "$mount_dir/etc/pacman.conf" echo '- Configuring fstab.' @@ -91,7 +91,7 @@ print_fstab() { } >> "$mount_dir/etc/fstab" { print_fstab root "$root_uuid" / ext4 rw,discard,errors=remount-ro,x-systemd.growfs 0 1 - print_fstab efi "$efi_uuid" /efi vfat uid=root,gid=root,umask=022,showexec 0 0 + print_fstab efi "$efi_uuid" /boot vfat uid=root,gid=root,umask=022,showexec 0 0 } echo '- Running additional setup in chroot.' @@ -175,16 +175,32 @@ arch-chroot -- "$mount_dir" /bin/bash -s <<-'EOS' rm /boot/initramfs-linux-fallback.img mkinitcpio --nocolor --preset linux - echo '-- Configuring grub.' - grub-install --target=x86_64-efi --efi-directory=/efi --no-nvram --removable - cat <<-'EOF' > /etc/default/grub - # GRUB boot loader configuration - GRUB_CMDLINE_LINUX="console=ttyS0,38400n8 net.ifnames=0 scsi_mod.use_blk_mq=Y" - GRUB_PRELOAD_MODULES="part_gpt" - GRUB_TIMEOUT=0 - GRUB_DISABLE_RECOVERY=true + echo '-- Running boot loader.' + bootctl install --no-variables --quiet + + echo '-- Configuring boot loader.' + cat <<-'EOF' > /boot/loader/loader.conf + default arch.conf + editor no + EOF + cat <<-'EOF' > /boot/loader/entries/arch.conf + title Arch Linux + linux /vmlinuz-linux + initrd /initramfs-linux.img + options rw console=ttyS0,38400n8 net.ifnames=0 scsi_mod.use_blk_mq=Y + EOF + mkdir -p -- "/etc/pacman.d/hooks" + cat <<-'EOF' > /etc/pacman.d/hooks/00-systemd-boot.hook + [Trigger] + Type = Package + Operation = Upgrade + Target = systemd + + [Action] + Description = Gracefully upgrading systemd-boot... + When = PostTransaction + Exec = /usr/bin/systemctl restart systemd-boot-update.service EOF - grub-mkconfig -o /boot/grub/grub.cfg EOS echo '- Cleaning up and finalizing the image.' |
