themaddoctor / linux-mybook-tools

tools for opening some encrypted WD My Book drives in linux
GNU General Public License v3.0
181 stars 26 forks source link

device-mapper: reload ioctl on wd-layer1 (253:1) failed: No such file or directory. #82

Open Antx0n opened 1 year ago

Antx0n commented 1 year ago

Hi, First of all, thank you for your work, it is remarkable, not only because of the amount of work but also because it is disinterested. As most people you are trying to help, I am trying to recover the pictures I had on a My Book Essential 3TB that died after an electrical overload. The closest thread/issue that I have found is this one: https://github.com/themaddoctor/linux-mybook-tools/issues/58, in the sens that I screwed up and clicked the initialize button when Windows prompted it (it was an early morning)... The procedure works fine (I get the DEK and activate the new module without issues) until setting up the filter, then I get the following error:

WARNING: Device /dev/sda already contains a 'gpt' partition signature.
device-mapper: reload ioctl on wd-layer1 (253:1) failed: No such file or directory.

Is there something that I can try? I eventually thought

Key-block: (my drive is from April 2012 according to the label):

00000000  57 44 76 31 b1 56 00 00  00 a0 4f 5d 01 00 00 00  |WDv1.V....O]....|
00000010  03 00 00 00 00 00 f0 00  00 00 00 00 00 00 00 00  |................|
00000020  01 00 00 00 00 00 17 70  00 00 00 00 00 00 00 00  |.......p........|
00000030  00 02 ff 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  20 00 3c ee 00 00 00 01  00 00 00 00 57 44 76 31  | .<.........WDv1|
00000060  33 a5 8f 18 57 53 78 c0  08 24 2f 92 75 3f d6 c3  |3...WSx..$/.u?..|
00000070  53 f5 9c ca f2 84 bf e1  ea 1b 3f a7 30 eb 1c d4  |S.........?.0...|
00000080  43 66 2d 79 54 e4 db d8  9a 33 56 38 0a a6 43 05  |Cf-yT....3V8..C.|
00000090  8e 27 2c 3d 19 b1 b3 e7  a4 e1 8f de e7 9c a5 ff  |.',=............|
000000a0  5f 55 20 8e ed 9b 87 e2  ba 87 19 37 73 c8 59 7f  |_U ........7s.Y.|
000000b0  04 e3 b3 cd ec bd 9a 36  d7 c9 b8 ee 07 41 20 3c  |.......6.....A <|
000000c0  3d 1a 85 75 7e d1 be 32  cd 20 9c 7e ea 3e f4 c2  |=..u~..2. .~.>..|
000000d0  45 e3 82 a1 59 59 4d f8  1b b4 28 40 40 25 d8 e3  |E...YYM...(@@%..|
000000e0  c3 7c ad ed b0 b1 de 16  2a 3d 25 74 42 73 a6 d1  |.|......*=%tBs..|
000000f0  f7 f8 de 92 bd 01 5f 17  d7 1a 3f 41 7f 77 77 bb  |......_...?A.ww.|
00000100  9a 40 89 43 45 53 1d 47  c4 c3 92 37 d7 55 e5 be  |.@.CES.G...7.U..|
00000110  bd a4 e9 a0 76 62 67 2b  f6 e3 1f f7 a0 0f 23 63  |....vbg+......#c|
00000120  7e 2a 10 3d d2 d6 51 72  8a 5c 86 43 f1 1b dd 93  |~*.=..Qr.\.C....|
00000130  71 d2 03 11 bb fb 9a ac  93 9e ab f7 c7 03 63 80  |q.............c.|
00000140  d4 d9 88 9b 2d 41 8a 01  40 5b 13 9a 53 53 28 39  |....-A..@[..SS(9|
00000150  69 a0 98 2e d2 23 c5 34  90 11 78 dd 67 06 0c 13  |i....#.4..x.g...|
00000160  db d6 ec 90 ca 49 75 df  22 f9 99 ed a8 77 28 0c  |.....Iu."....w(.|
00000170  a1 e8 c7 7b 8f be c0 50  7f 7b 07 aa 59 5d c1 2c  |...{...P.{..Y].,|
00000180  87 a8 a0 c8 2a db e2 6d  17 f3 a7 b1 5c c3 27 0c  |....*..m....\.'.|
00000190  5e 60 2a 9b 27 47 87 5a  04 b2 18 b3 d7 04 fb 47  |^`*.'G.Z.......G|
000001a0  02 2d 1e e4 a8 e5 62 44  e0 b9 74 d6 28 3e ad 8d  |.-....bD..t.(>..|
000001b0  1b d8 d8 31 db 28 e6 71  df 9c 27 40 80 db 07 a6  |...1.(.q..'@....|
000001c0  b8 66 f1 e6 62 49 f2 0e  30 0e 91 23 ac 18 11 3b  |.f..bI..0..#...;|
000001d0  0e 75 e8 10 82 d7 03 33  a1 a2 53 3a 62 f8 6d 9d  |.u.....3..S:b.m.|
000001e0  06 25 60 8d 73 80 0d 21  35 60 c8 14 50 b7 3a 4f  |.%`.s..!5`..P.:O|
000001f0  5e 23 c9 63 1d 28 51 5f  42 b6 07 43 af a4 04 fd  |^#.c.(Q_B..C....|
00000200

Sector 0:

00000000  33 c0 8e d0 bc 00 7c 8e  c0 8e d8 be 00 7c bf 00  |3.....|......|..|
00000010  06 b9 00 02 fc f3 a4 50  68 1c 06 cb fb b9 04 00  |.......Ph.......|
00000020  bd be 07 80 7e 00 00 7c  0b 0f 85 0e 01 83 c5 10  |....~..|........|
00000030  e2 f1 cd 18 88 56 00 55  c6 46 11 05 c6 46 10 00  |.....V.U.F...F..|
00000040  b4 41 bb aa 55 cd 13 5d  72 0f 81 fb 55 aa 75 09  |.A..U..]r...U.u.|
00000050  f7 c1 01 00 74 03 fe 46  10 66 60 80 7e 10 00 74  |....t..F.f`.~..t|
00000060  26 66 68 00 00 00 00 66  ff 76 08 68 00 00 68 00  |&fh....f.v.h..h.|
00000070  7c 68 01 00 68 10 00 b4  42 8a 56 00 8b f4 cd 13  ||h..h...B.V.....|
00000080  9f 83 c4 10 9e eb 14 b8  01 02 bb 00 7c 8a 56 00  |............|.V.|
00000090  8a 76 01 8a 4e 02 8a 6e  03 cd 13 66 61 73 1c fe  |.v..N..n...fas..|
000000a0  4e 11 75 0c 80 7e 00 80  0f 84 8a 00 b2 80 eb 84  |N.u..~..........|
000000b0  55 32 e4 8a 56 00 cd 13  5d eb 9e 81 3e fe 7d 55  |U2..V...]...>.}U|
000000c0  aa 75 6e ff 76 00 e8 8d  00 75 17 fa b0 d1 e6 64  |.un.v....u.....d|
000000d0  e8 83 00 b0 df e6 60 e8  7c 00 b0 ff e6 64 e8 75  |......`.|....d.u|
000000e0  00 fb b8 00 bb cd 1a 66  23 c0 75 3b 66 81 fb 54  |.......f#.u;f..T|
000000f0  43 50 41 75 32 81 f9 02  01 72 2c 66 68 07 bb 00  |CPAu2....r,fh...|
00000100  00 66 68 00 02 00 00 66  68 08 00 00 00 66 53 66  |.fh....fh....fSf|
00000110  53 66 55 66 68 00 00 00  00 66 68 00 7c 00 00 66  |SfUfh....fh.|..f|
00000120  61 68 00 00 07 cd 1a 5a  32 f6 ea 00 7c 00 00 cd  |ah.....Z2...|...|
00000130  18 a0 b7 07 eb 08 a0 b6  07 eb 03 a0 b5 07 32 e4  |..............2.|
00000140  05 00 07 8b f0 ac 3c 00  74 09 bb 07 00 b4 0e cd  |......<.t.......|
00000150  10 eb f2 f4 eb fd 2b c9  e4 64 eb 00 24 02 e0 f8  |......+..d..$...|
00000160  24 02 c3 49 6e 76 61 6c  69 64 20 70 61 72 74 69  |$..Invalid parti|
00000170  74 69 6f 6e 20 74 61 62  6c 65 00 45 72 72 6f 72  |tion table.Error|
00000180  20 6c 6f 61 64 69 6e 67  20 6f 70 65 72 61 74 69  | loading operati|
00000190  6e 67 20 73 79 73 74 65  6d 00 4d 69 73 73 69 6e  |ng system.Missin|
000001a0  67 20 6f 70 65 72 61 74  69 6e 67 20 73 79 73 74  |g operating syst|
000001b0  65 6d 00 00 00 63 7b 9a  00 00 00 00 00 00 00 00  |em...c{.........|
000001c0  02 00 ee fe ff ff 01 00  00 00 ff ff ff ff 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|

Sector 2048:

00000000  8c 2d 83 ce d3 2c 1a 08  ea 3f 01 3c 8a a7 13 1c  |.-...,...?.<....|
00000010  62 48 c1 6b 1f 45 5e 7e  14 69 bf ca b9 c3 b8 40  |bH.k.E^~.i.....@|
00000020  6e c4 55 bc ec c3 3d 18  3d 64 99 24 7e b7 f9 59  |n.U...=.=d.$~..Y|
00000030  e7 97 63 39 82 e9 5f 21  a6 79 f7 92 92 20 1b d6  |..c9.._!.y... ..|
00000040  db d1 30 30 68 3a 94 2e  f9 e9 31 55 3a b2 1f 74  |..00h:....1U:..t|
00000050  27 a2 c4 bc 0f be be 1d  db fb 3f 88 85 60 d3 78  |'.........?..`.x|
00000060  bf f5 ca ee 7e c0 c5 33  1e f0 75 c9 af cd e2 4b  |....~..3..u....K|
00000070  a6 7e 39 57 77 49 1b ca  ee df 3a 0a a1 31 e8 23  |.~9WwI....:..1.#|
00000080  98 b3 54 ec 79 8b e6 84  11 34 02 2b 5a cd 91 2b  |..T.y....4.+Z..+|
00000090  b9 bd 4f 11 c8 43 18 9c  10 67 8f 40 83 f7 8e c6  |..O..C...g.@....|
000000a0  3b 67 ee d5 76 64 f5 bd  88 a8 61 d8 38 ba 7b e9  |;g..vd....a.8.{.|
000000b0  39 50 5d 4c e0 39 9c 06  a3 6c fe 33 41 e7 93 64  |9P]L.9...l.3A..d|
000000c0  f3 66 16 1a f4 bc 86 df  9a 65 21 94 fc df a3 d9  |.f.......e!.....|
1+0 records in
1+0 records out
512 bytes copied, 0.000437318 s, 1.2 MB/s
000000d0  f9 64 35 12 5e 15 4b 8a  1a e8 fa d8 64 24 73 07  |.d5.^.K.....d$s.|
000000e0  ef 2a 4b fd 79 d0 cf 3b  12 c7 89 ef e1 8e 46 0f  |.*K.y..;......F.|
000000f0  10 44 b8 df af 66 0b 0f  54 28 1b 7e cc fc 1b c0  |.D...f..T(.~....|
00000100  1f ec ca 38 68 5d e6 58  2e b3 8a e8 2a a8 4b 64  |...8h].X....*.Kd|
00000110  cf db 0e 8d 76 d4 17 bf  0f ac 39 40 c3 0d f9 a8  |....v.....9@....|
00000120  c2 3e 3c 4b c6 f8 ca 6f  dc d6 cc 48 43 04 90 5f  |.><K...o...HC.._|
00000130  81 3e 4f 93 58 3d 40 b4  ac 90 aa 8f 8d 49 9b f4  |.>O.X=@......I..|
00000140  e6 86 b2 79 7b 29 b9 95  71 f9 3e 18 75 44 b1 31  |...y{)..q.>.uD.1|
00000150  78 c1 de 5f 9f a3 b5 e5  72 30 a7 3a 57 bd bc 39  |x.._....r0.:W..9|
00000160  a0 8e 34 1b 3f 16 81 10  f8 ea 61 8a 53 fe ee 42  |..4.?.....a.S..B|
00000170  c5 cc 38 40 96 ea 21 68  8b 78 42 16 15 74 aa 1f  |..8@..!h.xB..t..|
00000180  7e 96 46 1d c4 a6 29 2b  cf a6 a4 cb 6a c6 12 84  |~.F...)+....j...|
00000190  b9 5e 1c d5 81 8d e7 81  f2 f0 13 a5 8b b8 32 6d  |.^............2m|
000001a0  ef 66 b8 d0 bd e4 88 4b  76 22 f4 71 1b db e7 e4  |.f.....Kv".q....|
000001b0  04 da 76 7c 08 85 ac 19  cd 44 0c 25 9a 1b dc 17  |..v|.....D.%....|
000001c0  bc 92 60 f1 08 aa 2e c8  2a f1 1f 70 54 ed 60 81  |..`.....*..pT.`.|
000001d0  df 63 ad 67 7c 9d 8c 0c  92 76 f5 fc 64 49 d3 56  |.c.g|....v..dI.V|
000001e0  1f 6c e2 b3 53 80 cc 18  8f d8 12 b4 3d 1b db 97  |.l..S.......=...|
000001f0  44 61 b5 1e 5f 1a 8c 9c  1b f4 e6 3f ca be b6 e0  |Da.._......?....|
00000200
themaddoctor commented 1 year ago

Your NTFS filesystem is luckily still at sector 2048, and is encrypted. You will have to use the loopback method at the end of the PDF document.

The error message you report indicates that something doesn't exist. Try using /dev/dm-1 instead of /dev/mapper/wd-layer1, because a few years ago, linux decided to do things differently. Running the command ls -l /dev/mapper/wd-layer1 will tell you if it is a symbolic link and where it points.

Antx0n commented 1 year ago

Hi, Thank you very much for your answer; I have tried to implement your suggestions, but I still have the same issue.

Regarding the loopback method:

I get the same error when I try sudo file -s /dev/mapper/wd or sudo file -s /dev/dm-1

image

Regarding error:

ls -l /dev/mapper/wd-layer1 and echo | sudo cryptsetup -d - -c rev16-ecb \ create wd-layer1 /dev/sda
both return WARNING: Device /dev/sda already contains a 'gpt' partition signature. device-mapper: reload ioctl on wd-layer1 (253:1) failed: No such file or directory

Finally, the adapted cat dek.hex | xxd -p -r | sudo cryptsetup -d - --hash=plain \ --key-size=256 -c aes-ecb create wd-layer2 /dev/dm-1 returns Device /dev/dm-1 does not exist or access denied.

I suppose that I am doing something the wrong way or that there has been a second change in the way linux does things? I checked in the dev/mapper folder, and I only have 2 folders: control and cryptswap

themaddoctor commented 1 year ago

I dunno. Start over and make sure you don't make any mistakes.