[newbie] Cryptfs : Unexpected value for crypto key location (lineage os, 17.1, Samsung S9+)

leobassin

Member
Jul 11, 2020
35
3
8
- Samsung S9+, 256 Gb
- Lineage OS 17.1
- TWRP 3.5

I've successfully installed Lineage OS 17.1 on my Samsung S9+. It's been working fine so far. However, when I encrypt the OS from the security menu, right after the screen goes black with the green android-like logo, the phone quickly reboots back to the non encrypted OS. Going again through the process does not help. I'm not sure this issue is related to Lineage OS, so that's why I did not open this thread under Lineage.

I've checked forums on the web, and some of them are indicating a filesystem issue – wrong block size – after looking at the logs. The issue here is that logcat isn't showing anything related to that (recovery.log and dmesg.log). Where should I look for the logs related to the encryption failing?

Also, is there a way to run the encryption manually, from command like, at TWRP?
 
Last edited:

leobassin

Member
Jul 11, 2020
35
3
8
These are actual the partitions:
/boot | /dev/block/sda10 | Size: 55MB
/recovery | /dev/block/sda11 | Size: 64MB
/cache | /dev/block/sda21 | Size: 574MB Used: 0MB Free: 574MB Backup Size: 0MB
/system_root | /dev/block/sda18 | Size: 4281MB Used: 1574MB Free: 2707MB Backup Size: 1574MB
/vendor | /dev/block/sda19 | Size: 617MB Used: 511MB Free: 106MB Backup Size: 511MB
/data | /dev/block/sda25 | Size: 232658MB Used: 1544MB Free: 231020MB Backup Size: 1544MB
/system_image | /dev/block/sda18 | Size: 4400MB
/vendor_image | /dev/block/sda19 | Size: 650MB
/odm_image | /dev/block/sda20 | Size: 616MB
/modem | /dev/block/sda12 | Size: 50MB
/efs | /dev/block/sda3 | Size: 15MB Used: 2MB Free: 13MB Backup Size: 2MB
/misc | /dev/block/sda15 | Size: 1MB
/odm | /dev/block/sda20 | Size: 592MB Used: 102MB Free: 490MB Backup Size: 102MB
/preload | /dev/block/sda22 | Size: 40MB Used: 7MB Free: 32MB Backup Size: 7MB
/external_sd | /dev/block/mmcblk0p1 | Size: 30432MB Used: 642MB Free: 29789MB Backup Size: 642MB
/usb-otg | | Size: 0MB Used: 0MB Free: 0MB Backup Size: 0MB

Which partitions should be encrypted? Are there /boot, /recovery, /system_root, and /data?
 

leobassin

Member
Jul 11, 2020
35
3
8
I tried this too:
  • Boot into recovery
  • Select ‘Wipe’
  • Select ‘Advanced Wipe’
  • Select data partition
  • Select ‘Resize’
Not working, i.e., same result.
 

leobassin

Member
Jul 11, 2020
35
3
8
I finally got the logs via logcat. This is what comes out during the encryption through the Settings menu:

--------- beginning of main
01-20 19:17:52.959 4019 4129 D vold : fdeEnable(3, *, 0)
01-20 19:17:52.960 4019 4129 D vold : !fscrypt_is_native, spawning fdeEnableInternal
01-20 19:17:52.960 4019 403 E Cryptfs : Unexpected value for crypto key location
01-20 19:17:52.961 4019 403 E Cryptfs : Cannot get size of block device
01-20 19:17:53.067 4019 403 W vold : Found symlink /proc/29802/cwd referencing /data/misc/keystore
01-20 19:17:53.067 4019 403 W vold : Found symlink /proc/29803/fd/7 referencing /data/vendor/gps/.lhd.lock
01-20 19:17:53.068 4019 403 W vold : Found symlink /proc/29803/fd/12 referencing /data/vendor/gps/.pipe.gpsd_to_lhd.to_server
01-20 19:17:53.068 4019 403 W vold : Found symlink /proc/29803/fd/14 referencing /data/vendor/gps/.pipe.gpsd_to_lhd.to_client
01-20 19:17:53.069 4019 403 W vold : Found symlink /proc/29804/fd/7 referencing /data/vendor/gps/.gpsd.lock
...
...
01-20 19:17:53.217 4019 403 W vold : Sending Killed to 32740
01-20 19:17:53.218 4019 403 W vold : Sending Killed to 32509
01-20 19:17:53.218 4019 403 W vold : Sending Killed to 32383
...
...
01-20 19:17:53.221 4019 403 E Cryptfs : Unexpected value for crypto key location
01-20 19:17:53.221 4019 403 E Cryptfs : Cannot get size of block device
--------- beginning of crash

Is it because there are symlinks pointing to /data/? Newbie question: should I perhaps format /data/ and try again?
Needless to say that any help would be greatly appreciated!
 

leobassin

Member
Jul 11, 2020
35
3
8
Al right, I got it to work (finally!) by following Alecxs's advice on StackExchange, then Simuroc's script on Gitlab.
When the phone boots up, now, it asks for the PIN. The only remaining issue is TWRP not being able to decrypt /data as it asks for a password, which I do not know – the PIN does not work. This isn't really an issue for me at this point, but if anybody has a suggestion, I'd be happy to hear it.