1

Got a redmi note 5 pro, some time ago and I have been fiddling with it. I tried to encrypt the device when it ran Resurrection Remix OS, for some reason, it appears to be working and then less than 30 seconds later, it just shows me the lockscreen again. It never seems to encrypt.

Is it a problem in the latest oreo build or is it a problem in the ROM?

What might be a viable solution?

1 Answer 1

1

Encryption requires that 16KiB remain unused by the filesystem on the userdata partition. You can check if this is the issue by

  • Do adb logcat > android.log on a computer
    • enable developer options first
    • you might need to root, I don't think so though
  • Start the encryption process in settings

If this is the problem, you'll see the following in the logs:

E Cryptfs : Orig filesystem overlaps crypto footer region.  Cannot encrypt in place.

To fix this issue, you'll need to resize your userdata partition.


If it's ext4, I believe that you can use resize2fs to do this. I'm not sure how to do this though.


If it's f2fs, the process is quite a bit more involved:

Reboot into TWRP. Do adb shell on a computer. fdisk -l /dev/block/sda to view the partition structure. You'll see something like this:

Logical sector size: 4096
Disk identifier (GUID): 98101b32-bbe2-4bf2-a06e-2bb33d000c20
Partition table holds up to 16 entries
First usable sector is 6, last usable sector is 14145530

Number  Start (sector)    End (sector)  Size       Code  Name
   1               6               7        8192   0700  ssd
   2               8            8199       32.0M   0700  persist
   3            8200           73735        256M   0700  cache
   4           73736           73991       1024K   0700  misc
   5           73992           74119        512K   0700  keystore
   6           74120           74151        128K   0700  devcfg
   7           74152           74183        128K   0700  devcfgbak
   8           74184           74311        512K   0700  frp
   9           74312           76871       10.0M   0700  oem_dycnvbk
  10           76872           79431       10.0M   0700  oem_stanvbk
  11           79432           79687       1024K   0700  param
  12           79688           81711       8096K   0700  reserve1
  13           81712           85759       15.8M   0700  reserve2
  14           85760           85887        512K   0700  config
  15           85888        14145530       53.6G   0700  userdata

Make a note of:

  • the "Logical sector size"
  • the partition number for userdata
  • the start sector for userdata
  • the end sector for userdata

Make a backup of this partition. You will lose the data on it if you don't, it will be explicitly wiped. I believe that TWRP has a function to do this, but I used a tarball & adb pull:

In adb shell:

~ # mount /dev/block/sda15
~ # tar -cpzf /mnt/fs.tar.gz /mnt/
tar: removing leading '/' from member names
tar: /mnt/misc/camera/cam_socket2: socket ignored
...
tar: /mnt/fs.tar.gz: file is the archive; skipping

then adb pull /mnt/fs.tar.gz

Unmount the partition using umount /mnt

Next, wipe part of the existing filesystem to make sure that we don't get any warnings when making the new filesystem: dd if=/dev/zero of=/dev/block/sda<partition number> bs=1M count=128. This is the point of no return.

Create a new filesystem using the numbers you wrote down from before: calculate partition_size = end_sector - start_sector - (16384 / logical_sector_size) manually, and make a note of that number.

Then run mkfs.f2fs /dev/block/sda<partition number> <partition_size> to create a new partition of the appropriate size.

Mount it, and use adb push fs.tar.gz /mnt/ to send over your backed up data. cd /mnt; tar -xf fs.tar.gz; mv mnt/* .; rm -rf mnt fs.tar.gz to extract, and you're done!

Restart and retry encrypting! Hopefully everything will work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .