@@ -24,7 +24,7 @@ function main() {
2424 configure_profile
2525 configure_network
2626 configure_user
27- configure_grub
27+ configure_bootloader
2828 configure_ntp
2929 configure_wakeup
3030 # packages
@@ -189,7 +189,6 @@ function install_base() {
189189 base \
190190 base-devel \
191191 efibootmgr \
192- grub \
193192 iwd \
194193 linux \
195194 linux-firmware \
@@ -290,38 +289,77 @@ function configure_user() {
290289 printf " root:%s" " $PASSWORD_USER " | arch-chroot /mnt chpasswd --encrypted
291290}
292291
293- function configure_grub () {
294- echo " ==> Install and configure bootloader ."
292+ function configure_bootloader () {
293+ echo " ==> Install and configure systemd-boot ."
295294
296295 ROOT_UUID=$( blkid -s UUID -o value " $ROOT " )
297296
298- # Configure kernel parameters for LUKS
299- sed -i " s|^GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX=\" cryptdevice=UUID=${ROOT_UUID} :cryptroot root=/dev/mapper/cryptroot\" |" /mnt/etc/default/grub
297+ # Detect CPU microcode
298+ if grep -q AuthenticAMD /proc/cpuinfo; then
299+ MICROCODE=" amd-ucode.img"
300+ elif grep -q GenuineIntel /proc/cpuinfo; then
301+ MICROCODE=" intel-ucode.img"
302+ fi
303+
304+ # Install systemd-boot
305+ arch-chroot /mnt bootctl --path=/boot/efi install & > /dev/null
306+
307+ # Loader configuration
308+ mkdir -p /mnt/boot/efi/loader
309+
310+ cat > /mnt/boot/efi/loader/loader.conf << EOF
311+ default arch
312+ timeout 0
313+ editor no
314+ EOF
315+
316+ # Boot entry
317+ mkdir -p /mnt/boot/efi/loader/entries
300318
301- # Silent boot
302- sed -i ' s/^#GRUB_TIMEOUT=.*/GRUB_TIMEOUT=0/' /mnt/etc/default/grub
303- sed -i ' s/^#GRUB_TIMEOUT_STYLE=.*/GRUB_TIMEOUT_STYLE=hidden/' /mnt/etc/default/grub
304- sed -i ' s/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3"/' /mnt/etc/default/grub
319+ cat > /mnt/boot/efi/loader/entries/arch.conf << EOF
320+ title Arch Linux
321+ linux /vmlinuz-linux
322+ initrd /$MICROCODE
323+ initrd /initramfs-linux.img
324+ options cryptdevice=UUID=${ROOT_UUID} :cryptroot root=/dev/mapper/cryptroot rw quiet loglevel=3
325+ EOF
305326
306- # Enable encrypt hook
327+ # Ensure encrypt hook exists
307328 sed -i ' s/^HOOKS=.*/HOOKS=(base udev autodetect keyboard keymap consolefont modconf block encrypt filesystems fsck)/' /mnt/etc/mkinitcpio.conf
308329
309330 arch-chroot /mnt mkinitcpio -P & > /dev/null
310331
311- # Required temporarily for grub-install with encrypted root
312- echo ' GRUB_ENABLE_CRYPTODISK=y' >> /mnt/etc/default/grub
332+ # echo "==> Install and configure bootloader."
313333
314- arch-chroot /mnt grub-install \
315- --target=x86_64-efi \
316- --efi-directory=/boot/efi \
317- --bootloader-id=GRUB \
318- & > /dev/null
334+ # ROOT_UUID=$(blkid -s UUID -o value "$ROOT")
335+
336+ # # Configure kernel parameters for LUKS
337+ # sed -i "s|^GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX=\"cryptdevice=UUID=${ROOT_UUID}:cryptroot root=/dev/mapper/cryptroot\"|" /mnt/etc/default/grub
338+
339+ # # Silent boot
340+ # sed -i 's/^#GRUB_TIMEOUT=.*/GRUB_TIMEOUT=0/' /mnt/etc/default/grub
341+ # sed -i 's/^#GRUB_TIMEOUT_STYLE=.*/GRUB_TIMEOUT_STYLE=hidden/' /mnt/etc/default/grub
342+ # sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3"/' /mnt/etc/default/grub
343+
344+ # # Enable encrypt hook
345+ # sed -i 's/^HOOKS=.*/HOOKS=(base udev autodetect keyboard keymap consolefont modconf block encrypt filesystems fsck)/' /mnt/etc/mkinitcpio.conf
346+
347+ # arch-chroot /mnt mkinitcpio -P &> /dev/null
348+
349+ # # Required temporarily for grub-install with encrypted root
350+ # echo 'GRUB_ENABLE_CRYPTODISK=y' >> /mnt/etc/default/grub
351+
352+ # arch-chroot /mnt grub-install \
353+ # --target=x86_64-efi \
354+ # --efi-directory=/boot/efi \
355+ # --bootloader-id=GRUB \
356+ # &> /dev/null
319357
320- # Remove it to avoid double password prompt
321- sed -i ' /GRUB_ENABLE_CRYPTODISK/d' /mnt/etc/default/grub
358+ # # Remove it to avoid double password prompt
359+ # sed -i '/GRUB_ENABLE_CRYPTODISK/d' /mnt/etc/default/grub
322360
323- # Generate final config
324- arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg & > /dev/null
361+ # # Generate final config
362+ # arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg &> /dev/null
325363}
326364
327365function configure_ntp() {
0 commit comments