• Aucun résultat trouvé

Several fi le systems are available on Red Hat Enterprise Linux, but Ext4 is used as the default fi le system. Sometimes you may want to consider using another fi le system, however. Table 5.1 provides an overview of all the relevant fi le systems to consider.

c05.indd 129

c05.indd 129 1/8/2013 10:44:23 AM1/8/2013 10:44:23 AM

File system Use

Ext4 The default file system on RHEL. Use it if you’re not sure which file system to use, because it’s an excellent general-purpose file system.

Ext2/3 The predecessors of the Ext4 file system. Since Ext4 is much better, there is really no good reason to use Ext2 or Ext3, with one exception: Ext2 doesn’t use a file system journal, and therefore it is a good choice for very small par-titions (less than 100MB).

XFS XFS must be purchased separately. It offers good performance for very large file systems and very large files. Ext4 has improved a lot recently, however, and therefore you should conduct proper performance tests to see whether you really need XFS.

Btrfs Btrfs is the next generation of Linux file systems. It is organized in a com-pletely different manner. An important difference is that it is based on a B-tree database, which makes the file system faster. It also has cool features like Copy on Write, which makes it very easy to revert to a previous version of a file. Apart from that, there are many more features that make Btrfs a versa-tile file system that is easy to grow and shrink. In RHEL 6.2 and newer, Btrfs is available as a tech preview version only, which means that it is not supported and not yet ready for production.

VFAT and MS-DOS

Sometimes it’s useful to put files on a USB drive to exchange them among Windows users. This is the purpose of the VFAT and MS-DOS file systems.

There is no need whatsoever to format partitions on your server with one of these file systems.

GFS GFS is Red Hat’s Global File System. It is designed for use in high availability clusters where multiple nodes need to be able to write to the same file sys-tem simultaneously.

As you can see, Red Hat offers several fi le systems so that you can use the one that is most appropriate for your environment. However, Ext4 is a good choice for almost any situation. For that reason, I will cover the use and confi guration of the Ext4 fi le system exclusively in this book.

Before starting to format partitions and putting fi le systems on them, there is one fi le system feature of which you need to be aware—the fi le system journal. Modern Linux fi le systems offer journaling as a standard feature. The journal works as a transaction log in which the fi le system keeps records of fi les that are open for modifi cation at any given time. The benefi t of using a fi le system journal is that, if the server crashes, it can check to see what fi les were open at the time of the crash and immediately indicate which fi les are potentially damaged. Because using a journal helps protect your server, you would nor-mally want to use it by default. There is one drawback to using a journal, however: a fi le

c05.indd 130

c05.indd 130 1/8/2013 10:44:23 AM1/8/2013 10:44:23 AM

it’s not a good idea to create a journal on very small fi le systems because it might leave insuffi cient space to hold your fi les. If this situation applies to some of your partitions, use the Ext2 fi le system.

Creating File Systems

To create a fi le system, you can use the mkfs utility. There are different versions of this utility—

one for every fi le system type that is supported on your server. To create an ext4 fi le system, you use the mkfs.ext4 command or, alternatively, the command mkfs -t ext4. It doesn’t matter which of these you use because they both do the same thing.

Formatting a partition is straightforward. Although mkfs.ext4 offers many different options, you won’t need them in most cases, and you can run the command without addi-tional arguments. In Exercise 5.2, you’ll learn how to make an Ext4 fi le system on one of the partitions you created in Exercise 5.1.

E X E R C I S E 5 . 2

Creating a File System

In this exercise, you’ll learn how to format a partition with the Ext4 fi le system.

1. Use the fdisk -cul /dev/sdb command to generate a list of all partitions that cur-rently exist on the /dev/sdb device. You will see that /dev/sdb1 is available as a primary partition that has a type of 83. This is the partition on which you will create a fi le system.

2. Before creating the fi le system, you probably want to check that there is nothing already on the partition. To verify this, use the command mount /dev/sdb1 /mnt. If this command fails, everything is good. If the command succeeds, check that there are no fi les you want to keep on the partition by verifying the contents of the /mnt directory.

3. Assuming that you are able to create the fi le system, use mkfs.ext4 /dev/sdb1 to format the sdb1 device. You’ll see output similar to Listing 5.6.

4. Once you are fi nished, use mount /dev/sdb1 /mnt to check that you can mount it.

Listing 5.6: Making a file system

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks 65536 inodes, 262144 blocks

13107 blocks (5.00%) reserved for the super user First data block=1

Maximum filesystem blocks=67371008 32 block groups

8192 blocks per group, 8192 fragments per group 2048 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729, 204801, 221185 Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 27 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.