FORUMS

[6039y] **GUIDE** Repartitioning of the internal memory

367 posts
Thanks Meter: 274
 
By petrov.0, Senior Member on 10th August 2015, 08:46 PM
Post Reply Email Thread
Here it is as I promised.
This phone (the model with one sim card) is sold as a device with 8GB internal memory. In fact the memory chip inside is 16GB, so we can increase the available internal space.
PLEASE READ CAREFULLY AND IF SOMETHING IS NOT CLEAR DO NOT HESITATE TO ASK.
*** The data on your device will be untouched after this operation. But again please read carefully! ***
*** A good practice is always to make a backup of everything which will be changed. I do it and I've made a backup of the entire internal memory of the device before the start of the operation which is described below. ***
*** At the end of the post there is a link to a ZIP file which can be flashed through TWRP in order to perform the procedure automatically. Also includes a check for the size of the EMMC (as there are devices on which the resizing cannot be performed...their chip is smaller).***

1. You can go to this thread and to say Thanks! @meghd00t as his static build of gdisk is used in the recovery below.
2. What is needed:
- A different TWRP Recovery with gdisk inside. It can be downloaded from here twrp-2.8.7.0-idol3-6039y-with-gdisk.img - md5sum: 66b3f82a3e2e1afe14627b3b900a9319
- (Optional) An SD card for backup of the original GPT partition layout.
- Patience and careful reading.
- The Windows users probably need the drivers from this post, for access to the device in recovery mode.
3. How to do it (the output used below is from the terminal window from which I've done this operation on my device):
- reboot to bootloader:
Code:
 adb reboot-bootloader
- start the recovery
Code:
 fastboot -i 0x1bbb boot twrp-2.8.7.0-idol3-6039y-with-gdisk.img
- go to the device
Code:
 adb shell
- unmount all partitions of the internal memory
Code:
 ~ # umount /cache
 ~ # umount /sdcard 
 ~ # umount /and-sec
- ensure that there are no mounted partitions from mmcblk0. The output from the mount command should looks like this:
Code:
~ # mount 
rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,size=713016k,nr_inodes=157853,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)
tmpfs on /tmp type tmpfs (rw,seclabel,relatime,size=713016k,nr_inodes=157853)
adb on /dev/usb-ffs/adb type functionfs (rw,relatime)
/dev/block/mmcblk1p1 on /external_sd type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
- start gdisk
Code:
 ~ # gdisk /dev/block/mmcblk0
all partitions can be listed by pressing 'p' but we are interested by the last two:
Code:
  37         5000400        15269853   4.9 GiB     FFFF  userdata
  38        15269854        30535646   7.3 GiB     0700  userdatabak
and their information which will be shown by pressing 'i' and entering the partition number:
Code:
Command (? for help): i
Partition number (1-38): 37
Partition GUID code: 1B81E7E6-F50D-419B-A739-2AEEF8DA3335 (Unknown)
Partition unique GUID: BDD7FA27-93D4-40BC-B266-313E074E0E87
First sector: 5000400 (at 2.4 GiB)
Last sector: 15269853 (at 7.3 GiB)
Partition size: 10269454 sectors (4.9 GiB)
Attribute flags: 0000000000000000
Partition name: 'userdata'

Command (? for help): i
Partition number (1-38): 38
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data)
Partition unique GUID: BD12CF41-10E7-BBF7-D096-5553B89882E7
First sector: 15269854 (at 7.3 GiB)
Last sector: 30535646 (at 14.6 GiB)
Partition size: 15265793 sectors (7.3 GiB)
Attribute flags: 0000000000000000
Partition name: 'userdatabak'
The information which is needed from the above output is Partition GUID code, First sector, Last sector and Partition name. You can write these somewhere (if your values are different from the above) from where can be pasted easily later (alternatively you can use the scrollback function of the terminal ).

- if you have an SD card make a backup of the partitions layout (in case that something goes wrong):
Code:
Command (? for help): b
Enter backup filename to save: /external_sd/gpt_partitions_table.backup
The operation has completed successfully.
- delete partitions 37 and 38:
Code:
Command (? for help): d
Partition number (1-38): 38

Command (? for help): d
Partition number (1-37): 37
- create a new partition 37, bigger in size with the same (as before) Partition GUID code, and the same (as before) start sector:
Code:
Command (? for help): n
Partition number (37-40, default 37): 37
First sector (34-30535646, default = 5000400) or {+-}size{KMGTP}: 5000400
Last sector (5000400-30535646, default = 30535646) or {+-}size{KMGTP}: 30535546
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 1B81E7E6-F50D-419B-A739-2AEEF8DA3335
Changed type of partition to 'Unknown'
The difference here is in the last sector of the partition 30535546.

- create a new partition 38 with same Partition GUID code, but with different First sector:
Code:
Command (? for help): n
Partition number (38-40, default 38): 38
First sector (34-30535646, default = 34) or {+-}size{KMGTP}: 30535547
Information: Moved requested sector from 30535547 to 30535548 in
order to align on 2-sector boundaries.
Use 'l' on the experts' menu to adjust alignment
Last sector (30535548-30535646, default = 30535646) or {+-}size{KMGTP}: 30535646
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
Changed type of partition to 'Microsoft basic data'
Please note that here in the output after 'n' the default first sector is 34, so you explicitly must enter the value!!! As can be seen I've entered the next available sector (after partition 37) 305355547 but it has been corrected automatically to 30535548. So you can use directly 30535548 as a start sector. The last sector is at the end of the memory 30535646.

- write the names of the new partitions:
Code:
Command (? for help): c
Partition number (1-38): 37
Enter name: userdata

Command (? for help): c
Partition number (1-38): 38
Enter name: userdatabak
- if you list the partitions again (with 'p') the end of the table should looks like this:
Code:
  37         5000400        30535546   12.2 GiB    FFFF  userdata
  38        30535548        30535646   49.5 KiB    0700  userdatabak
- now it is safe to write the changes by pressing 'w':
Code:
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.
The operation has completed successfully.
- resize the file system:
Code:
~ # resize2fs -p /dev/block/mmcblk0p37
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/block/mmcblk0p37' first.
... hmm ... let's run it:
Code:
~ # e2fsck -f /dev/block/mmcblk0p37
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p37: 12519/321280 files (5.8% non-contiguous), 678615/1283425 blocks
~ # resize2fs -p /dev/block/mmcblk0p37
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/block/mmcblk0p37' first.
... well the resize2fs have some checks and refuses to resize the file system therefore we must force the execution:
Code:
~ # resize2fs -fp /dev/block/mmcblk0p37
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/block/mmcblk0p37 to 3191893 (4k) blocks.
The filesystem on /dev/block/mmcblk0p37 is now 3191893 blocks long.
The device now can be rebooted and its internal memory will be almost 12GB which compared to its previous size is a very nice upgrade. Screenshots before and after the repartitioning can be seen here.

Update (19.09.2015): This is a link to a flashabable zip which can be used from the TWRP to automate the process. Can be used with any TWRP recovery for 6039.
md5sum: c3f685310283bdc00cee5412fa33259c
The Following 33 Users Say Thank You to petrov.0 For This Useful Post: [ View ] Gift petrov.0 Ad-Free
15th August 2015, 12:34 AM |#2  
Junior Member
Thanks Meter: 4
 
More
Just tried it, and it worked like a charm. Thank you very much!
18th August 2015, 06:12 PM |#3  
Member
Thanks Meter: 12
 
More
Thumbs up
Wow ! Kudos to meghd00t and petrov.0. I just ordered this phone as a backup, waiting for my beloved Xperia Z1 Compact to be saved from watering (medium rain during less than 10min, so long Sony waterproof phones...). Can't wait to receive it and play with this extra storage !! Thank you
22nd August 2015, 01:43 AM |#4  
Senior Member
Thanks Meter: 21
 
More
Here i'am, crazy thinking that if the 6039y(Single chip, SDcard and 8Gb) come with 8Gb worth of wasted money, that the 6039j dual chip and 16Gb non-SDCard version may very well come with a SDCard reader hardware worth of wasted money.
It would be like just changing the Chip Support slot thing or whatever...

Can someone support my craziness and post a picture of thi "where the chip stays" of the SDCard reader version of this phone??

Thanks a lot!!
22nd August 2015, 03:45 AM |#5  
OP Senior Member
Thanks Meter: 274
 
Donate to Me
More
Quote:
Originally Posted by evilinheaven

Here i'am, crazy thinking that if the 6039y(Single chip, SDcard and 8Gb) come with 8Gb worth of wasted money, that the 6039j dual chip and 16Gb non-SDCard version may very well come with a SDCard reader hardware worth of wasted money.
It would be like just changing the Chip Support slot thing or whatever...

Can someone support my craziness and post a picture of thi "where the chip stays" of the SDCard reader version of this phone??

Thanks a lot!!

Well ... I like crazy things. But is impossible just to add a chip.
The thread itself is for other things. I don't want more reminders from the moderators. So please use the general section next time.
Thank you in advance.
The Following User Says Thank You to petrov.0 For This Useful Post: [ View ] Gift petrov.0 Ad-Free
30th August 2015, 06:24 PM |#6  
Senior Member
Thanks Meter: 90
 
More
Here is the complete partition list for 8Gb single sim variant:

Code:
Disk /dev/block/mmcblk0: 30535680 sectors, 14.6 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20
Partition table holds up to 40 entries
First usable sector is 34, last usable sector is 30535646
Partitions will be aligned on 2-sector boundaries
Total free space is 256464 sectors (125.2 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1          131072          262143   64.0 MiB    0700  modem
   2          262144          265215   1.5 MiB     FFFF  tunning
   3          265216          267263   1024.0 KiB  FFFF  traceability
   4          267264          267265   1024 bytes  FFFF  fsc
   5          267266          267281   8.0 KiB     FFFF  ssd
   6          267282          268305   512.0 KiB   FFFF  sbl1
   7          268306          269329   512.0 KiB   0700  sbl1bak
   8          269330          270353   512.0 KiB   FFFF  rpm
   9          270354          271377   512.0 KiB   0700  rpmbak
  10          271378          272401   512.0 KiB   FFFF  tz
  11          272402          273425   512.0 KiB   0700  tzbak
  12          273426          274449   512.0 KiB   FFFF  hyp
  13          274450          275473   512.0 KiB   0700  hypbak
  14          275474          278545   1.5 MiB     FFFF  modemst1
  15          278546          281617   1.5 MiB     FFFF  modemst2
  16          281618          283665   1024.0 KiB  FFFF  simlock
  17          283666          286737   1.5 MiB     FFFF  efsdata
  18          393216          393279   32.0 KiB    FFFF  DDR
  19          393280          396351   1.5 MiB     FFFF  fsg
  20          396352          396383   16.0 KiB    FFFF  sec
  21          396384          398431   1024.0 KiB  FFFF  aboot
  22          398432          400479   1024.0 KiB  0700  abootbak
  23          400480          466015   32.0 MiB    FFFF  boot
  24          466016          531551   32.0 MiB    FFFF  recovery
  25          531552         4306427   1.8 GiB     FFFF  system
  26         4325376         4390911   32.0 MiB    FFFF  persist
  27         4390912         4407295   8.0 MiB     FFFF  splash
  28         4407296         4448255   20.0 MiB    0700  tctpersist
  29         4448256         4468735   10.0 MiB    0700  hdcp
  30         4468736         4468751   8.0 KiB     FFFF  fota
  31         4468752         4993039   256.0 MiB   FFFF  cache
  32         4993040         4995087   1024.0 KiB  FFFF  misc
  33         4995088         4996111   512.0 KiB   FFFF  keystore
  34         4996112         4996175   32.0 KiB    FFFF  config
  35         4996176         4996303   64.0 KiB    FFFF  oem
  36         4996304         5000399   2.0 MiB     FFFF  FactoryRP
  37         5000400        15269853   4.9 GiB     FFFF  userdata
  38        15269854        30535646   7.3 GiB     0700  userdatabak
Maybe someone can post the list for 16Gb dual sim variant?
The Following User Says Thank You to rioachim For This Useful Post: [ View ] Gift rioachim Ad-Free
2nd September 2015, 04:49 PM |#7  
Senior Member
Thanks Meter: 90
 
More
Ok, I bit the bullet and resized the "userdata" partition. Only that I did not create the smaller #38 partition, I did not see any reason to do it (if any update tries to store something inside it, will fail anyway; this partition does not look special, all *bak partitions have the same GUID). Plus there isn't any "userdatabak" partition on 16Gb models. Instead I made partition #37 up to the latest available sector (30535646). The phone is working just fine.
2nd September 2015, 07:14 PM |#8  
OP Senior Member
Thanks Meter: 274
 
Donate to Me
More
Quote:
Originally Posted by rioachim

Ok, I bit the bullet and resized the "userdata" partition. Only that I did not create the smaller #38 partition, I did not see any reason to do it (if any update tries to store something inside it, will fail anyway; this partition does not look special, all *bak partitionshave the same GUID). Plus there isn't any "userdatabak" partition on 16Gb models. Instead I made partition #37 up to the latest available sector (30535646). The phone is working just fine.

OK. But don't be fulled by the GUID. Most of the bak partitions contain data which is equivalent to the data in the primary ones (aboot, rpm, sbl1 etc.). The data is patched in both partitions with the same patch during an upgrade.
3rd September 2015, 08:25 PM |#9  
Member
Thanks Meter: 2
 
More
Wink Script to repartition "internal memory"
Hello petrov.0, all

Is it possible to create a shell for all thoses commands ?

In this case if partitions are lost (upgrade, patchs....) we could apply it easily.
And nice discovered.
Regards
Google99
3rd September 2015, 09:26 PM |#10  
OP Senior Member
Thanks Meter: 274
 
Donate to Me
More
Quote:
Originally Posted by google99

Hello petrov.0, all

Is it possible to create a shell for all thoses commands ?

In this case if partitions are lost (upgrade, patchs....) we could apply it easily.
And nice discovered.
Regards
Google99

No it is not:
Code:
GPT  fdisk  (aka gdisk) is a text-mode menu-driven program for creation and manipulation of partition tables.
10th September 2015, 02:22 PM |#11  
Romagnolo1973's Avatar
Senior Member
Thanks Meter: 170
 
More
Hi petrov.0 great news and thanks.
Just a doubt, a friend of mine will receive Idol 3 4,7" 8 GB tomorrow, he can made OTA update (that I think are available for security reasons as "stagefright" and another I know Alcatel get users a way to set SD as main memory) and then use your guide to expand memory t 16 Gb or for this operation is better been in a fresh unchained device not updated?
Because in this second option device become 16 Gb Rom but will be afected by stagefright and for the rest of his life
Thanks!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes