Android Gzip userdata.img Compression file sizes problems (urgent) - General Questions and Answers

URGENT GZIP dump image of userdata problem ADB SHELL DD IF GZIP IMAGE FILE SIZES
I m using android lolipop 5.1.1 i in Qualcom smart phone was trying to root the phone i created Image file with dd command then rooted got some problems then again recovered it but when I created a fresh image file of unrooted recovered factory reset its showing different sizes for detail i am showing the commands and outputs
Created mmcblk0.img.gz through dd of /dev/block/mmcblk0 gzip
Code:
~ # ←[6n dd bs=4k conv=sync,noerror if=/dev/block/mmcblk0 | gzip -c -9 > /external_sd/mmcblk0.img.gz
PHP:
(15634268160 bytes (14.6GB) copied, 8996.230485 2 hrs 50 min seconds, 1.7MB/s)
File mmcblk0.img.gz created in external sd card formatted in ext4 showed by ls -l shows 3.68 GB size of mmcblk0.img.gz file
Code:
~ # ←[6n ls -l /external_sd/.
PHP:
-rw-rw-rw- 1 root root 3957044725 (3.685GB) Jan 5 12:32 /external_sd/mmcblk0.img.gz
where as when checked the /external_sd/ card mmcblk0.img.gz file size occupied space by df -h it showed 7.7GB occupied space
Code:
~ # ←[6n df -h
PHP:
Filesystem Size Used Available Use% Mounted on
/dev/block/mmcblk1p1 14.0G 7.7G 5.5G 58% /external_sd
Code:
~ # ←[6n df -hi
PHP:
Filesystem Inodes Used Available Use% Mounted on
/dev/block/mmcblk1p1 3.7M 12 3.7M 0% /external_sd
when i pulled mmcblk0.img.gz file to pc computer then it shows of 7.68 GB
Code:
~ # ←[6n adb pull -p /external_sd/mmcblk0.img.gz
PHP:
Copied in System 7.68 GB (8,252,012,021 bytes) file
Previously 5 days before rooting and flashing i took the same backup of mmcblk0.img.gz file with same command
Code:
adb pull -p /external_sd/mmcblk0.img.gz
PHP:
1.48 GB (1,599,262,720 bytes)
i have taken individual images also off boot.img recovery system.img and userdata.img i founded that the new images of userdata is high as well system when is less for details of user data i am giving details below
Created userdata.img.gz through dd of /dev/block/mmcblk0p29
Code:
~ # ←[6n dd bs=4k conv=sync,noerror if=/dev/block/mmcblk0p29 | gzip -c -9 > /external_sd/userdata.img.gz
PHP:
(12748570112 bytes (11.9GB) copied, 7325.311486 seconds, 2.0 hrs 1.7MB/s)
File userdata.img.gz size created in external sd card formatted in ext4 showed by ls -l shows 1.5Gb size of userdata.img.gz file
Code:
~ # ←[6n ls -l /external_sd/.
it was showing 1.5gb file
where as when checked the /external_sd/ card size of userdata.img.gz file occupied by df -h it showed 6.8 gb occupied space
/dev/block/mmcblk0p29 IS SHOWING SIZE MOUNTED IN /DATA /SDCARD OF 866.5 USED BUT ITS IMAGE IS 6.7 GB
Code:
~ # ←[6n df -h
PHP:
Filesystem Size Used Available Use% Mounted on
/dev/block/mmcblk0p29 11.6G 866.5M 10.7G 7% /data
/dev/block/mmcblk0p29 11.6G 866.5M 10.7G 7% /sdcard
/dev/block/mmcblk1p1 14.0G 6.7G 7.3G 47% /external_sd
Code:
~ # ←[6n df -hi
PHP:
Filesystem Inodes Used Available Use% Mounted on
/dev/block/mmcblk0p29 760.0K 1.9K 758.1K 0% /data
/dev/block/mmcblk0p29 760.0K 1.9K 758.1K 0% /sdcard
when i pulled userdata.img.gz file to pc computer then it shows of 6.7 GB
Code:
adb pull -p /external_sd/userdata.img.gz
PHP:
(1390 KB/s 7020532851 bytes 6.538 GB in 4929.140s 82.15 min)
userdata.img.gz file created in computer is 6.53 GB (7,020,535,808 bytes)
Previously 5 days before rooting and flashing i pulled userdata.img.gz image with same command
Code:
adb pull -p /external_sd/userdata.img.gz
PHP:
337 MB (353,608,243 bytes)
Summarized:-
DD if gzip -9 mmcblk0.img.gz compressed 15,634,268,160 bytes (14.6GB) Device data to external sd card ext4 file system
ls -l shows the file mmcblk0.img.gz size of 3,957,044,725 bytes (3.685GB) ext4 file system
Df-h shows the sd card having only one file with space occupied in external sd card with 7.77GB space
adb pull copied mmcblk0.img.gz file of 7.68 GB space (8,252,012,021 bytes)
the old image dumped file mmcblk0.img.gz of same phone and same mobile was 1.48 GB (1,599,262,720 bytes)
Founded userdata.img.gz has been enlarged
DD if gzip -9 userdata.img.gz compressed 12,748,570,112 bytes (11.9GB) Device data to external ext4 file system
ls -l shows the file userdata.img.gz size of 1.5 Gb ext4 file system
Df-h shows the sd card having only one file userdata.img.gz with space occupied in external sd card with 6.8gb space
/dev/block/mmcblk0p29 IS SHOWING SIZE MOUNTED IN /DATA /SDCARD OF 866.5M USED BUT ITS IMAGE IS 6.7 GB
adb pull copied file userdata.img.gz of 7020532851 bytes 6.538 GB
the old image dumped file userdata.img.gz of same phone and same mobile was 337 MB (353,608,243 bytes)
Now my queries kindly help and explain:-
Is there any problem with dd if gzip command syntax and options
why mmcblk0.img.gz file ls- l shows 3.685GB and df -h shows 7.7GB occupied in external_sd card and same in case of userdata.img.gz file ls -l shows 1.5gb but the occupied space as per external sd card is 6.8gb
why when the file mmcblk0.img.gz file pulled is 7.68 gb as its 7.7gb in df-h and i same in case of userdata.img.gz file pulled is 3. 6.538gb as its 6.7 Gb in df -h
why Df-h of /dev/block/mmcblk0p29 IS SHOWING SIZE MOUNTED IN /DATA /SDCARD OF 866.5M USED BUT ITS IMAGE IS made file name userdata.img.gz 6.7 GB and 1.5 Gb in ls-l
why 5 days before i flashed my rooted phone had pulled image file of mmcblk0.img.gz was 1.48 GB (1,599,262,720 bytes) and now it extended to 7.68 gb and in same way userdata.img file before was 337 MB and now its extended to 6.8gGB
Question is which file to keep and which one is ok or not mmcblk0.img.gz of 1.48 gb or 7.68 gb and same of userdata.img.gz file of 337mb or 6.85gb
before recovering i did erased userdata and system by command
Code:
flashboot erase userdata
I had uncompressed userdata previously by following command as gz file cant be flashed
Code:
gzip -d -c /external_sd/userdata.img.gz | dd of=/dev/block/platform/7824900.sdhci/by-name/userdata
is there any problem with command of recovering
As df -h showing /dev/block/mmcblk0p29 866.5M of data in df -h
in my guess thoughts after rooting there is some space occupied in userdata
Code:
flashboot erase userdata
didnt erased the userdata and there is some background data left which has been not been erased and still occupying space in creating dump image file
safe way to delete erase unused space in userdata or block/mmcblk0p29
[*]the major concern is that i want to keep backup of my rooted and fully loaded phone and unrooted also so i want to decrease the size of image which after compressing is large
After googling i coundt find an safe command to compress the image now question is that should i fill the mmcblk0p29 block or userdata zero data with zero by following command kindly tell me the safest and best command from to get the appropriate command for the problem
fastboot erase userdata
Code:
rm -r /data/. or rm -r /sdcard/. c. dd if=/dev/zero of=/dev/block/platform/7824900.sdhci/by- name/userdata bs=8192
or
Code:
dd if=/dev/urandom of=/dev/block/platform/7824900.sdhci/by- name/userdata bs=8192
(but i could not find any /dev/zero or /dev/urandom in my dev direcotry)
newfs command to format the userdata partition but i dont know its options any other best safe command to solve the problem
kindly guide me to find the best safest and appropriate command to find solution for decreasing the size of userdata.img.gz and mmcblk0.img.gz for unrooted and rooted partitions if possible by adb shell or any other method
Click to expand...
Click to collapse
thank you in advance waiting for quick and urgent suggestions replies and advice

Related

Linux Upgrade

How can i Creat partitions on the mmc card 256MB what the program is used to do this and i want expert to explain the following lines:
Code:
* Create partitions, for example a 10MB /dev/sda1 and /dev/sda2 using the rest:
fdisk /dev/sda
n
p
<default>
1
+10M
n
p
2
<default>
<default>
w
* Create file systems, a VFAT on /dev/sda1 and EXT2 on /dev/sda2:
mkdosfs /dev/sda1
mke2fs /dev/sda2
* Copy HaRET, the kernel and default.txt onto sda1:
mount /dev/sda1 /mnt
cp zImage-2.6.19-hh8+cvs20070111-magician-20070111150939 /mnt/zImage
cp gnuharet-200609162320.exe /mnt/haret.exe
cp default.txt /mnt/default.txt
umount /dev/sda1
* Unpack the GPE image onto sda2:
mount /dev/sda2 /mnt
bzcat Angstrom-gpe-image-test-20070111-magician.rootfs.tar.bz2 | (cd /mnt; tar x)
umount /mnt
Thank you For all
You must install Linux dist to do this with your memory card. This lines is commands in Linux's command interpreter(command line). every line it is a separate command.
Thank you
But i want to Explain to me Step by Step How to install Linux on Magician
see this site
http://linuxtogo.org/~htcpxa/htcmagician/

Error - ROM memory insufficient space

Hi Guys,
I have an Blu Dash 3.5 D170, but i do not have a system android yet... i've got a little problem:
I'm trying to install a backup system.img I got here, but always fails in writing step because the lack of space in /system
when i use adb shell ls -a /system the result is:
Code:
D:\Android\sdk\platform-tools>adb shell
~ # ls -a /system
ls -a /system
. .. lost+found
~ #
other words, there is nothing inside /system...
When i use "busybox df", results is:
Code:
~ # busybox df
busybox df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 80612 48 80564 0% /dev
/dev/block/mtdblock1 225280 148096 77184 66% /system
/dev/block/mtdblock4 179200 1216 177984 1% /data
/dev/block/mmcblk0p1 3850240 118624 3731616 3% /sdcard
/dev/block/mtdblock2 61440 1192 60248 2% /cache
~ #
I can not understand why occupies 66% of the space is has NOTHING within the directory
I tried using the command "fastboot erase system", and the command says that cleared the system, but it does not clear these 66%
what should I do to fix this?

[Q] Partiion table

What partitions there are in out tablet?
"fastboot getvar all" gets this:
bootloader
recovery
boot
system
cache
userdata
Also i can find such list:
mmcblk0boot0
mmcblk0boot1
mmcblk0 ... 8
(and mmcblk1 is external uSD card)
What is tre partition table (and its sizes, for 32G model), and what is function (and content) of these partitions?
tijl-comdor said:
What partitions there are in out tablet?
"fastboot getvar all" gets this:
bootloader
recovery
boot
system
cache
userdata
Also i can find such list:
mmcblk0boot0
mmcblk0boot1
mmcblk0 ... 8
(and mmcblk1 is external uSD card)
What is tre partition table (and its sizes, for 32G model), and what is function (and content) of these partitions?
Click to expand...
Click to collapse
mmcblk0 layout
All dumps were done on Asus Eee Pad Transformer Infinity TF700T, 64GB version, firmware 9.4.5.26, locked
mmcblk0 off-partition section
Offset: 0 (0x0)
Size: 38273024 (0x2480000)
Read command: busybox dd if=/dev/block/mmcblk0 of=/mnt/sdcard/mmcblk0pre1.img bs=524288 count=73
Offset: 0 (0x0)
Size: 3670016 (0x380000)
Contains: Zeroes
Purpose: Unknown
Extract command: dd if=mmcblk0pre1.img of=mmcblk0pre1s1.img bs=3670016 count=1
Process command: tr -d '\0' <mmcblk0pre1s1.img >mmcblk0pre1s1nz.img # mmcblk0pre1s1nz.img must be empty file
Offset: 3670016 (0x380000)
Contains: Recovery kernel image followed by zeroes
Size: 8388608 (0x800000)
Extract command: dd if=mmcblk0pre1.img of=mmcblk0pre1s2.img bs=524288 skip=7 count=16
Process commands:
perl split_bootimg.pl mmcblk0pre1s2.img
mkdir mmcblk0pre1s2.img-ramdisk
cd mmcblk0pre1s2.img-ramdisk
zcat ../mmcblk0pre1s2.img-ramdisk.gz | cpio -i
cd ..
# end Process commands
Offset: 12058624 (0xb80000)
Contains: Regular boot kernel image followed by zeroes
Size: 8388608 (0x800000)
Extract command: dd if=mmcblk0pre1.img of=mmcblk0pre1s3.img bs=524288 skip=23 count=16
Process commands:
perl split_bootimg.pl mmcblk0pre1s3.img
mkdir mmcblk0pre1s3.img-ramdisk
cd mmcblk0pre1s3.img-ramdisk
zcat ../mmcblk0pre1s3.img-ramdisk.gz | cpio -i
cd ..
# end Process commands
Offset: 20447232 (0x1380000)
Contains: Block of 16 bytes followed by 0x2de0 hexadecimal numbers followed by FF
Size: 12288 (0x3000)
Extract command: dd if=mmcblk0pre1.img of=mmcblk0pre1s4.img bs=524288 skip=39
Vital data:
Extract command: dd if=mmcblk0pre1s4.img of=mmcblk0pre1s4ss2.img bs=4096 skip=3
Binary part of vital data:
Extract command: dd if=mmcblk0pre1s4ss1.img of=mmcblk0pre1s4ss1ch1.img bs=16 count=1
Hexadecimal part of vital data:
Extract command: dd if=mmcblk0pre1s4ss1.img of=mmcblk0pre1s4ss1ch2.img bs=16 count=734 skip=1
Process command: unhex <mmcblk0pre1s4ss1ch2.img >mmcblk0pre1s4ss1ch2bin.img
FF part of vital data:
Extract command: dd if=mmcblk0pre1s4ss1.img of=mmcblk0pre1s4ss1ch3.img bs=16 skip=735
Process command: tr -d '\377' <mmcblk0pre1s4ss1ch3.img >mmcblk0pre1s4ss1ch3nff.img # mmcblk0pre1s4ss1ch3nff.img must be empty file
Zeroes:
Extract command: dd if=mmcblk0pre1s4.img of=mmcblk0pre1s4ss1.img bs=4096 count=3
Process command: tr -d '\0' <mmcblk0pre1s4ss2.img >mmcblk0pre1s4ss2nz.img # mmcblk0pre1s4ss2nz.img must be empty file
Purpose: Probably encrypted bootloader
mmcblk0p1
Offset: 38273024 (0x2480000)
Size: 805306368 (0x30000000)
File system size: 196608 * 4096 = 805306368 (fully occupies partition)
Format: Linux ext4 filesystem
Mounted at: /system
Mount options: read only, extended attributes, ACL
Permissions: only root can manipulate
Contains: Base system and embedded applications
Purpose: Base system
mmcblk0p2
Offset: 843579392 (0x32480000)
Size: 448790528 (0x1ac00000)
File system size: 109568 * 4096 = 448790528 (fully occupies partition)
Format: Linux ext4 filesystem
Mounted at: /cache
Mount options: read/write, no SUID, no device nodes, no atime
Permissions: only root can manipulate, UID system and GID cache can read and write
Contains: Cache
Purpose: Application cache
Note: The volume has the same UUID as mmcblk0p1
mmcblk0p3
Offset: 1292369920 (0x4d080000)
Size: 2097152 (0x200000)
File system size: 512 * 4096 = 2097152 (fully occupies partition)
Linux rev 1.0 ext3 filesystem
Not mounted
Permissions: GID system can manipulate
Contains: Empty file system
Purpose: Recovery /misc
Referenced by: /system/lib/libandroid_runtime.so recovery ramdisk: /etc/recovery.fstab
Note: File system is referenced in recovery as emmc, not ext3!
mmcblk0p4
Offset: 1294467072 (0x4d280000)
Size: 855638016 (0x33000000)
File system size: 208896 * 4096 = 855638016
Linux rev 1.0 ext3 filesystem
Not mounted
Permissions: GID system can manipulate
Contains: Empty file system
Purpose: Recovery /staging
Referenced by: recovery ramdisk: init.rc /etc/recovery.fstab
mmcblk0p5
Offset: 2150105088 (0x80280000)
Size: 5242880 (0x500000)
File system size: 5092 * 1024 = 5147488
Format: FAT32 file system, no partition table, MS-DOS "Non-system disk" boot block
Not mounted
Permissions: only root can manipulate
Contains: File system with files:
Serial numbers (ISN, PPID, SSN, UUID)
Calibration data (AL3010 light sensor, AMI304 magnetic sensor, KXTF9 motion sensor)
Purpose: Device specific unique system data, mounted as /btmac during Android boot
Referenced by: /system/bin/wifimacwriter /system/bin/brcm_patchram_plus /system/bin/sensors-config /system/bin/sixpair ramdisk: /init recovery ramdisk: /etc/recovery.fstab /init
mmcblk0p5 off file-system area
Offset in section: 5147488 (0x4e8b60)
Size: 28672 (0x7000)
Read command: busybox dd if=/dev/block/mmcblk0p5 of=/mnt/sdcard/mmcblk0p5s2.img bs=1024 skip=5092
Process command: tr -d '\0' <mmcblk0p5s2.img >mmcblk0p5s2nz.img # mmcblk0p5s2nz.img must be empty file
mmcblk0p6
Offset: 2155347968 (0x80780000)
Size: 524288 (0x80000)
Format: binary data
Permissions: UID drm can manipulate
Contains: 208 bytes of binary data, the rest are zeroes
Purpose: DRM, probably contains encrypted DRM key
Referenced by: /system/bin/wvdrmserver /system/vendor/lib/drm/libdrmwvmplugin.so
mmcblk0p7
Offset: 2155872256 (0x80800000)
Size: 5242880 (0x500000)
Format: empty
Contains: Zeroes
Purpose: Unknown
mmcblk0p8
Offset: 2161115136 (0x80d00000)
Size: 61415620608 (0xe4ca80000)
File system size: 14994040 * 4096 = 61415587840
Format: Linux ext4 filesystem
Mounted at: /data
Mount options: read/write, no SUID, no device nodes, no atime
Permissions: only root can manipulate, read and write are directory specific
Contains: User applications, user data, and virtual internal SD card
Note: /data/media is mounted via UID/GID stripping FUSE as /mnt/sdcard
mmcblk0p8 off file-system area
Offset in section: 61415587840 (0xe4ca78000)
Size: 32768 (0x8000)
Read command: busybox dd if=/dev/block/mmcblk0p8 of=/mnt/sdcard/mmcblk0p8s2.img bs=4096 skip=14994040
mmcblk0 off-partition section
Offset: 63576735744 (0xecd780000)
Size: 524288 (0x80000)
Read command: busybox dd if=/dev/block/mmcblk0 of=/mnt/sdcard/mmcblk0post8.img bs=524288 skip=121263
Process command: tr -d '\0' <mmcblk0p8s2.img >mmcblk0p8s2nz.img # mmcblk0p8s2nz.img must be empty file
Offset: 63576735744 (0xecd780000)
Offset in section: 0 (0x0)
Size: 507392 (0x7be00)
Contains: Zeroes
Purpose: Unknown
Extract command: dd if=mmcblk0post8.img of=mmcblk0post8s1.img bs=507392 count=1
Process command: tr -d '\0' <mmcblk0post8s1.img >mmcblk0post8s1nz.img # mmcblk0post8s1nz.img must be empty file
Offset: 63577243136 (0xecd7fbe00)
Offset in section: 507392 (0x7be00)
Size: 16896 (0x4200)
Contains: EFI Partition table (partition names: APP, CAC, MSC, USP, PER, YTU, CRA, UDA)
Extract command: dd if=mmcblk0post8.img of=mmcblk0post8s2.img bs=512 skip=991
Purpose: Partition table
Total size of mmcblk0: 63577260032 (0xecd800000)
Notes:
can manipulate = can read, write partition vital data, only root can mount
can read, write = can read, write partition file system contents
Read commands are ran on the Transformer
Extract and process commands are run anywhere, with pre-read image file in the current directory.
You need dd with large files support. Vanilla dd on TF700T does not support large files. Busybox dd does.

Safely format (zero fill) unsued space in userdata partition (/dev/block/mmcblk0p29)

What is secure safe way or command to format only userdata partition (/dev/block/mmcblk0p29) free space as when i create a Gzip image it creates huge 6.8 GB image and previously created was of 350 mb.
kindly tell me secure adb shell command or tool through which i can erase wipe delete only userdata partition . I searched but want to confirm which of the following way will be secure to format userdata partition only
i tried following commands but nothing worked for me:-
1.
Code:
Fastboot erase userdata
tried but still image is 6.8 gb
2.
Code:
rm -r /data/*.*
tried but still image is 6.8 gb
3.
Code:
rm -r /sdcard/*.*
tried but still image is 6.8 gb
4.
Code:
dd if=/dev/zero if=/dev/block/platform/7824900.sdhci/by-name/userdata bs=8192
tried but /dev/zero not found in device
5.
Code:
dd if=/dev/urandom of=/dev/block/platform/7824900.sdhci/by-name/userdata bs=8192
tried but/dev/urandom not found in device
6.
Code:
newfs
8. iShredder 3 app
but how i will format in unrooted while working in the android userdata partition
9. secure eraser app
but how i will format in unrooted while
working in the android userdata partition
10. Andro Shredder or Disk Sanitizer
but how i will format in unrooted while working in the android userdata partition
11 any adb shell command to clear format zero fill
i want to keep small compact compressed gzip or shadow images of clean unrooted and rooted partition on various dates and times

mitm on android emulator: a howto

Hello all,
I'd like to braindump how I managed to make android emulator v30 work with mitm, hope that helps someone.
Since it was not possible to neither write nor make writable the /system partition, I decided to roll my own system.img and that actually worked. I'm not going to upload a script because I might not remember 100%, but I'll going to descibe the steps in full, even though they exist elsewhere. The commands might not be exact, too, so if there's a typo you'll need to figure it out yourself.
Also, it will be a bit confusing because I shall refer to 2 files named system.img, one is the 2G file that comes with android, the other is 700M or something file that you will be creating in the process. I'll refer them as #1 and #2.
1. What is needed: android studio and emulator, linux, xattr, https://github.com/LonelyFool/lpunpack_and_lpmake , https://github.com/tytso/e2fsprogs, mitmproxy, parted. Build these github projects, you'll need their binaries in the process.
also, 'mkdir build' somewhere.
2. Find system.img (#1) in your android studio installation, then extract the system partition:
$ losetup -f system.img
$ losetup -a | grep system.img
/dev/loop5
$ partprobe /dev/loop5
$ ls /dev/loop5p*
/dev/loop5p1 /dev/loop5p2
$ lpunpack_and_lpmake/bin/lpunpack /dev/loop5p2 build
$ ls build
system.img system-ext.img product.img vendor.img
$ losetup -d /dev/loop5
3. Make system.img (#2) writable and usable. This is ext4 crunched with feature shared_blocks, which makes it not really writable even in theory, as it deduplicates identical blocks in the filesystem. You'll need to convert that to a normal ext4, but, there's not enough space to do that operation. So you'll need to expand the partition to accomodate for this. How much? Empirically, I added 30M to a 700M partition:
$ ls -l system.img
700000000 # for example
$ e2fsprogs/resize/resize2fs system.img 730M
$ ls -l system.img
730000000 # for example
$ e2fsprogs/e2fsck/e2fsck -f system.img
$ e2fsprogs/e2fsck/e2fsck -E unshared_blocks system.img
$ e2fsprogs/e2fsck/e2fsck -f system.img
4. Modify the now writable partiton to your heart's content (we're still with system.img #2 here). I needed to add just one file, mitmproxy-ca-cert.cer . According to the mitmproxy docs, the name must be the hash of the certificate:
$ losetup -f system.img
$ losetup -a | grep system.img
/dev/loop6
$ mount /dev/loop6 /mnt
$ hashed_name=`openssl x509 -inform PEM -subject_hash_old -in mitmproxy-ca-cert.cer | head -1
$ echo $hashed_name
c8750f0d
$ cp mitmproxy-ca-cert.cer /mnt/system/ext/security/cacerts/$hashed_name.0
$ cd /mnt/system/ext/security/cacerts/
$ chmod 644 $hashed_name.0
Now check if your android has extra attributes in these certificate files. Mine does:
$ xattr 00abcde.0 # some random certificate
security.selinux
$ xattr -p security.selinux 00abcde.0
ubject_r:system_security_cacerts_file:s0
if yes, you'll need it on this file too:
$ xattr -w security.selinux ubject_r:system_security_cacerts_file:s0 $hashed_name.0
and be done with the partition
$ umount /mnt
$ losetup -d /dev/loop6
5. Create new super-partition, the one we used as /dev/loop5p2. You'll need the file sizes of your .img partitions, and your command to create a super.img file will look like this:
$ cat repack
#!/bin/sh
P=/android/super/1
~/src/lpunpack_and_lpmake/bin/lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:2496462848 --group main:2647101440 \
--partition system:readonly:786432000:main --image system=$P/system.img \
--partition system_ext:readonly:131952640:main --image system_ext=$P/system_ext.img \
--partition product:readonly:1468575744:main --image product=$P/product.img \
--partition vendor:readonly:102739968:main --image vendor=$P/vendor.img \
--output $P/super2.img
the interesting numbers are the corresponding partition sizes (in --partition), and, if f ex you increased the system.img #2 to 30M in the step 3, the number in --device:super should be the size of /dev/loop5p2 in bytes plus at least these 30M (but also okay if a bit more).
6. Finally, create a new system.img #1 . Create a backup copy of it, and then append some 30M there, and fix the partition
$ dd if=/dev/zero of=system-new.img flags=append bs=1M size=30
$ losetup -f system-new.img
$ losetup -a | grep system-new.img
/dev/loop7
$ parted /dev/loop7
GNU Parted 3.3
Using /dev/loop7
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: Loopback device (loopback)
Disk /dev/loop7: 2444MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB vbmeta
2 2097kB 2443MB 2441MB super
you will need to expand the partion 2 to the max (plus minus same 30M). If is fails fix the number and retry:
(parted) resizepart 2 24460MB
Error: The location 24460MB is outside of the device /dev/loop7.
and finally copy data back:
$ partprobe /dev/loop7
$ dd if=super.img of=/dev/loop7p2 bs=1M
$ losetup -d /dev/loop7
and that's it. After that, rename system-new.img to system.img, and hopefully the emulator could run this new image.
Also, to check that the certificate is there and recognized, go to the setting/certificates/trusted certificates, the mitmproxy one should be in the list.
Hopefully this will be helpful.
Cheers!
/dk

Categories

Resources