S. Singh
S. Singh

Reputation: 99

Programmatically obtaining USB file system format

I need to mount a USB drive to an embedded system, running Linux. The USB could be in FAT, NTFS or ExFAT format.

How can i handle this in code so that I pass proper type in mount command such as

mount -t vfat /dev/sda1 /mnt

So I have tried mount with:

mount -t vfat,ntfs /dev/sda1 /mnt

This command gives invalid argument, but it successfully mounts the USB if USB is in NTFS or VFAT format. However if i try to give

mount -t vfat,ntfs,exfat /dev/sda1 /mnt

The command fails.

Any pointers will be really helpful.

Upvotes: 0

Views: 435

Answers (1)

Jan Müller
Jan Müller

Reputation: 423

From the mount manual page:

If no -t option is given, or if the auto type is specified, mount will try to guess the desired type. Mount uses the blkid library for guessing the filesystem type...

Is libblkid available for your embedded system?

Try:

mount -t auto /dev/sda1 /mnt

or

mount /dev/sda1 /mnt

And as mentioned in the comments, make sure the kernel on your embedded system supports exfat.

Upvotes: 1

Related Questions