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
Apps like Disk Info also provide the format (enable "show file system" in settings).
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
~$ 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
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
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 (
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
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
Similarly for EXT4
hexdump -e '"%X"' -n2 -s1080 should return
EF53 and for F2FS
hexdump -e '"%X"' -n4 -s1024 should return
Without root access:
Another option is to check
logcat soon after boot or inserting USB drive or SD card.
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"