It's not possible to create filesystem or set label without root access. Block devices in /dev/block/
are created with ownership 0:0
, mode 0600
. Also apps aren't allowed to access SELinux context device
or block_device
set on /dev
and /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)
Use mkfs.fat -F32 -n <LABEL>
or mkfs.ext4 -L <LABEL>
to create filesystem with required label. Or later use fatlabel
/mlabel
or e2label
/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 NTFS
/FAT32
/exFAT
). Similarly GUID partitions have a PARTUUID and PARTLABEL (as reported by blkid
).
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 /storage/[UUID]
:
"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 /storage/DCBA-4321/report.txt
.)"
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.