Le web de Dominique Guebey – Bazar informatique

Page : http://www.dg77.net/tekno/manuel/grub.htm


   D o m i n i q u e   G u e b e y    J u n g l e      Bazar informatique

Memento GRUB

Généralités

Présentation
Grub 2 et distribution Gnu Linux Ubuntu

Depuis la version 9.10 (29 oct. 2009), Ubuntu utilise GRUB 2. Ce qui suit a été écrit à partir d’une utilisation de GRUB 1. Avec Grub 2 les principes restent les mêmes mais des différences peuvent exister, comme par exemple pour les noms de fichiers de configuration. Pour des retours d’expérience récents, se reporter à la page Installation LINUX [http://www.dg77.net/tekno/manuel/install.html].

Principe de fonctionnement

Nomenclature des disques et partitions

Configuration

C’est le fichier (sous Linux du moins) /boot/grub/menu.lst.

Les lignes de commentaires commencent par un « hash » (#).

Paramètres généraux
default
Système qui sera chargé si on n’intervient pas au démarrage.
timeout
Délai (en secondes) avant le lancement par défaut.
Paramètres pour un système d’exploitation

Chaque série correspond à une entrée du menu de démarrage affiché au lancement du GRUB.

title
Titre qui sera affiché
root
Emplacement du fichier de configuration.
kernel
Image système à lancer. Si on n’indique pas d’unité, c’est qu’’elle se trouve au même endroit que GRUB.
initrd
Nécessaire sous Linux pour charger les modules du noyau.
rootnoverify
Pour les systèmes non reconnus par GRUB. GRUB ne cherchera pas à monter le système de fichier mais lancera ce qui se trouve dans le secteur de boot de la partition concernée.
chainloader
Utiliser le premier secteur de la partition sur laquelle on pointe.
makeactive
Rend la partition active, ce qui exécutera le chainloader suivant sans mention de partition cible.
quiet
Limite l’affichage pendant le lancement de l’O.S.

Utilisation avec Linux/Ubuntu

Mises à jour du noyau

La mise à jour ajoute automatiquement par le script update-grub les nouvelles entrées (les noyaux des versions successives sont les fichiers du répertoire /boot dont le nom commence par vmlinuz). Il faudra modifier au moins la spécification du système démarrant par défaut :

default    8
Mise-à-jour

Lancer le script : sudo  update-grub

Exemple multiboot

Description de l’ordinateur
Fichier de configuration Linux/Ubuntu (/etc/fstab)

Noter la différence de nomenclature des unités entre Linux et Grub. Disque IDE n. 1 = hda au lieu de hd0

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# /dev/hda1
UUID=98CC531CCC52F3CA /windows/win_c  ntfs    defaults,umask=007,gid=46 0       1
# /dev/hdb1
UUID=38BB-74FE  /windows/win_d  vfat    defaults,utf8,umask=007,gid=46 0       1
# /dev/hdb10
UUID=def9183c-6cd9-48db-85f8-3634a8fa6c21 /boot           ext3    defaults        0       2
# /dev/hdb11
UUID=55aaffd7-62bd-4b08-9899-af5e806607c4 /               ext3    defaults,errors=remount-ro 0       1
# /dev/hdb12
UUID=afb27168-ca91-4e1a-9e1d-5f83f6791ce0 none            swap    sw              0       0
# /dev/hdb13
UUID=44fa10b9-f87e-4b44-a4a6-3f0c21d18883 /var            ext3    defaults        0       2
# /dev/hdb5
UUID=14044489-b3d1-4fa7-b9bf-072a778713b3 /usr            ext3    defaults        0       2
# /dev/hdb6
UUID=a4422a7c-4db8-42a6-9620-8e4ed3da47f1 /usr/local      ext3    defaults        0       2
# /dev/hdb7
UUID=63895dae-0e49-4b77-a502-e8e102006aa5 /opt            ext3    defaults        0       2
# /dev/hdb8
UUID=0992f997-0c29-44f5-abea-16be13cedeeb /tmp            ext3    defaults        0       2
# /dev/hdb9
UUID=072310d3-f584-4b8c-8b3b-31b26f34756a /home           ext3    defaults        0       2
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto,exec 0       0
/dev/hdd        /media/cdrom1   udf,iso9660 user,noauto,exec 0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec 0       0
/boot/grub/menu.lst
# menu.lst - See: grub(8), info grub, update-grub(8)
#            grub-install(8), grub-floppy(8),
#            grub-md5-crypt, /usr/share/doc/grub
#            and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default  6

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout  30

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu

# Pretty colours
#color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line)  and entries protected by the
# command 'lock'
# e.g. password topsecret
#      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title  Windows 95/98/NT/2000
# root  (hd0,0)
# makeactive
# chainloader +1
#
# title  Linux
# root  (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
##      kopt_2_6_8=root=/dev/hdc1 ro
##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=55aaffd7-62bd-4b08-9899-af5e806607c4 ro

## Setup crashdump menu entries
## e.g. crashdump=1
# crashdump=0

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd1,9)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
##      alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
##      lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
##      lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
##      altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
##      howmany=7
# howmany=2

## should update-grub create memtest86 boot option
## e.g. memtest86=true
##      memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title  Ubuntu 8.04, kernel 2.6.24-19-generic
root  (hd1,9)
kernel  /vmlinuz-2.6.24-19-generic root=UUID=55aaffd7-62bd-4b08-9899-af5e806607c4 ro quiet splash
initrd  /initrd.img-2.6.24-19-generic
quiet

title  Ubuntu 8.04, kernel 2.6.24-19-generic (recovery mode)
root  (hd1,9)
kernel  /vmlinuz-2.6.24-19-generic root=UUID=55aaffd7-62bd-4b08-9899-af5e806607c4 ro single
initrd  /initrd.img-2.6.24-19-generic

title  Ubuntu 8.04, kernel 2.6.24-18-generic
root  (hd1,9)
kernel  /vmlinuz-2.6.24-18-generic root=UUID=55aaffd7-62bd-4b08-9899-af5e806607c4 ro quiet splash
initrd  /initrd.img-2.6.24-18-generic
quiet

title  Ubuntu 8.04, kernel 2.6.24-18-generic (recovery mode)
root  (hd1,9)
kernel  /vmlinuz-2.6.24-18-generic root=UUID=55aaffd7-62bd-4b08-9899-af5e806607c4 ro single
initrd  /initrd.img-2.6.24-18-generic

title  Ubuntu 8.04, memtest86+
root  (hd1,9)
kernel  /memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title  Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/hda1
title  Microsoft Windows XP Professionnel
root  (hd0,0)
savedefault
makeactive
chainloader +1

title  Free BSD
root  (hd1,12,c)
kernel          /boot/loader
chainloader +1