There are native programs available on Android for creating file systems, and in most cases they reside in a directory below /system
(my Motorola Droid 2 e.g. has them in /system/xbin
. Depending on the file system you want to create, you can chose between:
mkfs.ext2
mkfs.minix
(unlikely you want that -- and it might even be not available with your ROM)
mkfs.vfat
As the latter is probably what you want, some closer explanation on its options here:
mkfs.vfat [-v] [-n LABEL] BLOCKDEV [KBYTES]
What do those options stand for?
-v
: Generate verbose output (reporting)
-n Label
: Give the file system a name
BLOCKDEV
: the file system you want to format
KBYTES
: probably the block size (I'm not 100% sure with this)
So the minimal thing to do would be:
mkfs.vfat -v /dev/block/uba1
(provided your drive to format is available as /dev/block/uba1
on your system). One more example, giving the file system a name:
mkfs.vfat -v -n MyNewDisk /dev/block/uba1
It should report success then -- or an error if it failed.
EDIT: On some systems, the mkfs
commands seem to be part of the busybox
binaries -- which you can recognize with a full directory listing, e.g.
ls -l /system/xbin | grep mkfs
It should show them as "symbolic links" pointing to busybox then. In this case, you can optionally run them via busybox:
busybox mkfs.vfat
should show you the syntax then (thanks to ce4 for pointing this out -- credits to him ;) ).
mke2fs
(or, with full path,/system/bin/mke2fs
-- maybe in a different place on your phone)? There are also/system/xbin/mkfs.ext2
,/system/xbin/mkfs.minix
, and/system/xbin/mkfs.vfat
-- most likely you are looking for the last one ;)