I need to make a backup of a partition which I usually do with:

dd if=/dev/sda1 of=/mnt/secret/sda1_back.img

The point is secret is a LUKS/dm-crypt block level encrypted device, is dd gonna mess with the encryption since it works so low, or is it gonna work fine since dd goes into a file?


I think I need to clarify me question: sda1 is not encrypted. I need to make a backup asap since sda is giving me I/O Errors. On /mnt/secret I have got a LUKS/dm-crypt encrypted device mounted, it's actually for other things but, it's the only place I have enough free space to for the backup. My question is: after the above command, will i be able to read the .img file normally after I unlocked the LUKS container and mounted it? Or will it fuck up the LUKS container?

  • An encrypted system partition needs a non-encrypted /boot partition to boot. So, if your intention is cloning a system partition take that into consideration. The partition you're cloning itself will not be messed with because dd works with raw data, or simply copies the block device as stated in the first answer. – user692175 Aug 16 '17 at 20:49
  • 1
    There's nothing low-level in your of=. You instructed dd to output whatever it reads from /dev/sda1 to a file (a "real" one, not one under /dev), so no, nothing is gonna break. – Tom Yan Aug 17 '17 at 11:20
  • This is the answer I needed, I was looking for! Thank you! – silentpanther127 Aug 18 '17 at 19:02

It's not gonna mess with the encryption - as dd simply copies the block device. However, the copy will be encrypted, and you need the passphrase or other unlock method to mount it.

You can, if you want an unencrypted backup, copy the mapped container instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.