Outils pour utilisateurs

Outils du site


issue174:tutoriel1

Ceci est une ancienne révision du document !


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

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.

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.

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.

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.

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.

issue174/tutoriel1.1635701092.txt.gz · Dernière modification : 2021/10/31 18:24 de auntiee