10

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.

Community
  • 1
  • 1
Jan Hudec
  • 73,652
  • 13
  • 125
  • 172
  • 1
    May this will help you http://stackoverflow.com/questions/3348643/how-to-read-the-sd-card-id-number/5191484#5191484 – Dinesh Prajapati Nov 16 '11 at 12:39
  • @Drax: No, it may not (besides we already know that). It's totally unrelated to volume label. Volume label is the thing that user *specifies* when he formats the SD card in his computer. – Jan Hudec Nov 16 '11 at 12:51

4 Answers4

1

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

vanste25
  • 1,754
  • 14
  • 39
0

i don't know how it works exactly in android, but in linux i have kernel message about mounting sd-card, where volume name specified. You can try dmesg and cat /sys/devices/mmc... (or somethong like that)

  • Dmesg can't have it if the driver completely ignores it, or can it? And as already mentioned in the comments, the `/sys/devices/mmc...` is completely different thing (it has CID, which we use, but does not have the volume label, which is a filesystem thing, not an SD card thing). – Jan Hudec Nov 21 '11 at 06:48
0

Try to parse output of blkid command. It works for me, but I'm not sure if it is a firmware depended feature or not. I got permission denied with this command on AVD.

borisstr
  • 2,336
  • 4
  • 16
  • 15
  • The command is not there on the devices we have. And if I compiled it myself, it wouldn't work, because it wouldn't have permissions. – Jan Hudec Nov 21 '11 at 06:45
  • `blkid` works without root permissions both on my device (with custom 2.2 firmware) and my desktop linux system. So, as a last resort you might want to try to include `blkid` functionality to your project with the help of NDK. Not easy though... – borisstr Nov 22 '11 at 12:00
  • Of course it works on desktop, but that's totally irrelevant since that's not Android. It might also work with custom Android firmware, but that's still irrelevant, because random users don't have custom firmware. The standard firmware does not have it and does not allow reading the raw device from normal application. – Jan Hudec Nov 22 '11 at 12:08
-1

I don't know if this can help you: if you use the DDMS you can see the folders of the system. In my case, I found the sd card in: /mnt/media_rw.

You can get more information here and here

I hope it helps.

Community
  • 1
  • 1
  • No, it does not help, because ddms is not running on the device. Now if you found where ddms gets them, that might be another matter. – Jan Hudec Sep 23 '15 at 07:39
  • I don't run the DDMS on the Device. I run the DDMS on my computer, which is connected to the device. Of course, your computer must recognize the device. – No More Hello World Sep 23 '15 at 13:45
  • And therefore DDMS is totally absolutely useless for a device in somebody's hand on a train. Yes, the question does not state it explicitly, but if you have a computer to analyze the device and know how, you almost certainly know the labels already anyway. The interesting case is getting the labels from an application on the device. – Jan Hudec Sep 23 '15 at 18:39