13

I'm trying to reflash an old Galaxy Note N5100 but I realized that the system partition is too big (~1.5GB). The current ROM uses only about 40% of the partition so I want to shrink it to make space for cache and data. I heard that newer TWRP has resize2fs so I installed the latest (3.0.2-0) TWRP and try.

But after selected wipe > repair or change file system > resize file system there's no option to choose the new size! I tried swiping to resize it and the system is now even larger (~2.5GB). I checked with fdisk and it's really bigger now.

~ # fdisk -l /dev/block/mmcblk0
Found valid GPT with protective MBR; using GPT

Disk /dev/block/mmcblk0: 30777344 sectors, 2740M
Logical sector size: 512
Disk identifier (GUID): 52444e41-494f-2044-4d4d-43204449534b
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 30777310

Number  Start (sector)    End (sector)  Size       Code  Name
   1            8192           16383       4096K   0700  BOTA0
   2           16384           24575       4096K   0700  BOTA1
   3           24576           65535       20.0M   0700  EFS
   4           65536           81919       8192K   0700  PARAM
   5           81920           98303       8192K   0700  BOOT
   6           98304          114687       8192K   0700  RECOVERY
   7          114688          180223       32.0M   0700  RADIO
   8          180224         3325951       1536M   0700  CACHE
   9         3325952         8568831       2560M   0700  SYSTEM
  10         8568832         9715711        560M   0700  HIDDEN
  11         9715712         9732095       8192K   0700  OTA
  12         9732096        30769151       10.0G   0700  USERDATA

Why is that? Where does the new size come from? Is there anyway to enter the size in TWRP?

  • Issue shell commands manually. You can do it. – iBug Apr 5 '18 at 16:05
0

First to clarify, Resize Partition is different than Resize File System, TWRP provides latter option. It resizes the ext2/3/4 filesystem to the size of partition it's created on. Filesystem size can be checked with df command when mounted, and partition size with blockdev.

Just like HDDs or SSDs on PC, Android's eMMC storage is divided into partitions (can be 50+). Some of them have filesystem e.g. the larger ones userdata and system. In simple cases a filesystem occupies a complete physical partition, but it's not always the case, LVM makes it possible to have single filesystem on multiple partitions. Or the opposite what happened in your case as explained here:

Sometimes the zip file of:

a custom ROM does not have the correct size for the system partition and if the ROM flashes a raw system image, that image will not take up the full block device. Running resize2fs can fix the size

Similarly:

Sometimes flashing a factory image may flash userdata with an image with a file system that does not take up the full size of the block device

So TWRP can expand the filesystem to reclaim wasted space. That's what happened in your case to the /system partition. The actual size of partition was 2.5 GB, but flashed image was of 1.5 GB.

Coming to your query:

I realized that the system partition is too big (~1.5GB). The current ROM uses only about 40% of the partition so I want to shrink it to make space for cache and data.

You want to resize partition, not filesystem. So resize2fs (which TWRP uses at back end) isn't the right choice. As your partition table suggests, you need to delete and recreate partitions 9 to 12. IT'S DANGEROUS AND NOT RECOMMENDED, you may permanently brick your device. All data on these partitions will be lost, so do backup. Also, fdisk isn't proper tool for GPT, it's for MBR partition scheme. Use parted or gdisk instead, but with great care.

RELATED:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.