It's not possible to create filesystem or set label without root access. Block devices in
/dev/block/ are created with ownership
0600. Also apps aren't allowed to access SELinux context
block_device set on
/dev/block. You can use a rooted device or custom recovery like TWRP. Or use a PC (if available). On Linux and Android command-line is same.
I need to Format USB Drive (to FAT32 or Ext4)
mkfs.fat -F32 -n <LABEL> or
mkfs.ext4 -L <LABEL> to create filesystem with required label. Or later use
tune2fs to change label of an already created filesystem.
I can format USB drive in Storage Menu, but without any options, it just gives it Random number name
The random number is not name (or label), it's filesystem UUID (32-digits long string on Linux filesystems like
ext2/3/4) or Volume ID (8-digits long string on Windows filesystems like
exFAT). Similarly GUID partitions have a PARTUUID and PARTLABEL (as reported by
USB OTG and external SD card is mounted by Volume Daemon (
vold) on Android. Since Android 6 by default
vold uses filesystem UUID or VolumeID to create a mount path (which is not an actual path in case of USB OTG) like
"Developers may continue to build paths dynamically or statically depending on their use case. Including the UUID in the path identifies each card to make location clearer for developers. (For example,
/storage/ABCD-1234/report.txt is clearly a different file than
So even if you set label, whatever filesystem you choose, you will see the random number in path. However, like label, you can also set UUID/VolumeID of your choice (in case you want to retain same file path after formatting). Some file explorers, though, show filesystem label as storage name along with path.