0. What is this?
I'll tell you about the new version of the most popular bootloader. It appeared optionally in stable Debian 5.0 Lenny, which means it can be concluded about some stability. Unfortunately, according to the developers themselves, there is no time for documentation, so everything is still working by typing, logic and comments in the code :)
Speaking of versions. The first and so far the main branch is the 0.9x branch (which has already been dubbed GRUB Legacy), and versions 1.xx are officially called GRUB 2.
So, how does this version differ from the good old default bootloader of everything and everyone? The official website says
something like this :
- Script support, in particular cycles, conditions, variables and functions
- Graphical interface
- Dynamic podgruzka modules, allowing to extend the functionality not at the assembly stage, but directly during execution
- Portability to different architectures
- Internationalization
- True memory management makes GNU GRUB more flexible
- Modular, hierarchical, object-oriented framework for file systems, files, devices, drives, terminals, commands, partition tables and operating system loaders
- Cross-platform installation to install GRUB from a different architecture
- Safe mode for difficult cases. Stage 1.5 eliminated
- Correction of errors that were made when designing GRUB Legacy, and could not be corrected due to the requirements of backward compatibility. For example, the method of numbering sections
As you can see, a lot of changes. Here I want to dwell on some practical moments that I encountered in my life.
Traditionally, I warn you: I did all the actions on a stable Debian Lenny. Your commands or file locations may differ (although it should not).
1. How to edit the menu?
This is a natural question when working with the loader. The new version approached him from the other side. If you open an analogue of the old menu.lst, file / boot / grub / grub.cfg, a surprise is waiting for you. File header reads:
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/update-grub using templates
# from /etc/grub.d and settings from /etc/default/grub
#
That is, you can rule it with your hands, but this is not according to the rules.
According to the rules, the menu is now generated automatically, based on the scripts in /etc/grub.d and settings from the / etc / default / grub config
Having searched the script descriptions, we find the file /etc/grub.d/README, which sheds a ray of light on the tricky device of the new loader. We find out why we need prefixes in script names:
- 00_ *: Reserved for 00_header
- 10_ *: Boot Records
- 20_ *: Third-party programs (for example, memtest86 +)
You can see the scripts themselves, written in the usual shell-language. They should not cause much difficulty. These scripts are simply looking for compiled kernels and init.rd images, respectively, in the likely directories.
If you decide to compile the kernel yourself, everything will be extremely simple: using the appropriate guide, you will receive a deb-package. When installing, it will put everything in its place and start the bootloader update. When the scripts run, in /boot/grub/grub.cfg there will be an updated menu with a new kernel. Without a single edit configs.
2. Warnings.
Now look at the other side: what bad can happen with such a scheme of work?
- For specific kernels, you need to write special scripts.
- You don’t have to go far for an example - look at the Xen kernels. They run a little different from the standard ones, so the standard menu item for the Xen-core does not start anything good. If someone is interested, I will write about it in more detail. ( UPD : Wrote )
- If you still change the menu manually due to “some kind of non-similar” script operation, the next time (when updating the kernel or GRUB itself) the scripts will crash with an error and the grub-pc package will be considered unconfigured. We'll have to redo everything by the rules.
- As mentioned above, there is a lack of normal documentation. You have to interrupt with posts from blogs and wiki-pages.
')
3. Conclusion
As you can see, GRUB has changed a lot. Like it or not, after a while more and more developers will add it to their distributions. And that means, you need to test, test and just help the community in the transition to a new generation of loaders. Successes!