Outils pour utilisateurs

Outils du site


issue174:tutoriel1

Although the process I explained in “Create Hybrid Portable Clone of Your System” (Issue 171) provides a method to create a totally portable operating system, the resulting USB drive can also be used as an efficient way to run Ubuntu on a laptop with limited memory – a 64GB eMMC drive, for example, does not really have enough room for a dual boot Ubuntu/Windows installation. However, if you do buy a new laptop with sufficient storage space, you might still prefer to install Ubuntu on the hard drive and set up a dual boot system. In this final article of “The Clone Trilogy” I detail how to take a previously created portable clone USB and use it to install your own customized version of Ubuntu on a new computer; and, to configure it as a dual boot system with Windows. Although the Ubuntu installer can also produce a dual boot setup, it does a fresh install which then requires you to go through the tedious and time consuming process of modifying and tweaking your system to get it just right. Cloning your base system to a new computer avoids all of this aggravation and has the added bonus of providing a full backup of your base system on the new computer. Once you have created your portable clone USB the process is quite straightforward and quick, requiring just 4 basic steps: • Installing bootloader files on the new computer • Making space and creating a new partition on the hard drive of the new computer • Copying the Ubuntu partition from your clone drive to the new partition on the hard drive • Making final adjustments to ensure correct boot sequence

Bien que le processus que j'ai expliqué dans « Créer un clone hybride portable de votre système » (n° 171) fournisse une méthode pour créer un système d'exploitation totalement portable, la clé USB résultante peut également être utilisée comme un moyen efficace d'exécuter Ubuntu sur un ordinateur portable avec une mémoire limitée - un disque eMMC de 64 Go, par exemple, n'a pas vraiment assez de place pour une installation Ubuntu/Windows en double démarrage. Cependant, si vous achetez un nouvel ordinateur portable avec un espace de stockage suffisant, vous préférerez peut-être installer Ubuntu sur le disque dur et mettre en place un système de double amorçage. Dans ce dernier article de la « Trilogie des clones », je détaille comment prendre un clone USB portable précédemment créé et l'utiliser pour installer votre propre version personnalisée d'Ubuntu sur un nouvel ordinateur et comment le configurer comme un système de double amorçage avec Windows. Bien que le programme d'installation d'Ubuntu puisse également produire une configuration de double amorçage, il effectue une nouvelle installation qui vous oblige ensuite à passer par le processus fastidieux et long de modification et d'ajustement de votre système pour qu'il soit parfait. Le clonage de votre système de base sur un nouvel ordinateur évite toutes ces complications et offre en plus une sauvegarde complète de votre système de base sur le nouvel ordinateur.

Une fois votre clone USB portable créé, le processus est assez simple et rapide, ne nécessitant que 4 étapes de base : ••Installer des fichiers de démarrage sur le nouvel ordinateur. ••Faire de la place et créer une nouvelle partition sur le disque dur du nouvel ordinateur. ••Copier la partition Ubuntu de votre disque clone vers la nouvelle partition du disque dur. ••Effectuer les derniers ajustements pour garantir une séquence d'amorçage correcte.

You will require a portable clone USB as well as a second bootable USB (you can’t use the portable clone USB to copy itself unfortunately), the easiest thing to use is the live USB media that you used to install your original system. Installing Bootloader Files Since UEFI is now the standard, it is safe to assume that your new computer will use the UEFI boot protocol. This booting strategy requires a dedicated partition (EFI system partition) for the bootloader files which will already be on your new computer’s hard drive. We need to know its partition number so that we can copy the “ubuntu” folder from the EFI system partition on the portable clone USB to the EFI system partition present on the hard drive of the new computer. Plug in the portable clone USB and boot your computer from the USB, then open gparted. The partition layout from a recently purchased mid level laptop with a 1 TB drive is shown below. Your system might have a few other things shown but it doesn’t really matter, as you are only interested in two partitions: the Windows partition (/dev/sda3 in my case, yours may be different, it’s generally by far the largest partition) and the EFI system partition (/dev/sda1). Write down the appropriate device names for your system, you will need to know them later; and, while you are at it, right click on the EFI system partition, select Information and make a note of the 8 character UUID for this partition.

Vous aurez nécessairement besoin d'une clé USB de clonage portable ainsi que d'une seconde clé USB amorçable (vous ne pouvez malheureusement pas utiliser la clé USB de clonage portable pour qu'elle se copie elle-même). Le plus simple est d'utiliser le media USB Live que vous avez utilisé pour installer votre système original.

Installation des fichiers du chargeur de démarrage

L'UEFI étant désormais la norme, on peut supposer que votre nouvel ordinateur utilisera le protocole de démarrage UEFI. Cette stratégie de démarrage nécessite une partition dédiée (partition système EFI) pour les fichiers du chargeur de démarrage qui se trouvera déjà sur le disque dur de votre nouvel ordinateur. Nous devons connaître le numéro de sa partition afin de pouvoir copier le dossier « ubuntu » de la partition système EFI de la clé USB portable clone vers la partition système EFI présente sur le disque dur du nouvel ordinateur.

Branchez la clé USB portable de clonage et démarrez votre ordinateur à partir de cette clé, puis ouvrez gparted. La disposition des partitions d'un ordinateur portable de milieu de gamme récemment acheté avec un disque de 1 To est présentée ci-dessous.

Votre système peut afficher quelques autres éléments, mais cela n'a pas vraiment d'importance, car vous n'êtes intéressé que par deux partitions : la partition Windows (/dev/sda3 dans mon cas ; la vôtre peut être différente ; c'est généralement de loin la plus grande partition) et la partition système EFI (/dev/sda1). Notez les noms de périphériques appropriés de votre système, puisque vous en aurez besoin plus tard ; et, pendant que vous y êtes, faites un clic droit sur la partition système EFI, sélectionnez Information et notez l'UUID à 8 caractères de cette partition.

Close gparted, open a terminal and type sudo mount /dev/sdXY /mnt to mount the EFI partition of the hard drive (/dev/sda1 in my case, use appropriate values of X and Y for your system). Open File Manager and navigate to /mnt, then open the EFI folder displayed as administrator. A typical result is shown top left - this is the EFI system partition on the hard drive. Open a separate instance of File Manager and Open as Administrator the folder /boot/efi, then open the folder EFI. The result should be as shown below – this is the EFI system partition on the portable clone USB. Now right click on the “ubuntu” folder and Copy and Paste it into /mnt/EFI, the result is shown bottom middle. This ensures that the UEFI firmware will find two operating systems as boot choices when you power on the new computer. Close all instances of File Manager.

Fermez gparted, ouvrez un terminal et tapez

sudo mount /dev/sdXY /mnt

pour monter la partition EFI du disque dur (/dev/sda1 dans mon cas, utilisez les valeurs appropriées de X et Y pour votre système). Ouvrez le gestionnaire de fichiers et naviguez vers /mnt, puis, en tant qu'administrateur, ouvrez le dossier EFI affiché. Un résultat typique est montré en haut à gauche, c'est la partition système EFI sur le disque dur.

Ouvrez une autre instance du gestionnaire de fichiers et ouvrez en tant qu'administrateur le dossier /boot/efi, puis ouvrez le dossier EFI. Le résultat devrait être comme indiqué ci-dessous - c'est la partition système EFI sur le clone USB portable.

Maintenant, faites un clic droit sur le dossier « ubuntu » et copiez-collez-le dans le dossier /mnt/EFI ; le résultat est montré en bas au milieu.

Cela garantit que le firmware UEFI trouvera deux systèmes d'exploitation comme choix de démarrage lorsque vous allumerez le nouvel ordinateur. Fermez toutes les instances du gestionnaire de fichiers.

Copying the Ubuntu Partition Open gparted again and use the drop down menu to display the hard drive on the new computer. Right click on the Windows partition and select Move/Resize. Drag the right hand end of the partition to the left to create some unallocated space, how much is up to you, just make sure there is enough to copy the Ubuntu partition from the portable clone USB. Click the green arrow to apply this change. DO NOT try to create space at the beginning of the partition as this requires moving the partition and is much riskier than making space at the end. Now right click on this unallocated space, select New and create a new ext4 formatted partition, label it if you like. Click on the green arrow to apply this change. Close gparted and power down the computer. Temporarily unplug the portable clone USB, plug in your live USB and reboot the system from the live USB. Once the boot process is complete plug in the portable clone USB. Open gparted and navigate to the portable clone USB Make sure the Ubuntu partition (/dev/sdc3 in this case) is unmounted, then right click on it and select Copy, navigate to the computer’s hard drive, right click on the new partition that you just created and select Paste to copy the Ubuntu partition into it. This will take a while depending on the size of the partition and how much of it is used. It is worth noting, however, that although gparted makes an exact and complete copy, it only copies used blocks so it is quite efficient.

Copier la partition Ubuntu

Ouvrez à nouveau gparted et utilisez le menu déroulant pour afficher le disque dur du nouvel ordinateur. Faites un clic droit sur la partition Windows et sélectionnez Déplacer/Redimensionner. Faites glisser l'extrémité droite de la partition vers la gauche pour créer de l'espace non alloué. La taille de cet espace dépend de vous, mais assurez-vous qu'il y en a suffisamment pour copier la partition Ubuntu à partir du clone USB portable. Cliquez sur la coche verte pour appliquer cette modification. N'essayez PAS de créer de l'espace au début de la partition car cela nécessite de déplacer la partition et c'est beaucoup plus risqué que de créer de l'espace à la fin.

Maintenant, faites un clic droit sur cet espace non alloué, sélectionnez Nouveau et créez une nouvelle partition formatée en ext4, étiquetez-la si vous le souhaitez. Cliquez sur la coche verte pour appliquer ce changement.

Fermez gparted et éteignez l'ordinateur. Débranchez temporairement la clé USB du clone portable, branchez votre clé USB Live et redémarrez le système à partir de cette clé USB Live. Une fois le processus de démarrage terminé, branchez la clé USB du clone portable. Ouvrez gparted et naviguez jusqu'à la clé USB du clone portable.

Assurez-vous que la partition Ubuntu (/dev/sdc3 dans ce cas) est démontée, puis faites un clic droit dessus et sélectionnez Copier. Ensuite, naviguez vers le disque dur de l'ordinateur, faites un clic droit sur la nouvelle partition que vous venez de créer et sélectionnez Coller pour y copier la partition Ubuntu. Cette opération peut prendre un certain temps en fonction de la taille de la partition et de son degré d'utilisation. Il convient toutefois de noter que, bien que gparted effectue une copie exacte et complète, il ne copie que les blocs utilisés, ce qui le rend assez efficace.

Once the copy is completed without errors, close gparted. Now Open as Administrator the file /etc/fstab and change the UUID for the EFI system partition (see highlighted UUID in Figure 8) to the one you noted down from the computer’s hard drive previously. This is an important step, otherwise at boot time the computer will be looking for a partition identifier from the portable clone USB rather than the hard drive and it will be unable to find it. Save this file and close the editor. Power down the computer and remove all external devices. Final Adjustments Power on the computer and press the F12 key (or whatever one your computer uses) to bring up boot menu choices. You should see “ubuntu” and “Windows Boot Manager”. Select “ubuntu” and boot the computer. You should get a GRUB menu, select the first option and this should boot you into your familiar Ubuntu installation. Open a terminal and type: sudo update-grub and when it is finished reboot as before. This time the GRUB menu that appears should have an entry for Windows as well as Ubuntu and your dual boot system is complete. If you want to avoid having to press any keys to get the boot choice menu when you power up or restart, go into UEFI settings on the GRUB menu and set the boot order to boot “ubuntu” first. This will cause the GRUB menu to be displayed on boot, and then you can choose which operating system you wish to use.

Une fois la copie terminée sans erreur, fermez gparted. Ouvrez maintenant, en tant qu'administrateur, le fichier /etc/fstab et remplacez l'UUID de la partition système EFI (voir l'UUID en surbrillance dans la Figure 8) par celui que vous avez noté précédemment sur le disque dur de l'ordinateur. Il s'agit d'une étape importante, sinon, au moment du démarrage, l'ordinateur cherchera un identifiant de partition à partir de la clé USB du clone portable plutôt qu'à partir du disque dur et il sera incapable de le trouver. Enregistrez ce fichier et fermez l'éditeur. Mettez l'ordinateur hors tension et retirez tous les périphériques externes.

Ajustements finaux

Allumez l'ordinateur et appuyez sur la touche F12 (ou toute autre touche utilisée par votre ordinateur) pour afficher le menu de démarrage. Vous devriez voir « ubuntu » et « Windows Boot Manager ». Sélectionnez « ubuntu » et démarrez l'ordinateur. Vous devriez obtenir un menu GRUB, sélectionnez la première option et vous devriez démarrer dans votre installation Ubuntu familière. Ouvrez un terminal et tapez :

sudo update-grub

et quand il est terminé, redémarrez comme précédemment. Cette fois, le menu GRUB qui s'affiche doit contenir des entrées pour Windows et Ubuntu, et votre système de double amorçage est fini. Si vous voulez éviter d'avoir à appuyer sur une touche pour obtenir le menu du choix de démarrage lorsque vous allumez ou redémarrez, allez dans les paramètres UEFI dans le menu GRUB et définissez l'ordre de démarrage pour démarrer « ubuntu » en premier. Le menu GRUB s'affichera alors au démarrage, et vous pourrez choisir le système d'exploitation que vous souhaitez utiliser.

Please note that you will not be able to reliably boot this laptop from the portable clone USB, as the UUID of the Ubuntu partition of the clone USB will be the same as the one on the laptop. Given two identical UUIDs the computer picks one to boot from; but, it is impossible to tell which one it will be in any given instance. However, since the point of the exercise was to avoid having to boot the new machine from a portable clone USB this should not be a problem. You can still boot it from a live USB if needed. As always, it is not possible to guarantee that this method will work on every system; however, I have successfully used it to clone Ubuntu to a new computer several times without any problems. Hopefully it works as well for you as it has for me.

Veuillez noter que vous ne pourrez pas démarrer cet ordinateur portable de manière fiable à partir du clone portable sur USB, car l'UUID de la partition Ubuntu du clone USB sera le même que celui de l'ordinateur portable. Quand il y a deux UUID identiques, l'ordinateur en choisit un pour démarrer, mais il est impossible de dire lequel dans un cas donné. Cependant, puisque le but de l'exercice était d'éviter d'avoir à démarrer la nouvelle machine à partir d'un clone portable sur USB, cela ne devrait pas poser de problème. Vous pouvez toujours la démarrer à partir d'une clé USB Live si nécessaire.

Comme toujours, il n'est pas possible de garantir que cette méthode fonctionnera sur tous les systèmes ; cependant, je l'ai utilisée avec succès pour cloner Ubuntu sur un nouvel ordinateur plusieurs fois sans aucun problème. J'espère qu'elle fonctionnera aussi bien pour vous que pour moi.

Encadré de la page 17 :

Update: Cloning a BIOS/Legacy Installation I recently decided to create a hybrid USB with a clean Ubuntu installation to use for experimentation purposes. Using the same partitioning scheme as detailed in the first article of this series I used the “Do Something Else” option of the installer to install Ubuntu into Partition #3 of the USB drive. I chose to use my old laptop which uses BIOS/Legacy booting because I know that there is a bug in the installer when using removable media in UEFI mode which messes with the EFI partition on the hard drive. The USB booted fine on the BIOS machine so I switched to a UEFI laptop, booted into the USB installation and tried to install shim-signed but it failed! A quick look at /boot/grub revealed that the x86_64-efi folder was missing and so shim-signed doesn't have the required files for installation. The solution is simple enough, open a terminal and type: sudo grub-install –target=x86_64-efi /dev/sdX (replace X with the appropriate letter for your device) and then install shim-signed as explained in the article. Now the USB booted successfully on both BIOS and UEFI machines. I was still puzzled by the fact that I had cloned my old BIOS machine using the method in the first article to test the procedure and it worked fine! Again, a look at /boot/grub told the story – there was a x86_64-efi folder there, despite it being a BIOS machine. Then I recalled that I had added a “dummy” EFI partition to this machine so I could experiment with UEFI bootloaders and how they work. As part of that process I must have installed grub-efi, so everything worked when I tested the cloning technique using this computer. I suspect very few readers will want to clone a BIOS system as they are dated; but, if you do, just check the contents of /boot/grub before you start. If there is no x86_64-efi folder (there probably won’t be) install it as explained above and then proceed, using the method in the article.

Mise à jour : clonage d'une installation BIOS/Legacy

J'ai récemment décidé de créer une clé USB hybride avec une installation Ubuntu propre pour l'utiliser à des fins d'expérimentation. En utilisant le même schéma de partitionnement que celui détaillé dans le premier article de cette série, j'ai utilisé l'option « Do Something Else » (Autres choix) du programme d'installation pour installer Ubuntu dans la partition n° 3 de la clé USB. J'ai choisi d'utiliser mon ancien ordinateur portable qui utilise le démarrage BIOS/Legacy car je sais qu'il y a un bogue dans l'installeur lors de l'utilisation de supports amovibles en mode UEFI qui perturbe la partition EFI sur le disque dur. L'USB a bien démarré sur la machine BIOS, j'ai donc pris un ordinateur portable UEFI, j'ai démarré dans l'installation USB et j'ai essayé d'installer shim-signed mais cela a échoué !

Un rapide coup d'œil à /boot/grub a révélé que le dossier x86_64-efi était manquant et donc que shim-signed n'avait pas les fichiers requis pour l'installation. La solution est assez simple, ouvrez un terminal et tapez :

sudo grub-install –target=x86_64-efi /dev/sdX (remplacez X par la lettre appropriée pour votre périphérique) et, ensuite, installez shim-signed comme expliqué dans l'article.

Ensuite, l'USB a démarré avec succès sur les machines BIOS et UEFI.

J'étais toujours perplexe car j'avais cloné mon ancienne machine BIOS en utilisant la méthode du premier article pour tester la procédure et cela a bien fonctionné ! Une fois de plus, un coup d'oeil à /boot/grub a révélé le fin mot de l'histoire : il y avait un dossier x86_64-efi, bien qu'il s'agisse d'une machine BIOS. Je me suis alors rappelé que j'avais ajouté une partition EFI « factice » à cette machine afin de pouvoir expérimenter les chargeurs de démarrage UEFI et leur fonctionnement. Dans le cadre de ce processus-là, j'ai dû installer grub-efi et ainsi tout a fonctionné lorsque j'ai testé la technique de clonage en utilisant cet ordinateur.

Je pense que très peu de lecteurs voudront cloner un système BIOS, car ils sont dépassés ; mais si vous le faites, vérifiez le contenu de /boot/grub avant de commencer. S'il n'y a pas de dossier x86_64-efi (il n'y en aura probablement pas), installez-le comme expliqué ci-dessus et procédez ensuite en utilisant la méthode décrite dans l'article.

issue174/tutoriel1.txt · Dernière modification : 2021/11/04 10:45 de auntiee