Книга: Fedora™ Unleashed, 2008 edition

Creating the File System on the Partitioned Disk

Creating the File System on the Partitioned Disk

After you partition the disk for a specific file system, you can create the file system on it. In the DOS world, this two-part process is described by DOS as low-level formatting (creating the partitions and partition table) and formatting (creating the file system). In the Unix world, the latter is known as creating a file system. In this section, you learn how to create a file system in Linux.

An unformatted disk storage device (a floppy disk, hard disk drive, or removable media) typically arrives to you with a low-level format, which has been done with a tool such as fdisk or superformat. Although the disk might have a boot block and partition information, it typically lacks the file structure needed for a file system.

NOTE

If you are preparing to create a file system on any device other than a floppy disk, examine it with fdisk or another utility of your choice and modify the partition table accordingly (following the instructions you saw in the preceding sections of this chapter).

To create the file system structure, you need to do what is sometimes referred to as a high-level format. For FAT file systems, this is accomplished by the format command. In Linux, you use the mke2fs -j command to create an ext3 file system.

NOTE

If you are creating a Reiser file system, use the mkreiserfs command. To create a DOS file system, use the mkdosfs command. Other commands for other file systems include:

mkfs.ext2 — The ext2 file system

mkfs.msdos — The MS-DOS file system

mkfs.vfat — The FAT32 file system

Using mke2fs to Create the File System

The mke2fs command is used to create both the ext2 and the ext3 file systems. At its simplest, the command is used as:

# mke2fs partition

such as:

# mke2fs /dev/hdc4

Here are some of the most useful options for mke2fs:

-c — This option checks for bad blocks during file system creation.

-N — This option overrides the default number of inodes created. (The default number is usually a good choice, but you might need to use this option to allow additional useable disk space.)

-m — This option frees up some space on the disk, but you do so at your peril. By default, the system allocates 5% of the blocks to the super-user — to be used in file recovery during fsck. You can lower that allocation, but you might not leave enough blocks for fsck to recover enough files.

-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.

Using mkfs.ext3

To 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.

NOTE

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.

Using mkreiserfs

The 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

Оглавление книги


Генерация: 1.705. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз