Duplicate a Drive in Linux
Bash, Linux, Sysadmin
The dd
command allows you to duplicate or clone drives exactly - the target will have the same permissions, formatting and media name.
If the source drive is LUKS encrypted, the target drive will have exactly the same encryption state, and will be unlocked by the same passphrase as the original.
I find this useful for making cloned copies of thumbdrives containing password databases.
Determine Paths
This can be achieved with the lsblk
command:
In this case, /dev/sdc
is the source (or ‘input file’ in dd
parlance) and /dev/sdd
is the target (or ‘output file’).
Clone Drives
Make sure you correctly identify the drives - especially the output/target, since dd
will overwrite all data. In this case, we can easily identify the pair of thumbdrives based on their size.
When finished, the new drive will be an exact copy - with the same identifier. As such, it won’t be possible to mount the original and the clone at the same time.
Because of this, if you want to repeat the process you may need to temporarily change the passphrase on the target drive, or wipe it altogether. To wipe the drive:
References
/dev/zero
- provide null characters- Cloning an encrypted drive
comments powered by Disqus