I was trying to encrypt my Xiaomi Redmi 5 Plus (Settings -> Security & location -> Encryption & credentials -> Encrypt phone). I was not successful as I was hitting LineageOS bug.
Encryption did not finish, display just went black and returned back to lock screen.
In the output of adb logcat command was:

01-10 22:05:33.655   445  7908 E Cryptfs : Bad magic for real block device /dev/block/bootdevice/by-name/userdata
01-10 22:05:33.656   445  7908 E Cryptfs : Orig filesystem overlaps crypto footer region.  Cannot encrypt in place.
How to fix it:
  1. On the phone go to Settings -> About phone and click on Build number multiple times until you enable developer options.
  2. On the phone go to Settings -> System -> Advanced -> Developer options and enable Root access and Android debugging.
  3. Turn off the phone. Then press Volume Up and Power button to get into Recovery.
  4. Connect the phone to computer via USB cable. On the computer run adb shell command.
  5. Mount system partition by running command
      mount /dev/block/bootdevice/by-name/system /system
      
  6. Check filesystem:
      /system/bin/e2fsck /dev/block/bootdevice/by-name/userdata
      
  7. Find out Block count for the partition we are going to resize:
      tune2fs -l /dev/block/bootdevice/by-name/userdata | grep 'Block count:'
      
    Example:
    # tune2fs -l /dev/block/bootdevice/by-name/userdata | grep 'Block count:'
    Block count:              6273913
    
  8. Subtract 4 from Block count and use result in resize command for the partition.
    Example:
    # /system/bin/resize2fs  /dev/block/bootdevice/by-name/userdata 6273909
    resize2fs 1.43.3 (04-Sep-2016)
    Resizing the filesystem on /dev/block/bootdevice/by-name/userdata to 6273909 (4k) blocks.
    The filesystem on /dev/block/bootdevice/by-name/userdata is now 6273909 (4k) blocks long.
    
  9. Reboot the phone and start phone encryption again.

If you have any questions regarding this, feel free to contact me at my e-mail address.


Google ads



Last modified:

Valid HTML 4.01!
Copyright (c) 2020 PAVUK