As we skipped a few issues due to me not having employment and attending lots of interviews, let us quickly recap. In the very first article of this series, we looked at getting more information about your system, or a system that you may have connected to. Sometimes you need to know. We looked at all the ls-commands that you will find in Ubuntu. In the next article, we looked at basic logging and how to read users and groups. Then we moved over to storage, but we got a bit lost in the weeds getting another drive attached to a VM, so we could do more. In the third instalment we faffed with understanding how block devices work and how to get a disk ready via the command-line and a little bit about how Linux uses UUIDs to identify drives. Now that we are on the drive topic, let’s look at how a system boots, and maybe even shuts down. This has nothing to do with the horrible book above, but I was reading up on UEFI/EFI and the boot process, by a guy who forked rEFIt to handle multiple operating systems on one drive (Multi-boot). Now if you are ancient, like me , you may know that there used to be another bootloader, named LiLo, and GRUB wasn’t the only game in town (there was syslinux too, but it is defunct). It was very simple and you did not need to configure anything. GNU GRUB is the GRand Unified Bootloader, lovingly known as just GRUB.
Comme nous avons omis quelques points en raison de mon chômage et de mes nombreux entretiens, permettez-moi de récapituler rapidement.
Dans le premier article de cette série, nous avons abordé la question de l'obtention d'informations supplémentaires sur votre système, ou sur un système auquel vous vous êtes peut-être connecté. Il est parfois nécessaire de savoir. Nous avons examiné toutes les commandes ls disponibles dans Ubuntu. Dans l'article suivant, nous avons abordé la journalisation de base et la lecture des utilisateurs et des groupes. Nous sommes ensuite passés au stockage, mais nous nous sommes un peu perdus dans les détails en connectant un autre disque à une machine virtuelle, afin de pouvoir aller plus loin. Dans le troisième article, nous avons abordé le fonctionnement des périphériques de type bloc, la préparation d'un disque via la ligne de commande et la façon dont Linux utilise les UUID pour identifier les disques.
Maintenant que nous abordons le sujet des disques, voyons comment un système démarre, et peut-être même s'arrête. Cela n'a rien à voir avec le livre horrible cité précédemment, mais je lisais un article sur l'UEFI/EFI et le processus de démarrage, écrit par un gars qui a créé un dérivé de rEFIt pour gérer plusieurs systèmes d'exploitation sur un seul disque (multi-boot).
Si vous êtes un ancien, comme moi, vous savez peut-être qu'il existait autrefois un autre chargeur de démarrage, nommé LiLo, et que GRUB n'était pas le seul sur le marché (il y avait aussi Syslinux, mais il est obsolète). Il était très simple et ne nécessitait aucune configuration. GNU GRUB est le “GRand Unified Bootloader” (grand chargeur de démarrage unifié), affectueusement appelé simplement GRUB.
When Ubuntu starts up, GRUB is the first program that runs. It loads the kernel and then the kernel loads the rest of the operating system, including the shell, the desktop environment, and other operating system features. GRUB is also a boot manager. The boot loader is the part of GRUB that loads the kernel into memory. The ‘boot selector’ part of GRUB is the menu that allows you to select different operating system kernels to load. GRUB is also very configurable and has lots of options. Let’s look at a boot selector on one of my VM’s: Have you encountered a screen like this before? They do not all look the same and the first interaction most newbies have with this screen is when things go wrong. I say that they do not all look the same, as yours may show a list of previous kernels to boot from and mine does not. If you dual-boot with Windows, you may see that here too. You usually just select what you want and press enter, hence why it is called the boot selection screen. You can, should you want to, do the thing that is mentioned at the bottom of my screenshot, and hit “e” to edit the entries – usually when things go wrong, otherwise, you may never interact with it. Here we can see the output in edit mode. The changes you make when hitting “e” is temporary, only for this next boot (when you press F10 or type boot).
Au démarrage d'Ubuntu, GRUB est le premier programme exécuté. Il charge le noyau, puis le noyau charge le reste du système d'exploitation, dont le shell, l'environnement de bureau et d'autres fonctionnalités. GRUB est également un gestionnaire de démarrage. Le chargeur de démarrage est la partie de GRUB qui charge le noyau en mémoire. Le « sélecteur de démarrage » de GRUB est le menu qui vous permet de sélectionner les différents noyaux du système d'exploitation à charger. GRUB est également très configurable et offre de nombreuses options. Prenons l'exemple d'un sélecteur de démarrage sur l'une de mes machines virtuelles (image ci-contre).
Avez-vous déjà rencontré un écran comme celui-ci ? Ils ne se ressemblent pas tous et la première interaction de la plupart des débutants avec cet écran survient en cas de problème. Je précise qu'ils ne se ressemblent pas tous, car le vôtre peut afficher une liste des noyaux précédents à partir desquels démarrer, contrairement au mien.
Si vous utilisez un double démarrage avec Windows, vous le verrez peut-être aussi ici. Il suffit généralement de sélectionner ce que vous voulez et d'appuyer sur Entrée, d'où son nom d'écran de sélection de démarrage. Si vous le souhaitez, vous pouvez suivre la procédure indiquée au bas de ma capture d'écran et appuyer sur « e » pour modifier les entrées. C'est généralement le cas lorsque les choses tournent mal, sinon vous risquez de ne jamais interagir avec l'ordinateur.
Voici le résultat en mode édition (image ci-coontre). Les modifications apportées en appuyant sur « e » sont temporaires et ne s'appliquent qu'au prochain démarrage (lorsque vous appuyez sur F10 ou saisissez « boot »).
Let’s break it down, oomph, oomph, oh, not that way. OK then, the first line, “setparams”, is which entry in the list we are working with, most of the time there will be more than one. The usual suspect and a recovery option. If we look at the block following that, up to the if-statement, that is usually where all the modules and variables are. The if-statement that has feature_platform_search_hint = xy is where your system determines where to boot from. This is where those UUIDs come into play that we discussed. You can see that it says “search” and it will do just that, with parameters like “–no-floppy” to skip searching for floppy drives. We can see my drive’s UUID, starting with 58de…, yours will be different. That is why Linux is so “smart” compared to Windows. You see, with Windows I could add another drive, and that may become the “C” drive, and it will fail to boot. This is precisely the reason Linux does not rely on booting from sda1. So you could swap the cables on your drives and Linux will still boot. If you were to page down on that screen, after the UUID, you will see which kernel is being loaded and where root is, and how to mount it – usually it reads “ro” for read only, and you should not change this unless you are recovering your drive. I usually like removing the “quiet” option on my slow machines, then I get to see the boot messages scroll by. This works only on spinning rust really, as with SSDs it will just flash by and there is no point looking as it will scroll too fast.
Décomposons-le, ouf, ouf, oh, pas comme ça. Bon, la première ligne, « setparams », indique l'entrée de la liste sur laquelle nous travaillons ; la plupart du temps, il y en aura plusieurs. Le suspect habituel et une option de récupération.
Si l'on regarde le bloc suivant, jusqu'à l'instruction if, c'est généralement là que se trouvent tous les modules et variables. L'instruction if avec feature_platform_search_hint = xy permet à votre système de déterminer où démarrer. C'est là qu'entrent en jeu les UUID dont nous avons parlé. Vous pouvez voir qu'il indique « search » et c'est exactement ce qu'il fait, avec des paramètres comme « –no-floppy » pour ignorer la recherche de lecteurs de disquettes. On voit l'UUID de mon lecteur, commençant par 58de…, le vôtre sera différent. C'est pourquoi Linux est si « intelligent » par rapport à Windows. Voyez-vous, avec Windows, je pourrais ajouter un autre disque, qui deviendrait alors le disque « C », et le démarrage échouerait. C'est précisément la raison pour laquelle le démarrage de Linux ne repose pas sur « sda1 ». Vous pourriez donc intervertir les câbles de vos disques et Linux démarrerait quand même.
Si vous faites défiler l'écran vers le bas, après l'UUID, vous verrez quel noyau est en cours de chargement, où se trouve la racine et comment la monter. En général, « ro » signifie lecture seule, et vous ne devriez pas modifier ce paramètre, sauf si vous récupérez votre disque. J'aime généralement désactiver l'option « quiet » (silencieux) sur mes machines lentes, car je peux alors voir défiler les messages de démarrage. Cela ne fonctionne que sur les vieux disques tournants, car avec les SSD, ils s'affichent rapidement et il est inutile de regarder, car ça défile trop vite.
That “initrd” that you see is the initial ram disk, that gets loaded into memory to start your daemons. If you make changes, you need to press CRTL+c to cancel and boot normally, or CTRL+x, to boot with the temporary changes. There is also the option to use the GRUB console, by pressing just “c”. This is a shell, but it is not bash, more like a GRUB-shell. When you type “help”, you will see commands that are not available in bash, and even the commands that you may be familiar with, will not operate in the way you expect. I would encourage you to enter the GRUB-shell and use the “ls” command. If you have never used this shell before, I suggest running the help command followed by the listed command to see what it actually does. If you use logical volumes, I would suggest paying attention, maybe even taking a picture with your phone, before attempting anything. If you roll your own kernel, this would be where you go to boot from it. As always, misc@fullcirclemagazine.org if there are mistakes.
L'« initrd » que vous voyez est le disque RAM initial, chargé en mémoire pour démarrer vos démons. Si vous apportez des modifications, appuyez sur Ctrl+c pour annuler et démarrer normalement, ou sur Ctrl+x pour démarrer avec les modifications temporaires. Vous pouvez également utiliser la console GRUB en appuyant simplement sur « c ». Il s'agit d'un shell, mais ce n'est pas du bash, mais plutôt un shell GRUB. Lorsque vous tapez « help », vous verrez des commandes qui ne sont pas disponibles dans bash, et même les commandes que vous connaissez ne fonctionneront pas comme prévu. Je vous encourage à entrer dans le shell GRUB et à utiliser la commande « ls ». Si vous n'avez jamais utilisé ce shell, je vous suggère d'exécuter la commande help suivie de la commande listée pour voir son effet. Si vous utilisez des volumes logiques, soyez attentif, et prenez peut-être même une photo avec votre téléphone, avant toute tentative. Si vous créez votre propre noyau, c'est ici que vous démarrerez.
Comme toujours, envoyez un mail à misc@fullcirclemagazine.org s'il y a des erreurs.