How can I format a flash drive using terminal emulator? I have a Huawei u8160 running Cyanogenmod 7.2.

I've recently installed the usb host package and some time then I successfully activated the usb host mode.

after that I needed to format a flash drive using ONLY my phone.

my phone doesn't recognize thumb drives, but I mount them on /mnt/sdcard/data folder.

So I wanted to know if there's any command in the terminal emulator that can format a usb drive.

NOTE: I've already tried "mkfs" command it doesn't exist,I won't accept answers telling me to format it on my PC.
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 ;) ).