5

How can I find the file system type of USB drive without using computer? Drive is attached to Android phone and I can see the files in it. I want to know if it is extFAT etc.

Irfan Latif
  • 20,353
  • 3
  • 70
  • 213
LifeLongStudent
  • 151
  • 1
  • 2

3 Answers3

7

Related question: How to detect filesystem type of un-mounted partition?

Just to complete some missing pieces:

Usually we use mount command to see mounted filesystems, it works without root e.g. from a terminal emulator app or adb shell:

~$ mount
...
/dev/block/sda1 on /mnt/media_rw/C8BA-D0E2 type sdfat ...
/dev/block/sda2 on /mnt/media_rw/C78E-434F type vfat ...
/dev/block/sda3 on /mnt/media_rw/C81D-4E8D type vfat ...

It shows mounted filesystems on external USB drive to be sdfat and vfat which are not actual filesystems but filesystem drivers. A driver can support multiple filesystems and a filesystem can be mounted using different drivers. sdfat can be exFAT, FAT32 or FAT16. vfat can be one of latter two. Similarly filesystem types sdcardfs, fuse or fusectl aren't actual but virtual filesystems (FUSE can be used to mount any filesystem theoretically). So the output of mount command or apps like DiskInfo can be insufficient or misleading.

A more certain way is to read filesystem magic (file and blkid commands do this). But the problem is that storage devices are enumerated as block devices by Linux/Android kernel and device nodes are created by Android init/vold with restricted permissions so that only root processes can access them (see How to read ext4 filesystem without mounting on a non-rooted device?). So it's not possible to read partitions directly which hold filesystems inside them.

With root access:

~# blkid
/dev/block/sda1: ... TYPE="exfat"
~# file -s /dev/block/sda*
/dev/block/sda2: DOS/MBR boot sector ... FAT (32 bit)
/dev/block/sda3: DOS/MBR boot sector ... FAT (16 bit)

* Android's builtin blkid does have filesystem magic values but toybox file applet doesn't have. Use e.g. file on Termux which looks for a large magic database.

~# hexdump -C -n100 /dev/block/sda1 | grep -o '[EX]*FAT[0-9]*'
EXFAT

* hexdump is a busybox applet.

exFAT magic is found at offset 3, FAT32 at 82 and FAT12/FAT16 at 54. So for exFAT hexdump -e '"%_p"' -n5 -s3 /dev/block/sda1 returns EXFAT.

Similarly for EXT4 hexdump -e '"%X"' -n2 -s1080 should return EF53 and for F2FS hexdump -e '"%X"' -n4 -s1024 should return F2F52010.

Without root access:

Another option is to check logcat soon after boot or inserting USB drive or SD card. vold uses blkid at back end to detect filesystem before mounting which appears in log:

~$ adb logcat -v brief -s vold:V | grep TYPE=                                                                                                 
V/vold    (  752): /dev/block/vold/public:8,1: LABEL="disk" UUID="C8BA-D0E2" TYPE="exfat"
Firelord
  • 25,084
  • 20
  • 124
  • 286
Irfan Latif
  • 20,353
  • 3
  • 70
  • 213
  • For adb logcat, if I run that command C:\blah>adb logcat -v brief -s vold:V and I take out the SD card and put it back in. I get this output https://pastebin.com/raw/dt3zFb6L which says within it. /dev/block/vold/public:179,65: UUID="21FE-E026" TYPE="vfat" So still not so specific. More specific than the mount command though that said sdcardfs! – barlop Dec 20 '23 at 18:27
  • By the way you wrote "sdfat can be exFAT, FAT32 or FAT16. vfat can be one of latter two. ". A google shows that vFAT can be FAT12, not just FAT16 or FAT32. "The vFAT filesystem format is primarily used on older windows systems and portable USB drives or flash modules. It comes in three types FAT12 , FAT16 , and FAT32 all of which are supported by the vfat kernel module." – barlop Dec 20 '23 at 18:38
4

Apps like Disk Info also provide the format (enable "show file system" in settings).

Firelord
  • 25,084
  • 20
  • 124
  • 286
beeshyams
  • 40,739
  • 30
  • 119
  • 269
  • 1
    no, sdcardfs is a driver, not the actual thing(as answerer irfan mentions). For an app showing file system on sd card, the other suggestion of devcheck by answerer "fred", works – barlop Dec 20 '23 at 18:13
1

The app DevCheck will show you the actual filesystem of /system and /sdcard. (unlike the "diskinfo" app).

barlop
  • 635
  • 5
  • 16
  • 25
Fred Eric
  • 11
  • 2
  • if you see here this screenshot https://i.stack.imgur.com/aOqel.png granted it doesn't say sdcardfs which mount said and what diskinfo would probably have said . But it says vfat (which might be ab it more descriptive but still isn't the actual file system). Irfan mentions "sdfat can be exFAT, FAT32 or FAT16. vfat can be one of latter two" – barlop Dec 20 '23 at 18:24