Score:1

Update EFI/grub to dualboot two distribs from single drive with btrfs

sd flag

I'm trying to create dualboot system with openSuse (15.4) and Ubuntu (20.04).

I had Suse installed on a drive /dev/sda with following structure:

/dev/sda
|- /dev/sda1
  |- /boot/efi              (vfat)
|- /dev/sda2
  |- /                      (btrfs subvol @/.snapshots/1/snapshot)
  |- /boot/grub2/x86_64-efi (btrfs subvol @/boot/grub2/x86_64-efi)
  |- /boot/grub2/i386-pc    (btrfs subvol @/boot/grub2/i386-pc)
  |- /home                  (btrfs subvol @/home)
  ...

The idea was to create separate subvol for ubuntu / and share all other subvols like /home

I've created new subvol @/ubuntu-root mounted it to /mnt/ubuntu-root:

|- /dev/sda2
  ...
  |- /mnt/ubuntu-root       (btrfs subvol @/ubuntu-root)

Afer that I debootstrap'd ubutntu into it.

I can successfully chroot into freshly installed ubuntu, but I can't come up with the way to properly update EFI loader and grub.

I'm really new to all grub stuff and all guides are really messy in terms of what comes first and what should be manually updated and what should be generated by what. ALso, and none of them seem to mention EFI.

update-grub mentioned in answers to this question does not exist on Suse, os-prober does not seem to detect ubuntu from Suse thus grub2-mkconfig does not change anything.

Is there some place where All this stuff is concisely explained, or maybe there's a guide that could help me but I can't somehow find on google?

UPD#1: I've installed proper kernel (5.4) and done update-initramfs -c -k 5.4.0-26-generic from chroot. Now, grub-mkconfig from ubuntu chroot generates somewhat proper config for ubuntu with proper menuentries and load targets:

...
menuentry 'Ubuntu' ...
...
linux   /@/ubuntu-root/boot/vmlinuz-5.4.0-26-generic

However, it does not see existing openSuse (obviously, I guess)

As far as I understand there's following order of things happening:

  1. BIOS loads EFI from /dev/sda1 which is /boot/efi/EFI/boot/bootx64.efi
  2. /boot/efi/EFI/boot/bootx64.efi has hardcoded path to /boot/efi/EFI/opensuse/grub.cfg which it tries to load
  3. /boot/efi/EFI/opensuse/grub.cfg has follwoing contents
set btrfs_relative_path="yes"
search --fs-uuid --set=root {UUID}
set prefix=(${root})/boot/grub2
source "${prefix}/grub.cfg"

which I ASSUME mounts default btrfs subvolume from FS on /dev/sda2 and loads next grub config from that subvolume /boot/grub2/grub.cfg that resides on opensuse root subvolume.

I can manually alter that config and insert ubuntu menuentries but those would be on subvolume that is not mounted, since default one is mounted outside that config and before any OS choices

Can I replace grub.cfg on /boot/efi/EFI with one from OS root subvolume? Or there are some tools that should do that for me?!

David avatar
cn flag
Can you not run the Ubuntu install and use the update grub?
maiksaray avatar
sd flag
@David I'm not sure I follow, I'm not installing from external media and to run installer I've just debootstrapped (it's installer, not the OS, right?) I need to somehow tell EFI/grub to load it first, no?
David avatar
cn flag
From you question "freshly installed ubuntu" You say Ubuntu is installed.
maiksaray avatar
sd flag
I just did `debootstrap focal /mnt/ubuntu-root` and now I'm not sure if it's a complete installation or just basic components...
David avatar
cn flag
I do not think you installed Ubuntu at all. Maybe follow a tutorial on how to install Ubuntu will help?
David avatar
cn flag
From this description I do not see how this works with Ubuntu. Ubuntu is not Debian. debootstrap is a tool which will install a Debian base system into a subdirectory of another, already installed system. It doesn't require an installation CD, just access to a Debian repository.
maiksaray avatar
sd flag
@David But it did install ubuntu... after chroot: #cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 And I got there by following a tutorial on how to install ubuntu. It just stopped making sense for my case once it got to grub/EFI part
guiverc avatar
cn flag
FYI: Sharing a $HOME between two OSes can be problematic don't forget; esp. when the age of the software stacks (*thus program versions*) varies; 20.04 is the 2020-April release thus is somewhat old; Leap 15.4 isn't! So I hope you've done your homework on the apps where data is important to you. I have no issues in Ubuntu grub detecting OpenSuSE leap/tumbleweed, Fedora, Debian etc. but *fs* does matter & it's more complex with BTRFS on Ubuntu as it's not a default install type (ps: my OpenSuSE detects Ubuntu so why not OpenSuSE control booting). Either way what you're doing I think unwise
maiksaray avatar
sd flag
@guiverc Thanks for the warning. I'm aware of the possible software issues and thoughht about ubuntu 22.04 but debootstrap couldn't process it properly so I had to fallback to 20.04 and possibly upgrade later.
Joepie Es avatar
eg flag
'/boot/efi/EFI/opensuse/grub.cfg has following contents.' etc. Try change the line 'source "${prefix}/grub.cfg" ' to 'source "${prefix}/boot/grub.cfg" '. As your grub.cfg lives in the /boot-folder.
maiksaray avatar
sd flag
@JoepieEs `set prefix=(${root})/boot/grub2` which means that $prefix already has /boot part
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.