I’m trying to clone my wife’s laptop to a USB. Her laptop is a dual boot WIN11 and ubuntu 22.04.
The laptop has a 500gb NVME ssd and we want to backup to a 1tb usbc.
I know I can easily use dd to copy nvme —> usb. The problem is if the NVME goes bad, how to restore using dd from a 1tb usb to the 500gb NVME ? DD wants a Destination => the Source.
I’ve had some problems with clonezilla, but it might have been my bad. I would prefer not to use clonezilla.
I prefer not to use an image file, just an exact copy that hopefully would boot.
If you want a reliable way to clone an entire dual-boot disk and be able to restore it later without messing with partition sizes manually, Clonezilla is usually the best option. It creates a bootable USB you can run independently of your installed OS and will clone the whole drive (all partitions, bootloader, UEFI, etc.) so the target should boot just like the source.
Yes, I did notice that the OP prefers not to use Clonezilla.
However, I suggested it because in this specific scenario (full disk clone, dual boot, different drive sizes, and bootability requirements), it is generally the safest and most reliable solution.
As long as your external USB drive is larger than your internal disk, you really answered your own question with the reference to “dd”.
Best to work from “static” or “quiescent” system, so should boot from Live ISO to perform the “mirroring” tasks:
internal disk to external USB
external USB to internal disk
For that process, the command I would use to perform the mirroring would be:
DSK_internal="if=/dev/sd[a-z]" # edit with your drive's assigned letter
USB_target="of=${USB_device}"
options="bs=4M status=progress conv=fdatasync iflag=direct oflag=direct"
echo "\n COMMAND: dd ${DSK_internal} ${USB_target} ${options} ...\n"
dd ${DSK_internal} ${USB_target} ${options}
BUT … I personally believe it best to use the approach of
partition to partition
and not
disk to disk
Again boot from a Live ISO but, this time, the operation should be limited to actual data on disk. This should be performed using the rsync utility.
This approach does not mirror the boot sector or partition table, which you would need to (re)build on the replacement internal disk, before restoring the mirror image, again using rsync.
For the rsync mirroring, I would use the following command:
#!/bin/sh
DSK_internal="/dev/" # e.g. /dev/sdb1 (partition on internal disk which is usually mounted as root)
USB_disk="/dev/" # e.g. /dev/sdc1 (partition on external USB drive intended as target for mirroring of internal disk)
exit ## delete this line after updating the above with the proper *** PARTITION *** values
###
### Define disk mountpoints
###
DSK_mount="/mirror_source"
mkdir "${DSK_mount}"
test $? -eq 0 || { echo "\n was unable to create required mountpoint for internal disk ROOT directory.\n" ; exit 1 ; }
USB_mount="/mirror_usb"
mkdir "${USB_target}"
test $? -eq 0 || { echo "\n was unable to create required mountpoint for external USB drive.\n" ; exit 1 ; }
###
### Mount disks
###
DSK_fstype=$( lsblk -P -p -o NAME,FSTYPE | grep "${DSK_internal}\"" | cut -f4 -d\" )
mount -t ${DSK_fstype} ${DSK_internal} "${DSK_mount}"
USB_fstype=$( lsblk -P -p -o NAME,FSTYPE | grep "${USB_disk}\"" | cut -f4 -d\" )
mount -t ${USB_fstype} ${USB_disk} "${USB_target}"
USB_target="${USB_mount}/root/"
mkdir "${USB_target}"
test $? -eq 0 || { echo "\n was unable to create required mirror ROOT directory on external USB drive.\n" ; exit 1 ; }
USB_log="${USB_mount}/logs/"
mkdir "${USB_log}"
test $? -eq 0 || { echo "\n was unable to create required directory for persisten log of mirror task on external USB drive.\n" ; exit 1 ; }
###
### Mirror data from internal onto USB
###
cd "${DSK_mount}"
test $? -eq 0 || { echo "\n was unable to set ROOT on internal disk as work directory to start mirror process.\n" ; exit 1 ; }
rsync \
--one-file-system \
--recursive \
--outbuf=Line \
--links \
--perms \
--times \
--group \
--owner \
--devices \
--specials \
--verbose \
--out-format="%t|%i|%M|%b|%f|" \
--delete-during \
--whole-file \
--human-readable \
--protect-args \
--ignore-errors \
--msgs2stderr \
./ "${USB_target}" 2>${USB_log}.err | tee ${USB_log}.out
Confirm that personal data backups are recent and intact
Boot into a “Try Ubuntu” live session
Attach your usb (target) device
Open Gparted
Check that the internal disk and target disks are visible
Verify that the partitions are not mounted
The target disk must have the same partition table as the source (should be GPT as Windows 11 is involved). No need to create partitions on the target disk.
Copy the first source partition and paste to the free space on the target disk
Repeat until all partitions have been copied and pasted sequentially without error
Ubuntu will boot from the external USB (the source disk must be removed/isolated/de-activated)
Ubuntu will boot on another (similar) PC
Windows 11 will not boot from an external device. It may boot as an internal disk, but be aware about Microsoft policy concerning Hardware Change
The procedure to restore is identical (change source and target)
I am a happy user of Clonezilla, but you want alternatives.
dd is dangerous. It will do what you tell it to do without any questions. This means that a minor mistake (selecting the wrong letter for the target device) can make you erase valuable personal files (documents, photos, video clips etc).
I created mkusb in order to wrap a ‘safety belt’ around dd. Later on I have added several other functions to the program package mkusb. I suggest that you use the tool dus to clone your nvme device to a USB device.
Boot from a separate drive (not the nvme source, not the target usb drive). Install mkusb into that system (I suggest a live Ubuntu system booted from a separate USB drive)
Use the following command to identify the nvme device
lsblk -e7 -f
My nvme device is seen as nvme0n1. You should clone the whole nvme device, not a partition. You may need to modify some device letter or digit according to the output of lsblk
dus /dev/nvme0n1
Now there will be a dialogue, that will help you identify the target device, and there will be a final checkpoint, where you can doublecheck that you have selected the correct target device. When you know that you are pointing to the correct target, start the cloning process.
Clone to restore
Boot from a separate drive (not the nvme source, not the target usb drive). Install mkusb into that system.
Use the following command to identify the devices
lsblk -e7 -f
When you want to restore from the USB drive to an nvme device, you can run the following command
dus /dev/sdx
where x is the device letter of the usb drive (maybe a, b, c …) depending on what is connected to the computer and the order that the devices are identified at boot or when connected after boot. You can use the dialogue to identify the target (in this case the nvme device) and doublecheck the selection at the final checkpoint. When you know that you are pointing to the correct target, start the cloning process.
Just to review, I want to make a clone of my wife’s Dual boot (Win11 & Ubuntu) laptop as I am about to add Refind and upgrade her ubuntu 22.04 to 24.04. If something goes wrong than I will be looking for a place to move in to . I am really trying to wean her off of Microsoft.
So I would ideally clone the FULL laptop nvme to a removable drive. If something happens to the laptop nvme, an error on my part, or the nvme ‘burns out’, I would replace the laptop nvme with a band new one and:
Boot the laptop with an ubuntu usb
Mount the backup containing the original cloned nvme, and copy it, byte for byte, to the new laptop nvme.
Ideally, that would allow me to boot the laptop’s new nvme, and all is good.
Hopefully Microsoft won’t complain about the ‘hardware upgrade’ .
And you are right - clonezilla may be the best option. I have been ‘playing’ on computers since 1966, and I am super careful when backing up/restoring drives. Somehow, maybe a finger problem, I used clonezilla to clone a drive and it wrote something on my source drive.
I guess I will give clonezilla another shot. Do any of you have a spare bedroom?
If your wife’s PC has “Secure Boot” with UEFI, you need to research that to ensure you have the correct process down pat to temporarily bypass the boot security in order to make your proper copy.
If you are using Clonezilla, I suggest that you make a compressed image on the USB drive, and then restore from that image to whatever drive, that you want to use later.
As the name indicates, It is possible to clone using Clonezilla, but it does not want to clone from a bigger drive to a smaller drive. If that is what you want, I would suggest that you use mkusb as described in my previous post (its tool dus).
When using mkusb, the crucial thing is that all the partitions (and the backup partition table) fit into the target drive (both in the backup step and the restore step). If there is a GUID partition table, mkusb (or to be more detailed, dus) will run a function that fixes the backup partition table at the tail end of the drive.
If the partitions do not fit into the smaller drive, but there is enough free space in the last partition you can shrink it to fit (you can use gparted to do it fairly easily).