Partitioning mmcblk0 with Gparted - Android Q&A, Help & Troubleshooting

I have encountered a problem with partitioning my J320FN.. I mounted mmcblk0 which is the root directory of the device and contains partitions 1-27. I wish to make the system partition smaller (since my system folder is 1.2gb smaller than the official) and give that space to userdata which will then be available and usuable even in Smart Manager.
The problem begins with the SYSTEM and userdata partitions not being consecutive... I have a HIDDEN partition between them
[email protected]:/ $ su
[email protected]:/ # parted /dev/block/mmcblk0
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
p
Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? i
i
Warning: Not all of the space available to /dev/block/mmcblk0 appears to be
used, you can fix the GPT to use all of the space (an extra 16384 blocks) or
continue with the current setting?
Fix/Ignore? i
i
Model: MMC QN16BB (sd/mmc)
Disk /dev/block/mmcblk0: 7818MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
25 344MB 2491MB 2147MB ext4 SYSTEM
26 2491MB 2701MB 210MB ext4 HIDDEN
27 2701MB 7806MB 5104MB ext4 userdata
Click to expand...
Click to collapse
Now, the thing this hidden partition is the same size as the CACHE partition which is located at partition 24 mmcblk0p24 /CACHE and is 210mb(exact same size in bytes)
24 134217728B 343932927B 209715200B ext4 CACHE
25 343932928B 2491416575B 2147483648B ext4 SYSTEM
26 2491416576B 2701131775B 209715200B ext4 HIDDEN
27 2701131776B 7805599743B 5104467968B ext4 userdata
Click to expand...
Click to collapse
Im kinda worried about what is in the hidden partition as i will need to dd it out and back in after creating the partition anew.. Anyone know what is stored in hidden partition or how to pull it? dd doesn't give an output file with .img or .zip, they're just broken files...
TIA
Peace [emoji1]

Bump..

Related

[Q] Corrupt GPT?

I think after running wrong exit_recovery.zip, I managed to trash partition table/GPT - or some other combination of stupidity - hoping someone can help..
CWM Recovery Log
Starting recovery on Mon Jun 25 21:11:17 2012
can't open /dev/tty0: No such file or directory
framebuffer: fd 3 (1280 x 800)
ClockworkMod Recovery v5.8.2.0
recovery filesystem table
=========================
0 /tmp ramdisk (null) (null) 0
1 /system ext4 /dev/block/mmcblk0p1 (null) 0
2 /cache ext4 /dev/block/mmcblk0p2 (null) 0
3 /misc emmc /dev/block/mmcblk0p3 (null) 0
4 /staging ext3 /dev/block/mmcblk0p4 (null) 0
5 /data ext4 /dev/block/mmcblk0p8 (null) 0
6 /boot emmc /dev/block/mmcblk0p10 (null) 0
7 /recovery emmc /dev/block/mmcblk0p9 (null) 0
W:Unable to get recovery.fstab info for /datadata during fstab generation!
W:Unable to get recovery.fstab info for /emmc during fstab generation!
W:Unable to get recovery.fstab info for /sdcard during fstab generation!
W:Unable to get recovery.fstab info for /sd-ext during fstab generation!
I:Completed outputting fstab.
Irocessing arguments.
...
[recovery session] Fdisk
/tmp # fdisk -l /dev/block/mmcblk0
Disk /dev/block/mmcblk0: 63.5 GB, 63577260032 bytes
4 heads, 16 sectors/track, 1940224 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk /dev/block/mmcblk0 doesn't contain a valid partition table
[recovery session] Parted
/tmp # ./parted /dev/block/mmcblk0
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
p
Error: /dev/block/mmcblk0: unrecognised disk label
Hypothesis
By doing exit recovery opt 1a http://forum.xda-developers.com/showthread.php?t=1514088 I was able to bring up the virtuousprime ROM boot, but virtuous failed (reboot) after trying to format /data.
I dd'd the first 8096 bytes of mmcblk0 and they are all zeros?
From CWM, I am able to mount partitions mmcblk0p1, mmcblk0p3, mmcblk0p5.
So from all that, I am thinking I need to flash MBR, replace GPT on LBA 1? If this is correct, does anyone have a stock GPT for the tf201?
I can then format /data (mmcblk0p8) and I think my ROMs will then work.
kind regs,
Based on the information here: https:// en.wikipedia.org/wiki/GUID_Partition_Table#Partition_table_header_.28LBA_1.29, replacing LBA 1 will only fix the GPT header. Since you said that the first 8096 bytes were all zeros, it would seem that those would fall into LBA 2, 3, etc., corrupting the partition table.
But since you said that CWM can mount your partitions, you might be able to use GPT fdisk's recovery features to fix the problem. I don't know if anyone has compiled it for Android though Please note that the regular fdisk cannot handle GPT, only MBR.
When you said "flash MBR", what exactly do you mean? GPT and MBR are two different partition structures and if you replace either one with the other, the partition table will be lost and you won't be able to mount any partition.
Was thinking about building LBA0 and LBA 1 separately, was going from that Wikipedia article, "...Legacy MBR information is contained in LBA 0, the GPT header is in LBA 1.." and I thought - perhaps naively - that an fdisk command with /mbr option would sort out LBA0, then I worry about GPT in LBA1, but maybe I am confusing fdisk /mbr option with another command (old DOS)?
I have all the partition offsets and disk size from backup (/sys/devices/platform/sdhci-tegra.3/mmc_host/mmc0/mmc0:0001/block/mmcblk0/..) and know what the partition table should look like; there was no "Partition 9", I made this up because there was 1024 unaccounted bytes after mmcblk0p8 (/data) ends:
Disk size: 1241744336 bytes
Partition 1 (/system): start 74752; End 1123328; Size 1048576
Partition 2 (/cache): start 1123328; End 1999872; Size 876544
Partition 3 (/misc): start 1999872; End 2003968; Size 4096
Partition 4 (/staging): start 2003968; End 3096576; Size 1092608
Partition 5 (/btmac): start 3096576; End 3106816; Size 10240
Partition 6 (/?): start 3106816; End 3107840; Size 1024
Partition 7 (/?): start 3107840; End 3118080; Size 10240
Partition 8 (/data): start 3118080; End 124173312; Size 121055232
Partition 9: start 124173312; End 124174336; Size 1024
Given that /system mounts, I think if I had a stock dump from a tf201 of bytes 0-74752 might also be an alternative - I could verify the GPT table against above before I put it in.
Another option I can think of, comes from reference I see to a "backup GPT" held in last sector of GPT disks? If you look at partition offsets above, there is 1024 bytes at the end where I may get this information - but I think injecting in a dump of those first 74k bytes into mmcblk0 - as above - would be safer.
damonbrisbane said:
Was thinking about building LBA0 and LBA 1 separately, was going from that Wikipedia article, "...Legacy MBR information is contained in LBA 0, the GPT header is in LBA 1.." and I thought - perhaps naively - that an fdisk command with /mbr option would sort out LBA0, then I worry about GPT in LBA1, but maybe I am confusing fdisk /mbr option with another command (old DOS)?
Click to expand...
Click to collapse
I wouldn't suggest doing that. That would create a hybrid MBR. When a hybrid MBR disk is read using MBR, only the first four partitions can be visible (after redefining the partition table in LBA0). If the disk is read using GPT, all the partitions will be visible. I don't know if Android and Linux prefer MBR over GPT, but if they do, you might lose access to partitions 5-8.
By the way, the '/mbr' option is for the diskpart tool from MSDOS and Windows
damonbrisbane said:
Another option I can think of, comes from reference I see to a "backup GPT" held in last sector of GPT disks? If you look at partition offsets above, there is 1024 bytes at the end where I may get this information - but I think injecting in a dump of those first 74k bytes into mmcblk0 - as above - would be safer.
Click to expand...
Click to collapse
You're absolutely right. I had forgotten about this. Do you happen to know if those mmcblk0p# partitions are visible when the tablet is plugged into a Linux computer? If so, GPT fdisk can restore the partition table and GPT header from the backup GPT.
You would run something like this to restore the backup GPT:
http://paste.kde.org/488054/
EDIT: I found a version of gdisk compiled for Android by meghd00t (http://forum.xda-developers.com/showpost.php?p=24805392&postcount=74). You may be able to restore the backup GPT directly from the tablet
Download link from the post: http://dl.dropbox.com/u/64885133/gptfdisk.zip
Thanks Chen, i plan to try the gptfdisk tonight when I get home from work and can post the result.
One thing i'm not sure about is access mmcblk0 from linux - does this mean I can access the internal mmcblk0 of the tf201 directly through a linux device? Right now I access mmcblk0 solely through adb shell to CWM recovery.
damonbrisbane said:
Thanks Chen, i plan to try the gptfdisk tonight when I get home from work and can post the result.
One thing i'm not sure about is access mmcblk0 from linux - does this mean I can access the internal mmcblk0 of the tf201 directly through a linux device? Right now I access mmcblk0 solely through adb shell to CWM recovery.
Click to expand...
Click to collapse
No problem There's also an option to backup the GPT header and partition table to file. I'd suggest doing that just in case anything goes wrong.
I'm not entirely sure if the internal memory can be accessed directly from Linux. But from what I've been reading in the forums today, it seems that it might not possible (I'm pretty new to Android).
Hopefully gptfdisk will work via adb shell
Whew, we're off life support! and more importantly - my wife wont kill me for an Unauthorised Brick to The Birthday Device
Steps Performed
ADB - Write backup GPT to LBA1 mmcblk0
~ # ./gdisk /dev/block/mmcblk0
GPT fdisk (gdisk) version 0.8.4
Unsupported GPT version in backup header; read 0x00000000, should be
0x00010000
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): r
Recovery/transformation command (? for help): ?
b use backup GPT header (rebuilding main)
c load backup partition table from disk (rebuilding main)
…
? b
Recovery/transformation command (? for help):
? c
Warning! This will probably do weird things if you've converted an MBR to
GPT form and haven't yet saved the GPT! Proceed? (Y/N): Y
Caution! After loading partitions, the CRC doesn't check out!
Recovery/transformation command (? for help): p
Disk /dev/block/mmcblk0: 124174336 sectors, 59.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2E8491CC-AFFC-43B9-B1C4-97D2F258BE1C
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 124174302
Partitions will be aligned on 2048-sector boundaries
Total free space is 75709 sectors (37.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 74752 1123327 512.0 MiB 0700 AP
2 1123328 1999871 428.0 MiB 0700 CC
3 1999872 2003967 2.0 MiB 0700 MC
4 2003968 3096575 533.5 MiB 0700 UP
5 3096576 3106815 5.0 MiB 0700 PR
6 3106816 3107839 512.0 KiB 0700 YU
7 3107840 3118079 5.0 MiB 0700 CA
8 3118080 124173311 57.7 GiB 0700 UA
Recovery/transformation command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/block/mmcblk0.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
~ #
ADB/CWM - Exit recovery and attempt Virtuousprime ROM install
I then did exit recovery as per 1a http://forum.xda-developers.com/showthread.php?t=1514088
Upon reboot Virtuousprime wouldn't go as far as it got before. I went back into adb shell and did wipe data:
Wipe data/factory reset
Formatting /data
Error mounting /data !
Skipping format...
Formatting /cache
Formatting /sd-ext
Formatting /sdcard/.android_secure...
Error mounting /sdcard/.android_secure!
Skipping format...
Data wipe complete
Note the error on /data. Could not format /data either using the CWM mounts and storage menu. I named the partitions I knew about and formatted /data (mmcblk0p8) from adb shell:
Number Start End Size File system Name Flags
1 38.3MB 575MB 537MB ext4 system
2 575MB 1024MB 449MB ext4 cache
3 1024MB 1026MB 2097kB misc
4 1026MB 1585MB 559MB ext3 staging
5 1585MB 1591MB 5243kB fat32 btmac
...
8 1596MB 63.6GB 62.0GB ext4 data
mke2fs -t ext4 /dev/block/mmcblk0p8
I then found that CWM data/factory reset went through without errors:
Wipe data/factory reset
Formatting /data
Formatting /cache
..
Data wipe complete
And subsequently exit recovery and virtuous prime rom have installed OK, tested across reboot and shutdown
Cheers!
damonbrisbane said:
Whew, we're off life support! and more importantly - my wife wont kill me for an Unauthorised Brick to The Birthday Device
Click to expand...
Click to collapse
Haha, I'm glad I was able to help

SGP5 USA - Brick

Hello all,
I have a question regarding the manner in which my galaxy player (YP-G70) is bricked. I have bricked it before and have been able to get out of it but on this one i cannot. I tried flashing multiple kernels and os's but none seem to work. The problem i am having is i cant get into cwm but when i can i get error messages saying that it cant mount and/or find files. If i try to format it says cant mount then a block error. I can get into download mode. Another weird thing is that when the samsung logo comes up it does not flash it stays a solid white then straight to cwm even though i flashed the stock factory image. Any help would be greatly appreciated.
Thanks.
Flash stock firmware through Odin, then wipe data and cache in recovery
Sent from my YP-G70 using xda app-developers app
Well i reflashed the stock firmware and this is what i get: youtube.com/watch?v=xBQi4tbbsI0&feature=youtu.be
Flash this in Odin
http://forum.xda-developers.com/showthread.php?t=1389873
Sent from my YP-G70 using xda app-developers app
For some reason i am still getting the same errors. Any other ideas?
Update: i was fiddling around with it while it was in recovery through adb and when i typed "mount sdcard" in adb shell i get the error:
~ # mount sdcard
mount sdcard
mount: can't read '/etc/fstab': No such file or directory
UPDATE2:
Sorry for all the updates
i just ran
cat /proc/partitions
major minor #blocks name
179 0 7757824 mmcblk0
179 1 1 mmcblk0p1
179 5 256 mmcblk0p5
179 8 15558144 mmcblk1
179 9 15557120 mmcblk1p1
this is not even close to how many there normally are. Any ideas?
UPDATE3:
This isnt looking good, ran parted on the partitions and this is what i got:
~ # cat /proc/partitions
cat /proc/partitions
major minor #blocks name
179 0 7757824 mmcblk0
179 1 1 mmcblk0p1
179 5 256 mmcblk0p5
179 8 15558144 mmcblk1
179 9 15557120 mmcblk1p1
~ # parted /dev/block/mmcblk0 print
parted /dev/block/mmcblk0 print
Error: Invalid partition table on /dev/block/mmcblk0 -- wrong signature feb7.
Ignore/Cancel? i
i
i
Model: MMC SEM08G (sd/mmc)
Disk /dev/block/mmcblk0: 7944MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.8kB 7944MB 7944MB extended
5 65.5kB 328kB 262kB logical
~ # parted /dev/block/mmcblk0p1 print
parted /dev/block/mmcblk0p1 print
Error: Can't have a partition outside the disk!
~ # parted /dev/block/mmcblk0p5 print
parted /dev/block/mmcblk0p5 print
Error: /dev/block/mmcblk0p5: unrecognised disk label
~ # parted /dev/block/mmcblk1 print
parted /dev/block/mmcblk1 print
Model: SD SU16G (sd/mmc)
Disk /dev/block/mmcblk1: 15.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 15.9GB 15.9GB primary fat32 boot, lba
~ # parted /dev/block/mmcblk1p1 print
parted /dev/block/mmcblk1p1 print
Model: Unknown (unknown)
Disk /dev/block/mmcblk1p1: 15.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
Not So Pro said:
Update: i was fiddling around with it while it was in recovery through adb and when i typed "mount sdcard" in adb shell i get the error:
~ # mount sdcard
mount sdcard
mount: can't read '/etc/fstab': No such file or directory
UPDATE2:
Sorry for all the updates
i just ran
cat /proc/partitions
major minor #blocks name
179 0 7757824 mmcblk0
179 1 1 mmcblk0p1
179 5 256 mmcblk0p5
179 8 15558144 mmcblk1
179 9 15557120 mmcblk1p1
this is not even close to how many there normally are. Any ideas?
UPDATE3:
This isnt looking good, ran parted on the partitions and this is what i got:
~ # cat /proc/partitions
cat /proc/partitions
major minor #blocks name
179 0 7757824 mmcblk0
179 1 1 mmcblk0p1
179 5 256 mmcblk0p5
179 8 15558144 mmcblk1
179 9 15557120 mmcblk1p1
~ # parted /dev/block/mmcblk0 print
parted /dev/block/mmcblk0 print
Error: Invalid partition table on /dev/block/mmcblk0 -- wrong signature feb7.
Ignore/Cancel? i
i
i
Model: MMC SEM08G (sd/mmc)
Disk /dev/block/mmcblk0: 7944MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.8kB 7944MB 7944MB extended
5 65.5kB 328kB 262kB logical
~ # parted /dev/block/mmcblk0p1 print
parted /dev/block/mmcblk0p1 print
Error: Can't have a partition outside the disk!
~ # parted /dev/block/mmcblk0p5 print
parted /dev/block/mmcblk0p5 print
Error: /dev/block/mmcblk0p5: unrecognised disk label
~ # parted /dev/block/mmcblk1 print
parted /dev/block/mmcblk1 print
Model: SD SU16G (sd/mmc)
Disk /dev/block/mmcblk1: 15.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 15.9GB 15.9GB primary fat32 boot, lba
~ # parted /dev/block/mmcblk1p1 print
parted /dev/block/mmcblk1p1 print
Model: Unknown (unknown)
Disk /dev/block/mmcblk1p1: 15.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
Click to expand...
Click to collapse
-------------------------------------------------------------------------------------------------------
Easy! you destroyed the memory partitioing thanks to a wrong kernel flashing.
Solution here, starting from post 39:
http://forum.xda-developers.com/showthread.php?t=1676606&page=4
Good lick and welcome to the club
:
Thanks so much, i figured out what cause it and it was [Kernel][JB][YP-G70] Mercurius v5 the USA fixed version. Anyways thanks again!
Not So Pro said:
Thanks so much, i figured out what cause it and it was [Kernel][JB][YP-G70] Mercurius v5 the USA fixed version. Anyways thanks again!
Click to expand...
Click to collapse
PLEASE tell me what you did! I have the exact same problem, and it came after trying to restore an apparently corrupted backup of the same ROM ^
After I restored, it booted into cwm and was trying to do some update or installation... it was going too fast to read, but it said FAILED, and then would go on a boot loop doing the same thing.
I tried all the things I know could help in Odin. I was a able to boot into a rom one time, but the capacitive buttons didn't work.
As of yet, I am able to get into download mode, and then flash entropy's kernel, which then allows me to reboot into recovery, but only if it's rebooted automatically by odin. Once in recovery, I tried wiping everything and installing roms, but when I reboot nothing happens, and I can't get back into recovery, only download mode. >.<
Refer to post #7. If you cannot figure it out still then post what player you have and its capacity.

[U] [GB+JB] Repartitioning guide

Thanks to @munjeni for tipping me off in the right direction and to @judas1977 + @Tesla-MADAL93 for having done this on the Ace 2 I come from ~~
Everything else in this post applies to Gingerbread, scroll down to the 5th message for a more clear guide centered around a 4.1.2 ROM.
This is my annotated diary about the last 2 hours, I'm sorry if the story feels a little bit Dadaist but I don't want to encourage people who don't feel ready to try it, so please read all of it first and if anything is unclear ask instead of doing!!
I installed Busybox 1.22.1 (iirc) and replaced the default shell with bash (install Bash-X from market, copy /S/xbin/bash over /S/bin/sh, remove app if you like to). All of this was done with Gingerbread .188 and CWM 5.5.0.4 from Supercharged kernel.
Original partition table, with names added:
[email protected]:~$ adb shell
Code:
sh-4.2# fdisk -u -l /dev/block/mmcblk0
Disk /dev/block/mmcblk0: 7944 MB, 7944011776 bytes
4 heads, 16 sectors/track, 242432 cylinders, total 15515648 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 1 2047 1023+ 0 Empty #### TA ("Trim Area") IMEI, BL UNLOCK, SIMLOCK ETC -- DO NOT TOUCH
Partition 1 does not end on cylinder boundary
/dev/block/mmcblk0p2 2304 3327 512 f0 Linux/PA-RISC boot #### SBL? Mem-init? Power management? PARAM?
Partition 2 does not end on cylinder boundary
/dev/block/mmcblk0p3 2048 2303 128 f0 Linux/PA-RISC boot #### unknown, as above
Partition 3 does not end on cylinder boundary
/dev/block/mmcblk0p4 3328 15269887 7633280 5 Extended #### GROUPS ALL FOLLOWING PARTITIONS FOR THEM TO FIT INTO THE 4-PARTS MBR SCHEME
Partition 4 does not end on cylinder boundary
/dev/block/mmcblk0p5 4096 20479 8192 4a Unknown #### another of the 4 unclear partitions
/dev/block/mmcblk0p6 20480 26623 3072 83 Linux #### MODEMFS (Samsung's "EFS") RADIO CALIBRATION
/dev/block/mmcblk0p7 26624 36863 5120 70 Unknown #### no idea either
/dev/block/mmcblk0p8 36864 53247 8192 83 Linux #### IDD (apparently related to usage stats reporting)
/dev/block/mmcblk0p9 53248 86015 16384 48 Unknown #### KERNEL
/dev/block/mmcblk0p10 118784 2215935 1048576 83 Linux #### SYSTEM
/dev/block/mmcblk0p11 2727936 6922239 2097152 83 Linux #### DATAFS
/dev/block/mmcblk0p12 2215936 2727935 256000 83 Linux #### CACHEFS
/dev/block/mmcblk0p13 86016 118783 16384 48 Unknown #### FOTAKERNEL?
/dev/block/mmcblk0p14 6922240 15269887 4173824 c Win95 FAT32 (LBA) #### SDCARD/EMMC/UMS
Partition table entries are not in disk order
so let's rearrange this list for easier thinking & reading
Code:
/dev/block/mmcblk0p1 1 2047 1023+ TA
/dev/block/mmcblk0p3 2048 2303 128 ?
/dev/block/mmcblk0p2 2304 3327 512 ?
/dev/block/mmcblk0p5 4096 20479 8192 ?
/dev/block/mmcblk0p6 20480 26623 3072 MODEMFS
/dev/block/mmcblk0p7 26624 36863 5120 ?
/dev/block/mmcblk0p8 36864 53247 8192 IDD
/dev/block/mmcblk0p9 53248 86015 16384 KERNEL
/dev/block/mmcblk0p13 86016 118783 16384 FOTAKERNEL?
/dev/block/mmcblk0p10 118784 2215935 1048576 SYSTEM
/dev/block/mmcblk0p12 2215936 2727935 256000 CACHEFS
/dev/block/mmcblk0p11 2727936 6922239 2097152 DATAFS
/dev/block/mmcblk0p14 6922240 15269887 4173824 SDCARD
great, the important (for us) stuff is contiguous so we can delete those partitions and recreate them
(if fdisk works like parted we must do that in numerical order, so system>data>cache>ums)
we must delete and recreate partition 13 with the same sizes
OTOH fdisk lets us experiment without saving in real time (!!!) but let's do this in recovery mode
Let's research the sizes we want first -- I find Link2SD's graphical df the best way to do this (see photo 1)
so 540 MB for /system should be enough (I have 454M used, account a safety margin as I integrate updates + FS overhead + 1000 vs 1024 units)
4,14 MB used on /cache... 7,8 MB should be more than enough (same size I used on my Ace 2 which had about 5 MB used there)
this large size is for dalvik cache on ROMs that store it there (vm.dalvik.dexopt-data-only=0 and vm.dalvik.dexopt-cache-only=1 or something)
494 MB on /data, but I'd probably want to change apps and stuff... let's try with 1,25 GB
but if we remove /system we'll have to reflash the rom from a zip, which I'd need to make...
let's leave that partition alone for this first time
reboot now
Click to expand...
Click to collapse
Launching fdisk:
#### SONY
#### SONY (red green blue lightbar)
#### + button
#### CWM-based recovery v5.5.0.4
[email protected]:~$ adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -
#### No shell in ramdisk? Very lame...
#### [Mounts and storage]
#### [Mount /system, unmount everything else]
[email protected]:~$ adb shell
sh-4.2# fdisk -u /dev/block/mmcblk0
Command (m for help):
What I did in fdisk:
u #### change units to sectors
d #### delete
14
d
13
d
12
d
11
c #### disable cylinder rounding
n #### new
l #### logical partition
First sector (3334-15269887, default 3334): 2215936
Sector 2215936 is already allocated #### Apparently this version of fdisk makes you waste a sector...
First sector (2215937-15269887, default 2215937): Using default value 2215937
Last sector or +size or +sizeM or +sizeK (2215937-15269887, default 15269887): +1600M
#### CACHEFS:
n
l
First sector (3334-15269887, default 3334): 5340938
Sector 5340938 is already allocated
First sector (5340939-15269887, default 5340939): Using default value 5340939
Last sector or +size or +sizeM or +sizeK (5340939-15269887, default 15269887): +8M
#### FOTAKERNEL
n
l
First sector (3334-15269887, default 3334): 86016
Sector 86016 is already allocated
First sector (86017-15269887, default 86017): Using default value 86017
Last sector or +size or +sizeM or +sizeK (86017-118783, default 118783): Using default value 118783
t
Partition number (1-14): 13
Hex code (type L to list codes): 48
Changed system type of partition 13 to 48 (Unknown)
#### USB STORAGE
n
l
First sector (3334-15269887, default 3334): 5356564
Sector 5356564 is already allocated
First sector (5356566-15269887, default 5356566): Using default value 5356566
Last sector or +size or +sizeM or +sizeK (5356566-15269887, default 15269887): Using default value 15269887
c
Partition number (1-14): 14
Hex code (type L to list codes): c
Changed system type of partition 14 to c (W95 FAT32 LBA)
w
The partition table has been altered.
Calling ioctl() to re-read partition table
fdisk: WARNING: rereading partition table failed, kernel still uses old table: Device or resource busy
sh-4.2# reboot
Now enter CWM again and factory reset -- you'll get an error as it can't delete /sdcard/.android_secure as it's unformatted
(and for that matter this CWM can't format /sdcard either...)
No problem apart from skipped heartbeats, boot into Android and format it from the settings! (see photo 2)
Well, the last screenshot speaks for itself... but I'll repeat, don't try this at home! (Have a friend try it so you'll have someone to blame if it gets bricked)
Very interesting... It causes problems?
Inviato dal mio ST25i utilizzando Tapatalk
ale467 said:
Very interesting... It causes problems?
Click to expand...
Click to collapse
Unlike my example, you must have over 50M free on /cache (at least in Gingerbread) or cheat by bind-mounting it somewhere else... or give up on directly installing stuff from the market
I tried bind mounting /cache to /data/local/tmp/cache but Google Play is still broken, so I guess you'll want a 57M partition there...
Also, you can always return to stock layout by flashing a full ROM in green light download mode, then wiping /sdcard from settings
I'm going to update this for 4.1, it's even somewhat easier and more predictable
----------------
1: think of the rough partition sizes
Code:
system (350M)
data (1,5G)
cache (280M) ## keep in mind whether ROM uses this for dalvik-cache and at least in 2.x Google Play downloads there
sdcard (remaining space)
2: make sure you have some files ready
→ROM in recovery zip format
→Backup of everything you want
→Kernel with fdisk in ramdisk
→ADB known working in recovery and normal mode
→Fixed busybox (http://forum.xda-developers.com/attachment.php?attachmentid=1057725&d=1336884034)
3: enter recovery and dump partition table (adb shell, fdisk /dev/block/mmcblk0, p)
Unlike my previous experiment, I'll calculate sizes in cylinders -- harder but fdisk appears to work better that way
Code:
Disk /dev/block/mmcblk0: 7944 MB, 7944011776 bytes
4 heads, 16 sectors/track, 242432 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
[...]
/dev/block/mmcblk0p10 1857 34624 1048576 83 Linux #SYSTEM
/dev/block/mmcblk0p11 42625 108160 2097152 83 Linux #DATAFS
/dev/block/mmcblk0p12 34625 42624 256000 83 Linux #CACHEFS
/dev/block/mmcblk0p13 1345 1856 16384 48 Unknown #FOTAKERNEL, move this on another line if it helps you think better but put it back there after calculations
/dev/block/mmcblk0p14 108161 238592 4173824 c Win95 FAT32 #UMS
so our work area starts at cylinder 1857 and ends at 238592!
4: calculate partition sizes (I'll only list start & end cylinders for clarity)
Code:
/dev/block/mmcblk0p10 1857 12538 << 1857 + (350000000÷32768)
/dev/block/mmcblk0p11 12538+1 >> 12539 58315 << 12539+(1500000000÷32768)
/dev/block/mmcblk0p12 58315+1 >> 58316 66861 << 58316 +(280000000÷32768)
/dev/block/mmcblk0p13 1345 1856
/dev/block/mmcblk0p14 66861+1 >> 66862 238592
5: remove partitions (d, 14, d, 13, ..., 10)
6: create partitions (n, l, 1857, 12538, repeat for next row)
7: retype partitions (t, 13, 48, t, 14, c)
8: save changes (w, reboot) - enter recovery again, you should get 5 "E: Can't {mount|open} /cache/[...]" lines
9: go to mounts and storage and run all 4 formats, sdcard will probably fail -- if it doesn't skip to step 13
10: install fixed busybox (adb push '/home/riki/Desktop/busybox' /cache/)
11: enter adb shell, make it executable (chmod +x /cache/busybox)
12: format media partition (/cache/busybox mkfs.vfat /dev/block/mmcblk0p14)
13: quit shell, mount /sdcard in CWM
14: adb push your ROM to /sdcard, install it and reboot!
This is so interesting, I've being doing this on a Samsung Galaxy SCL to fix it as its internal storage and /data partition were totally corrupted. I used parted instead of fdisk to repartition the external SD and edit then kernel's RAM disk to make it mount /data in one of the new partitions. Because of this that I've been doing lately, I'm thinking of using fdisk in my Xperia U too to have more available space in internal SD, that would be great, as I use dual boot feature.
I think I'll do this when I'm be fed up of Jelly Bean being the main ROM and KitKat just the secondary one.
By the way, I think it can be possible to leave enough free space before mmcblk0p14 to create my secondary ROM's partitions there (mmcblk0p15 for /system, mmcblk0p16 for /data and mmcblk0p17 for /cache) instead of creating system.ext4, data.ext4 and cache.ext4 inside my internal SD and mounting them in loop devices... What do you think? Could I brick my phone doing that? I've asked here too just in case.
The only thing I'd have to do is to format my mmcblk0p15 using mke2fs to set the same UUID as in mmcblk0p10 just if my secondary ROM doesn't boot (but I think this wouldn't be necessary):
Code:
mke2fs -T ext4 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -U [COLOR="Silver"][mmcblk0p10's UUID][/COLOR] -I 256 /dev/block/mmcblk0p15
You've explained this how-to so well, @Ryccardo! Thanks for this tutorial.
Many, many thanks to you, sir!
Thanks to you i was able to increase data partition on my P (similar partition scheme to U).
Other tutorials weren't so useful than yours and i was searching quite a lot. Thank you, live in wealth!

[Q] Merge /data and internal storage

Hi, I noticed there are about two similar threads but focusing on slightly different things so I am starting a new one.
I have ZLR F9006 (aka. ALPS F9006 or STAR F9006). It's a MT6582 cheap nobrand phone.
It has 4GB internal memory divided into several partitions. Since I have a 32 GB sdcard in it,
I find the existance of 1GB internal sd partition very annoying and I would like to merge that space
to /data instead, completely vanishing the internal_sd.
I have installed CWM Touch and booted into it. Here is df in recovery via adb:
Code:
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 497520 48 497472 0% /dev
/[email protected] 127044 4208 122836 3% /cache
/dev/block/mmcblk1 31159328 6732768 24426560 22% /sdcard
/[email protected] 1029872 47888 981984 5% /emmc
/[email protected] 1828400 1133596 694804 62% /data
/[email protected] 706392 488788 217604 69% /system
/sbin # cd /emc
(usrdata=/data, emmc=internal storage)
I installed parted but I get this error:
Code:
~ # parted /dev/block/mmcblk0 print
parted /dev/block/mmcblk0 print
Error: Can't have a partition outside the disk!
I know this is the internal memory because mmcblk1 is the SD card (and opening it in parted works).
I have these block devices:
Code:
/dev/block # ls
ls
loop0 loop4 mmcblk0 mmcblk0p2 mmcblk0p6 platform
loop1 loop5 mmcblk0boot0 mmcblk0p3 mmcblk0p7 zram0
loop2 loop6 mmcblk0boot1 mmcblk0p4 mmcblk0p8
loop3 loop7 mmcblk0p1 mmcblk0p5 mmcblk1
As you can see, there are 8 partitions on the internal block device, with the p7 being the /data partition:
Code:
/dev/block # parted /dev/block/mmcblk0p7 print
parted /dev/block/mmcblk0p7 print
Model: Unknown (unknown)
Disk /dev/block/mmcblk0p7: 1900MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Number Start End Size File system Flags
1 0.00B 1900MB 1900MB ext4
And the p8 being the internal SD i want to get rid of:
Code:
/dev/block # parted /dev/block/mmcblk0p8 print all
parted /dev/block/mmcblk0p8 print all
Model: Generic SD/MMC Storage Card (sd/mmc)
Disk /dev/block/mmcblk0p8: 1055MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
(Strangely enough, you can't see the filesystem on those, but the msdos partition table and size fits.)
I was hoping I would simply delete that p8 and then expand the p7 to the remaining size, all that
should be perfectly doable with parted without even losing data (apart from few empty dirs on the p8).
But I highly doubt I can do it by directly calling parted on that specific partitions, I think that I need to make
it work calling it for the whole /dev/block/mmcblk0 (could someone confirm this?).
If yes, how can I make that happen?
You're likely to brick your phone if you do it that way. Take a look here on how to repartition your internal memory. It's for MT6577, but I think it could be of relevance to your situation.
Thanks, this is very relevant. This is how my block table looks like (attached). I was right about the partitions being the last (but i am not sure about the bmtpool at the end).

Mounting an image made with adb pull ...

I had a S3 i9300 and I want to check if I can recover some files from data partition
after a hard reset.
I have been able to get an image of data partition with
Code:
adb pull /dev/block/mmcblk0p12 mmcblk0p12.img
My problem is to mount this image on linux.
I tried of course:
Code:
mount -o loop,ro -t auto mmcblk0p12.img ./galaxys3/
but I get ..
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
I tried to understand what was going on with fdisk ...
Code:
# fdisk -l mmcblk0p12.img
Disk mmcblk0p12.img: 11.5 GiB, 12381585408 bytes, 24182784 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
and it doesn't seem to find a partition and give the offset.
anyway android mount that block like that ...
Code:
/dev/block/mmcblk0p12 /data ext4 rw,nosuid,nodev,noatime,barrier=1,journal_async_commit,data=ordered,noauto_da_alloc,discard 0 0
any suggestions?
Anyway my goal is to run testdisk (photorec) on it.
TIA.
The fs will be in ext*. Android isnt linux, thats why it works on android and not linux. That's why android needs busybox.
Sent from my HTC One M9 using Tapatalk
shivadow said:
The fs will be in ext*. Android isnt linux, thats why it works on android and not linux. That's why android needs busybox.
Sent from my HTC One M9 using Tapatalk
Click to expand...
Click to collapse
Actually I manage to mount it on linux. I forgot to unmount the data partition
before make the image so it wasn't consistent ... I made a e2fsck and now I can easily
mount it.

Categories

Resources