dd partition into file on block device level encrypted drive

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 my 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 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 do something wrong to the LUKS container?


Solution 1:

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.