Is it possible to find out volume label of SD card inserted into Android device?
I understand that Android is designed to have just one "external storage" (as returned by Environment.getExternalStorageDirectory()
), but there are quite a few devices in the wild that have internal flash as "external storage" and an SD card mounted under that or even wilder combinations (see this other question). It is possible to enumerate these additional devices by reading /proc/mounts
, but we need something to identify them to the user. Is there any chance to get to their volume labels?
I checked that Linux vfat driver ignores the volume label dentry altogether and that blkid
from util-linux reads the vfat itself. I also checked that, at least on device I have, the block device of the SD card has mode 660
and owner root.root
, so I can't do that. So basically it boils down to whether there is any utility that could read it available.
A volume label or volume name is a unique name assigned to a storage medium by the user. For example, a user is capable of changing the label on a floppy disk and hard drive to describe its contents.
I have found a solution.
The easiest solution is to build busybox and use it like this: busybox blkid
Complicated solution is to find blkid for Android and find what you need in its source code (blkid_dev_devname function).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With