Data partition with 23GB only shows 8GB when mounted I have a Sony Xperia Z5 Compact, and I was finding strange that the storage manager showed that the system was filling 20GB of the 32GB internal storage, so I went to dig a little further into this.

I found that the data partition is p42 in the internal rom using TWRP's fdisk, which correctly reports it as having 23GB (I haven't found how to get the TWRP terminal output here, though). However, using fdisk with the device fully booted up, via ADB shell, I get this:

suzuran:/ # fdisk -l /dev/block/mmcblk0                                        

Disk /dev/block/mmcblk0: 31.2 GB, 31272730624 bytes  
255 heads, 63 sectors/track, 3802 cylinders  
Units = cylinders of 16065 * 512 = 8225280 bytes  

               Device Boot      Start         End      Blocks  Id System  
/dev/block/mmcblk0p1               1        3803    30539775+ ee EFI GPT  


not showing the full partition table...

However, when I try to read the partition, it gives no errors:  

suzuran:/ # dd if=/dev/block/mmcblk0p42 of=/dev/null                           
48365568+0 records in  
48365568+0 records out  
24763170816 bytes transferred in 246.927 secs (100285391 bytes/sec)  


Reading the entire storage also gives no errors:

suzuran:/ # dd if=/dev/block/mmcblk0 of=/dev/null                              
61079552+0 records in
61079552+0 records out
31272730624 bytes transferred in 365.211 secs (85629213 bytes/sec)


But when mounted, either booted or inside TWRP (I also mounted it manually) it shows only a 8GB size:

suzuran:/ # df
Filesystem                    1K-blocks     Used Available Use% Mounted on
[ other skipped mounts ]
/dev/block/mmcblk0p43           5215496  1188900   4026596  23% /system
/dev/block/mmcblk0p42           8641912  6071544   2570368  71% /data
/dev/block/mmcblk0p41            197472      188    197284   1% /cache
/dev/block/mmcblk0p3              81872    57808     24064  71% /firmware
/dev/block/mmcblk0p31             28144      164     27980   1% /persist
/dev/block/mmcblk0p39             14327      160     14167   2% /idd
/dev/block/loop0                  92656      980     91676   2% /su


I'm using LineageOS, but in the stock Sony rom I had the same issue, only didn't have the tools to check this further.

Anyone had this issue before or can help me with this?



Edit: I just found about 'blockdev' command:

suzuran:/ # blockdev --getsize64 /dev/block/bootdevice/by-name/userdata        
24763170816


which gives the correct size of the partition. What's happening with the 'mount' command? Could this be kernel related? If so, why does it happen in TWRP too?
After "playing" a bit with the device, I managed to trace the problem to the ext4 partition data. Booted into TWRP, terminal, backed up the files in the partition, unmounted, then:

mke2fs -t ext4 /dev/block/bootdevice/by-name/userdata


And voila! 23GB of data storage available. Restored the backed up files to the new ext4 filesystem and everything is working now, although I feel it a little slower. Nevertheless, it's solved.