► -L — This option gives the volume a label, which is useful if you need to be reminded what the file system is used for; it also provides some flexibility in identifying volumes in /etc/fstab.
► -S — This option is a last-ditch effort for recovering a broken file system; it writes only the superblock and descriptors, leaving the information in the inodes unchanged. Always run fsck after using this option.
As you can see, mke2fs offers a few options to make more space available for the regular users. But that extra space always comes from the super user's space for recovering damaged files. The default settings accommodate most users, so think carefully before using one of these options. Hard disks are getting less expensive all the time, so adding another might be a better solution.
mkfs.ext3To make a new ext3 file system, you use the mke2fs command with the -j or -J option, or call the command as mkfs.ext3. Use the tune2fs command on an existing ext2 file system to add journaling. You learn how to convert an existing ext2 file system into an ext3 file system later in this chapter. Here, x represents a partition:
# tune2fs /dev/hdx -j
Some arguments you can use with this command include:
► -j — This option adds an ext3 journal to the new file system, using the default values. Note that you must be using a kernel that has ext3 support to actually make use of the journal.
► -J journal-options — This option overrides the default ext3 journal parameters so that you can choose the options you desire. The following journal options are comma separated and you can provide an argument by using the = sign.
► size=journal-size — This option creates a journal of journal-size megabytes. With a minimum size of 1,024 blocks, it cannot be more than 102,400 blocks. There must be enough free space in the file system to create a journal of that size.
► device=external-journal — This option associates the file system with a journal not contained within the file system (one that must have already been created with the command mke2fs -O journal_device journal_name); in other words, the journal and the data files do not have to be on the same device.
The latter two options in the arguments list are mutually exclusive.
To select the ext3 journaling mode, you must add the appropriate entry in /etc/fstab.
Because the ext3 file system is a new version of the ext2 file system with journaling added, it supports the same options as ext2, as well as the following additions:
► noload — This option disables the ext3 file system's journal when mounting; it becomes an ext2 file system.
► data=journal / data=ordered / data=writeback — This option specifies the journaling mode; ordered is the default. Metadata is always journaled.
► journal — The slowest, but most secure mode because all the data is written to the journal before it is written to the regular file system.
► ordered — This is the default mode in which all data is written to the main file system prior to its metadata being committed to the journal.
► writeback — With this option, data can be written into the main file system after its metadata has been committed to the journal. This option enables old data to appear in files after a crash and journal recovery, but it is the fastest option.
mkreiserfsThe Reiser file system journals file data and handles smaller files more efficiently than the ext3 file system. Although it is suitable for use as the root file system, Fedora does not officially support its use in that way. You use the mkreiserfs command to create a Reiser file system. The default values for mkreiserfs work well. To create a Reiser file system, use:
# mkreiserfs device
Creating a DOS File System with mkdosfs
It is possible to create DOS file systems without owning any Microsoft software if you use the mkdosfs command. To create a DOS file system in an image file, use the -C option. The -n option enables you to specify a volume label. To create a 1.4MB DOS file system as an image file with the label dosfloppy, the sector size (-S) should be 512 and the block count should be 1440. Use the -v option to provide verbose output so that you can observe what happens.
# mkdosfs -n dosfloppy -v -C floppy.img -S 512 1440
A complete review of all the argument options and syntax for creating a DOS file system can be found in the man page for mkdosfs. The new file system must be mounted (as described in the following section) and then formatted with the mformat command.
Mounting File Systems
File systems in Unix are very flexible in that they need not be physically present on your computer; you can have network access to other file systems on other machines. The Linux file system structure (the Virtual File System we spoke of at the beginning of the chapter) makes it appear as if all the file systems, regardless of type and location, are local and mounted somewhere on the root file system. As the system administrator, you decide what file systems are to be made available and where they will be attached, or mounted, to the root file system. The standard arrangement of the file system tree is that installed by default by Fedora. The source of that standard arrangement is found in the file system hierarchy standards. Although a detailed discussion of those standards is beyond the scope of this section, they can be examined at http://www.pathname.com/fhs/. In this section, you learn how to mount file systems to the root file system and add file systems to the system, and you learn the traditional mount points of commonly used file systems as well.
In Linux (and its Unix cousins), all file systems — whether local, remote, images on a disk, or in memory — are mounted on a single point known as root (which is not the same as the root operator, also known as the super-user). This mount point is written as a forward slash, /, which is read and pronounced "root." The resulting file directory hierarchy all starts from /. After they are mounted, the physical location of the files is unimportant because they all appear to be local.
Even if the file systems are different (FAT, ext2, HPFS, NTFS, and so on), the Linux kernel modules and the VFS make them all appear as part of the directory tree as native files. Listing the file systems as native files obviates the need for any applications to be aware of the physical location of the file or the true nature of the native file system. As a result, programming these applications is simplified because the applications have to work only with what they think are local, native files.
Any file system can be mounted anywhere, but some places are more traditional than others. Removable media devices are traditionally mounted under the /mnt directory (for example, CD-ROM drives on /mnt/cdrom). The /mnt directory is the traditional place to mount removable or remote file systems that are unrelated to the local system directories that branch from the root mount point.