issue88:grub2_et_multibooting
                Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| issue88:grub2_et_multibooting [2014/10/30 16:38] – créée andre_domenech | issue88:grub2_et_multibooting [2015/01/30 14:10] (Version actuelle) – auntiee | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | ===== 1 ===== | ||
| + | ** | ||
| In previous parts, I explained how GRUB (version 2) works and how you can tune its behaviour, either instantly through the GRUB terminal or permanently by editing a couple of files and running update-grub. Now we arrive at the final stage of this exciting adventure! We will customize GRUB so that it offers a choice between multiple installed operating systems (OSs) to choose from. We will do it in such a way that this GRUB menu no longer depends on one of the installed distros, but is at your command only… | In previous parts, I explained how GRUB (version 2) works and how you can tune its behaviour, either instantly through the GRUB terminal or permanently by editing a couple of files and running update-grub. Now we arrive at the final stage of this exciting adventure! We will customize GRUB so that it offers a choice between multiple installed operating systems (OSs) to choose from. We will do it in such a way that this GRUB menu no longer depends on one of the installed distros, but is at your command only… | ||
| Before starting, we need to know some basics about partitioning. One physical hard drive can be ‘divided’ into separate partitions, which are formatted according to a specific filesystem (like FAT, NTFS, ext3, etc. – refer to Wikipedia and other sources if you are unfamiliar with this). When installing multiple (Linux) operating systems, you will need a number of partitions, plus one for swap space if it is needed on your machine (swap serves as extended, but much slower, memory on the hard drive; see online resources). Some may want to take a separate /home partition into account. However, better avoid having several Linux installations use the same /home partition, as that may lead to inconsistencies. | Before starting, we need to know some basics about partitioning. One physical hard drive can be ‘divided’ into separate partitions, which are formatted according to a specific filesystem (like FAT, NTFS, ext3, etc. – refer to Wikipedia and other sources if you are unfamiliar with this). When installing multiple (Linux) operating systems, you will need a number of partitions, plus one for swap space if it is needed on your machine (swap serves as extended, but much slower, memory on the hard drive; see online resources). Some may want to take a separate /home partition into account. However, better avoid having several Linux installations use the same /home partition, as that may lead to inconsistencies. | ||
| + | ** | ||
| + | Dans les numéros précédents, | ||
| + | |||
| + | Avant de commencer, nous avons besoin de connaître quelques notions de base sur le partitionnement. Un disque physique peut être « divisé » en partitions distinctes, qui sont formatées selon un système de fichiers spécifique (comme FAT, NTFS, ext3, etc., reportez-vous à Wikipedia et d' | ||
| + | |||
| + | Lors de l' | ||
| + | |||
| + | ** | ||
| Is there a (relevant) limit to the number of partitions on one hard drive? Well, it depends on the type of partition: | Is there a (relevant) limit to the number of partitions on one hard drive? Well, it depends on the type of partition: | ||
| Ligne 8: | Ligne 18: | ||
| • if you need more partitions (like us), you have to do this with an extended partition. One hard drive can hold one extended partition at most, and it counts as one of the maximum four primary partitions on the hard drive. So if you already had four primary partitions, you have to delete a primary partition first and create an extended partition instead; | • if you need more partitions (like us), you have to do this with an extended partition. One hard drive can hold one extended partition at most, and it counts as one of the maximum four primary partitions on the hard drive. So if you already had four primary partitions, you have to delete a primary partition first and create an extended partition instead; | ||
| • one extended partition can hold as many logical partitions as you like (including swap). They can be formatted as any filesystem (while an extended partition cannot be formatted: its only purpose is to hold the logical partitions). | • one extended partition can hold as many logical partitions as you like (including swap). They can be formatted as any filesystem (while an extended partition cannot be formatted: its only purpose is to hold the logical partitions). | ||
| + | ** | ||
| + | Y-a-t-il une limite (raisonnable) au nombre de partitions sur un disque dur ? Eh bien, cela dépend du type de partition : | ||
| + | |||
| + | • un disque dur physique peut porter au mieux quatre partitions primaires. C'est le type de partition de base (et par défaut) ; | ||
| + | • si vous voulez plus de partitions (comme nous), vous devez les faire avec des partitions étendues. Un disque dur peut porter au mieux une partition étendue, et elle compte comme une des quatre partitions primaires maximum sur le disque dur. Donc si vous avez déjà quatre partitions primaires, vous devez d' | ||
| + | • une partition étendue peut porter autant de partitions logiques que vous voulez (swap inclus). Elles peuvent être formatées comme tout système de fichier (alors qu'une partition étendue ne peut pas être formatée : son seul but est de contenir les partitions logiques). | ||
| + | |||
| + | ===== 2 ===== | ||
| + | ** | ||
| In Linux, the partitions are denoted as /dev/sda1, /dev/sda2, /dev/sda3, etc. (considering partitions on your first hard drive, i.e. /dev/sda). To access their contents, you may have to mount each one as follows (for the first partition): | In Linux, the partitions are denoted as /dev/sda1, /dev/sda2, /dev/sda3, etc. (considering partitions on your first hard drive, i.e. /dev/sda). To access their contents, you may have to mount each one as follows (for the first partition): | ||
| Ligne 16: | Ligne 35: | ||
| An excellent way to create-extend-move-shrink-delete partitions, is to use GParted in a live session from USB-stick/ | An excellent way to create-extend-move-shrink-delete partitions, is to use GParted in a live session from USB-stick/ | ||
| + | ** | ||
| + | |||
| + | Pour Linux, les partitions sont appelées /dev/sda1, /dev/sda2, /dev/sda3, etc. (si on considère les partitions de votre premier disque dur, /dev/sda). Pour accéder à leur contenu, vous pourriez devoir monter chacune comme ceci : | ||
| + | |||
| + | mkdir / | ||
| + | |||
| + | C' | ||
| + | |||
| + | Un excellent moyen de créer-étendre-déplacer-réduire-supprimer des partitions, est d' | ||
| + | ** | ||
| The rest of my story is to give you one (of several possible) ways to achieve a multiboot system with an independent GRUB on the MBR of your hard drive. The key will be to provide one extra partition on which /boot/grub - and nothing else - resides with all its usual contents (including grub.cfg). Let’s call this partition GRUBpart. ONLY the GRUB installed on the Master Boot Record (which I will call MasterGRUB) is allowed to refer to this partition! The grub.cfg file on GRUBpart should only contain menu entries that chainload either Windows or GRUB installations on the distribution-specific partitions. The GRUBs on the Linux partitions use their ‘own’ /boot/grub directory within the distro’s partition. Therefore the /boot/grub folder on GRUBpart will NOT be used or updated by any of the installed distros! Consequently, | The rest of my story is to give you one (of several possible) ways to achieve a multiboot system with an independent GRUB on the MBR of your hard drive. The key will be to provide one extra partition on which /boot/grub - and nothing else - resides with all its usual contents (including grub.cfg). Let’s call this partition GRUBpart. ONLY the GRUB installed on the Master Boot Record (which I will call MasterGRUB) is allowed to refer to this partition! The grub.cfg file on GRUBpart should only contain menu entries that chainload either Windows or GRUB installations on the distribution-specific partitions. The GRUBs on the Linux partitions use their ‘own’ /boot/grub directory within the distro’s partition. Therefore the /boot/grub folder on GRUBpart will NOT be used or updated by any of the installed distros! Consequently, | ||
| Let’s make such a system in 10 steps. But be prepared first! Especially by learning GRUB terminal commands and knowing how GRUB works; see previous sessions for more information. I have tested the below myself, but of course I am not responsible for your own GRUB- and PC-adventures… | Let’s make such a system in 10 steps. But be prepared first! Especially by learning GRUB terminal commands and knowing how GRUB works; see previous sessions for more information. I have tested the below myself, but of course I am not responsible for your own GRUB- and PC-adventures… | ||
| + | ** | ||
| + | Le reste de mon histoire est de vous donner une (ou plusieurs) façons de réaliser un système de multidémarrage avec un GRUB indépendant sur le MBR (Master Boot Record - zone d' | ||
| + | |||
| + | Créons un tel système en 10 étapes. Mais soyez d' | ||
| + | |||
| + | ===== 3 ===== | ||
| + | ** | ||
| I will start from a blank hard disk, so if you already have something installed, first read everything in order to decide what you will need to do. And in that case: first backup all your precious stuff please… To be broadly applicable, I presume that you will install Windows as well – but of course that is up to you. | I will start from a blank hard disk, so if you already have something installed, first read everything in order to decide what you will need to do. And in that case: first backup all your precious stuff please… To be broadly applicable, I presume that you will install Windows as well – but of course that is up to you. | ||
| Ligne 26: | Ligne 62: | ||
| • Install Windows onto its primary partition. Beware that creating an NTFS partition beforehand (step 1) was necessary to prevent Windows 7 (and alike) to create an extra primary partition for specific system files. It would do so when you installed Windows on an unpartitioned hard disk. And in that case, live with it and shrink partitions (see link at the end). | • Install Windows onto its primary partition. Beware that creating an NTFS partition beforehand (step 1) was necessary to prevent Windows 7 (and alike) to create an extra primary partition for specific system files. It would do so when you installed Windows on an unpartitioned hard disk. And in that case, live with it and shrink partitions (see link at the end). | ||
| + | ** | ||
| + | |||
| + | Je commencerai avec un disque dur vierge, donc si vous avez déjà quelque chose d' | ||
| + | |||
| + | • Utilisez GParted dans une session live pour créer deux partitions primaires, Windows et GRUBpart, et une partition étendue avec le nombre de partitions logiques correspondant au swap (en option) plus le nombre (maximum) de distributions Linux que vous voudrez multi-amorcer. Pour Windows, utilisez le système de fichiers NTFS, et pour Linux et GRUBpart utilisez ext2 ou supérieur. Bien sûr, vous devez décider vous-même de la taille des partitions ; je considère que 15 Go est, pour les partitions OS, une limite inférieure pratique. Décidez si vous avez besoin d'une partition pour le swap (formatée comme telle) et de sa taille. Si vous avez seulement 1 Go de RAM, il est sage d' | ||
| + | |||
| + | • Installez Windows sur sa partition primaire. Comprenez que la création d'une partition NTFS au préalable (étape 1) a été nécessaire afin d' | ||
| + | ** | ||
| Keep in mind which Linux distro you (eventually) want to let install its GRUB on the MBR. My choice would be a distro that holds the latest version of the grub-pc package (see distrowatch.com for an easy overview). Let’s call that distro ‘distro Z’. Install each Linux distro, except Z, on its own partition. For all distros except Z, install their GRUB (during installation) on their OWN partition; this differs from the suggested default during installation. This means that you will usually have to change /dev/sda as GRUB’s target into - for example - /dev/sda5 (correctly choosing the partition number of course). | Keep in mind which Linux distro you (eventually) want to let install its GRUB on the MBR. My choice would be a distro that holds the latest version of the grub-pc package (see distrowatch.com for an easy overview). Let’s call that distro ‘distro Z’. Install each Linux distro, except Z, on its own partition. For all distros except Z, install their GRUB (during installation) on their OWN partition; this differs from the suggested default during installation. This means that you will usually have to change /dev/sda as GRUB’s target into - for example - /dev/sda5 (correctly choosing the partition number of course). | ||
| Ligne 38: | Ligne 82: | ||
| You may get some warnings, but the job should get done (otherwise, add --force). At this point, both MasterGRUB and Z’s GRUB use the same grub.cfg. | You may get some warnings, but the job should get done (otherwise, add --force). At this point, both MasterGRUB and Z’s GRUB use the same grub.cfg. | ||
| + | ** | ||
| + | Gardez à l' | ||
| + | |||
| + | • Installez distro Z en dernier. Ici, nous prendrons la valeur par défaut /dev/sda pour installer GRUB. Maintenant, nous avons GRUB dans le MBR pointant vers le /boot/grub de la partition de Z. Cela nous donne une machine qui démarrera, ce qui est la raison de cette façon de faire (une alternative plus avancée est que vous manipuliez Z comme dans l' | ||
| + | |||
| + | • Démarrez sur votre disque dur, et vérifiez que tous les systèmes d' | ||
| + | |||
| + | • Lancez distrib. Z et installez le GRUB de Z sur sa propre partition (en supposant la partition 8) : | ||
| + | |||
| + | sudo grub-install /dev/sda8 | ||
| + | |||
| + | Il se peut que vous ayez quelques avertissements, | ||
| + | |||
| + | |||
| + | ===== 4 ===== | ||
| + | ** | ||
| • In distro Z, add chainload entries to / | • In distro Z, add chainload entries to / | ||
| sudo update-grub | sudo update-grub | ||
| Ligne 77: | Ligne 137: | ||
| Yes, we just installed our final MasterGRUB, which is told to look into the GRUBpart partition! | Yes, we just installed our final MasterGRUB, which is told to look into the GRUBpart partition! | ||
| + | ** | ||
| + | • Dans distrib. Z, ajoutez des entrées de chaînage à / | ||
| + | sudo update-grub | ||
| + | |||
| + | Vérifiez la mise à jour de grub.cfg pour voir s'il y a des truc anormaux, et redémarrez si tout va bien. Essayez tous vos GRUB en chaîne. Nous y sommes presque. Rappelez-vous que c'est toujours la distrib. Z qui gouverne le MasterGRUB. | ||
| + | |||
| + | • Redémarrez dans la distrib Z. Nous allons maintenant remplacer le GRUB dans le MBR par un qui pointe vers la partition GRUBpart. Nous ferons également deux fichiers grub.cfg différents, | ||
| + | |||
| + | sudo -s | ||
| + | |||
| + | cd /boot/grub | ||
| + | |||
| + | cp grub.cfg grubZ.cfg | ||
| + | |||
| + | ici nous sauvegardons le grub.cfg actuel de Z | ||
| + | |||
| + | cd /etc/grub.d | ||
| + | |||
| + | chmod –x *linux* *lupin* *memtest* *prober* | ||
| + | |||
| + | # ne vous inquiétez pas si l'un des motifs n'est pas disponible. | ||
| + | |||
| + | update-grub | ||
| + | |||
| + | cela crée un grub.cfg que nous pouvons utiliser pour notre MasterGRUB, avec seulement les entrées pour le chaînage. | ||
| + | |||
| + | chmod +x *linux* *lupin* *memtest* | ||
| + | |||
| + | pour faire en sorte que les futurs grub-update de Z fassent un grub.cfg « normal » pour Z à nouveau | ||
| + | # ça ne fait rien si l'un des motifs n'est pas disponible : | ||
| + | |||
| + | mkdir / | ||
| + | |||
| + | bien sûr remplacez sda2 par le numéro approprié de la partition GRUBpart. Vous pouvez sauter cette étape si GRUBpart est déjà monté. | ||
| + | |||
| + | mkdir / | ||
| + | |||
| + | grub-install /dev/sda --boot-directory=/ | ||
| + | il peut y avoir quelques avertissements, | ||
| + | |||
| + | Oui, nous venons d' | ||
| + | |||
| + | ** | ||
| For version 1.98 and earlier, set –-root-directory=/ | For version 1.98 and earlier, set –-root-directory=/ | ||
| Ligne 91: | Ligne 194: | ||
| exit | exit | ||
| + | ** | ||
| + | Pour les versions 1.98 et antérieures, | ||
| + | |||
| + | cd /boot/grub | ||
| + | |||
| + | cp grub.cfg / | ||
| + | |||
| + | et faites de même pour une éventuelle image de fond si grub.cfg pointait déjà vers une. | ||
| + | |||
| + | mv grubZ.cfg grub.cfg | ||
| + | |||
| + | c' | ||
| + | |||
| + | exit | ||
| + | |||
| + | ===== 5 ===== | ||
| + | ** | ||
| To finish grub.cfg in the GRUBpart partition, you need to look for all lines in grub.cfg above your custom entries and replace pointers to the Z's partition with pointers to GRUBpart. In our example this means replacing hd0,8 by hd0,2 and also the corresponding listed UUID' | To finish grub.cfg in the GRUBpart partition, you need to look for all lines in grub.cfg above your custom entries and replace pointers to the Z's partition with pointers to GRUBpart. In our example this means replacing hd0,8 by hd0,2 and also the corresponding listed UUID' | ||
| Ligne 97: | Ligne 217: | ||
| sudo dpkg-reconfigure grub-pc | sudo dpkg-reconfigure grub-pc | ||
| After some questions, for which you can safely accept the default, you will be asked to set the default target device to install updates of Z’s GRUB, which must be its own partition ONLY (/dev/sda8 in our example). Select it with an asterisk by hitting the spacebar. Also grub.cfg (in /boot/grub on /dev/sda8) will be overwritten in this process. | After some questions, for which you can safely accept the default, you will be asked to set the default target device to install updates of Z’s GRUB, which must be its own partition ONLY (/dev/sda8 in our example). Select it with an asterisk by hitting the spacebar. Also grub.cfg (in /boot/grub on /dev/sda8) will be overwritten in this process. | ||
| + | ** | ||
| + | |||
| + | Pour finir le grub.cfg dans la partition GRUBpart, vous devez vérifier toutes les lignes dans grub.cfg au-dessus de vos entrées personnalisées et remplacer les pointeurs vers la partition Z par des pointeurs vers GRUBpart. Dans notre exemple, cela signifie le remplacement de hd0,8 par hd0,2 et aussi des UUID listés correspondants, | ||
| + | |||
| + | • Vérifiez que tout fonctionne bien maintenant. Nous avons accompli l' | ||
| + | |||
| + | sudo dpkg-reconfigure grub-pc | ||
| + | |||
| + | Après quelques questions, pour lesquelles vous pouvez accepter le défaut en toute sécurité, vous serez invité à configurer le périphérique cible par défaut pour installer les mises à jour du GRUB de Z, qui doit être sa propre partition UNIQUEMENT (/dev/sda8 dans notre exemple). Cochez-la avec une astérisque en appuyant sur la barre d' | ||
| + | ** | ||
| • Tune each distro’s own grub configuration file according to your taste (edit / | • Tune each distro’s own grub configuration file according to your taste (edit / | ||
| Ligne 103: | Ligne 233: | ||
| Floris is very grateful to David H. and Bart A. for their useful comments on an earlier version of the manuscript. | Floris is very grateful to David H. and Bart A. for their useful comments on an earlier version of the manuscript. | ||
| + | ** | ||
| + | • Adaptez le fichier de configuration de grub propre à chaque distribution selon votre goût (modifier / | ||
| + | |||
| + | Et voilà, c'est tout ! Ça vous a peut-être pris un certain temps pour apprendre les choses, mais après tout, c' | ||
| + | |||
| + | Floris est très reconnaissante à David H. et Bart A. pour leurs commentaires utiles sur une version antérieure du manuscrit. | ||
| + | |||
| + | ** | ||
| Interesting links | Interesting links | ||
| Ligne 116: | Ligne 254: | ||
| Sanket Totewar’s article on GRUB2 multibooting: | Sanket Totewar’s article on GRUB2 multibooting: | ||
| + | ** | ||
| + | |||
| + | Liens intéressants | ||
| + | |||
| + | Communauté Ubuntu, documentation « swap » : http:// | ||
| + | |||
| + | Communauté Ubuntu « Les partitions » : http:// | ||
| + | |||
| + | Redimensionner des partitions Windows avec Linux : http:// | ||
| + | |||
| + | Tutoriel complet GRUB2 de Dedoimedo, sur la configuration de GRUB et le multi-amorçage : http:// | ||
| + | |||
| + | L' | ||
| + | |||
| + | |||
issue88/grub2_et_multibooting.1414683520.txt.gz · Dernière modification : 2014/10/30 16:38 de andre_domenech
                
                