Changing Grub Default Boot - [ Solved ]

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
User avatar
Pjotr
Level 22
Level 22
Posts: 15553
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Changing Grub Default Boot - [ Solved ]

Post by Pjotr »

AZgl1500 wrote:
Fri Aug 03, 2018 10:25 am
OMG,
"only" added 377 lines of code to do what Grub does in a precious few at most.

My two line fix seems to be a bit simpler :)
Indeed. As this problem (changing the dominant Grub) is not uncommon, I've put the fix how-to on my website:
https://sites.google.com/site/easylinux ... -one-Linux
(item 6, left column)

For future reference. :)
Tip: 10 things to do after installing Linux Mint 20 Ulyana
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
rui no onna
Level 4
Level 4
Posts: 241
Joined: Thu Jul 19, 2018 4:18 pm

Re: Changing Grub Default Boot - [ Solved ]

Post by rui no onna »

Pjotr wrote:
Fri Aug 03, 2018 1:38 pm
As this problem (changing the dominant Grub) is not uncommon, I've put the fix how-to on my website:
https://sites.google.com/site/easylinux ... -one-Linux
(item 6, left column)

For future reference. :)
Maybe just add a footnote/fine print, this solution doesn't work with Btrfs subvolumes. Most normal people would probably stick to ext4 but apparently, I'm a masochist. :D

I couldn't get auto-detection working even after changing /etc/default/grub. For Btrfs, I've had to manually add multiboot entries to /etc/grub.d/40_custom. Incidentally, this also solves the issue of Arch needing dominant grub.

e.g.

Code: Select all

menuentry 'Linux Mint 19 Cinnamon 64-bit' {
    insmod part_gpt
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 01234567-89ab-cdef-0123-456789abcdef
    configfile /@mint19/boot/grub/grub.cfg
}

menuentry 'Manjaro KDE 17.1.11' {
    insmod part_gpt
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 01234567-89ab-cdef-0123-456789abcdef
    configfile /@manjaro/boot/grub/grub.cfg
}

menuentry 'Linux Mint 18.3 Cinnamon 64-bit Snapshot 2018-07-31' {
    insmod part_gpt
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 01234567-89ab-cdef-0123-456789abcdef
    configfile /@mint18_180731/boot/grub/grub.cfg
}

menuentry 'ISO: Linux Mint 18.3 Cinnamon 64-bit' {
    set isofile="/linuxmint-18.3-cinnamon-64bit.iso"
    loopback loop (hd0,5)$isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject toram
    initrd (loop)/casper/initrd.lz
}
User avatar
Pjotr
Level 22
Level 22
Posts: 15553
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Changing Grub Default Boot - [ Solved ]

Post by Pjotr »

rui no onna wrote:
Fri Aug 03, 2018 3:52 pm
Pjotr wrote:
Fri Aug 03, 2018 1:38 pm
As this problem (changing the dominant Grub) is not uncommon, I've put the fix how-to on my website:
https://sites.google.com/site/easylinux ... -one-Linux
(item 6, left column)

For future reference. :)
Maybe just add a footnote/fine print, this solution doesn't work with Btrfs subvolumes. Most normal people would probably stick to ext4 but apparently, I'm a masochist. :D

I couldn't get auto-detection working even after changing /etc/default/grub. For Btrfs, I've had to manually add multiboot entries to /etc/grub.d/40_custom. Incidentally, this also solves the issue of Arch needing dominant grub.

e.g.

Code: Select all

menuentry 'Linux Mint 19 Cinnamon 64-bit' {
    insmod part_gpt
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 01234567-89ab-cdef-0123-456789abcdef
    configfile /@mint19/boot/grub/grub.cfg
}

menuentry 'Manjaro KDE 17.1.11' {
    insmod part_gpt
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 01234567-89ab-cdef-0123-456789abcdef
    configfile /@manjaro/boot/grub/grub.cfg
}

menuentry 'Linux Mint 18.3 Cinnamon 64-bit Snapshot 2018-07-31' {
    insmod part_gpt
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 01234567-89ab-cdef-0123-456789abcdef
    configfile /@mint18_180731/boot/grub/grub.cfg
}

menuentry 'ISO: Linux Mint 18.3 Cinnamon 64-bit' {
    set isofile="/linuxmint-18.3-cinnamon-64bit.iso"
    loopback loop (hd0,5)$isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject toram
    initrd (loop)/casper/initrd.lz
}
Cool! Thanks for the warning about BTRFS. :)
Tip: 10 things to do after installing Linux Mint 20 Ulyana
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
User avatar
jimallyn
Level 18
Level 18
Posts: 8955
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Changing Grub Default Boot

Post by jimallyn »

Valsodar wrote:
Fri Aug 03, 2018 7:12 am
Bottom line: there's no way this guy could convince me GC screws things up, especially without giving any concrete evidence for that.
The concrete evidence can be found, among other places, on my home desktop computer, which I have had to boot from a SuperGrub2 disc since November 25, 2017. I posted about my experiences here:

viewtopic.php?f=46&t=257778

Note that I titled the thread, "How does one recover from having used Grub Customizer?" I still don't have an answer to that question. I expect I will be fully recovered from it when I install Mint 19 one day soon.

You're free to do whatever you like with your computers, but I will never use Grub Customizer again, and I will recommend to others that they NOT use it.
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
User avatar
Valsodar
Level 4
Level 4
Posts: 228
Joined: Thu Jul 19, 2018 11:30 pm
Location: Sofia, Bulgaria
Contact:

Re: Changing Grub Default Boot

Post by Valsodar »

jimallyn wrote:
Fri Aug 03, 2018 6:03 pm
I still don't have an answer to that question.
What would be the problem to run a live USB or CD, manually delete everything related to grub as root and then rebuild grub also manually using the terminal?

Just because you had a negative experience once, that doesn't mean the program sucks. In every case I had a corrupted/lost grub for whatever reason, every time GC came to the rescue and fixed things for me. Ofc, I can do it manually too but why bothering when GC does the same with a few clicks? Well, one, actually, but I like to remove all the unnecessary elements first. So, unlike you, I will continue to recommend it with the footnote that GC works only with legacy grub but not with Grub2 which makes it useless for customizing grub of Manjaro, for instance.
AsRock B85M Pro4, Core i7-4770, Palit GTX 1050 Ti 4GB, Corsair CX750 PSU, Corsair 32GB DDR3-1600, Corsair Force LE 120GB, 2xSSD = 610 GB, 1xHDD = 1TB, Waterfox-Current, (rolling) Arch Cinnamon
User avatar
MrEen
Level 21
Level 21
Posts: 13267
Joined: Mon Jun 12, 2017 8:39 pm

Re: Changing Grub Default Boot

Post by MrEen »

Valsodar wrote:
Fri Aug 03, 2018 6:15 pm

What would be the problem to run a live USB or CD, manually delete everything related to grub as root and then rebuild grub also manually using the terminal?
Why not avoid the risk in the first place and learn (via this forum or elsewhere) the (most often 1 or 2 lines) commands needed for the intended purpose?
User avatar
Valsodar
Level 4
Level 4
Posts: 228
Joined: Thu Jul 19, 2018 11:30 pm
Location: Sofia, Bulgaria
Contact:

Re: Changing Grub Default Boot

Post by Valsodar »

MrEen wrote:
Fri Aug 03, 2018 6:38 pm
Why not avoid the risk in the first place and learn (via this forum or elsewhere) the (most often 1 or 2 lines) commands needed for the intended purpose?
I already know these commands and they're not just one or two lines nor they're simple to remember.

Code: Select all

1. sudo mount /dev/sdXY /mnt
2. sudo mount --bind /dev /mnt/dev
3. sudo mount --bind /dev/pts /mnt/dev/pts
4. sudo mount --bind /proc /mnt/proc
5. sudo mount --bind /sys /mnt/sys
6. sudo chroot /mnt
7. grub-install /dev/sdX
8. update-grub
9. exit
10. sudo umount /mnt/sys
11. sudo umount /mnt/proc
12. sudo umount /mnt/dev/pts
13. sudo umount /mnt/dev
14. sudo umount /mnt
AsRock B85M Pro4, Core i7-4770, Palit GTX 1050 Ti 4GB, Corsair CX750 PSU, Corsair 32GB DDR3-1600, Corsair Force LE 120GB, 2xSSD = 610 GB, 1xHDD = 1TB, Waterfox-Current, (rolling) Arch Cinnamon
rui no onna
Level 4
Level 4
Posts: 241
Joined: Thu Jul 19, 2018 4:18 pm

Re: Changing Grub Default Boot

Post by rui no onna »

Valsodar wrote:
Fri Aug 03, 2018 8:16 pm
MrEen wrote:
Fri Aug 03, 2018 6:38 pm
Why not avoid the risk in the first place and learn (via this forum or elsewhere) the (most often 1 or 2 lines) commands needed for the intended purpose?
I already know these commands and they're not just one or two lines nor they're simple to remember.

Code: Select all

1. sudo mount /dev/sdXY /mnt
2. sudo mount --bind /dev /mnt/dev
3. sudo mount --bind /dev/pts /mnt/dev/pts
4. sudo mount --bind /proc /mnt/proc
5. sudo mount --bind /sys /mnt/sys
6. sudo chroot /mnt
7. grub-install /dev/sdX
8. update-grub
9. exit
10. sudo umount /mnt/sys
11. sudo umount /mnt/proc
12. sudo umount /mnt/dev/pts
13. sudo umount /mnt/dev
14. sudo umount /mnt
That's one option if one's gonna do it via Live CD/USB or while booted to a different install. I'm not sure grub-install works under chroot, though.

If one can boot into the desired default system, it's as simple as boot into default system then:

Code: Select all

sudo update-grub
sudo grub-install
Alternately,
1. While booted into Live CD:

Code: Select all

sudo mount /dev/sdXY /mnt
sudo grub-install --root-directory=/mnt /dev/sdX
sudo umount /mnt
2. Then restart, booting into default system:

Code: Select all

sudo update-grub
Mind, I did try installing grub-customizer on my system and tried to add an ISO boot. Didn't seem to have changed my /etc/grub.d or /etc/default/grub files much (minor change in 40_custom) but it did give me an error. Easily fixable but I think I'll restore from snapshot from before adding the ppa anyway. Gotta say, Btrfs is so convenient for playing around. :D
grub-customizer.png
User avatar
Valsodar
Level 4
Level 4
Posts: 228
Joined: Thu Jul 19, 2018 11:30 pm
Location: Sofia, Bulgaria
Contact:

Re: Changing Grub Default Boot

Post by Valsodar »

rui no onna wrote:
Fri Aug 03, 2018 9:40 pm
That's one option if one's gonna do it via Live CD/USB or while booted to a different install. I'm not sure grub-install works under chroot, though.

Mind, I did try installing grub-customizer on my system and tried to add an ISO boot.
It works but you have to boot the live env of the OS whose grub you're gonna rebuild. If the installed OS is Mint, you must boot a live Mint. Mint 16 can restore grub for Mint 18 and vice versa, so the version doesn't matter much (unless the difference is ancient).

What's an "ISO boot"?

I can't see the rest of your OSes but I suspect this error is because of Souparo (Manjaro, actually, I just call it like that because it's a soup of codes, not an OS). That thing uses grub2 on the chosen device's MBR, so whatever GC tries to do, grub2 negates it, hence the errors. I tried that recently - triple boot of Windows 7, Mint and Souparo Cinnamon. The latter occupied the MBR of its storage device and it seems the computer's BIOS/UEFI prioritizes the MBR before any local grub. Naturally the Soup didn't run and all I could see was rescue mode and my MBR was so screwed up that I had to boot Windows from the other SD and use a program in it to rebuild the MBR, so that I can actually boot the Soup and Mint.
AsRock B85M Pro4, Core i7-4770, Palit GTX 1050 Ti 4GB, Corsair CX750 PSU, Corsair 32GB DDR3-1600, Corsair Force LE 120GB, 2xSSD = 610 GB, 1xHDD = 1TB, Waterfox-Current, (rolling) Arch Cinnamon
rui no onna
Level 4
Level 4
Posts: 241
Joined: Thu Jul 19, 2018 4:18 pm

Re: Changing Grub Default Boot

Post by rui no onna »

Valsodar wrote:
Sat Aug 04, 2018 5:25 am
What's an "ISO boot"?

I can't see the rest of your OSes but I suspect this error is because of Souparo (Manjaro, actually, I just call it like that because it's a soup of codes, not an OS). That thing uses grub2 on the chosen device's MBR, so whatever GC tries to do, grub2 negates it, hence the errors. I tried that recently - triple boot of Windows 7, Mint and Souparo Cinnamon. The latter occupied the MBR of its storage device and it seems the computer's BIOS/UEFI prioritizes the MBR before any local grub. Naturally the Soup didn't run and all I could see was rescue mode and my MBR was so screwed up that I had to boot Windows from the other SD and use a program in it to rebuild the MBR, so that I can actually boot the Soup and Mint.
What I meant by ISO boot was that I tried to add linuxmint-19-mate-64bit-v2.iso to my boot options. I had already manually created entries for 18.3 and 19 Cinnamon ISO previously. I'm still playing with my multiboot setup and having to keep plugging/unplugging the USB was getting tiresome.

As for Manjaro, it shouldn't have. For one thing, I was using GPT, not MBR and I had Calamares install Manjaro's bootloader to an external HDD to avoid overwriting Mint 18.3's bootloader on /dev/sda. Since I'm getting the grub menu for Mint instead of Manjaro, I'm guessing the method worked.

For another, my Manjaro menuentry was an extremely simple manual entry in 40_custom because as previously mentioned, autodetection didn't work on btrfs subvolumes.

Code: Select all

menuentry 'Manjaro KDE 17.1.11' {
    insmod part_gpt
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 01234567-89ab-cdef-0123-456789abcdef
    configfile /@manjaro/boot/grub/grub.cfg
}
Halbarad
Level 1
Level 1
Posts: 28
Joined: Tue Feb 05, 2019 2:30 pm

Re: Changing Grub Default Boot - [ Solved ]

Post by Halbarad »

I know that the last post is six months old, but I wish to thank rui no onna for the simple and elegant solution to the problem. update-grub and install-grub did it. Many thanks also to Pjotr for his advice and his easylinuxtipsproject, which proved very useful. My past experience with Grub Customizer has been quite bad. It simply seemed not to do anything, after which I removed it. I wonder, if it messed up with my grub, is it enough to reinstall grub? I know that grub2 is complex and distributed into several directories, both in the root and in the EFI partition.
Post Reply

Return to “Installation & Boot”