Can you remove encryption? - Xperia Z3 Compact Q&A, Help & Troubleshooting

I setup Lineage 16 on my Xperia X and encrypted the phone. Now whenever I try other ROMS (installed from twrp) it always asks for my encryption password in TWRP and on bootup. I've already tried wiping all of the partitions, I've tried changing the filesystems, I've tried the ADB command ./adb shell recovery --wipe_data --set_filesystem_encryption=off
Encryption is still intact. What can I do to nuke the phone?

I experienced something similar a while ago and if I recall correctly then played around in TWRP with "repair filesystem", and finally I got it working unencrypted again

I was in the same situation. The only way for me was to install a stock fw with Flashtools (while in bootloader mode)...and start again from zero.

Connect to PC and enter recovery
Then type following commands
Caution!!
You will lose all data!!
$ adb shell
# umount /data
# umount /sdcard
# make_ext4fs /dev/block/platform/msm_sdcc.1/by-name/userdata
Click to expand...
Click to collapse
This is pure format command. Encryption will be removed.
But only these commands we loose crypt footer. (We can never re-encrypt)
You had better add these commands also.
$ adb shell
# umount /data
# umount /sdcard
# make_ext4fs /dev/block/platform/msm_sdcc.1/by-name/userdata
(Upper section commands)
# e2fsck -f /dev/block/platform/msm_sdcc.1/by-name/userdata
(You should check "Block count" section)
# resize2fs -f /dev/block/platform/msm_sdcc.1/by-name/userdata xxxxxxxx
Click to expand...
Click to collapse
If "Block count" equals 2991611, type like this (subtract 4 from block count... 2991611-4=2991607)
# resize2fs -f /dev/block/platform/msm_sdcc.1/by-name/userdata 2991607
Click to expand...
Click to collapse

Related

[SOLVED]help creating persistent swap partition.

I am using CyanogenMod v3.6.8.1 and I decided I wanted a swap partition.
I partitioned my 2GB SD with a 32MB swap partition and formatted using gparted.
From the shell (using adb) I remounted /dev/block/mtdblock3 with rw and edited /system/etc/fstab and added a line for the swap. Here is what the entire file looks like now:
Code:
/dev/block/mtdblock3 /system yaffs2 rw
/dev/block/mtdblock4 /cache yaffs2 rw
/dev/block/mtdblock5 /data yaffs2 rw
/dev/block/mmcblk0p1 /sdcard vfat rw
/dev/block/mmcblk0p2 /system/sd auto rw
/dev/block/mmcblk0p3 none swap sw
/system/modules/modules.sqf /system/modules squashfs ro,loop
/system/xbin/xbin.sqf /system/xbin squashfs ro,loop
I can turn on the swap with 'swapon -a' which works and shows up in /proc/swaps and with the 'free' command, but upon boot, swap isn't activating.
I'm not really familiar with the android init scripts, so I'm not sure how I can enable the swap automatically upon boot. Any advice would be appreciated.
Okay I fixed it.
I downloaded one of Drizzy's roms that I know use swap, extracted, and searched for 'swap' in all the files. I found it in /system/bin/a2sd at the end. Here is what's there:
Code:
if [ -n /dev/block/mmcblk0p3 ];
then
mkswap /dev/block/mmcblk0p3;
fi;
if [ -e /dev/block/mmcblk0p3 ];
then
echo 30 > /proc/sys/vm/swappiness;
swapon /dev/block/mmcblk0p3;
fi;
The first if doesn't make sense to me as it's a string test which will always be true, so I got rid of it and just kept the test for the file existing, but I changed it to -b to be a little more specific (to see if it's a block device), and I commented out the swappiness change to leave it at default.
Im using same rom and i woild love to do this but is there any other way as im totally unfamiliar with adb
turboyo said:
Im using same rom and i woild love to do this but is there any other way as im totally unfamiliar with adb
Click to expand...
Click to collapse
I just used adb because I can use the copy/paste function of my gnome terminal and it's easier than using the shell on the phone itself.
Here is what is needed:
Get into a root shell, either on the phone or using adb.
Code:
mount -t yaffs2 -o rw,remount /dev/block/mtdblock3 /system
vi /system/bin/a2sd
press capital G which will take you to the bottom of the file
press lower case o which will open a line below your cursor for editing.
type in the following:
Code:
if [ -b /dev/block/mmcblk0p3 ];
then
echo 30 > /proc/sys/vm/swappiness;
swapon /dev/block/mmcblk0p3;
fi;
press escape to exit insert mode (I read that in the terminal emulator you have to hold the trackball and press 1 for esc)
type :wq and press enter.
exit terminal and reboot. To see if it's working, get back into a terminal and use the command 'free'
you can also do 'swapon -a' instead of specifying the swap partition itself. Note that the above example uses the third partition of the SD card as the swap.
This also assumes you have already created the swap partition and formatted it as swap.
You can omit the swappiness line to leave it at the linux default of 60.

Clear a partition

I'm looking to delete all the data and subfolders in my partitions ext3 and linux-swap, start fresh.. i dont feel like going through that long procedure of removing the actual partitions and then re-adding and allocating the blocks.
I don't use adb, i just use the console from cyanogen's recovery page. i just starting learning all of this fun linux stuff when i got my dream a few months back =P
So what's the commands to mount, then clear the info on the partitions including all sub folders?
TIA!
Boot into recovery home+power
Go to console ALT+X
type:
(press enter)
#
# mount -o rw /dev/block/mmcblk0p2 /system/sd
# rm -rf /system/sd/*
# reboot recovery
Much thanks! worked great.

Custom boot.img

Here you go, a boot.img with a custom default.prop & init.rc:
- ro.secure = 0, which means ADB running as root;
- /, /system, /data mounted as rw;
- /data/local/bin added to PATH, to ease usage of installed local commands.
Anyone wanting to use this should already now how to flash it by now
Update:
Version 2 of this boot image, that automatically loads tattoo-hack.ko, uploaded here http://forum.xda-developers.com/showpost.php?p=5792750&postcount=38.
thx,
Someone has tested? comment to be helping mainfram3
leon i go to test
mainfram3 thanks for you hard work
Thank you very much
adb push ./boot.mf3.img /sdcard
- Then, open a shell to your phone via 'adb shell', get root (type "su"), and do the following two commands to flash your new boot image:
# cat /dev/zero > /dev/mtd/mtd2
write: No space left on device [this is ok, you can ignore]
# flash_image boot /sdcard/boot.mf3.img
-Reboot
Is it right?
It´s work!!!! Thanks a lot mainfram3
chusen said:
It´s work!!!! Thanks a lot mainfram3
Click to expand...
Click to collapse
How have you installed it?
*.- adb shell
*.- su
*.- insmod /data/local/bin/tattoo-hack.ko
*.- mount -o rw,remount /dev/block/mtdblock5 /data
*.- mount -o rw,remount /dev/block/mtdblock3 /system
*.- chmod 755 /data/local/bin/flash_image
*.- /data/local/bin/flash_image boot /sdcard/boot.mf3.img
You need flash_image by mainfram3 in /data/local/bin
chusen said:
*.- adb shell
*.- su
*.- insmod /data/local/bin/tattoo-hack.ko
*.- mount -o rw,remount /dev/block/mtdblock5 /data
*.- mount -o rw,remount /dev/block/mtdblock3 /system
*.- chmod 755 /data/local/bin/flash_image
*.- /data/local/bin/flash_image boot /sdcard/boot.mf3.img
You need flash_image by mainfram3 in /data/local/bin
Click to expand...
Click to collapse
Thank you chusen
I got this:
Code:
# /data/local/bin/flash_image boot /sdcard/boot.mf3.img
/data/local/bin/flash_image boot /sdcard/boot.mf3.img
mtd: read error at 0x00000000 (Cannot allocate memory)
.............
mtd: read error at 0x00160000 (Cannot allocate memory)
flashing boot from /sdcard/boot.mf3.img
#
It is correct?
svprm said:
I got this:
Code:
# /data/local/bin/flash_image boot /sdcard/boot.mf3.img
/data/local/bin/flash_image boot /sdcard/boot.mf3.img
mtd: read error at 0x00000000 (Cannot allocate memory)
.............
mtd: read error at 0x00160000 (Cannot allocate memory)
flashing boot from /sdcard/boot.mf3.img
#
It is correct?
Click to expand...
Click to collapse
mmmm.. i think no but i dont help you sorry
Now when i go to "adb shell"
It directly go to "#"
works fine here too.
Is it safe now to delete from /data/local/bin m7, su, flash_image etc, or needed to be there?
svprm said:
Now when i go to "adb shell"
It directly go to "#"
Click to expand...
Click to collapse
mmmm.....then is correctly? any dev can help he?
mainfram3 said:
- ro.secure = 0, which means ADB running as root;
Click to expand...
Click to collapse
If you're getting a root shell, than the image is working as intended
Thanks mainfram3, works as stated
Hi
Good work Mainfram3. Congratulations.
Sorry for my English. I'm Spanish.
adb shell ----> # ---->"root"
But there is a problem. to change something in /system runs out of space.
Tested with "df" command.
before:
/system: 153600K total, 142156K used, 11444K available (block size 4096)
after:
/system: 153600K total, 153600K used, 0K available (block size 4096)
Editar/Borrar Mensaje
EDIT:
This also happened before with M7 hack.
bye
mainfram3:
Hi, how did you repack the boot.img? Repacking it as thisWiki discribed seems not working.
maverixx said:
Hi
Good work Mainfram3. Congratulations.
Sorry for my English. I'm Spanish.
adb shell ----> # ---->"root"
But there is a problem. to change something in /system runs out of space.
Tested with "df" command.
before:
/system: 153600K total, 142156K used, 11444K available (block size 4096)
after:
/system: 153600K total, 153600K used, 0K available (block size 4096)
Editar/Borrar Mensaje
EDIT:
This also happened before with M7 hack.
bye
Click to expand...
Click to collapse
I think you didn't use the tattoo-hack.ko kernel module - right? Take some time and read here: http://forum.xda-developers.com/showthread.php?t=635961 - first post under "Other developer stuff"...
-bm-
I know perfectly this post.
If system is RW is assumed that the tattoo-hack.ko module is loaded.
even by executing:
insmod /data/local/bin/tattoo-hack.ko
mount -o rw,remount /dev/block/mtdblock3 /system
it is the same.
Thanks
@mainfram3: yo can modify boot.mf3.img to load tattoo-hack.ko at star?thanks in advance

Phone won't accept decryption (FDE) password anymore.

My device: HTC One M7 Android 4.2.2, S-ON, Root, CWM recovery (years old version)
My ultimate goal was: Get xposed framework. Install via app failed after rebooting due to S-ON, so I wanted to install through recovery. (this is irrelevant to the issue IMO)
What I tried to get there: Decrypting my /data partition in adb (because CWM doesn't support it)
What I found: https : // forumDOTfairphoneDOTcom/t/how-to-mount-encrypted-data-in-recovery/25724
Everything(!) I actually did: (commands after $ means executed on host machine (ubuntu), prefixed by ~ # means run on phone in adb shell)
$ adb shell
~ # setprop ro.crypto.state encrypted
~ # vdc cryptfs checkpw "<wrong password>"
200 0 1
~ # mount /dev/block/dm-0 /data
mount: mounting /dev/block/dm-0 on /data failed: no such file or directory
(( a couple commands like ls and cat to find out what my /data partition should be ))
(( ended up finding out in fstab that it's mmcblk0p37 ))
~ # mount /dev/block/mmcblk0p27 ((accidentally wrong one))
mount: mounting /dev/block/mmcblk0p27 on /data failed: Invalid argument
~ # mount /dev/block/mmcblk0p37
mount: mounting /dev/block/mmcblk0p37 on /data failed: Invalid argument
(( notice i entered wrong password ))
~ # vdc cryptfs checkpw "<right password>"
200 0 2
~ # mount /dev/block/mmcblk0p37
mount: mounting /dev/block/mmcblk0p37 on /data failed: Invalid argument
(( a couple more tried of the previous two commands for no legit reason ))
~ # mount -o rw,remount /dev/block/mmcblk0p37
mount: mounting /dev/block/mmcblk0p37 on /data failed: Invalid argument
(( exit adb shell ))
(( execute $ adb remount )) (( as google suggested (on host machine, not in adb shell obv) ))
$ adb shell
~ # mount -t ext2 /dev/block/mmcblk0p37 (( accidentally wrong fstype ))
mount: mounting /dev/block/mmcblk0p37 on /data failed: Invalid argument
~ # mount -t ext4 /dev/block/mmcblk0p37
mount: mounting /dev/block/mmcblk0p37 on /data failed: Invalid argument
~ # mount -t ext4 /dev/block/mmcblk0p27 (( why not? ))
mount: mounting /dev/block/mmcblk0p37 on /data failed: Invalid argument
~ # exit (( i got frustrated ))
Before I did all this the phone was working normally (after install xposed via app (which gave me xposed version 3x because I had that one previously installed via receovery. But I wanted the newest (5x) so I went all that way)). After I did all these steps - which to me are readonly things which shouldn't brick anything - I got frustrated and wanted to give up, so I rebooted. Now everytime I enter the - 100% correct - password, it tells me to "try again" (guessing it means wrong password? idk).
The whole xposed stuff is irrelevant in my opinion, because after I've installed it using the xposed installer (APK) I rebooted twice and decryption worked fine both times.
What the hell have I done (I'd say I'm a linux expert and I honestly don't see how I could've possible broken anything by what I did) and how can I fix it?
UPDATE: I got myself the cryptheader from the "extra" partition using the read_emmc vulnerability. That way I got the encrypted key and salt. (cryptheader)
I then used this and a modified bruteforce script to check if my right password is still right. Result: It doesn't seem so.
My password contained special characters and was 15 chars long, bruteforce is not an option.
Is there anyway what I did could've changed the password? If so, can I reproduce and get the new key somehow? The cryptheader is not corrupted and still intact. The /data partition (encrypted) is not corrupted and still intact. (I assume this because the encrypted partition's hexdump starts with "This is an encrypted partition", which is a HTC easter egg.)
htcuser311 said:
UPDATE: I got myself the cryptheader from the "extra" partition using the read_emmc vulnerability. That way I got the encrypted key and salt. (cryptheader)
I then used this and a modified bruteforce script to check if my right password is still right. Result: It doesn't seem so.
My password contained special characters and was 15 chars long, bruteforce is not an option.
Is there anyway what I did could've changed the password? If so, can I reproduce and get the new key somehow? The cryptheader is not corrupted and still intact. The /data partition (encrypted) is not corrupted and still intact. (I assume this because the encrypted partition's hexdump starts with "This is an encrypted partition", which is a HTC easter egg.)
Click to expand...
Click to collapse
I'm far from being a linux expert but the simplest would be to factory reset using htc's recovery to remove /data encryption and start from scratch (unless you have some really important data that must be saved from your /data partition)
alray said:
I'm far from being a linux expert but the simplest would be to factory reset using htc's recovery to remove /data encryption and start from scratch (unless you have some really important data that must be saved from your /data partition)
Click to expand...
Click to collapse
I have decided to give up on trying and did a "factory reset" (formatted /data and /data/sdcard through CWM, rebooted, set up device for first use, formatted /data again through CWM to result in clean system).
Fun-fact: Before I did what bricked the system I actually made a backup. The device (µSD-Card) decided to go corrupted filesystem though. I managed to recover most of the files but the /system partition backup (which might have saved me) remained corrupted. I was able to restore all my personal data though, so doing a factory reset wasn't that bad for me.

[Q] /system/vendor is read-only

Everything was tried, adb terminal, adb pc, different file explorers but that folder stays read-only, even can't change permissions, MAgisk 17.1. ANy ideas?
Stiiigg said:
Everything was tried, adb terminal, adb pc, different file explorers but that folder stays read-only, even can't change permissions, MAgisk 17.1. ANy ideas?
Click to expand...
Click to collapse
be careful what you wish for...
you need to remount the partitions. you can do this through adb shell or terminal emulator on your device.
Adb commands
Code:
adb shell
su
mount -o rw,remount -t ext4 /system
mount -o rw,remount -t ext4 /vendor
Daha3ker said:
be careful what you wish for...
you need to remount the partitions. you can do this through adb shell or terminal emulator on your device.
Adb commands
Code:
adb shell
su
mount -o rw,remount -t ext4 /system
mount -o rw,remount -t ext4 /vendor
Click to expand...
Click to collapse
In response for remount /vendor, it gives
Code:
'/dev/block/dm-0' is read-only
Roman2508 said:
In response for remount /vendor, it gives
Code:
'/dev/block/dm-0' is read-only
Click to expand...
Click to collapse
You need to unlock the other parts of your bootloader then. It will factory reset the device, but you need unlock flashing and unlock flashing critical. This let's you remount critical partitions. Vendor is a critical partition.
Daha3ker said:
You need to unlock the other parts of your bootloader then. It will factory reset the device, but you need unlock flashing and unlock flashing critical. This let's you remount critical partitions. Vendor is a critical partition.
Click to expand...
Click to collapse
It was figured out to be a Magisk problem

Categories

Resources