title: Grub date: 2012-05-11 tags: Geekeries, Linux, Humeur url: grub Les joies de l'informatique, l'évolution des logiciels, l'abandon sur le bord de la route des anciennes versions considérées comme étant obsolètes, je m'égare… Bref, unticketarticle pour dire encore que **c'était mieux avant** , en regardant le cas de GRUB "Legacy" et Grub "2" GRUB, pour GRand Unified Bootloader, est un petit "logiciel", qui s'exécute au démarrage de l'ordinateur [1], entre le moment où le BIOS/EFI [2] donne la main et qu'un système d'exploitation [3] démarre. GRUB permet (entre autres) * De choisir un Système d'Exploitation [4] * De choisir un autre chargeur de démarrage (pratique pour "chaîner" les bootloaders [5] * De passer en mode "ligne de commande" et de booter n'importe quoi n'importe comment [6] GRUB existe en deux versions : * GRUB Legacy, "l'ancienne" version * GRUB2, la "nouvelle" version La principale différence entre les deux (point de vue administration) est dans la configuration. Les autres innovations sont au niveau du support des gros disques, de gpt et d'autres trucs que je n'ai pas retenu. ##### GRUB Legacy Un seul fichier, simple, clair, parfaitement lisible et éditable depuis un liveCD/USB, situé dans /boot/grub/menu.lst Genre : # Config file for GRUB - The GNU GRand Unified Bootloader # /boot/grub/menu.lst # DEVICE NAME CONVERSIONS # # Linux Grub # ------------------------- # /dev/fd0 (fd0) # /dev/sda (hd0) # /dev/sdb2 (hd1,1) # /dev/sda3 (hd0,2) # # FRAMEBUFFER RESOLUTION SETTINGS # for more details and different resolutions see # http://wiki.archlinux.org/index.php/GRUB#Framebuffer_Resolution # general configuration timeout 10 default 1 color light-blue/black light-cyan/blue # boot sections follow # each is implicitly numbered from 0 in the order of appearance below #-* # (0) Arch Linux title Arch Linux (RC) root (hd0,5) kernel /boot/vmlinuz-3.4-rc6-yue root=/dev/sda6 ro # (1) Arch Linux title Arch Linux (Stable) root (hd0,5) kernel /boot/vmlinuz-3.2.7-yue root=/dev/sda6 ro # (2) Arch Linux title Arch Linux (Old stable) root (hd0,5) kernel /boot/vmlinuz-3.2.6-yue root=/dev/sda6 ro # (3) Windows title Windows rootnoverify (hd0,0) #makeactive chainloader +1 # (4) Meego (default kernel) title Meego root (hd0,6) kernel /boot/vmlinuz-2.6.38.2-8.26-adaptation-pinetrail root=/dev/sda7 # (5) Meego (custom kernel) title "Meego-yue" root (hd0,6) kernel /boot/vmlinuz-2.6.38-yue root=/dev/sda7 #configfile /boot/grub/menu.lst ##### GRUB2 Un brol monstre dans /etc, avec des fichiers éparpillés dans grub.d, genre (tiré d'Ubuntu 11.10) dans /boot/grub $ ls 915resolution.mod gcry_tiger.mod parttool.mod acpi.mod gcry_twofish.mod password.mod affs.mod gcry_whirlpool.mod password_pbkdf2.mod afs.mod gettext.mod pbkdf2.mod afs_be.mod gfxblacklist.txt pci.mod aout.mod gfxmenu.mod play.mod at_keyboard.mod gfxterm.mod png.mod ata.mod gptsync.mod probe.mod ata_pthru.mod grldr.img pxe.mod befs.mod grub.cfg pxeboot.img befs_be.mod grubenv pxecmd.mod biosdisk.mod gzio.mod raid.mod bitmap.mod halt.mod raid5rec.mod bitmap_scale.mod hashsum.mod raid6rec.mod blocklist.mod hdparm.mod read.mod boot.img hello.mod reboot.mod boot.mod help.mod regexp.mod bsd.mod hexdump.mod reiserfs.mod btrfs.mod hfs.mod relocator.mod bufio.mod hfsplus.mod scsi.mod cat.mod hwmatch.mod search.mod cdboot.img iorw.mod search_fs_file.mod chain.mod iso9660.mod search_fs_uuid.mod cmostest.mod jfs.mod search_label.mod cmp.mod jpeg.mod sendkey.mod command.lst kernel.img serial.mod configfile.mod keylayouts.mod setjmp.mod core.img keystatus.mod setpci.mod cpio.mod legacycfg.mod sfs.mod cpuid.mod linux.mod sleep.mod crypto.lst linux16.mod squash4.mod crypto.mod lnxboot.img tar.mod cs5536.mod loadenv.mod terminal.lst date.mod locale terminal.mod datehook.mod loopback.mod terminfo.mod datetime.mod ls.mod test.mod diskboot.img lsacpi.mod test_blockarg.mod dm_nv.mod lsapm.mod testload.mod drivemap.mod lsmmap.mod tga.mod echo.mod lspci.mod trig.mod efiemu.mod lvm.mod true.mod efiemu32.o mdraid09.mod udf.mod efiemu64.o mdraid1x.mod ufs1.mod elf.mod memdisk.mod ufs2.mod example_functional_test.mod memrw.mod uhci.mod ext2.mod minicmd.mod usb.mod extcmd.mod minix.mod usb_keyboard.mod fat.mod minix2.mod usbms.mod font.mod mmap.mod usbserial_common.mod fs.lst moddep.lst usbserial_ftdi.mod fshelp.mod msdospart.mod usbserial_pl2303.mod functional_test.mod multiboot.mod usbtest.mod g2hdr.img multiboot2.mod vbe.mod gcry_arcfour.mod nilfs2.mod vga.mod gcry_blowfish.mod normal.mod vga_text.mod gcry_camellia.mod ntfs.mod video.lst gcry_cast5.mod ntfscomp.mod video.mod gcry_crc.mod ntldr.mod video_bochs.mod gcry_des.mod ohci.mod video_cirrus.mod gcry_md4.mod part_acorn.mod video_fb.mod gcry_md5.mod part_amiga.mod videoinfo.mod gcry_rfc2268.mod part_apple.mod videotest.mod gcry_rijndael.mod part_bsd.mod xfs.mod gcry_rmd160.mod part_gpt.mod xnu.mod gcry_seed.mod part_msdos.mod xnu_uuid.mod gcry_serpent.mod part_sun.mod xzio.mod gcry_sha1.mod part_sunpc.mod zfs.mod gcry_sha256.mod partmap.lst zfsinfo.mod gcry_sha512.mod parttool.lst Dans /etc/grub.d $ ls 00_header 05_debian_theme 10_linux 20_linux_xen 20_memtest86+ 30_os-prober 40_custom 41_custom README Le contenu de grub.cfg (attention les yeux) # # DO NOT EDIT THIS FILE # # It is automatically generated by grub-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### if [ -s $prefix/grubenv ]; then set have_grubenv=true load_env fi set default="0" if [ "${prev_saved_entry}" ]; then set saved_entry="${prev_saved_entry}" save_env saved_entry set prev_saved_entry= save_env prev_saved_entry set boot_once=true fi function savedefault { if [ -z "${boot_once}" ]; then saved_entry="${chosen}" save_env saved_entry fi } function recordfail { set recordfail=1 if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi } function load_video { insmod vbe insmod vga insmod video_bochs insmod video_cirrus } insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 279b47e5-8d60-4520-aba9-aef38ec9e3b5 if loadfont /usr/share/grub/unicode.pf2 ; then set gfxmode=auto load_video insmod gfxterm insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 279b47e5-8d60-4520-aba9-aef38ec9e3b5 set locale_dir=($root)/boot/grub/locale set lang=fr_FR insmod gettext fi terminal_output gfxterm if [ "${recordfail}" = 1 ]; then set timeout=-1 else set timeout=10 fi ### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/05_debian_theme ### set menu_color_normal=white/black set menu_color_highlight=black/light-gray if background_color 44,0,30; then clear fi ### END /etc/grub.d/05_debian_theme ### ### BEGIN /etc/grub.d/10_linux ### if [ ${recordfail} != 1 ]; then if [ -e ${prefix}/gfxblacklist.txt ]; then if hwmatch ${prefix}/gfxblacklist.txt 3; then if [ ${match} = 0 ]; then set linux_gfx_mode=keep else set linux_gfx_mode=text fi else set linux_gfx_mode=text fi else set linux_gfx_mode=keep fi else set linux_gfx_mode=text fi export linux_gfx_mode if [ "$linux_gfx_mode" != "text" ]; then load_video; fi menuentry 'Ubuntu, avec Linux 3.0.0-12-generic' --class ubuntu --class gnu-linux --class gnu --class os { recordfail set gfxpayload=$linux_gfx_mode insmod gzio insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 279b47e5-8d60-4520-aba9-aef38ec9e3b5 linux /boot/vmlinuz-3.0.0-12-generic root=UUID=279b47e5-8d60-4520-aba9-aef38ec9e3b5 ro quiet splash vt.handoff=7 initrd /boot/initrd.img-3.0.0-12-generic } menuentry 'Ubuntu, avec Linux 3.0.0-12-generic (mode de dépannage)' --class ubuntu --class gnu-linux --class gnu --class os { recordfail insmod gzio insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 279b47e5-8d60-4520-aba9-aef38ec9e3b5 echo 'Chargement de Linux 3.0.0-12-generic ...' linux /boot/vmlinuz-3.0.0-12-generic root=UUID=279b47e5-8d60-4520-aba9-aef38ec9e3b5 ro recovery nomodeset echo 'Chargement du disque mémoire initial ...' initrd /boot/initrd.img-3.0.0-12-generic } ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/20_linux_xen ### ### END /etc/grub.d/20_linux_xen ### ### BEGIN /etc/grub.d/20_memtest86+ ### menuentry "Memory test (memtest86+)" { insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 279b47e5-8d60-4520-aba9-aef38ec9e3b5 linux16 /boot/memtest86+.bin } menuentry "Memory test (memtest86+, serial console 115200)" { insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 279b47e5-8d60-4520-aba9-aef38ec9e3b5 linux16 /boot/memtest86+.bin console=ttyS0,115200n8 } ### END /etc/grub.d/20_memtest86+ ### ### BEGIN /etc/grub.d/30_os-prober ### if [ "x${timeout}" != "x-1" ]; then if keystatus; then if keystatus --shift; then set timeout=-1 else set timeout=0 fi else if sleep --interruptible 3 ; then set timeout=0 fi fi fi ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # 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. ### END /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/41_custom ### if [ -f $prefix/custom.cfg ]; then source $prefix/custom.cfg; fi ### END /etc/grub.d/41_custom ### Dès que l'on a modifié une entrée dans un fichier, il faut exécuter une commande, grub-mkconfig, qui va regénérer la config de GRUB. On se croirait **PRESQUE** revenu sur LILO, la légèreté en moins. (LILO au moins est clair). L'avantage serait : "Cela permet de définir des options dans différents fichiers, et le script de mise à jour génère automatiquement un fichier de config propre. Pourquoi pas, mais que ça génère alors un truc léger et propre, pas un truc quasiment illisible. Il faudrait regarder sur des autres distributions (genre maegia, fedora, suse) pour voir si c'est aussi "bordélique". * * * Notes : [1]: Type PC x86, à quelques exceptions près (rEFIt) pour les MacIntel. Cela n'inclut pas les téléphones, les mainframe AS/400 ni Skynet. [2]: Le truc qui affiche des lignes genre "AMI truc, Phoenix machin, 2048MB Found, ou qui affiche le logo du constructeur du PC [3]: Vu ce que l'utilisateur doit faire comme tâches d'administration, je confirme en disant qu'il s'agit d'un Système d'Exploitation de l'Utilisateur. [4]: Et oui, de nos jours, on peut choisir à quelle sauce on sera mangé, c'est beau le progrès… [5]: Au boot : GRUB, permettant de choisir entre le GRUB d'ubuntu, le GRUB d'ArchLinux et le GRUB de Meego [6]: Celui qui se demande l'intérêt de cette possibilité n'a jamais vu de boot cassé suite à la mise à jour d'un noyau sous GNU/Linux. .