TeamWin / Team-Win-Recovery-Project

Core recovery files for the Team Win Recovery Project (T.W.R.P) - this is not up to date, please see https://github.com/TeamWin/android_bootable_recovery/
http://twrp.me
1.94k stars 740 forks source link

Format Data as f2fs doesn't leave room for crypto footer on 2013 Moto X (Ghost) #1060

Open csnook opened 6 years ago

csnook commented 6 years ago

TWRP 2.8.7.0 2013 Moto X Developer Edition (Ghost)

LineageOS only supports f2fs on Ghost, so ext4 is not an option for me. When formatted as f2fs from TWRP, it doesn't leave room for the cryptfs footer, so it's impossible to enable encryption. When Data is reformatted with 'fastboot erase userdata', I'm able to encrypt after installing.

While there is a workaround, this is incredibly frustrating and I burned several hours on it before the LineageOS devs helped me figure out what was going wrong.

nailyk-fr commented 6 years ago

Do you know if your device have a metadata partition? Have the same issue on leo, crypto footer was not wiped with format data nor wipe data,yes menu. Looks like at twrp start crypto footer is 'locked' so a few reboot+format later encryption was gone.

csnook commented 6 years ago

My device has lots of partitions, most of which don't show up in TWRP and are not mounted by LineageOS. I have no idea if any of them are considered metadata partitions for these purposes.

shell@ghost:/ $ cat /proc/partitions
major minor  #blocks  name

 179        0   30535680 mmcblk0
 179        1     102400 mmcblk0p1
 179        2       1500 mmcblk0p2
 179        3       1500 mmcblk0p3
 179        4        514 mmcblk0p4
 179        5        512 mmcblk0p5
 179        6        142 mmcblk0p6
 179        7        210 mmcblk0p7
 179        8        512 mmcblk0p8
 179        9       1024 mmcblk0p9
 179       10       3076 mmcblk0p10
 179       11       1500 mmcblk0p11
 179       12       2048 mmcblk0p12
 179       13       1500 mmcblk0p13
 179       14        500 mmcblk0p14
 179       15        500 mmcblk0p15
 179       16        512 mmcblk0p16
 179       17       1632 mmcblk0p17
 179       18       3072 mmcblk0p18
 179       19       3072 mmcblk0p19
 179       20       2048 mmcblk0p20
 179       21        640 mmcblk0p21
 179       22          8 mmcblk0p22
 179       23       8192 mmcblk0p23
 179       24          8 mmcblk0p24
 179       25       3072 mmcblk0p25
 179       26       1024 mmcblk0p26
 179       27        512 mmcblk0p27
 179       28       3072 mmcblk0p28
 179       29        128 mmcblk0p29
 179       30       4096 mmcblk0p30
 179       31       4096 mmcblk0p31
 259        0       1024 mmcblk0p32
 259        1      10240 mmcblk0p33
 259        2      10240 mmcblk0p34
 259        3       8192 mmcblk0p35
 259        4    1041920 mmcblk0p36
 259        5       1024 mmcblk0p37
 259        6    1572864 mmcblk0p38
 259        7     110592 mmcblk0p39
 259        8   27606912 mmcblk0p40
 254        0   27606896 dm-0
shell@ghost:/ $ mount
rootfs on / type rootfs (ro,seclabel,relatime)
tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,seclabel,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
/sys/kernel/debug on /sys/kernel/debug type debugfs (rw,seclabel,relatime)
none on /acct type cgroup (rw,relatime,cpuacct)
none on /sys/fs/cgroup type tmpfs (rw,seclabel,relatime,mode=750,gid=1000)
tmpfs on /mnt type tmpfs (rw,seclabel,relatime,mode=755,gid=1000)
none on /dev/cpuctl type cgroup (rw,relatime,cpu)
none on /sys/fs/cgroup/bfqio type cgroup (rw,relatime,bfqio)
/dev/block/platform/msm_sdcc.1/by-name/system on /system type ext4 (ro,seclabel,relatime,data=ordered)
/dev/block/platform/msm_sdcc.1/by-name/cache on /cache type ext4 (rw,seclabel,nosuid,nodev,noatime,nodiratime,noauto_da_alloc,data=writeback)
/dev/block/platform/msm_sdcc.1/by-name/fsg on /fsg type ext4 (ro,context=u:object_r:firmware_file:s0,nosuid,nodev,relatime,nobarrier)
/dev/block/platform/msm_sdcc.1/by-name/modem on /firmware type ext4 (ro,context=u:object_r:firmware_file:s0,nosuid,nodev,relatime,nobarrier,data=ordered)
/dev/block/platform/msm_sdcc.1/by-name/persist on /persist type ext4 (rw,defcontext=u:object_r:persist_file:s0,seclabel,nosuid,nodev,relatime,data=ordered)
/dev/block/platform/msm_sdcc.1/by-name/pds on /pds type ext4 (ro,defcontext=u:object_r:pds_file:s0,seclabel,nosuid,nodev,relatime,nobarrier,errors=remount-ro,data=ordered)
tmpfs on /storage type tmpfs (rw,seclabel,relatime,mode=755,gid=1000)
/dev/block/dm-0 on /data type f2fs (rw,seclabel,nosuid,nodev,noatime,nodiratime,background_gc=on,user_xattr,inline_xattr,acl,inline_data,active_logs=6)
/dev/fuse on /mnt/runtime/default/emulated type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/fuse on /storage/emulated type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/fuse on /mnt/runtime/read/emulated type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/fuse on /mnt/runtime/write/emulated type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)
csnook commented 6 years ago

It's worse than I thought. TWRP is unable to decrypt that partition that was reformatted with fastboot, so I can't install updates.

I'll soon have another phone and be able to do destructive experiments, but this is outside my area of expertise, so I need some guidance.