#[solved] multiple arch installs-same kernel, how to populate grub?

121 messages · Page 1 of 1 (latest)

jolly vortex
#

I have two different arch installs using two different filesystems both with the mainline kernel installed. Is there anyway to populate grub with different options for booting?

spare plank
#

is it not as simple as os-prober

jolly vortex
#

I assumed that was just for windows but that is a stupid assumption

spare plank
#

you could also manually make an entry

jolly vortex
#

Nope windows works so this is odd, and it’s in fstab

#

Forgot to mount windows efi, lol, silly me!

jolly vortex
#

For some reason when I start arch now on btrfs it’s super super slow, any idea why? I’m stuck on:
Starting version 251.4-1-arch

For so long until it lets me log in as cli, or now that I have gdm installed and enabled loads that

jolly vortex
#

I manually added my swap to the fstab and messed up the uuid-lol

jolly vortex
#

Hmmm, so far os prober has not been the solution, I’m gonna need to nuke grub and reinstall it :/

#

Yeah when I try to load my ext4 grub gives me this:

#

it is obviously in there but I assume it's got like a system link to the btrfs install

#

basically both my btrfs arch and my ext4 arch each want to make their own /boot/initramfs-linux.img by the looks of things

#

is it that I just can't use the mainline kernel on both, or else use seperate efi partitions to boot them?

jolly vortex
#

I was joking Nhail, I don't expect you to solve this 😂

drifting laurel
#

Have you tried the solution you gave me?

#

I guess with multiple installs it wouldn't necessarily apply

jolly vortex
drifting laurel
#

You installed it across both? Like a sort of RAID setup?

jolly vortex
#

both have the same EFI partition

#

it's not RAID

#

they're seperate OS's

drifting laurel
#

Ah, okay

#

Yeah no real experience with dual boots, sorry

jolly vortex
#

as I said I was kidding, though it's technically a tri-boot as I do have a windows partition

#

@deft dome hope you don't mind the ping, I believe you have a silly kernel name, I wondered if that might be the solution here?

lethal knot
#

.aw grub

coral girderBOT
lethal knot
#

lemme check this

jolly vortex
#

I thought you meant for me 😂

fading robin
#

u dont have to mount the efi parts for grub-mkconfig to find them

jolly vortex
#

I nuked /boot and made /boot/efi on both ext4 and btrfs, and then reinstalled arch there once, and reinstalled the kernel and the intel-ucode on both, then ran grub-mkconfig from the btrfs arch, at first it only showed btrfs arch, but now it seems to show both. I'm not really sure why.
It's now not showing all of my snapshots, and I want to see if I can get it to select the last grub selection, not sure if that'll be possible or not, given that fat can't write to btrfs, which does a new mkconfig every time I install a package.

Not sure if I would need to reinstall it once more, but from the ext4 partition instead, to get that working?
For now I'll call it a night, not fully resolved.

Also curious some boots it seems to have my keys set to UK, others it doesn't (only on btrfs, ext4 never gets my keys right on boot so far)

I can tell which one is which as one is called btrfsarch and one is called ext4arch, and the usernames correspond like that as well XD

Thanks for your help so far @spare plank and @fading robin

shell valleyBOT
#

fishie, and deezinit received a thank you cookie!

deft dome
jolly vortex
jolly vortex
#

I'm wondering if I can get my grub mkconfigs made from my btrfs to save to my ext4, in the hopes of being able to recall the previous entry

deft dome
#

yes

#

just install grub with the ext4 arch install as the root

jolly vortex
deft dome
#

if you mean grub-btrfs then it probably wont

jolly vortex
#

:/

jolly vortex
#

so the main question there now is can my ext4 ever see the btrfs snapshots so that they can be included in the makeconfig

jolly vortex
#

so if I mount my @snapshots subvolume, mkconfig on ext4 won't find the root (perhaps because both have the same UUID and it's from EXT4? but if I unmount the @snapshots partitions then it can find the btrfs root at least, but no way of, so far, finding the btrfs root and the snapshots from doing a mkconfig on ext4

#

But nope, now btrfs won’t load. Guess I’ll try reinstalling grub again.

deft dome
# jolly vortex

did you manually make that entry?
cus that should be relative to the id5 subvol

#

and you should also add a rootflag that specifies the subvol to be used as root

jolly vortex
#

I haven’t manually touched the cfg at all

deft dome
#

L for grub for not being able to generate a correct config then

jolly vortex
#

Hoping I can eventually get everything setup manually

#

I’m not convinced it’s not a skill issue on my part

jolly vortex
deft dome
#

yes
or one of your snapshots

jolly vortex
#

so this is what I've got for my fstab entry to mount the btrfs when I boot up ext4:



UUID=cd6bf273-37c9-4a0b-84e7-bdd383d32d74    /mnt/btrfs/rootsys    btrfs         rw,relatime,compress=lzo,ssd,space_cache=v2,subvolid=256,subvol=/@    0 0```
#

I'm wondering if it's the / that's the problem?

#

I'll remove that and mount manually and see if that helps

deft dome
#

no the problem is the path for the kernel and initrd and because it doesnt have a rootflags for the root subvol also

#

@ is on toplevel right?

jolly vortex
#

yes

deft dome
#

same with the initrd

#

you would also need rootflags=subvol=@ in the kernel cmdline

jolly vortex
#

would that mean that every kernel update I'd need to manually change the kernel cmdline?

deft dome
#

no

#

the only time you would want to change it is when you want to boot into a snapshot

jolly vortex
#

also what you're proposing is completely outside of my knowledge so I'm a bit lost on how to do any of that :p

deft dome
jolly vortex
#

I'm very much outside of my knowledge zone :p

jolly vortex
# deft dome but in that case youre better off making another entry

if I'm doing that I just do this:

mount /dev/sdb2 /mnt
nano /mnt/@snapshots/*/info.xml
#Find snapshot you want, go between files by using alt + , and alt + .
#when you have the snapshot you want, remember the number.
#for every file open do:
ctrl + x

rm -rf /mnt/@

btrfs subvol snapshot /mnt/@snapshots/<number>/snapshot /mnt/@
#

I'll have a google of how to change the kenrel cmdline I guess

deft dome
jolly vortex
#

do you mean grub_cmdline_linux_default when you say the kernel command line?

#

as in, in /etc/default/grub

deft dome
#

next to the path of the kernel

jolly vortex
#

oh manually changing the .cfg

#

will I need to change that every mkconfig?

#

just makiny a test .cfg in my documents to play with I guess XD

deft dome
# deft dome aye that's what i used to do but you dont really need an iso

you can just

sudo mv /mnt/@ /mnt/borked
sudo btrfs su sn /mnt/snapshot/thesnapshot /mnt/@```
then reboot

if you use the esp on /boot you will need to do an extra step which is mounting the esp on /mnt/@/boot (this is after the switch)
then arch-chroot /mnt/@ pacman -S linux

then just reboot and delete the old borked subvol
deft dome
jolly vortex
#

I'll have to read about that later, as I'm messing with grub for now

#

this is all a valuable learning experience for me though

#

I might try refind and systemd-boot later

jolly vortex
#

Yeah this is shockingly different

#

on the left is my mkconfig generated from ext4

On the right is my mkconfig generated from btrfs

jolly vortex
#

yeah copying a chunk from the btrfs generated mkconfig to the ext4 mkconfig has allowed grub to load btrfs, which is useful, I just wish I could make the ext4 generate it correctly, and also pick up on snapshots, and also have the btrfs mkconfig write correctly but preserve the mkconfig to the /mnt/ext4/boot/grub/grub.cfg

fading robin
#

have u considered swapping the roles and setting up grub from the btrfs partition?

jolly vortex
#

My solution thus far has been:
Install grub using ext4 as root.
Then from the snap-pac-grub aur package, edit this file it makes:

sudoedit /usr/share/libalpm/scripts/grub-mkconfig
I've changed the grub-mkconfig to be /mnt/ext4/boot/grub/grub.cfg instead of the normal /boot/grub/grub.cfg

And always do the grub-mkconfig as such from btrfs

fading robin
jolly vortex
#

never making the grub-mkconfig from ext4

jolly vortex
# fading robin can grub-customizer not set that for u??

the traditional way of doing it is editing /etc/default/grub, I've edited both the ext4 file and the btrfs file, but I can't do that, the issue is on btrfs you can't have it done, I'll get the relevant part of the wiki page

jolly vortex
#

those two lines explain why:
This will only work if /boot is not a btrfs, because grub cannot write to btrfs. But it will generate a misleading error message: "sparse file not allowed. Press any key to continue.".

#

I'm wondering if that simply won't be possible at all due to this setup, I don't understand enough

fading robin
#

do u actually get that error tho? i have /boot on btrfs and grub works fine?

fading robin
jolly vortex
#

it's not

#

but this also isn't the standard use case

fading robin
#

yea

jolly vortex
#

given that the mkconfig is on ext4 I think it should work, but instead of getting the "sparse file not allowed" I'm just not getting any change behaviour

#

it will be nice when grub can write to btrfs, as that'll solve all of this headache :p

#

this is very much just a nice to have QoL as well

#

not a "I'm throwing everything out"

#

it is interesting that grub on ext4 is seemingly incapable of automatically making a correct config for btrfs subvolumes

#

Oh it works fine I just forgot to redo mkconfig from btrfs

#

Hahaha

#

Beautiful

#

Will rewrite the solution at the bottom and mark as solved soon

fading robin
#

awesome :)

jolly vortex
#

Solution: In order to be able to have the grub menu work, and be able to use grub tricks, the following must be done:

1) mount ext4 to /mnt and the EFI partition to mnt/boot/efi (you'll need to create that directory), then chroot in
2) do grub-install
3) install the kernel and ucode in ext4
4) exit
5) umount EFI and ext4 root
6) mount btrfs (in most cases it'll start mount -o subvol=@ /dev/<insert here> /mnt) and then the EFI partition same as above mnt/boot/efi (will need to mkdir again), and mount the ext4 onto /mnt/mnt/<any further mountpoint you choose to make)
7) install the kernel and ucode
8) do the mkconfig from btrfs, but do it to /<where ext4 is mounted>/boot/grub/grub.cfg
9) exit, reboot into the live system, and install the packages you want.

If that includes a package that does the mkconfig on every package installed, as I have a snapshot made every time I install, uninstall and update, then you'll want to edit a file, in my case I used the package from the aur: `snap-pac-grub'. I found out which file by doing `pacman -Ql snap-pac-grub` and realised the file I wanted was:
/usr/share/libalpm/scripts/grub-mkconfig
I edited that so that the mkconfig changed from:
/boot/grub/grub.cfg
To:
/mnt/ext4/boot/grub/grub.cfg

Finally I wanted it to select the last selected boot entry when I used grub, so I did the standard change to:
/etc/default/grub
so that the top now reads:
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

And then installed a package as that would automatically create a new grub-mkconfig.

That behaviour wouldn't work if I was writing to my btrfs partition, but instead as grub was installed from ext4 it is writing to ext4, so this can work. If I were to do a new mkconfig then the last selected option is wiped, and it goes to the top option, but if I'm doing a mkconfig it's from btrfs anyway, so it is correct by accident!```
#

If any of the above doesn't make sense to anyway and you want an explanation, please let me know

#

and to clarify:
pacman -Ql <package> shows you the files that a package owns, which is why that was useful, as snap-pac-grub automates a new grub-mkconfig with every update, install and uninstall from pacman.

#

[solved] multiple arch installs-same kernel, how to populate grub?

jolly vortex
#

@compact minnow when you run grub-mkconfig and os-prober picking up btrfs as a secondary OS it seems unable to create the correct .cfg entry for btrfs, you have to actually be in btrfs. If you have multiple Linux OSes that are btrfs then you seemingly need to manually change the .cfg, but if you are running it like o do that means a manual cfg change every time you do an update, uninstall or install a new package