share
Unix & LinuxAccidentally executed luksFormat instead of luksOpen
[0] [1] user1753343
[2020-04-14 19:30:54]
[ raid luks mdadm restore ]
[ https://unix.stackexchange.com/questions/580080/accidentally-executed-luksformat-instead-of-luksopen ]

I have two disks as RAID-1 encrypted via LUKS:

# blkid
...
/dev/md0: UUID="x-x-x-x-x" TYPE="crypto_LUKS"

Accidently I executed cryptsetup luksFormat /dev/md0 instead of cryptsetup luksOpen /dev/md0 secure. luksFormat returned WARNING: Device /dev/md0 already contains a 'crypto_LUKS' superblock signature.

Now I cant use open anymore, the following lines provide more information:

# cryptsetup luksOpen /dev/md0 secure
Device /dev/md0 is not a valid LUKS device.
# cryptsetup luksDump /dev/md0
Device /dev/md0 is not a valid LUKS device.
# hexdump -C /dev/md0 | grep LUKS
00000000  4c 55 4b 53 ba be 00 02  00 00 00 00 00 00 40 00  |LUKS..........@.|
hexdump: /dev/md0: Input/output error

Is there anything I can do, to get my data?

(2) What happened after the "WARNING: Device /dev/md0 already contains a 'crypto_LUKS' superblock signature."? Did you go on with the format or did you abandon it? Also, the "Input/output error" lets me believe you have a drive with a problem. - bey0nd
There wasn't any additional output. I interpreted it as "found data but will format it anyway". - user1753343
[+1] [2020-04-14 20:22:02] bey0nd [ACCEPTED]

From man cryptsetup (section luksFormat):
WARNING: Doing a luksFormat on an existing LUKS container will make all data of the old container permanently irretrievable, unless you have a header backup.

I guess you don't have a header backup and therefore your data will be history.
Sorry for the bad news.

Nevertheless, the hexdump: /dev/md0: Input/output error indicates a problem with one of your drives!!


You are correct regarding the man-pages and also regarding the drives: dmesg shows many messages like Buffer I/O error on dev md0, logical block 64, async page read. - user1753343
1