archlinux / archinstall

Arch Linux installer - guided, templates etc.
GNU General Public License v3.0
6.2k stars 538 forks source link

Grub Installer should use `/boot/efi` #1189

Open neo-sam opened 2 years ago

neo-sam commented 2 years ago

Problem

--efi-directory=/boot should be --efi-directory=/boot/efi

https://github.com/archlinux/archinstall/blob/2316f5416438e11f65e007d7e411894c307391d9/archinstall/lib/installer.py#L837

My Env

manually format, mount, and install into /mnt/archinstall

Disk Layout: EFI + /boot + dm-crypt(single btrfs parition as root)

Install Command: archinstall --script swiss --mode only_os

Torxed commented 2 years ago

This is one of our goals, to support https://github.com/archlinux/archinstall/issues/1072. However, it would require quite of a lot of testing so it doesn't break setups some where. And if that is the case, we'll need to support both options which is a bit of a PITA.

I'll keep this issue open as it's more towards Grub, and the other systemd-boot. But the concept is the same. So we'll track GRUB here, and systemd-boot there.

LorenzoBettini commented 2 years ago

Maybe that's related to the problem I'm having (or maybe it's just the same): after experimenting with archinstall with VMs (thus, wiping all the disk), I tried to install that on my computer where I already have a few Linux distros (Fedora, EndeavourOS, Ubuntu).

Thus I created a new partition mounting that as "/" and mounting the existing ESP partition as "/boot/efi". But the installation fails when configuring GRUB with

Could not detect root ... or boot (None) in /mnt/archinstall based on...

I tried by creating a separate small ext4 partition mounting that as "/boot", and mounting the existing ESP partition as "/efi", but the installation fails with

Could not install GRUB to /mnt/archinstall/boot: 
['/usr/bin/arch-chroot', '/mnt/archinstall', 'grub-install', '--debug', 
'--target=x86_64-efi', '--efi-directory=/boot', '--bootloader-id=GRUB', '--removable'] 
exited with abnormal exit code [256]: ... 
grub-install: error: /boot doesn't look like an EFI partition.

The only solution that ends with success is mounting the existing ESP partition as "/boot" (besides having the new partition mounted as "/"). However, on booting, no Arch entry is available, and I guess that's because EFI entries were already in place by existing Linux installations (which all rely on the "/boot/efi" mount point). In fact, Arch installed everything starting from the root of the ESP partition (mounted as "/boot") not in the "EFI" subdirectory, as done by other distributions.

This is the resulting tree (where I highlighted things generated by archinstall)

/boot/efi
├── Boot
...
├── bootmgr
├── BOOTNXT
├── EFI
│   ├── Boot
...
│   ├── endeavouros-1510
│   │   └── grubx64.efi
│   ├── fedora
│   │   ├── grub.cfg
...
│   ├── Microsoft
│   │   ├── Boot
...
│   └── ubuntu
│       ├── BOOTX64.CSV
│       ├── grub.cfg
│       ├── grubx64.efi
│       ├── mmx64.efi
│       └── shimx64.efi
├── grub *** ARCH ***
│   ├── fonts
│   │   └── unicode.pf2
│   ├── grub.cfg *** ARCH ***
│   ├── grubenv
│   ├── locale
...
│   ├── themes
...
│   └── x86_64-efi
...
├── initramfs-linux-fallback.img  *** ARCH ***
├── initramfs-linux.img  *** ARCH ***
├── intel-ucode.img
├── mach_kernel
├── System
│   └── Library
│       └── CoreServices
│           └── SystemVersion.plist
├── System Volume Information
└── vmlinuz-linux  *** ARCH ***

So I guess that for the moment I could only try an existing distribution grub configuration to try booting the Arch grub.cfg with an entry with a proper "configfile"?

Or are there any other ways to succeed?

thanks in advance

Torxed commented 2 years ago

Currently archinstall is pretty dumb when it comes to "detecting" /boot or in your case /efi. All archinstall does currently is to make sure a partition is mounted at /mnt/archinstall and is found by findmnt /mnt/archinstall. It then looks through your partition definition given by --disk-layout (come to think of it, this is true for / as well) and it tries to locate specifically /boot in the JSON structure. We need more generic handling of these two partitions in order to support a "/boot" (could be just a folder under a physically mounted /) and a separate location for /efi as well as tweak the bootloader code to use these changes.

LorenzoBettini commented 2 years ago

@Torxed as I said above, archinstall also wants /boot to be an ESP partition (see my attempts above). it is happy only if /boot corresponds to an ESP partition, for the moment, I seem to understand.

However, as a follow-up of my experiments, I chose the working solution (mount the ESP as /boot) and then I managed to have Fedora boot the Arch installation by editing Fedora's /etc/grub.d/40_custom and adding the entry

menuentry "Arch" {
        insmod part_gpt
        insmod btrfs
        insmod ext2
        rmmod tpm
        set root='hd0,gpt13'
        configfile (hd0,gpt1)/grub/grub.cfg
}

where gpt13 is the root of Arch, and gpt1 is the ESP partition, where archinstall put the grub.cfg (in the subdirectory grub), the initramfs-linux.img and vmlinuz-linux).

Thus, for the moment I'm settled! ;)

LorenzoBettini commented 2 years ago

Sorry for pinging, but is there any progress on this? This is a blocker for multi-distro installations...

Strit commented 1 year ago

I love this tool.

I would also like to point out that with the current default setup for UEFI and BTRFS selections, the ESP partition is mounted as /boot, where it dumps all the kernel images and grub files etc too. This makes restoring a btrfs snapshot often not work, since the kernel image is on a vfat filesystem and thus not included in the snapshot, resulting in incorrect versions between kernel image and kernel modules.

Having the ESP partition mounted at /boot/efi or /efi instead, would make all kernel files be on a BTRFS subvolume and thus included in the snapshots.

LorenzoBettini commented 6 months ago

Are there any news on this?