My objective is to determine the name of a mounted USB flash drive programmatically in linux using C.
Has anyone got any suggestions?
My objective is to determine the name of a mounted USB flash drive programmatically in linux using C.
Has anyone got any suggestions?
think the USB stick is registered as /dev/sdb
(you can determine which is the USB stick in /dev
using sudo fdisk -l
or dmesg
with tail
and grep
)
if you want to get the label of the USB stick you can use sudo mlabel -i /dev/sdb1 -s ::
and then extract the label using grep
, awk
or sed
https://help.ubuntu.com/community/RenameUSBDrive
if you want to get the UUID you can use sudo blkid /dev/sdb1
-> https://unix.stackexchange.com/questions/67464/how-to-get-uuid-for-a-usb-drive <-
https://serverfault.com/questions/3132/how-do-i-find-the-uuid-of-a-filesystem
See this Execute a Linux command in the c program and how to execute a command as root for executing linux commands like blkid
in C