From a90c8025b24350bcfb987a45589845e2738acc7e Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 3 Jul 2022 02:31:59 +0700 Subject: all: replace grub with systemd-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. --- build-arch-gce | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'build-arch-gce') 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.' -- cgit v1.3