Advertisement
FocusedWolf

Arch: UEFI bootloader install for dualboot

Jun 3rd, 2024 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.94 KB | None | 0 0
  1. The purpose of these notes is to create a second Linux-only EFI partition and leave the tiny 100 MB Windows EFI partition untouched. With two EFI partitions you have the option to set either Windows or Linux-boot-loader as the default boot option in the bios. Also you can reinstall either OS without issue, and delete/recreate/resize the Linux EFI as needed. You can also set the Windows EFI as the default boot option if you don't want to see the Linux grub screen every boot (and still boot Linux by selecting its entry in your BIOS's "Drive Selection" menu during system startup).
  2.  
  3. NOTE: At this point in the install i have one functioning EFI partition. It is the first partition of the primary drive and just used by Windows. I have a second EFI partition that is blank right now (created earlier when partitioning drives), it is the last partition of a second drive (it is positioned last for situations where i might need to resize it or recreate/delete it if i decide to install another distro).
  4.  
  5. Installing the grub bootloader in the secondary EFI partition (mounted as /boot/efi):
  6.  
  7. $ pacman -S grub efibootmgr os-prober
  8. $ grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Arch --removable
  9.  
  10. Then i configure grub (my preferences, and i have some nvidia settings here so do what works for you):
  11.  
  12. $ vim /etc/default/grub
  13.  
  14. GRUB_DEFAULT=0 <-- Change to 2 (0-based) to select the third item in menu, "Windows Boot Manager".
  15. GRUB_HIDDEN_TIMEOUT=5 <-- Change to 7.
  16. GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet nvidia_drm.modeset=1" <-- For wayland support on Nvidia proprietary drivers add nvidia_drm.modeset=1 (this fixes the issue where all you get is a black screen and a mouse cursor).
  17. GRUB_CMDLINE_LINUX="" <-- Leave this "" because it applies to both normal AND recovery modes: https://askubuntu.com/questions/575651/what-is-the-difference-between-grub-cmdline-linux-and-grub-cmdline-linux-default
  18.  
  19. GRUB_GFXMODE=auto <-- Change "auto" to "1280x720" if you want. If it doesn't work then press 'c' at the grub menu and use the command $ videoinfo to see what resolutions are supported.
  20.  
  21. GRUB_COLOR_NORMAL="red/black"
  22. GRUB_COLOR_HIGHLIGHT="black/red"
  23.  
  24. #GRUB_DISABLE_OS_PROBER=false <-- Uncomment last line. This tells grub to use os-prober to detect other bootable partitions.
  25.  
  26. Generate the main configuration file:
  27.  
  28. $ grub-mkconfig -o /boot/grub/grub.cfg
  29.  
  30. NOTE: [$ os-prober] will not return anything. We need to repeat this step after first reboot to detect windows EFI and add Windows to grub menu.
  31.  
  32. Exiting chroot and restarting or shutting down machine:
  33.  
  34. $ exit or Ctrl+d
  35. $ umount -lR /mnt/ <-- Unmount all partitions.
  36. Remove installation media.
  37. $ reboot
  38.  
  39. Boot up:
  40.  
  41. Login to arch install.
  42. $ sudo grub-mkconfig -o /boot/grub/grub.cfg
  43. Now [$ os-prober] will work and grub-mkconfig output will say "Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi".
  44.  
  45. And then do whatever else you need to do to complete the base install, i.e. connect to internet, config pacman etc.
  46.  
  47. -----
  48.  
  49. Some extra info regarding fstab for this setup:
  50.  
  51. How my /etc/fstab looks (note the two mounted EFI partitions):
  52.  
  53. # Static information about the filesystems.
  54. # See fstab(5) for details.
  55.  
  56. # NOTE: If a drive is a SSD (that supports TRIM) then for SOME filesystems you can add the 'discard' option which causes discard/TRIM commands to be issued to the block device when blocks are free.
  57. # WARNING: Users need to be certain that their SSD supports TRIM before attempting to use it. Data loss can occur otherwise! https://wiki.archlinux.org/title/Solid_state_drive#TRIM
  58. # Instead of 'discard' (continuous TRIM) use in fstab, you can enable the fstrim timer (periodic TRIM) for more efficiency.
  59.  
  60. # <file system> <mount point> <type> <options> <dump> <pass>
  61. UUID=6d3bcf47-8794-4335-b408-7385d219f284 / ext4 defaults,noatime 0 1
  62. UUID=bb944a3b-86fa-41db-80d8-64b8e51ef575 /home ext4 defaults,noatime 0 2
  63. UUID=1AF1-9AF7 /boot/efi vfat defaults,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
  64. UUID=CECF-FFCB /boot/efi-win vfat defaults,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro,nofail,x-systemd.device-timeout=15 0 2
  65.  
  66. # Mount your other drives here...
  67.  
  68. -----
  69.  
  70. fstrim mini-tutorial for SSDs:
  71.  
  72. Setting up fstrim timer:
  73. While you can use the discard option for the swap file on an SSD, using periodic TRIM with fstrim is often recommended to avoid potential performance impacts.
  74. This ensures that the SSD can efficiently manage unused blocks without the overhead of continuous TRIM commands.
  75.  
  76. Check Timer Status:
  77. sudo systemctl status fstrim.timer
  78. sudo systemctl list-timers --all
  79.  
  80. Enable the Timer:
  81. sudo systemctl enable fstrim.timer
  82. sudo systemctl start fstrim.timer
  83.  
  84. When the timer runs, it executes the following command:
  85. fstrim -Av <-- This command trims all mounted filesystems (-A for all) that support trimming, and shows verbose output (-v). You can run this manually to see what drives are trimmed and which are skipped because they don't support trimming.
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement