The mkfs Command Filesystem Creation

6.2.3 Filesystem Creation

The discussed filesystem structures, including the superblock, are the result of the procedure known as to create a filesystem. In the UNIX terminology, we say to make a filesystem. UNIX provides several commands to deal with filesystems, and often additional user−friendly character−based or GUI tools. We will focus on the related UNIX commands available on all UNIX flavors. UNIX sees storage entities at the moment we talk about disk partitions through the corresponding special device files. Remember that storage entities are accessible through both types of special device files characterraw and block special device files.

6.2.3.1 The mkfs Command

This the basic UNIX command for this purpose. It offers the most flexibility; practically all filesystem parameters could be specified. For most cases, however, the default specification should be appropriate. The format of the command is: mkfs [options] char−spec−file size [operands] where options Generic or filesystem type specific options char−spec−file The character special file for the corresponding disk partition size The size of filesystem in 512−byte blocks operands Optional arguments for a fine−tuning of the filesystem parameters such as a number of inodes to create the default is one inode for every 2 KB of disk space, a primary block size, a fragment size, free disk space threshold, and others The mkfs command is a versatile command that enables flexible creation of the filesystem; myriad of options and operands specify many details of the created filesystem. It checks for dependencies among specified parameters to prevent any wrongdoing. The command varies slightly among different vendors flavors. 6.2.3.2 The newfs Command Another BSD−style front−end command, newfs, can also be used to create a filesystem. This command actually invokes the mkfs command but with a number of predefined filesystem parameters. It is much easier to work with this command, and the author recommends its use whenever possible. The format of the newfs command is: newfs [options] char−spec−file where options Generic, filesystem−type specific, and mkfs−related options char−spec−file Raw character special file for the corresponding disk partition Remember that most of the filesystem−related commands require character special device files to identify the storage entity here the disk partition. 147 newfs char−spec−file disk−name where char−spec−file Raw character special file for the corresponding disk partition disk−name The name of the entry specified in the disk description file etcdisktab HP−UX version 9 used such an approach. The main disadvantage was that required disktab entries could not include all available disk models. Simply, newer disk models appeared after the file installation cannot be included. This led to a frequent patching of the disk description table, which could be annoying. HP−UX version 10 retained the disk description file for backward compatibility but switched to the new type of the newfs command: one that is not dependent on the disk description table. 6.2.3.3 The tunefs Command UNIX also provides the command tunefs to tune adjust the created filesystem. The command can modify dynamically certain filesystem parameters. It is not unusual to realize after some time that the created filesystem does not optimally match your needs. The used filesystem cannot be easily recreated; in most cases it is almost impossible. This command is the UNIX response for that purpose. Some UNIX flavors provide other filesystem specific commands, for example, a command to extend the size of a filesystem.

6.2.4 File Identification and Allocation