Wednesday, October 1, 2014

mount - How to list all major partitions with their labels?


I want to figure out all partitions on my device together with their resp. mount points or labels (i.e. to know which partition is holding system, recovery, boot, etc.). This needs to be device independent (as I have multiple devices). Goal is to dd them and know which image is what.


I have seen Command to list partition mount points? – however, there the goal was just a partition list of mounted partitions. I need them all, and e.g. /recovery is not mounted when booting into "normal work mode".



So far, my recherche has brought up a bunch of approaches – but none of them works on any of the devices I've tested:



  • cat /proc/mtd: this is empty or non-existing

  • cat /proc/emmc: this is empty or non-existing

  • cat /proc/dumchar_info: non existing (MTK/MediaTek)

  • ls -al /dev/block/platform/*/by-name: either non-existing, or not having the wanted details


Any idea of what I could have missed? Of course I could walk all the /dev/block/mmcblk0p* devices, dump them, and sort them out later – but then I had to repeat that investigation for every of my devices (and again when someone turns up with another one), so that's no solution.




EDIT: Please note the tag to this question. I'll have to access that information via ADB, and do not want to install some app on a device handed to me for investigation. Consider it "forensics background" (no changes to the device), though that's not exactly true ;)



Also apologies for my initial mis-phrasing: the "mount points" are only interesting in so far they reveal the purpose of the partition. I don't want to mount/remount them :)



Answer



As existing answers already show, there seems to be no "unique way" to achieve that. So I started combining ideas from allover, joining them into a script (or rather a "script library") to have them checked sequentially (until a good hit was made), and integrated that into my "Device Documentation Tool" named Adebar. Those interested can find it in the lib/partitions.lib file. As Adebar is open-source (GPLv2), feel free to copy and use it – or fork the project and improve it.


The full solution is a bit long to post here (as said, you can grab it at Github), but as our policy is to include at least the general part in the post, here's what it does:


Different sources provide different sets of details, so it tries the "best ones" first – and then recurses down until at least something was found.



  • /proc/dumchar_info gives the most details, so this is tried first. Happy MTK users will get this.

  • /proc/mtd is the second best source.

  • /proc/emmc should have almost as much as the previous candidates, but is a bit tricky to use

  • /dev/block/platform/*/by-name, cross-checked with …


  • /proc/partitions cross-checked with /proc/mounts gives us at least the partitions mounted


So the script I've built basically walks the sources in this order, stopping as soon as it was able to collect details (e.g. if /proc/dumchar_info was found, no need to parse all the others). All of them put into separate functions, returning data using the very same structure, one could even merge results from all of them.


If someone can come up with a better solution, I'm of course always open for the idea :)


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...