lubuntu 18.10 x64 installed on USB stick clone to usb stick 2
Solution 1:
Cloning from one drive to another drive
What you describe in your question works in general.
sudo dd if=/dev/sdx of=/dev/sdy bs=4096 && sync
I have done it successfully with USB pendrives as well as with HDDs and SSDs.
But there are several things that can make it go wrong.
-
The target drive must be at least as big as the source drive. Not one single byte smaller. It is not enough that the drives have the same nominal size, for example 16 GB. You can check with
sudo parted /dev/sdx u b p sudo parted /dev/sdy u b p
where
x
andy
should be replaced with the device letters for the source and target drives, andu b
makes the output in bytes andp
tellsparted
to print (to standard output). If there is a GUID partition table, GPT, (and not an old style MSDOS partition table), and the drives have not exactly the same size, you must repair the backup partition table at the tail end of the drive. The previous command lines with
parted
will also show the partition table. You can usegdisk
for this repair job.If the physical sector sizes are different between the source and target drives, there will also be problems. Small and old drives have usually 512 bytes physical sectors, but some new drives (medium size and huge size) sometimes have 4096 bytes physical sectors. This can cause problems after cloning, and it is probably better the install a fresh system in the new drive and transfer the files, that you want into the new drive (copy on the file level instead of cloning on the drive level). The previous command lines with
parted
will also show the physical sector size.Both the source drive and the target drive must be healthy. If there is a bad sector (physical sector), the corresponding data cannot be transferred for that particular location, and it may cause a problem (big or small, depending on what is stored in that location).
-
Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file in order to clone from a drive with an installed Lubuntu system to some other drive.
No partition on the source drive and the target drive should be mounted. Unmount if some partition is mounted.
sudo umount /dev/sdxn
where
x
is the device letter andn
is the partition number. -
Cloning with
dd
is risky, because it does what you tell it to do without any questions. A minor typing error is enough to make it overwrite the family pictures. For this reason it is better to use a tool which helps you identify the target drive and has a final checkpoint, where you can double-check that things will go right.- in Linux you can use Disks alias
gnome-disks
or mkusb - in Windows you can use Win32 Disk Imager.
- in Linux you can use Disks alias
You can also clone with Clonezilla. Boot a USB pendrive or DVD disk made from a stable
clonezilla.iso
file. This is safer thandd
because of several checkpoints and questions, and faster because Clonezilla is smart enough to only copy used blocks (and skip free blocks) of the file systems. This makes a big difference if a file system is far from full.And last but not least, you must let the process finish properly and let the system flush the buffers to the target drive. This is why it is important to run
sync
and wait until it finishes, and the terminal window returns to prompt.
Cloning via an image file
- What is described here is also relevant if you clone in an indirect way by creating an image file from the source drive and restore from the image file to the target drive.
After the cloning, connect only one drive to the computer
-
If there are writable file systems, you must not boot a computer with both the source and target (of the cloning) connected. These drives have identical data, and there will probably be confusion, which can destroy one or both of the drives.
So boot into either the original (source) drive or into the cloned copy (target) drive, and keep the other drive disconnected (unplugged).