Outils pour utilisateurs

Outils du site


issue173:tutoriel2

Ceci est une ancienne révision du document !


In a previous article, I described a step-by-step procedure to create a hybrid (boots on BIOS or UEFI system) portable clone of your system on a 512 byte sector USB drive. Although I had tested the technique successfully on a number of devices I had laying around, when I tried it on a recently purchased SSD, it did not work! It turned out that the new SSD had physical/logical sectors of 4096 bytes and this caused two problems with the method employed that made the drive non-bootable. I was able to track down and resolve the difficulty, although it does require a different set of steps to those in the earlier article. As many newer drives are now in 4K format, I thought it would be useful to share the results of my findings. (The process described here does work on 512-byte sector drives with only one minor modification – see Technical Note #2). One important thing to note before we begin is that BIOS booting is not generally supported from drives with 4096-byte sectors; consequently, we cannot create a hybrid clone on such a drive. The resulting cloned system is still portable, however, and should boot on whatever UEFI machine it is plugged into.

Dans un précédent article, j’ai décrit une procédure étape par étape de création d’un clone hybride (qui démarre à la fois sur un système BIOS ou UEFI) portable de votre système sur un lecteur USB de secteurs de 512 bytes. Bien que j’aie testé la technique sur de nombreux dispositifs que j’avais à portée de la main, sans aucun problème, quand je l’ai essayé sur un SSD que je venais d’acheter, cela n’a pas fonctionné ! Il s’est avéré que le nouveau SSD avait des secteurs physiques/logiques de 4096 bytes et cela a causé deux problèmes avec la méthode utilisée et ces problèmes ont rendu la clé non amorçable. J’ai réussi à trouver et à résoudre la difficulté, bien qu’il nécessite un jeu d’étapes différent de celui dans l’autre article. Puisque beaucoup des disques sont maintenant en format 4K, je pensais que ce serait utile de partager les résultats de mes recherches. (Le processus décrit ici fonctionne sur des disques de secteurs de 512 bytes avec une seule modification mineure – CF la Note technique n° 2). Avant de commencer, il est important de noter que le démarrage sur BIOS n’est pas généralement pris en charge par des disques avec des secteurs de 4096 bytes ; par conséquence, nous ne pouvons pas créer un clone hybride sur un tel disque. Toutefois, le système cloné résultant reste portable et devrait démarrer sur n’importe quelle machine UEFI sur laquelle il est branché.

It is not possible to anticipate the particulars of every conceivable system configuration so I have made a few assumptions: • The system to be cloned is a typical installation with the Ubuntu system on a single partition, and no swap partition. • The source computer that you are cloning boots in UEFI mode and has a separate EFI partition. • The destination drive must be big enough to accommodate the Ubuntu partition that we are going to clone – the whole partition, not just the used space! (Resizing your Ubuntu partition to make it smaller with gparted is quite safe – the Ubuntu installer does this when you set up a dual boot installation – BUT there is always the potential for data loss so don’t do it unless you have backed up anything you cannot afford to lose.) • Many of these steps require Administrator privileges so make sure you know how to use this facility on your system as it varies a bit across Ubuntu flavours. I have written this article for the non-expert (like myself) and so I have included a lot of cross-checks to avoid errors. More experienced readers can probably skip some of these steps if desired.

Étant donné l’impossibilité d’anticiper les particularités de toute configuration de système imaginable, j’ai fait quelques suppositions : * Le système à cloner est une installation typique où le système Ubuntu se trouve sur une seule partition, sans partition swap. * L’ordinateur source que vous clonez démarre en mode UEFI et a une partition EFI séparée. * Le disque de destination doit être assez grand pour contenir la partition Ubuntu que nous allons cloner – toute la partition et pas seulement l’espace utilisé ! (Le redimensionnement de votre partition Ubuntu pour la rendre plus petite avec gparted, est très sûr – MAIS le potentiel de perte de données existe toujours. Ne le faites pas sans avoir sauvegardé tout ce que vous ne devez pas perdre.) * Beaucoup de ces étapes nécessite les droits d’Administrateur ; assurez-vous donc que vous savez utiliser cela sur votre système, car il y en a de petites variations dans divers parfums d’Ubuntu.

J’ai écrit cet article pour les non experts (comme moi) et j’ai donc inclus beaucoup de contrôles croisés pour éviter des erreurs. Les lecteurs plus expérimentés peuvent sans doute sauter certaines de ces étapes s’ils le souhaitent.

Getting Information About Your System Boot your computer normally and open a terminal. Type: df and look under the “Mounted On” column to find the root symbol (/). On my machine, this is opposite /dev/sda2, and this tells me that the system presently running is on Partition #2 (below). Make a note of this number from your own system, the drive name might change after rebooting but the partition number won’t, so it is important to remember which partition you are going to copy. Now type: sudo mkdir /00_CLONE to provide an easily recognizable marker for the cloned system in the root folder.

Récupérez des informations concernant votre système

Démarrez votre ordinateur normalement et ouvrez un terminal. Tapez :

df

et cherchez le symbole de root (/) dans la colonne « Monté sur ». Sur ma machine, c’est en face de /dev/sda2 et cela m’indique le système s’exécute sur la Partition n° 2 (ci-dessous). Notez ce numéro sur votre propre système, car le nom du disque peut changer après un redémarrage, mais le numéro de la partition ne le fera pas et c’est important de vous souvenir de la partition que vous allez copier.

Tapez maintenant :

sudo mkdir /00_CLONE

pour fournir un marqueur pour le système cloné qui soit facilement reconnaissable dans le dossier root.

Cloning Your System Now reboot your computer from a Live USB stick; you can use the install media for your system or any other Ubuntu flavour – I am using a clone of my base system on a USB. Booting from a live USB is important as you will be working on the system partitions, and it is much safer if nothing is mounted. This way, we can be sure that your base system in particular is unmounted, and not damaged by anything that you do. So, begin by opening a terminal and typing sudo umount -a to unmount everything. Plug in your installation media to a vacant USB port. Open the program gparted (included as part of the live USB)

Cloner votre système

Maintenant, redémarrez votre ordinateur à partir d’une clé USB Live ; vous pouvez utiliser le média d’installation de votre système ou celui de n’importe quelle saveur d’Ubuntu – j’utilise un clone de mon système de base sur une clé USB. Démarrer à partir d’une clé USB live est important, car vous travaillerez sur les partitions du système sur l’ordinateur, et c’est beaucoup plus sûr si rien n’est monté. Comme cela, on peut être certain que votre système de base, en particulier, n’est pas monté et ne sera pas endommagé quoi que vous fassiez. Ainsi, commencez par ouvrir un terminal et tapez

sudo umount -a

pour démonter tout.

Branchez le média d’installation sur un port USB vacant.

Ouvrez le programme gparted, qui est inclus sur l’USB live.

This is my “testing” laptop and you can see that I have a 250GB drive designated as /dev/sda with 4 partitions (below). I have arranged my system with 2 partitions for storage of personal files (/dev/sda3 and /dev/sda4), so my Ubuntu system partition (/dev/sda2, mounted at /) is just 30GB. If you click the pulldown menu at the top-right, you will get the partition layout for the other drives on the system, in this case the portable SSD that you will use to clone your system, as well as the Live USB that you booted from. If your drive contains any data, it will be completely destroyed by the following process so make sure you don’t need anything that is left on the SSD. Select the SSD from the drop-down menu, click on Device > Create Partition Table, and make sure you choose “gpt” as the partitioning system so that it is compatible with UEFI booting. Click Apply to make the change, your device now shows unallocated space for the entire drive (top right).

Ceci est mon portable de « tests ». Vous pouvez voir que j’ai un disque de 250 Go appelé /dev/sda avec 4 partitions (ci-dessous). J’ai regroupé mes fichiers personnels dans 2 partitions (/dev/sda3 et /dev/sda4) et, ainsi, la partition de mon système Ubuntu (/dev/sda2, monté à /) ne fait que 30 Go. Si vous cliquez sur le menu déroulant en haut à droite, vous aurez la disposition des partitions pour les autres disques sur le système, dans ce cas le SSD portable que vous utiliserez pour cloner votre système, ainsi que l’USB Live sur lequel vous avez démarré.

Si votre disque contient des données, elles seront complètement détruites par le processus qui suit. Aussi, assurez vous de n’avoir besoin de rien qui reste sur le SSD. Sélectionnez le SSD dans le menu déroulant, cliquez sur Périphérique → Créer une table de partitions et assurez-vous de choisir « gpt » comme système de partitionnement pour qu’il soit compatible avec le démarrage UEFI. Cliquez sur Appliquer pour faire la modification et votre dispositif affiche maintenant Non alloué pour le disque entier (en haut à droite).

to reboot. It is unclear why this message sometimes appears when other times it does not; however, it seems that clicking Ignore and proceeding does not appear to cause any problems. If this makes you nervous, close gparted, reboot, and then proceed. Now select Partition > New to create the first of 2 partitions. The “Free space following (MiB)” will vary depending on the size of your SSD, but the other values should be as shown here – note the use of “cleared” in the File System box, this ensures there are no filesystem remnants still present (bottom right). Click “Add” and then click on the green checkmark at the top to apply this change. Do NOT format this partition to FAT 32, it will not work for devices with 4096-byte sectors. (See Technical Note #1 at the end of the article for a full explanation of why this is the case).

pour redémarrer. La raison pour laquelle ce message apparaît - ou pas – n’est pas claire ; toutefois, cliquer sur Ignorer et continuer de semble pas causer de problème. Si cela vous rend anxieux, fermez gparted, redémarrez, puis continuez.

 Maintenant sélectionnez Partition → Nouvelle pour créer la première de 2 partitions.

L’« Espace disponible suivant (Mo) » variera selon la taille de votre SSD, mais les autres valeurs devraient être celles qui sont montrées ici – notez l’utilisation de « supprimé » dans la boîte du Système de fichiers : cela vous assure qu’il n’y reste plus de vestiges du système de fichiers (en bas à droite). Cliquez sur « Ajouter » puis cliquez sur le crochet vert en haut pour appliquer ce changement. NE FORMATEZ PAS cette partition en FAT 32, car il ne fonctionnera pas pour des dispositifs à secteurs de 4096 bytes. (CF la Note technique n°1 à la fin de l’article pour une explication complète des raisons pour cela.)

Next select Partition > New to create the second partition for the Ubuntu system itself and adjust the values as appropriate (above). Once again, select Add and then apply this change. Each of these partitions serves an important function: Partition #1 provides a place for the UEFI GRUB bootloader files, and Partition #2 contains your Ubuntu filesystem. Now go back to select the device name of your hard drive, right-click on your Ubuntu partition, and select Copy. Switch to the SSD, double check that Partition #2 is unmounted, right-click on it, and select Paste. Depending on the size of the partition you are copying, this could take an hour or more; for this size of partition it was about 15 minutes. This procedure makes an exact and complete copy of your Ubuntu partition, including the label if there is one, and the UUID (Universal Unique ID). Furthermore, gparted will automatically “grow” the filesystem to use all of the partition (bottom left).

Ensuite sélectionnez Partition → Nouvelle pour créer la seconde partition pour le système d’Ubuntu lui-même et ajustez les valeurs comme il faut (ci-dessus). À nouveau, sélectionnez Ajouter, puis appliquez ce changement.

Chacune de ces partitions a une fonction importante : la Partition n° 1 fournit un endroit pour les fichiers du du chargeur de démarrage GRUB UEFI et la Partition n° 2 contient le système de fichiers de votre Ubuntu.

Maintenant, retournez sélectionner le nom de dispositif de votre disque dur. Faites un clic droit sur la partition Ubuntu et sélectionnez Copier. Changez pour le SSD, vérifiez à nouveau que la Partition n° 2 n’est pas montée, faites un clic droit dessus et sélectionnez Coller. Selon la taille de la partition que vous copiez, cela peut prendre une heure ou plus ; pour cette taille de partition, c’était environ 15 minutes. Cette procédure crée une copie exacte et complète de la partition d’Ubuntu, y compris l’étiquette, le cas échéant, et l'UUID (l’ID universel et unique). Qui plus est gparted étendra automatiquement le système de fichiers pour qu’il utilise toute la partition (en bas à gauche).

Once this copying step is complete, right-click on Partition #2, and give the partition the label Ubuntu_SSD, just to make it easier to identify; and apply the change. Right-click on Partition #1 and select Manage Flags > boot,esp so that this partition is recognized as an EFI partition. Click Close to apply the change but don’t close gparted yet as it is still needed in the next step. If you open a terminal and type: sudo blkid you will note that both the hard drive Ubuntu partition (/dev/sda2 in my case) and the partition on the SSD (/dev/sdb2 in my case) have exactly the same UUID . This is a problem for GRUB as it typically will boot the first partition it finds with the UUID in its configuration file, generally the hard drive, resulting in a failure to boot from the SSD. Using gparted, select the SSD and right-click on the Ubuntu_SSD partition, select New UUID, and apply this change; now gparted can be closed. Open a terminal and type: sudo blkid again and you will see that the UUID for the Ubuntu system partition is unchanged BUT the Ubuntu_SSD partition now has a different UUID.

Une fois cette étape de copie terminée, faites un clic droit sur la Partition n° 2 et donnez-lui l’étiquette Ubuntu_SSD pour le rendre plus facile à identifier, puis appliquez le changement. Faites un clic droit sur la Partition n° 1 et sélectionnez Gérer les drapeaux → boot, esp afin que cette partition soit reconnue comme un partition EFI. Cliquez sur Fermer pour appliquer le changement, mais ne quittez pas encore gparted, car vous en aurez besoin lors de la prochaine étape.

Si vous ouvrez un terminal et saississez :

sudo blkid

vous verrez que les deux partitions Ubuntu, celle sur le disque sur (/dev/sda2 dans mon cas) et celle sur le SSD (/dev/sdb2 dans mon cas) ont exactement la même UUID. C’est un problème pour GRUB car, habituellement, il démarrera sur la première partition qu’il trouve avec l’UUID dans son fichier de configuration, généralement le disque dur, et ne démarrera pas sur le SSD. Dans gparted, selectionnez le SSD et faites un clic droit sur la partition Ubuntu_SSD, sélectionnez Nouvelle UUID et appliquez ce changement. Vous pouvez maintenant fermer gparted. Ouvrez un terminal et tapez :

sudo blkid

à nouveau et vous verrez que l’UUID pour la partition du système Ubuntu n’a pas changé, MAIS que la partition Ubuntu_SSD a maintenant une UUID différente.

Now we need to format the EFI partition (/dev/sdb1 in my case) with a FAT32 filesystem. Open a terminal and type: sudo mkfs.fat -v -F 32 -S 4096 -s 1 /dev/sdX1 (change X to an appropriate value for your system where X = a, b, c …), and after this completes successfully, you can close the Live USB, remove it when prompted to do so, and reboot your system normally. At this point, I suggest that you right-click on the Desktop and at least temporarily change the background. Later on, this is an easy way for you to know you booted from the SSD (which will have the old background) rather than the system on the hard drive which has the new one. Also open a terminal and type: sudo rmdir /00_CLONE which puts your base system back the way it was before we started; but, leaves a 00_CLONE marker in the root directory of the SSD. This marker provides a good way to ensure that we don’t mix up our locations between the hard drive and the SSD clone and edit the wrong system files.

Maintenant, il faut formater la partition EFI (/dev/sdb1 dans mon cas) en FAT32. Ouvrez un terminal et tapez :

sudo mkfs.fat -v -F 32 -S 4096 -s 1 /dev/sdX1

(en changeant X à la valeur approprié pour votre système où X = a, b, c …), et, quand cela se termine avec succès, vous pouvez fermer la clé USB Live, enlevez-la à l'invite et redémarrez votre système normalement.

À ce stade, je suggère de faire un clic droit sur le Bureau et de changer le fond d'écran, au moins temporairement). Plus tard, ce sera une façon simple pour savoir si vous avez démarré sur le SSD (qui aura le vieux fond d'écran) plutôt que le système sur le disque dur qui a le nouveau. Il faut aussi ouvrir un terminal et taper :

sudo rmdir /00_CLONE

ce qui mettra votre système de base à son état de départ, avant que l'on n'ait commencé le travail ; mais laissera un repère 00_CLONE dans le répertoire root du SSD. Ce repère fournit une bonne façon de nous assurer que nous ne mélangeons pas notre emplacement - soit sur le disque dur, soit sur le clone SSD - et que ne n'éditons donc pas les mauvais fichiers système.

Adjusting UUIDs to Correct Values The next thing to do is to change the UUIDs in two system files on the SSD to match their new values so that GRUB finds the SSD system rather than the system on the hard drive that we cloned. (Note: Remember, all of these UUIDs will be different on your system so use the ones displayed in your terminal window rather than the ones displayed here). The two files that require adjustment are: /etc/fstab and /boot/grub/grub.cfg. Open a terminal and type: sudo blkid to bring up the UUIDs of all the partitions on your system once again, then open the File Manager and click on Ubuntu_SSD. (bottom left)

Ajuster les UUID aux valeurs correctes

Ensuite, il faudra changer l'UUID dans deux fichiers système sur le SSD à leur nouvelle valeur afin que GRUB trouve le système SSD plutôt que celui sur le disque dur que nous avons cloné. (Note : Souvenez-vous que toutes ces UUID seront différentes sur votre système ; il faut utiliser celles affichées dans la fenêtre de votre terminal plutôt que celles montrées ici). Les deux fichiers qu'il faut ajuster sont : /etc/fstab et /boot/grub/grub.cfg. Ouvrez un terminal et tapez :

sudo blkid

pour faire afficher à nouveau les UUID de toutes les partitions sur votre système, puis ouvrez le Gestionnaire de fichiers et cliquez sur Ubuntu_SSD (en bas à gauche).

You should see the folder 00_CLONE and the address bar showing Ubuntu_SSD mounted at /media since it is an external USB device, otherwise you are in the wrong location. Remedy this immediately, you do NOT want to edit the fstab file of your base system! Navigate to /etc so you can Edit as Administrator the file /etc/fstab. Copy and paste the UUID for Ubuntu_SSD into this file and delete the previous UUID entry (line 9). You will also need to edit the entry like the one at line 14, with the UUID for the EFI partition so that it gets mounted when Ubuntu_SSD boots (above). Save the file and exit after making these changes. Next, use the up-arrow of File Manager to move back up the directory structure to navigate to /boot/grub, and Edit as Administrator the file /boot/grub/grub.cfg. Find the old UUID (the one for your hard drive) somewhere in the file, and highlight it. Select Search, and this highlighted value will be in the “Search for” box. Paste the UUID for Ubuntu_SSD from the terminal into the “Replace with” box, and select “Replace All (next page, top right). Select Close, then Save this file and exit.

Vous devez voir le dossier 00_CLONE ; la barre d'adresses elle, doit montrer Ubuntu_SSD monté à /media puisse qu'il s'agit d'un dispositif USB externe, sinon vous n'êtes pas là où vous devez être. Il faut y remédier tout de suite, car vous ne voulez PAS éditer le fichier fstab de votre système de base ! Naviguez à /etc afin de pouvoir éditer come Administrateur le fichier /etc/fstab/ Faites un copier/coller de l'UUID pour Ubuntu_SSD dans ce fichier et supprimez l'entrée UUID précédente (ligne 9). Il faudra aussi éditer l'entrée comme celle à la ligne 14, avec l'UUID pour la partition EFI afin qu'elle soit montée quand 'Ubuntu_SSD démarre (ci-dessus). Enregistrez le fichier et quittez après avoir fait ces modifications.

Ensuite, utilisez la flèche vers le haut du Gestionnaire de fichiers pour remonter le structure des répertoires et naviguer jusqu'à /boot/grub, puis éditez comme Administrateur le fichier /boot/grub/grub.cfg. Trouvez la vieille UUID (celle pour votre disque dur) quelque part dans le fichier et surlignez-la. Sélectionnez Rechercher et cette valeur surlignée figurera dans le champ de recherches. Collez l'UUID pour Ubuntu_SSD à partir du terminal et dans le champ Remplacer et sélectionnez Tout remplacer (page suivante, en haut à droite). Sélectionnez Fermer, puis Enregistrer ce fichier et quittez.

Installing Bootloaders

Although there is a complete Ubuntu installation on the SSD, it is not yet directly bootable; however, it is safest to install boot loaders from a working system. As this step is crucial to the process, I am providing two different methods of booting into your cloned system in the unlikely event that one or the other does not work. This way, the appropriate bootloaders can be installed from the SSD in a working state.

Method #1 (Preferred):

There is an easy “trick” you can use to boot your newly created Ubuntu_SSD system without a bootloader installed. Simply open a terminal and type:

sudo update-grub

When you do this, GRUB should find the Ubuntu_SSD installation on /dev/sdX2 (where /dev/sdX2 is the device name for your Ubuntu_SSD partition), and add it to the GRUB boot menu. If update-grub does not find Ubuntu_SSD on /dev/sdX2, then use Method #2. Otherwise reboot your system and use the down-arrow to select the new entry corresponding to your Ubuntu_SSD installation and boot into the cloned system – you will know you were successful as long as the old background appears.

Method #2 (Fallback):

Reboot your system normally and when the GRUB menu appears, press the “c” key immediately to get a grub > prompt. If you don’t normally get a GRUB menu when you boot, then press the ESC key repeatedly as soon as you reboot and the GRUB menu should appear, then press “c” immediately. Type:

ls

and you will get a list of all the devices that GRUB recognizes, for example: (hd0), (hd0,gpt1), (hd0, gpt2), (hd1), (hd1,gpt1), and so on. You need to find which one of these is the location of Ubuntu_SSD. Because it was installed on the second partition, just check each drive’s second partition until you find the right one. Type:

ls (hd0,2)/

If you see the folder 00_CLONE, you’re done; if not, type ls (hd1,2)/ then ls (hd2,2)/ … until you find it. Now type each of the following commands, one at a time, and press ENTER after each command. If you don’t get an error message, then they have executed correctly. Replace X with the value you found for the Ubuntu_SSD partition in the previous step.

set prefix=(hdX,2)/boot/grub

set root=(hdX,2)

insmod normal

normal

The computer should now boot and display a rather unusual GRUB menu which consists of two typical GRUB menus stacked one after the other. These are the menus from the base system (the top one) and the SSD system (the second one). Simply use the down-arrow to select the “Ubuntu” entry in the second GRUB menu and the computer should boot into the cloned system – once again the old background tells you that you have successfully booted from the SSD.

Open a terminal and type:

df

and check the device name (/dev/sdX2) mounted at the root (/) as drive names sometimes change after a reboot. There should also be a device (/dev/sdX1) mounted at /boot/efi (if there isn't, that will get addressed in a moment). Open the File Manager and check that 00_CLONE is present in the root filesystem, then Open as Administrator the /boot folder of your Ubuntu_SSD system. There should be a folder called efi; if there isn’t, right-click to create a new folder named efi. This ensures that there is a mount point of /boot/efi for the EFI partition as required. The EFI partition ought to have been mounted here by fstab at boot time, but just to err on the side of caution, let’s unmount and remount it to be sure. Type:

sudo umount /boot/efi

and then mount the EFI partition from the SSD with:

sudo mount /dev/sdX1 /boot/efi

(where /dev/sdX1 is the device name for your EFI partition) so that bootloader files can be written to that partition.

The first thing to check before doing anything else is that all of the appropriate grub packages are installed on your SSD. To do this, open Synaptic, select Status > Installed, and scroll down to grub entries. There are 6 things to look for (below). Depending on how your system is configured, these may or may not be installed but they all need to be there to proceed.

If any are missing, select All and scroll down to the grub packages and install it/them. If you do one at a time, others may get installed automatically in the event several are missing. If Synaptic is not on your system (it is no longer installed on newer Ubuntu distros by default), install it with:

sudo apt-get install synaptic

However, if you have another preferred method for checking installed packages and installing any missing ones, you can use that instead. Once the 6 grub packages are all installed, open a terminal and type:

sudo apt-get install –reinstall shim-signed

You may be asked to confirm where you want to install the bootloader files and this is /dev/sdX1 (the EFI partition we created at the start). If you are presented with a graphical screen with several choices, use the space-bar to toggle the asterisk indicating your choice, the arrow keys to navigate; and the ENTER key when you are ready to proceed.

This particular method actually installs a series of bootloader files, including those required for booting with secure boot enabled. If you Open as Administrator the folder /boot/efi and then double-click on EFI, you should see 2 folders, BOOT and ubuntu. These folders contain the files needed to boot Ubuntu (ubuntu) and also a “fallback” option (BOOT) in case something doesn’t work properly.

Your clone Ubuntu_SSD is now a complete, portable system. Reboot your computer and press the F12 key (or whatever key you normally use) to bring up the boot menu. Select the USB SSD device and you should boot into Ubuntu with the old background screen. Open a terminal and type:

df

and you should see both the Ubuntu_SSD partition mounted as root (/) and the EFI partition mounted on /boot/efi; if you don’t, go back and double-check the UUIDs in /etc/fstab and edit as required. As your final step type:

sudo update-grub

to ensure that the GRUB configuration file is correctly updated. If you plan to use this SSD clone in a semi-permanent way, I suggest you modify the boot order settings in the UEFI firmware to boot from USB first. This way, the computer will always boot from the USB SSD if it’s plugged in, and you can always choose to boot to the hard drive by selecting the appropriate option from the GRUB menu that will be displayed at boot time.

I have successfully booted this SSD drive on both of my laptops that support UEFI booting (Acer and Dell). It is impossible to guarantee that it will perform correctly on every system; but, hopefully it works for you!

Technical Note #1

I originally used gparted to format the EFI partition to a FAT32 filesystem and although I did not receive any error messages, the resulting system would not boot! Interestingly, using gparted to check the EFI partition does produce an error message saying that “Filesystem is bigger than its volume!”, but there is really no reason to do that when there is no indication anything is wrong. After seeing this cryptic message, I used the terminal command:

sudo fsck.fat -v -n /dev/sdb1

to check the filesystem on the EFI partition to try to get more detailed information. The resulting details (Figure 11), along with some digging into the FAT32 specification, explain the problem.

A valid FAT32 partition must contain a minimum of 65,525 clusters, where a cluster is a whole number (1, 2, 4, 8, … 128) multiple of the sector size. The sector size of this SSD is 4096 and the program that gparted calls to do the formatting (mkfs.fat) chooses to use a multiple of 8 for a cluster size of 8 × 4096 = 32,768 bytes. The minimum size for a valid FAT32 partition with this cluster size would be 65,525 × 32,768 = 2,147,123,200 bytes (~ 2.1 GB), far bigger than our 500MB partition. I suspect that mkfs.fat uses this multiple because with a sector size of 512, a multiple of 8 produces a 4096-byte cluster, which is the recommended size for partitions between 256MB and 2 GB; however, it seems that gparted doesn’t check sector size before calling mkfs.fat with its default values. Unfortunately, the UEFI firmware checks the number of clusters to decide if there is a valid EFI partition or not, and because there are not 65,525 clusters, it won’t recognize the partition or boot from it. The workaround is to use the terminal command:

sudo mkfs.fat -v -F 32 -S 4096 -s 1 /dev/sdX1

where the -s 1 option specifies a multiple of 1. A multiple of 1 produces a cluster size of 1 × 4096 = 4096, which requires only 4096 × 65,525 = 268,390,400 bytes (~ 268MB), well within the 500 MB size of the EFI partition. Problem solved.

Technical Note #2

If you are using a device with 512-byte sectors, just use gparted to format the EFI partition to FAT32 rather than using the terminal command. Everything else stays the same.

issue173/tutoriel2.1632930481.txt.gz · Dernière modification : 2021/09/29 17:48 de auntiee