Data partition with 23GB only shows 8GB when mounted


Question

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?


Answer

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.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes