Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find SD card volume label on Android

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.

like image 758
Jan Hudec Avatar asked Nov 16 '11 12:11

Jan Hudec


People also ask

What is the volume label?

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.


1 Answers

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).

like image 172
vanste25 Avatar answered Sep 29 '22 18:09

vanste25