Directly Cloning Partition Layout of Main Linux Installation: Updated UUIDs and EFIs
Cloning a Linux drive can be a challenging task, especially when dealing with UEFI files and SATA/USB connections that tend to freeze. This article will provide a detailed guide on how to clone a Linux drive, update the UUIDs, and manage EFI files while ensuring a smooth SATA/USB connection.
Prerequisites
- A Linux drive to clone
- A target drive with equal or greater storage capacity
- A USB drive or SATA cable to connect the target drive to the system
- A Linux live environment, such as Ubuntu or Fedora, to perform the cloning process
Partitioning the Target Drive
To ensure a successful clone, the target drive must have the same partition layout as the source drive. Use a partitioning tool, such as fdisk or gdisk, to create identical partitions on the target drive.
Example: Partitioning with fdisk
sudo fdisk /dev/sdX
# List current partitions
p
# Delete all existing partitions
d
# Create new partitions with the same layout as the source drive
n
# Follow the on-screen instructions to create partitions
t
# Set partition types as needed
w
Cloning the Source Drive
Clone the source drive to the target drive using a cloning tool, such as dd or clonezilla.
Example: Cloning with dd
sudo dd if=/dev/sdY of=/dev/sdX bs=4M status=progress
Updating UUIDs
After cloning, the UUIDs of the target drive's partitions may conflict with the source drive. Use the tune2fs command to update the UUIDs.
Example: Updating UUIDs
sudo tune2fs -U random /dev/sdX1
Managing EFI Files
Ensure that the EFI files are correctly copied to the target drive's EFI system partition. If the SATA/USB connection freezes, try using a different cable or port, or consider using an external USB enclosure.
Example: Checking EFI Files
ls /boot/efi/EFI/
Updating Boot Loader
Update the boot loader on the target drive using the efibootmgr command.
Example: Updating Boot Loader
sudo efibootmgr -c -d /dev/sdX -p Y -l \\EFI\\\\grubx64.efi -L
- Partition the target drive to match the source drive layout
- Clone the source drive to the target drive using a cloning tool
- Update the UUIDs of the target drive's partitions
- Manage EFI files and update the boot loader on the target drive
References
-
Book: Linux Bible by Christopher Negus
-
Online Resource: Arch Linux: Partitioning
--endarticle--