Pages

2013-06-25

Grub 1.99 in Debian 7. Part 2

Changing menu item looks in Grub2 menu. Deleting and adding entries.
Now - I am no coder and know next to nothing of scripting. So I really can't rewrite grubs' scripts. After more hours wasted with combing interweb for tutorials how to change files 10_linux and 30_os-prober, I came to conclusion that it's hard to find ready-made drop-in script-bits for easy tweaking. And I didn't feel like spending all my time with testing...
I decided to drop my ambitious plans to alter above-mentioned files and go for easier (and commonly used) way: create a 06_custom file.

What I did:
Took existing /etc/grub.d/40_custom file and saved it as 06_custom (in this way it will be the first entry of menu). Then I copied whole entry from between #10_linux start and end lines in file /boot/grub/grub.cfg to my custom-file, under first 5 existing lines.
- Then I changed menuentrys' name
- deleted class statements
- and replaced filenames in /boot/ with links in /. That's because it's said that then you will allways boot with latest kernel (through those links). We'll see about that when there is kernel update... But - if there is kernel number in menuentry, it has to be changed manually, of course.
And final result, scriptways (after first 5 existing lines):
menuentry 'Debian 7 Wheezy, kernel 3.2.0-4-amd64 on /dev/sdb6' { 
load_video set 
gfxpayload=keep 
insmod gzio 
insmod part_msdos 
insmod ext2 
set root='(hd1,msdos6)' 
search --no-floppy --fs-uuid --set=root cc715c11-4b56-4d78-bb29-6d78688ce48b 
echo 'Loading Linux 3.2.0-4-amd64 ...' 
linux /vmlinuz root=UUID=cc715c11-4b56-4d78-bb29-6d78688ce48b ro quiet nomodeset nouveau.modeset=0 
echo 'Loading initial ramdisk ...' 
initrd /initrd.img 
}
And, update-grub when done, of course. Interesting enough, custom entry is not shown in 'Found' list... but, when
grep menuentry /boot/grub/grub.cfg - it's there alright.
Reboot, test your freshly baked menu-item. If boot is successful, do
sudo chmod -x 10_linux, to exclude this file from menu.
That's it. The same way you can deal with 30_os-prober. Entries like kernel instances etc can be deleted or added (might be wise to make os-prober temporarily active for adding - to get correct entry for copy-paste). Downside is that when distros come and go, all entries has to be deleted/added manually. Doesn't make you to spit blood but is still a bit bothersome...

No comments: