How to change random filesystem label on USB OTG?


Question

I am without PC right now, but I need to Format USB Drive (to FAT32 or Ext4) with Samsung S8 (Android 9) and change label. But I can't find any app that can do this. I can format USB drive in Storage Menu, but without any options, it just gives it Random number name (I can see it in Total commander) and I think it's Ext4, but again no options. Is there any option to rename the Label?



I found they there is Aparted app (port of gparted) but it needs ROOT and also it gives random label.



I also tried to rename drive in Total commander, but it says it's ranamed, but in reality it has old label. Thanks for any help :).


Answer

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.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes