Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom code with GRUB?

Can I run some some custom code at the time when GRUB loads up? In other words does GRUB provide a facility to run some custom code before loading any operating system?

like image 873
Usman Avatar asked Sep 13 '26 01:09

Usman


1 Answers

Since GRUB support the Multiboot specification, yes you can. You would get your code loaded by GRUB, then you'll have to load the operating system yourself (which you could do by supporting the Multiboot specification yourself...). Depending on what you want to do, that may not be the easiest way to do it.

If you want to run some custom code before loading a linux-based operation system, creating a custom initramfs would be a lot easier.

like image 66
Laurent Parenteau Avatar answered Sep 14 '26 15:09

Laurent Parenteau