Last night, I messed up my LineageOS 16 install on my Galaxy S5 and had to reinstall it, starting essentially from scratch. I wanted to see if there was any way I could decrypt the 128 GB microSD card I used as adopted storage and found this tutorial. I got the key from a backup made using TWRP and tried it on Linux Mint 20 MATE (booting from USB), but it didn't work. The following command gave me an error:
dmsetup create crypt1 --table "0 `blockdev --getsize /media/mint/4B2E-1F13` crypt aes-cbc-essiv:sha256 [16-BYTE HEX KEY] 0 /media/mint/4B2E-1F13 0"
blockdev: ioctl error on BLKGETSIZE: Inappropriate ioctl for device
/dev/mapper/control: open failed: Permission denied
Failure to communicate with kernel device-mapper driver.
Incompatible libdevmapper 1.02.167 (2019-11-30) and kernel driver (unknown version).
Doing it with sudo gave me this error:
blockdev: ioctl error on BLKGETSIZE: Inappropriate ioctl for device
Invalid format on line 1 of table.
Command failed.
I couldn't even mount the SD card with Termux when after putting it back into my phone. Is my data unrecoverable? Do I have the wrong key? Thanks.
/media/mint/4B2E-1F13must be a directory. You need to provide the block device path todmsetup. It must be something like/dev/sdbor/dev/sdc. Usedfto see available block devices. Or see kernel log usingdmesgwhen connecting SD card to PC. // Btw your question is about Linux, not Android. – Irfan Latif Jul 22 '20 at 00:51/media/mint/4B2E-1F13to/dev/mmcblk0p1(my SD card according todf -h) and the error messages were the same except theBLKGETSIZElines were replaced withblockdev: cannot open /dev/mmcblk0p1: Permission denied. The same thing happens when inputting/dev/mmcblk0instead. – Pete Jul 22 '20 at 01:18blockdevin backticks just type value of partition size directly and use proper path to block device – alecxs Jul 22 '20 at 03:01sudowithdmsetupas well asblockdev(both are separate commands). Or write partition size directly as alecxs said to avoid usingblockdevin subshell. Provide encrypted partition (mmcblk0p1), not whole SD card (mmcblk0). – Irfan Latif Jul 22 '20 at 07:24mmcblk0p1is ~17 MB and gets mounted automatically upon insertion at/media/mint/4B2E-1F13. The file browser shows it as empty with ~127 GB free. There's an unmounted 2nd partition (~119 GB) calledmmcblk0p2and I don't know if I can mount this (or if I even should). I think I'll try the command again, but with ````sudobeforeblockdevas well asdmsetupand use/dev/mmcblk0p1instead of/dev/mmcblk0``` and see what happens. – Pete Jul 22 '20 at 10:37/dev/mmcblk0p2. You need to decrypt it before you can mount it. There is no visible filesystem on it until it's encrypted. – Irfan Latif Jul 22 '20 at 10:40