Formatting
Formatting is the procedure of writing marks on the magnetic media which are used to mark sectors and tracks. Earlier a disk is formatted; its magnetic surface is a complete mess of magnetic signals. Whenever it is formatted, a few orders are brought into the chaos through essentially drawing lines where the tracks go and where they are separated into sectors. The real details are not quite accurately like this, but which is irrelevant. A disk cannot be used unless it is formatted.
Within MS-DOS, the word formatting is also used to refer to the procedure of creating a file-system. There, the two processes are frequently combined, especially for floppies. Whenever the distinction required to be made, the real formatting is known as low-level formatting, although making the file-system is known as high-level formatting. Within UNIX, the two are known as formatting and making a file-system.
For IDE and a few SCSI disks the formatting is really done at the factory and does not required to be repeated. In reality, formatting a hard disk can cause it to work less efficiently, for instance since a disk might require to be formatted in a unique way to permit automatic bad sector replacement to work.
Disks which require to be or can be formatted frequent need a special program since the interface to the formatting logic inside the drive differs from drive to drive. The formatting program is frequently either on the controller BIOS or is supplied as an MS-DOS program; neither of these can simply be used from inside Linux.
In During formatting bad spots may be encountered on the disk, known as bad blocks or bad sectors. These are sometimes handled through the drive itself, but if more of them develop categories of the disk should not be used. The logic behind this is built into the file-system. Instead, one might create a small partition which covers just the bad part of the disk. This approach may be a good idea if the bad spot is simply large, because filesystems can sometimes have trouble with extremely large bad areas.
Floppies are formatted using fdformat. The floppy device file which is to be used is provided as the parameter. For instance, the following command would format a high density, 3.5 inch floppy in the 1st floppy drive:
# fdformat /dev/fd0H1440
Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.
Formatting ... done
Verifying ... done
#
The given command would format a high density of 3.5 inch floppy in the first floppy drive.
To use an autodetecting device (Example for., /dev/fd0), the parameters of the device have to be set along with setfdprm first. To get the similar effect as above, the subsequent has to be performed:
# setfdprm /dev/fd0 1440/1440
# fdformat /dev/fd0
Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kb.
Formatting ... done
Verifying ... done
#
In the given example the setfdprm, will automatically set the device and whenever using the fdformat command there is no requirement to specify particulars of the device.
It is commonly more convenient to select the correct device file which matches the type of the floppy. Remember that it is unwise to format floppies to hold more information than what they are designed for.
fdformat will also validate the floppy, that is check for bad blocks. That will try a bad block various times (the drive noise modifications dramatically). fdformat would not complain If the floppy is only marginally bad (due to dirt on the read or write head, some errors or false signals), except a real error will abort the validation process. A kernel will print log messages for each I/O error which it searches. These messages will go to the console or, to the file /usr/log/messages if syslog is being used. fdformat itself does not denotes the error.
# fdformat /dev/fd0H1440
Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.
Formatting ... done
Verifying ... read: Unknown error
#
In the given example the errors denotes the bad floppy and the format procedure is incomplete. Therefore the floppy cannot be used.
The badblocks command can be used to find any disk or partition for bad blocks (involving a floppy). It doesn't format the disk; consequently it can be used to check even existing filesystems. The instance below checks a 3.5 inch with floppy with two bad blocks.
# badblocks /dev/fd0H1440 1440
718
719
#
Badblocks command outputs the block numbers of the bad blocks which are found. Most filesystems can prevent such bad blocks. It maintains a list of known bad blocks that is initialized whenever the filesystem is made and can be changed later. The initial search for bad blocks can be done through the mkfs command (that initializes the filesystem), but later checks shall be complete with badblocks and the new blocks should be added with fsck.
Several modern disks automatically notice bad blocks and attempt to fix them through using a special reserved good block. This is invisible to the OS. Even many disks can fail, if the number of bad blocks grows extremely large.