next up previous contents
Next: Mounting and unmounting Up: Filesystems Previous: Which filesystem should be

Creating a filesystem


Filesystems are created, i.e., initialized, with the mkfs(8) command. There is actually a separate program for each filesystem type. mkfs is just a front end that runs the appropriate program depending on the desired filesystem type. The type is selected with the -t fstype option.

The programs called by mkfs have slightly different command line interfaces. The common and most important options are summarized below; see the manual pages for more.

-t fstype
Select the type of the filesystem.
Search bad bad blocks and initialize the bad block list accordingly.
-l filename
Read the initial bad block list from the file filename.

To create an ext2 filesystem on a floppy, one would give the following commands:


First, the floppy was formatted (the -n option prevents validation, i.e., bad block checking). Then bad blocks were searched with badblocks, with the output redirected to a file, bad-blocks. Finally, the filesystem was created, with the bad block list initialized by whatever badblocks found.

The -c option could have been used with mkfs instead of badblocks and a separate file. The example below does that.


The -c is more convenient than a separate use of badblocks, but badblocks is necessary for checking after the filesystem has been created.

The process to prepare to filesystems on hard disks or partitions is the same as for floppies, except that the formatting isn't needed.

Andrew Anderson
Thu Mar 7 22:36:29 EST 1996