2

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.

1
  • Did you try 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 ;)
    – Izzy
    Sep 10, 2012 at 18:52

2 Answers 2

5

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 ;) ).

-2

The command to format through adb/terminal emulator is simply format.

6
  • format : not found Sep 10, 2012 at 19:10
  • Well that's unusual. I thought all adb commands worked in a terminal emulator. I'll keep looking.
    – SaintWacko
    Sep 10, 2012 at 19:21
  • don't bother yourself looking for it the right answer was already chosen Sep 10, 2012 at 19:23
  • Oh, I thought mkfs didn't exist either... Or I guess the symlink fixed that.
    – SaintWacko
    Sep 10, 2012 at 19:24
  • it existed but in busybox that's why I thought it didn't exist at all Sep 10, 2012 at 19:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .