Formatting the Flash Disk
|Top Previous Next|
Before the flash disk can be used it must be formatted. Formatting allocates and initializes the "housekeeping" area of the disk. This consists of two boot sectors plus a certain number of sectors for the file record table (FRT), the file allocation table (FAT), and possibly the transaction journal if you wanted one. For details see Disk Area Allocation Details.
Formatting is performed using the fd.format or fd.formatj method. These methods accept, as arguments, two parameters: total number of sectors to be occupied by the disk, and the maximum number of files that you wish to be able to store on the disk. Fd.formatj additionally has the third argument: the number of sectors that you want to allocate to the transaction journal. Fd.format does not give any sectors to the latter, so it is like setting the journal size to 0.
The total number of sectors cannot exceed the size of the data area. That is, the maximum "gross" disk size is fd.availableflashspace sectors. The flash disk needs a number of sectors for its internal housekeeping, so actual useful capacity of the disk will be less. Checking Disk Vitals topic explains how to find out current disk capacity, as well as get other useful info. There is also a minimum limit that will be accepted for the total disk size. The minimum exists because the number of sectors occupied by the disk must at least be enough for the "housekeeping" data.
The fd. object stores up to 64 files on the disk, in a single "root" directory. You can choose to have less files if you don't need so many. This will reduce the number of "housekeeing" sectors required for the disk. The economy is not dramatic, but you can still save some space. Each file record occupies 64 bytes, so one sector of the FRT table can store 4 file records. For this reason, the number of files you specify will always be adjusted to be the multiple of 4. For example:
After the formatting the disk will be in the dismounted state and will need to be mounted before any disk-related activity can be successfully performed.