Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| grub-pc-annexe [Le 10/01/2010, 19:45] – Correction erreur /etc/bootd est en fait /etc/grub.d lucge | grub-pc-annexe [Le 06/11/2014, 21:54] (Version actuelle) – Suppression : le code des fichiers de configuration cité est très différent de qu'il était en 2009/2010. De plus, les noyaux ne sont visibles que dans un sous-menu maintenant. frombenny | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== Annexe à grub-pc : exemples de scripts d' | ||
| - | {{tag> | ||
| - | Compléments à la documentation [[grub-pc]]. | ||
| - | |||
| - | Cette annexe donne des exemples de fichiers de génération du menu de boot. | ||
| - | Ces scripts sont placés dans le répertoire /etc/grub.d et doivent être validés en exécution. | ||
| - | La génération du fichier / | ||
| - | |||
| - | < | ||
| - | sudo update-grub | ||
| - | </ | ||
| - | |||
| - | La sortie de la commande permet de contrôler les éléments qui seront placés dans le menu. | ||
| - | |||
| - | |||
| - | ===== Faire apparaître un nombre fixe de noyaux du système en cours ===== | ||
| - | |||
| - | On modifie ici le scripts / | ||
| - | |||
| - | ==== Nouveaux paramètres introduits dans le script ==== | ||
| - | 1) NBLISTMAX: | ||
| - | |||
| - | Nombre de noyaux à afficher dans le menu. | ||
| - | |||
| - | 2) PREFILTER et POSTFILTER: | ||
| - | |||
| - | Filtre sur le nom du noyau permettant de sélectionner les noyaux du système sur lequel on est, dans le cas ou la partition /boot est commune à plusieurs systèmes distincts. | ||
| - | |||
| - | Dans le cas de ubuntu Karmic, on a: PREFILTER=" | ||
| - | |||
| - | //Nota: ces paramètres peuvent être mis à "" | ||
| - | |||
| - | ==== code du script / | ||
| - | |||
| - | |||
| - | < | ||
| - | #! /bin/sh -e | ||
| - | |||
| - | # grub-mkconfig helper script. | ||
| - | # Copyright (C) 2006, | ||
| - | # | ||
| - | # GRUB is free software: you can redistribute it and/or modify | ||
| - | # it under the terms of the GNU General Public License as published by | ||
| - | # the Free Software Foundation, either version 3 of the License, or | ||
| - | # (at your option) any later version. | ||
| - | # | ||
| - | # GRUB is distributed in the hope that it will be useful, | ||
| - | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| - | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| - | # GNU General Public License for more details. | ||
| - | # | ||
| - | # You should have received a copy of the GNU General Public License | ||
| - | # along with GRUB. If not, see < | ||
| - | # | ||
| - | # Number of version to display - can be changed to desired value | ||
| - | NBLISTMAX=$((2)) | ||
| - | # pre-filtering for kernel to use - can be changed to desired value | ||
| - | PREFILTER=" | ||
| - | # post-filtering for kernel to use - can be changed to desired value | ||
| - | POSTFILTER=" | ||
| - | # Intermediate variable - do not change | ||
| - | NBLIST=$((0)) | ||
| - | # | ||
| - | |||
| - | |||
| - | prefix=/usr | ||
| - | exec_prefix=${prefix} | ||
| - | libdir=${exec_prefix}/ | ||
| - | . ${libdir}/ | ||
| - | |||
| - | |||
| - | |||
| - | if [ " | ||
| - | OS=GNU/ | ||
| - | else | ||
| - | OS=" | ||
| - | fi | ||
| - | |||
| - | # loop-AES arranges things so that /dev/loop/X can be our root device, but | ||
| - | # the initrds that Linux uses don't like that. | ||
| - | case ${GRUB_DEVICE} in | ||
| - | / | ||
| - | GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e " | ||
| - | # We can't cope with devices loop-mounted from files here. | ||
| - | case ${GRUB_DEVICE} in | ||
| - | /dev/*) ;; | ||
| - | *) exit 0 ;; | ||
| - | esac | ||
| - | ;; | ||
| - | esac | ||
| - | |||
| - | if [ " | ||
| - | || ! test -e "/ | ||
| - | || [ " | ||
| - | LINUX_ROOT_DEVICE=${GRUB_DEVICE} | ||
| - | else | ||
| - | LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} | ||
| - | fi | ||
| - | |||
| - | # add crashkernel option if we have the required tools | ||
| - | if [ -x "/ | ||
| - | GRUB_CMDLINE_EXTRA=" | ||
| - | fi | ||
| - | |||
| - | linux_entry () | ||
| - | { | ||
| - | cat << EOF | ||
| - | menuentry " | ||
| - | recordfail=1 | ||
| - | if [ -n \${have_grubenv} ]; then save_env recordfail; fi | ||
| - | EOF | ||
| - | if [ " | ||
| - | cat << EOF | ||
| - | set quiet=1 | ||
| - | EOF | ||
| - | fi | ||
| - | save_default_entry | sed -e " | ||
| - | prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e " | ||
| - | cat << EOF | ||
| - | linux ${rel_dirname}/ | ||
| - | EOF | ||
| - | if test -n " | ||
| - | cat << EOF | ||
| - | initrd ${rel_dirname}/ | ||
| - | EOF | ||
| - | fi | ||
| - | cat << EOF | ||
| - | } | ||
| - | EOF | ||
| - | } | ||
| - | |||
| - | list=`for i in / | ||
| - | if grub_file_is_not_garbage " | ||
| - | done` | ||
| - | |||
| - | while [ " | ||
| - | #LL-start | ||
| - | NBLIST=$((NBLIST+1)) | ||
| - | # echo " | ||
| - | linux=`version_find_latest $list` | ||
| - | if [ " | ||
| - | echo "Found linux image: $linux" | ||
| - | #LL-end | ||
| - | basename=`basename $linux` | ||
| - | dirname=`dirname $linux` | ||
| - | rel_dirname=`make_system_path_relative_to_its_root $dirname` | ||
| - | version=`echo $basename | sed -e " | ||
| - | alt_version=`echo $version | sed -e " | ||
| - | linux_root_device_thisversion=" | ||
| - | |||
| - | initrd= | ||
| - | for i in " | ||
| - | " | ||
| - | " | ||
| - | if test -e " | ||
| - | initrd=" | ||
| - | break | ||
| - | fi | ||
| - | done | ||
| - | if test -n " | ||
| - | echo "Found initrd image: ${dirname}/ | ||
| - | else | ||
| - | # " | ||
| - | linux_root_device_thisversion=${GRUB_DEVICE} | ||
| - | fi | ||
| - | |||
| - | linux_entry " | ||
| - | " | ||
| - | quiet | ||
| - | if [ " | ||
| - | linux_entry " | ||
| - | " | ||
| - | fi | ||
| - | #LL-start | ||
| - | fi | ||
| - | #LL-end | ||
| - | list=`echo $list | tr ' ' ' | ||
| - | # echo " | ||
| - | |||
| - | done | ||
| - | </ | ||
