Home Contents | # os.format | OS | Core4 Lua Commands

## SYNOPSIS

#include <lua/block.lh>
os.format(device[, type])

## DESCRIPTION

Formats a block device to prepare it for storing files. device must be a valid block device name. Examples for block devices are:

/dev/nv0 | Battery backed static ram.
/dev/df0b | On board NOR data flash.
/dev/mmc0a | Removable memory card.
/dev/sdUSB2aa | A USB flash stick in the 2nd USB slot.

The optional type parameter choses the type of filesystem to be used. By default, the kernel will chose the best format for the given device.

## RETURN VALUE

On success, returns true. On error, three values are returned: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library.

## CAVEATS

This function will DESTROY all data that is stored on the device. Applications should take proper precautions before allowing the user to call this function.

## NOTES

See the filesystem documentation for more information about device names.

## BUGS

The only filesystem type supported is "fat", so passing anything for type makes no sense.

## SEE ALSO

/dev, /media