You are not logged in.
I'm using Arch Linux in a Virtual Machine (VMware Workstation) and when I installed it, I tested two installations:
* set UEFI boot on VM settings
* set BIOS/Legacy on VM Settings
In the first case, the boot directory is /boot/efi while in the second case is /boot.
I created a hook file in "/etc/pacman.d/hooks/kernel-linux.hook":
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = linux
Target = linux-lts*
Target = linux-zen*
[Action]
Description = Pacman hook to update-grub automatically
When = PostTransaction
Exec = /bin/sh -c "grub-mkconfig -o /boot/grub/grub.cfg"
so, each time that the kernel is upgraded, this hook is triggered and run:
/bin/sh -c "grub-mkconfig -o /boot/grub/grub.cfg"
I guess that this approach is right for BIOS/Legacy scenario. For EFI boot scenario, this command is different? Should I execute a different command?
Not sure if related to this, but when I use the EFI boot approach in baremetal with Dual Boot with Windows, and I use the hook file above, when I upgrade the system (and the kernel), sometimes all the entries of the bootloader are removed except for the Arch Linux one, so when I access to it and I run "update-grub", it restores the other removed entries (like Windows one), but I'm not sure if this mentioned issue is related to the usage of this hook above in EFI boot scenario.
Last edited by D3vil0p3r (2023-11-13 12:06:49)
Offline
...and what's the point of doing that on every update?
Offline
...and what's the point of doing that on every update?
Is it not a good practice to do that at each kernel upgrade? Is this hook useless? If so, in which cases the grub config should be updated?
Offline
The grub config should be updated when you add or remove a kernel, or when you change command line parameters. Also when you reinstall grub to disk, to make sure the config is compatible with the grub that's actually running.
Regenerating the config on every update is useless on Arch. Arch doesn't change the kernel image name on every update.
Last edited by Scimmia (2023-11-13 01:15:22)
Offline
Ok. So let's guess I use that hook only for Install and Removal (I can delete the Upgrade line), how can I face the questions I posted on the first post?
Offline
The only question I see is if you should use that command or a different one, so the answer is that you shouldn't use that command, or any command, at all. The rest of the post is hard to decipher, as statements like "In the first case, the boot directory is /boot/efi while in the second case is /boot" make no sense at all.
Offline
The only question I see is if you should use that command or a different one, so the answer is that you shouldn't use that command, or any command, at all.
But I should use that command if I add a new kernel or remove one.
The rest of the post is hard to decipher, as statements like "In the first case, the boot directory is /boot/efi while in the second case is /boot" make no sense at all.
I try to make the question better: if I'm using EFI boot, the update of GRUB can be performed by "grub-mkconfig -o /boot/grub/grub.cfg" or a different command?
Offline
I try to make the question better: if I'm using EFI boot, the update of GRUB can be performed by "grub-mkconfig -o /boot/grub/grub.cfg" or a different command?
Not quite.
An installed GRUB consists of the configuration (basic: /etc/default/grub, /etc/grub.d/*, active: /boot/grub/grub.cfg) and the runtime files (basic: /usr/bin/grub*, /usr/lib/grub/*, /usr/share/grub/*, active: boot sector or EFI binary, /boot/grub/*).
Each time you change a part of the basic GRUB configuration, grub.cfg needs to be updated.
Each time an updated kernel and/or initrd is installed replacing the current one, GRUB needs no action.
Each time a new kernel is installed, GRUB needs an update for grub.cfg adding those kernels - regardless of the boot method.
Each time GRUB itself is updated, it's good practice to update the configuration (grub.cfg) and the active loader (grub-install ...) with the latter being different for the boot method.
Last edited by -thc (2023-11-15 07:33:08)
Offline
Each time a new kernel is installed, GRUB needs an update for grub.cfg adding those kernels - regardless of the boot method.
Each time GRUB itself is updated, it's good practice to update the configuration (grub.cfg) and the active loader (grub-install ...) with the latter being different for the boot method.
Thank you for the detailed answer. Sorry for the stupid question: In EFI boot method, the output of "grub-mkconfig" can be "/boot/grub/grub.cfg" right?
Offline
Yes.
Offline