How can I low-level format flash memory in Linux?

"Low level formatting" was done on floppies, where you could write at different densities by choosing to organize the tracks and sectors differently. But this makes no sense for most modern media. Its notion of how to organize the data on the device is fixed and unchangeable. It doesn't make any sense at all for flash, which has discrete bits, rather than magnetic domains. Higher level formatting is possible, which is mkfs in unix-land.


Low-level formatting means many different things to different people and on different contexts.

The original meaning was a step needed in the formatting of disks - disk drives need header, sync and other patterns written on the media before it can store data to it. In this way the head can detect when it is A) on a track and B) where it is on the track. Low-level formatting a floppy prepares the disk to be able to read and write blocks. Early MFM and RLL PC hard drives could be low-level formatted, often using a utility built into the hard drive controller's (an ISA card) ROM. Modern IDE and SATA hard drives are low-level formatted too, but only at the factory.

Various other meanings include writing zeros to all blocks, configuring the drive to disable "hidden" areas such as HPA and DCO and then zeroing all blocks, or other things more related to partitioning than formatting.

Raw flash needs a different initial preparatory step at the factory - each flash "eraseblock" (analogus to a "block" on disks) needs to be tested and marked as bad if it is indeed bad. Each "eraseblock" has an additional small "OOB" block that holds error correcting information - and this is where it is marked as bad. You do NOT want to repeat this step as the act of writing to a bad block could prevent you from setting that particular bit again that identifies it as bad.

But you are not dealing with raw flash. You are dealing with a USB flash drive. There is a controller chip in all flash drives that accepts USB commands from the host and talks to the raw flash inside on the host's behalf. Some of these controller chips can be configured to report part of the flash as a separate CD-ROM partition, or act like two separate USB storage devices. Depending on the make and model of the controller chip, you may be able to find a recovery or configuration utility (likely Windows only) that could reset this controller chip. You would begin by opening the flash drive, looking for the smaller of (likely) two chips that are on the small PCB, and doing some Googling. The make and model printed on the outside of the case is not likely to help you find who made the controller inside of it.


There is no way to do a low-level format on most flash devices, since they have an additional translation layer from USB/ATA/SD/etc. to MTD which obscures the low-level MTD devices (which can be low-level formatted if gotten to directly [which you can't]).

Tags:

Flash Memory