[Solved] Help with Grub Customizer not Saving Configurations Correctly

Message
Author
User avatar
asqwerth
Developer
Posts: 7212
Joined: Sun May 27, 2007 5:37 am

Re: Help with Grub Customizer not Saving Configurations Correctly

#21 Post by asqwerth »

oops wrote: Mon Oct 15, 2018 4:08 am
asqwerth wrote: Mon Oct 15, 2018 4:06 am...
Nope, custom.cfg is totally not affected by updates to grub.cfg via update-grub.

It exists outside of the grub.cfg menu items and I don't edit grub.cfg at all.
Ah Ok, then sorry for the mistake. But if a kernel update is applied into your main distrib, you have to modify by hand your custom file?
Not at all. When there is a kernel update in main distro, it will generate a new /boot/grub/grub.cfg file. But /boot/grub/custom.cfg file does not change.

And I don't need to change custom.cfg file in my main distro, since the entries in my custom.cfg file are made up only of chainloaders or entries which seek out and run directly the grub.cfg files of the other distros found on the other partitions.

Fehlix uses a similar system, and to have an idea of what is found in his custom.cfg file, see here:

viewtopic.php?p=457524#p457524
Desktop: Intel i5-4460, 16GB RAM, Intel integrated graphics
Clevo N130WU-based Ultrabook: Intel i7-8550U (Kaby Lake R), 16GB RAM, Intel integrated graphics (UEFI)
ASUS X42D laptop: AMD Phenom II, 6GB RAM, Mobility Radeon HD 5400

User avatar
oops
Posts: 1603
Joined: Tue Apr 10, 2018 5:07 pm

Re: Help with Grub Customizer not Saving Configurations Correctly

#22 Post by oops »

asqwerth wrote: Mon Oct 15, 2018 4:26 am...
Not at all. When there is a kernel update in main distro, it will generate a new /boot/grub/grub.cfg file. But /boot/grub/custom.cfg file does not change.

And I don't need to change custom.cfg file in my main distro, since the entries in my custom.cfg file are made up only of chainloaders or entries which seek out and run directly the grub.cfg files of the other distros found on the other partitions.

Fehlix uses a similar system, and to have an idea of what is found in his custom.cfg file, see here:

viewtopic.php?p=457524#p457524
Thanks for the link, so I have now to learn this trick ;-)

Edit: Ok, this is only because it is not the same name /boot/grub/custom_grub.cfg instead /boot/grub/grub.cfg, if no this file is updated

Code: Select all

#
# DO NOT EDIT THIS FILE /boot/grub/grub.cfg
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
...
Pour les nouveaux utilisateurs: Alt+F1 pour le manuel, ou FAQS, MX MANUEL, et Conseils Debian - Info. système “quick-system-info-mx” (QSI) ... Ici: System: MX-19_x64 & antiX19_x32

rej
Posts: 140
Joined: Thu Mar 09, 2017 11:11 pm

Re: Help with Grub Customizer not Saving Configurations Correctly

#23 Post by rej »

Fehlix-

Thanks for your help.

I installed AntiX 17.2 on a new partition [sda7] and bootloader on sda7. Booted to MX sda3 (where Grub is installed) - sudo update-grub. Back to sda7 with AntiX 17.2 - sudo chmod -x /etc/grub.d/30_os-prober.

Boot Menu is much better, but cannot get sda7 and Win8 up past all the various entries/options connected with sda6 - no duplicates though. Would there be a way to move sda7 and Win8 above them easily?

Checked your link with the chainloaded entries [post #21, asquerth]. Have not been able to determine how to set up the code for 40_custom to reflect the MX, antiX & Win8 entries. Searched MX, antiX, Gentoo wiki, ubuntuforums.org and access.redhat.com, among others, to find how to configure etc/grub.d custom boot O.S. entries and the other files that may need to be edited or deleted in MX. Looked at boot-grub-grub.cfg, to compare to your example, Male's and others found online. All very different. Some appear to be old configurations or specific for that particular distribution, and might not pertain to Legacy boot.
______

Don't know if this brand new boot issue is connected with Grub or just an odd coincidence:

After selecting partition with Grub installed [sda3] on startup, it gets 2 lines into loading the files, doesn't do anything for about 30 seconds and then the next line is "Gave up waiting for suspend/resume device" and then continues loading (sometimes that line is not there and it still waits 30 seconds). This only occurs with sda3, where bootloader is installed.

Thank you caprea, male, asqwerth, KoO and oops for all your input! Good information.

User avatar
fehlix
Developer
Posts: 10310
Joined: Wed Apr 11, 2018 5:09 pm

Re: Help with Grub Customizer not Saving Configurations Correctly

#24 Post by fehlix »

rej wrote: Fri Oct 19, 2018 6:29 pm I installed AntiX 17.2 on a new partition [sda7] and bootloader on sda7. Booted to MX sda3 (where Grub is installed) - sudo update-grub. Back to sda7 with AntiX 17.2 - sudo chmod -x /etc/grub.d/30_os-prober.

Boot Menu is much better, but cannot get sda7 and Win8 up past all the various entries/options connected with sda6 - no duplicates though. Would there be a way to move sda7 and Win8 above them easily?
Yes, send grub.cfg fom sda3 and sda7 and I'l show you how the ??_custom entries might look like.
Do send as compressed tar-gzip archive.
rej wrote: Fri Oct 19, 2018 6:29 pm After selecting partition with Grub installed [sda3] on startup, it gets 2 lines into loading the files, doesn't do anything for about 30 seconds and then the next line is "Gave up waiting for suspend/resume device" and then continues loading (sometimes that line is not there and it still waits 30 seconds). This only occurs with sda3, where bootloader is installed.
Thats probably your swap device initram is looking after and cannot find.
One fix would be: Set this

Code: Select all

# /etc/initramfs-tools/conf.d/resume
RESUME=UUID=<swap_UUID>
where <swap_UUID> is from your swap device to be find with "lsblk -f"
and than do

Code: Select all

sudo update-initramfs -u -k all
:puppy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
asqwerth
Developer
Posts: 7212
Joined: Sun May 27, 2007 5:37 am

Re: Help with Grub Customizer not Saving Configurations Correctly

#25 Post by asqwerth »

oops wrote: Mon Oct 15, 2018 4:32 am....

Edit: Ok, this is only because it is not the same name /boot/grub/custom_grub.cfg instead /boot/grub/grub.cfg, if no this file is updated

Code: Select all

#
# DO NOT EDIT THIS FILE /boot/grub/grub.cfg
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
...
@oops, I didn't understand your post above.

1. do not touch or edit /boot/grub/grub.cfg
This is autogenerated/updated by the system whenever you update grub or you update/remove/install a kernel. This is the main grub menu that shows up when you turn on your computer.

2. create a file called custom.cfg in the /boot/grub folder. It must be called this name, not custom_grub.cfg. See the grub script /etc/grub.d/41_custom:

Code: Select all

#!/bin/sh
cat <<EOF
if [ -f  \${config_directory}/custom.cfg ]; then
  source \${config_directory}/custom.cfg
elif [ -z "\${config_directory}" -a -f  \$prefix/custom.cfg ]; then
  source \$prefix/custom.cfg;
fi
EOF

The 41_custom script tells the system that if custom.cfg file exists, then display the menu entries within that file after the menu entries of the main grub menu (grub.cfg) on your bootscreen. You could of course edit the script in 41_custom itself to look for a file with a different name from custom.cfg, but you do that at your own risk.

If you want the custom entries to appear before the main grub menu, then copy 41_custom to 09_custom so that it comes before 10_linux, which is the script for generating grub.cfg.

Then comment out all the lines in 41_custom, and do a

Code: Select all

sudo update-grub
Once you have done that first update-grub to get the system to recognise that 09_custom now exists and 41_custom is commented out, you no longer need to update-grub whenever you edit the menu entries in custom.cfg file.
Desktop: Intel i5-4460, 16GB RAM, Intel integrated graphics
Clevo N130WU-based Ultrabook: Intel i7-8550U (Kaby Lake R), 16GB RAM, Intel integrated graphics (UEFI)
ASUS X42D laptop: AMD Phenom II, 6GB RAM, Mobility Radeon HD 5400

User avatar
asqwerth
Developer
Posts: 7212
Joined: Sun May 27, 2007 5:37 am

Re: Help with Grub Customizer not Saving Configurations Correctly

#26 Post by asqwerth »

@rej, I don't have Windows on my home machines.

For what it's worth, here is part of my custom entries in my custom.cfg file, and I'll explain each of the 5 entries at the bottom of the post because I was experimenting and mixing/matching many different ways of doing the same thing, ie, booting into my many distros:

For your system, obviously the partition numbers/labels and UUID numbers will all be different.

Code: Select all

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
#
# Manjaro Controlling grub
menuentry 'Manjaro Linux (Kernel: 4.14-MANJARO x64)' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.14.60-1-MANJARO x64-advanced-2dfde925-1bcb-45b3-be68-aafd86795420' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt 
		insmod part_msdos
		insmod ext2
		set root='hd1,gpt2'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  2dfde925-1bcb-45b3-be68-aafd86795420
		else
		  search --no-floppy --fs-uuid --set=root 2dfde925-1bcb-45b3-be68-aafd86795420
		fi
		echo	'Loading Linux 4.14-MANJARO x64 ...'
		linux	/boot/vmlinuz-4.14-x86_64 root=UUID=2dfde925-1bcb-45b3-be68-aafd86795420 rw  quiet splash
		echo	'Loading initial ramdisk ...'
		initrd	/boot/intel-ucode.img /boot/initramfs-4.14-x86_64.img
}
#The other distros
menuentry "MX17 Final (ex-MX15) at sdb15" --class mx --class gnu-linux --class gnu --class os {
	insmod part_gpt
	insmod chain
	chainloader (hd1,15)+1
}
menuentry "MX16 at sda3" --class mx --class gnu-linux --class gnu --class os {
	insmod part_msdos
	insmod ext2
	set root='hd0,msdos3'
	chainloader +1
}
menuentry "Korora Configfile sdb16" --class korora --class fedora --class gnu-linux --class gnu --class os {
insmod part_gpt
insmod part_msdos
insmod ext2
search --set=root --label korora
configfile /boot/grub2/grub.cfg
}
# ----------------------------------
    menuentry 'FEHLIX GRUB MULTIBOOT KDE-NEON (/dev/sdb8)' --class neon --class gnu-linux --class gnu --class os $menuentry_id_option 'grub-multiboot-086fa4af-75fa-44b5-bf22-3c8a26fe6a98' {
# ----------------------------------
      savedefault
        insmod part_gpt
        insmod part_msdos
        insmod ext2
        set root='hd1,gpt8'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt8 --hint-efi=hd1,gpt8 --hint-baremetal=ahci1,gpt8  086fa4af-75fa-44b5-bf22-3c8a26fe6a98
        else
          search --no-floppy --fs-uuid --set=root 086fa4af-75fa-44b5-bf22-3c8a26fe6a98
        fi
        set OS_boot_config='/boot/grub/grub.cfg'
        multiboot /boot/grub/i386-pc/core.img
}
My multiboot setup:
sda = msdos-partition table SSD. Controlling grub is written onto the MBR of /dev/sda
sdb = gpt-partition table hard drive (If I used msdos-formatting only the first 2 TB of the 3TB disk would be usable). Since MBR is on the msdos first disk, most distro installers don't seem to get confused that the distro is to be installed on a secondary GPT-formatted disk without the user using UEFI boot. A few did, so I just didn't install bootloader at all for those distros.

Entry #1 = Manjaro is my controlling grub. Nothing special, I just opened up Manjaro's grub.cfg file and copied the relevant section into my custom.cfg file. Manjaro keeps the kernel name of a kernel series the same even when there are updates to it, so as long as I continue using 4.14 kernel, I don't have to change this custom entry.

Entry #2 = MX17, in the gpt 2nd disk. This uses the usual chainloader command in grub2.

Entry #3 = MX16, which is in the msdos first disk. Another way to set out the usual chainloader command.

From what I understand, these traditional chainloader commands tell your system to JUMP from the main grub menu in my MBR, to the grub menu found in the partition boot record of the target distro, and then continue from there.

Entry #4 = Korora.
OK this is where it a little different. I use gparted to give labels to all my distro partitions.
search --set=root --label korora
configfile /boot/grub2/grub.cfg
Instead of setting root by referring to hard drive number and partition number, e.g. set root='hd0,msdos3'
I used the search command to search for a partition labelled "korora" and set that as root.
Then I use the "configfile" command to tell my main grub menu in MBR that instead of running all the menu entries it currently has, that it should "replace" those entries with the ones found in the /boot/grub/grub.cfg file found in partition labelled as "korora".

So unlike normal chainloading commands, I haven't jumped to the korora grub in its partition boot record, I'm running directly its grub.cfg file from the MBR grub menu. That's good because I never did install Korora's grub in its root partition (it wasn't allowed by Fedora's grub-mkconfig). I just installed the grub program itself and it could generate a grub.cfg file but the grub menu wasn't written into PBR.

Entry #5 = Neon, using Fehlix's template.

He uses hard drive and partition numbers, plus UUID to set root.
set OS_boot_config='/boot/grub/grub.cfg'
multiboot /boot/grub/i386-pc/core.img
Then he uses set OS_boot_config for use the boot configuration settings in korora's grub.cfg file,
and the "multiboot" command to boot from Korora's core.img.

I really have no idea of the differences between the multiboot and configfile methods, but both work fine. I have a configfile menu entry for Neon as well, and I interchange between that and Fehlix's "multiboot" entry. I can't see any differences.

Many ways to skin this particular cat.
Desktop: Intel i5-4460, 16GB RAM, Intel integrated graphics
Clevo N130WU-based Ultrabook: Intel i7-8550U (Kaby Lake R), 16GB RAM, Intel integrated graphics (UEFI)
ASUS X42D laptop: AMD Phenom II, 6GB RAM, Mobility Radeon HD 5400

User avatar
fehlix
Developer
Posts: 10310
Joined: Wed Apr 11, 2018 5:09 pm

Re: Help with Grub Customizer not Saving Configurations Correctly

#27 Post by fehlix »

asqwerth wrote: Sat Oct 20, 2018 3:29 am I really have no idea of the differences between the multiboot and configfile methods, but both work fine.
multioot in BIOS / chainloader in UEFI:
this is equivalent/identical to load/boot the grub-bootloader as if you would boot from MBR/PBR or ESP(UEFI)

configfile /sourcing ... grub.cfg :
This loads into the current running grub another grub-menu (grub.cfg).

The difference: As long as you have similar grub-versions this appear to behave identical.

If you chainload into another grub, e.g. into Manjaro, which uses now grub version 2.03,
you might have issues with "sourcing" via configfile , if some grub-functions have changed
within the newer/other version or behave slightly differently or are incompatibe within current
running version of grub. If you load the other grub via chainload/multiboot, you would always
have made sure that the newly started grub will get all loaded modules and function within the
correct version matching the grub version.
In addition you might expirience some theming issues with the configfile methode.
:puppy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
oops
Posts: 1603
Joined: Tue Apr 10, 2018 5:07 pm

Re: Help with Grub Customizer not Saving Configurations Correctly

#28 Post by oops »

asqwerth wrote: Sat Oct 20, 2018 2:27 am
oops wrote: Mon Oct 15, 2018 4:32 am....

Edit: Ok, this is only because it is not the same name /boot/grub/custom_grub.cfg instead /boot/grub/grub.cfg, if no this file is updated

Code: Select all

#
# DO NOT EDIT THIS FILE /boot/grub/grub.cfg
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
...
@oops, I didn't understand your post above.

1. do not touch or edit /boot/grub/grub.cfg
This is autogenerated/updated by the system whenever you update grub or you update/remove/install a kernel. This is the main grub menu that shows up when you turn on your computer.

2. create a file called custom.cfg in the /boot/grub folder. It must be called this name, not custom_grub.cfg. See the grub script /etc/grub.d/41_custom:

Code: Select all

#!/bin/sh
cat <<EOF
if [ -f  \${config_directory}/custom.cfg ]; then
  source \${config_directory}/custom.cfg
elif [ -z "\${config_directory}" -a -f  \$prefix/custom.cfg ]; then
  source \$prefix/custom.cfg;
fi
EOF

The 41_custom script tells the system that if custom.cfg file exists, then display the menu entries within that file after the menu entries of the main grub menu (grub.cfg) on your bootscreen. You could of course edit the script in 41_custom itself to look for a file with a different name from custom.cfg, but you do that at your own risk.

If you want the custom entries to appear before the main grub menu, then copy 41_custom to 09_custom so that it comes before 10_linux, which is the script for generating grub.cfg.

Then comment out all the lines in 41_custom, and do a

Code: Select all

sudo update-grub
Once you have done that first update-grub to get the system to recognise that 09_custom now exists and 41_custom is commented out, you no longer need to update-grub whenever you edit the menu entries in custom.cfg file.
Hi,
In fact i do not use this way (for now), but it is interesting to learn it too for me.

I use rEFInd and a custom grub script but into the dir: /etc/grub.d/proxifiedScripts/custom (with inside: frugal install for MX17 AntiX, Slitaz, plop, systemRescue, etc...)
... So sometimes I start directly with rEFInd , and sometimes "rEFInd + a Grub.cfg" (I have 2 linux distrib Ubuntu 16.04 & MX17.1 - and some frugal install)

Sample:

Code: Select all

#/etc/grub.d/proxifiedScripts/custom

menuentry "Plop boot via USB sur sda11 ...."{
	set root='(hd0,11)'
	search --no-floppy --fs-uuid --set 1111-2222-3333-4444
	linux16 /plpbt.bin
}
menuentry "..SystemRescueCD 64b hdd efi sur sda9 -OK"{
	set root=(hd0,9)
	linux   /sysrcd/rescue64 subdir=sysrcd setkmap=fr nomodeset efi
	initrd  /sysrcd/initram.igz
}
...
menuentry "0 dynamic persist=root!,home! Frugal MX17-1 snapshot juin2018 -on sda10"{
	set root=(hd0,10)
#	linux /antiX-Frugal-4.17.0/vmlinuz quiet noxorg bdev=sda10 bdir=/antiX-Frugal-4.17.0 antiX=LMX nomodeset
	linux /frugal/MX17_eepc_x32/vmlinuz quiet noxorg bdev=sda10 bdir=/frugal/MX17_eepc_x32 nomodeset kbd=fr kbvar=oss kbopt=caps:none lang=fr_FR tz=Europe/Paris hostname=TOF-XEON from=hd persist=root!,home!
	initrd /frugal/MX17_eepc_x32/initrd.gz
}

menuentry "1 persist_static Frugal MX17-1 snapshot juin2018 -on sda10"{
	set root=(hd0,10)
#	linux /antiX-Frugal-4.17.0/vmlinuz quiet noxorg bdev=sda10 bdir=/antiX-Frugal-4.17.0 antiX=LMX nomodeset
	linux /frugal/MX17_eepc_x32/vmlinuz quiet noxorg bdev=sda10 bdir=/frugal/MX17_eepc_x32 nomodeset kbd=fr kbvar=oss kbopt=caps:none lang=fr_FR tz=Europe/Paris hostname=TOF-XEON from=hd persist_static
	initrd /frugal/MX17_eepc_x32/initrd.gz
	}
	...
	
menuentry "SliTaz-Rolling Release V5.0 rootfs_tof - sur sda10 " {
linux (hd0,10)/frugal/slitaz-rolling/slitaz-rolling_5.0/boot/bzImage rw root=/dev/null kmap=fr-latin9 nomodeset

initrd (hd0,10)/frugal/slitaz-rolling/slitaz-rolling_5.0/boot/rootfs_tof.gz
}
... But maybe it is not the best way to do, and your way is better ?
Pour les nouveaux utilisateurs: Alt+F1 pour le manuel, ou FAQS, MX MANUEL, et Conseils Debian - Info. système “quick-system-info-mx” (QSI) ... Ici: System: MX-19_x64 & antiX19_x32

User avatar
asqwerth
Developer
Posts: 7212
Joined: Sun May 27, 2007 5:37 am

Re: Help with Grub Customizer not Saving Configurations Correctly

#29 Post by asqwerth »

fehlix wrote:...If you chainload into another grub, e.g. into Manjaro, which uses now grub version 2.03,
you might have issues with "sourcing" via configfile , if some grub-functions have changed
within the newer/other version or behave slightly differently or are incompatibe within current
running version of grub. If you load the other grub via chainload/multiboot, you would always
have made sure that the newly started grub will get all loaded modules and function within the
correct version matching the grub version.
In addition you might expirience some theming issues with the configfile methode.
The "fehlix" Neon menu entry was the one you helped create for me because I had told you that I couldn't change the grub theme in Neon.

But whether I use my configfile entry or your multiboot one, the grub menu that appears for Neon is the old one, and the new grub theme I applied just didn't register. I also have a chainloader menu entry for Neon, still no change in grub theme. Maybe they did something to it....

PCLinux's grub theme applies fine when booted with configfile command.

I chainload into MX, and generally I have fallback chainloader entries for most other distros, commented out.
Desktop: Intel i5-4460, 16GB RAM, Intel integrated graphics
Clevo N130WU-based Ultrabook: Intel i7-8550U (Kaby Lake R), 16GB RAM, Intel integrated graphics (UEFI)
ASUS X42D laptop: AMD Phenom II, 6GB RAM, Mobility Radeon HD 5400

User avatar
fehlix
Developer
Posts: 10310
Joined: Wed Apr 11, 2018 5:09 pm

Re: Help with Grub Customizer not Saving Configurations Correctly

#30 Post by fehlix »

oops wrote: Sat Oct 20, 2018 4:56 am

Code: Select all

#/etc/grub.d/proxifiedScripts/custom
...
Your approach is based on functionality provided by grub-customizer.
Which might be fine as long as you have a working grub-customizer. :eek:

In addtion setting root through a "fixed" device-name like set root=(hd0,10),
might break as soon as you plugin another SATA device, as those
device names will be generated during boot and might change.
:snail:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

Post Reply

Return to “Software / Configuration”