Managing RAID on Linux - Derek Vadala [110]
RAID options
Using the -R flag to mke2fs sets options specific to software RAID during filesystem initialization. Currently, only one option is available—stride, which distributes metadata blocks evenly across an array so that an equal number of blocks is included in each chunk-size stripe. An array with a 64 KB chunk-size and an ext2 filesystem with a block size of 4 KB needs 16 blocks to fill a 64 KB chunk. In this case, a stride of 16 will yield optimal performance.
# mke2fs -b 4096 -R stride=16
* * *
Tip
The stride option increases the performance of any striped array (RAID-0, RAID-4, and RAID-5), but it has no impact on linear arrays or mirroring arrays.
* * *
Access time
Each file on an ext2 partition contains metadata concerning when it was created (ctime), the last time it was modified (mtime), and the last time it was accessed (atime). Whenever a file is written, its ctime and mtime are updated, and because these values are updated during write operations, the performance overhead is not noticeable. Keeping track of when files were created and modified is also quite useful for system administration, while access times are not often required.
Unlike modification and creation timestamps, access time (atime) is updated whenever a file is read or opened. This means that each time a file is accessed (read), a write operation, albeit a small one, is performed. On heavily used filesystems, this process can become an unwarranted burden. Is it really necessary to update the atime every time the ls command is executed? Certainly not. Likewise, the overhead needed to update the atime for files stored in news and mail spool directories, web caches, and httpd servers' document roots is also a waste of performance.
You can use the chattr command to set files and directories so that their atime is no longer updated.
# chattr +A /bin/ls
Using chattr +A on a directory automatically sets the noatime option for all new files created within that directory tree. But files that already exist under a directory structure must be manually changed after the command is issued. You can recursively set entire directory structures to cease recording atime information using the -R flag.
# chattr -R +A /usr/local/httpd/htdocs/
Modifying the atime flag is useful when you wish to continue updating access times for certain files and directories, while ignoring them for others. In some circumstances, it might be useful to ignore all atime updates for an entire mounted partition. For example, a machine that is hosting Usenet news might use a software RAID to store new articles. Passing the noatime option at mount time is better than issuing chattr, because storing the atime for any file on the news spool is unnecessary.
# mount -o noatime /dev/md0 /var/spool/news
A working example
To illustrate the ext2 features I have discussed so far, I'll create a RAID-5 array with a 32 KB chunk-size. This array will contain mostly compressed graphics files that are each about 100 KB in size. In this case, I'm not worried about the default number of inodes, because given the average image size, it's unlikely that all of my inodes will be exhausted before running out of space on the array. I'll create the filesystem with the following command:
# mke2fs -b 4096 -R stride=8 /dev/md0
Here, I've initialized an ext2 filesystem, making sure to include eight 4 KB blocks in each 32 KB array stripe. Because I'm working with large files, I've also chosen a block size of 4 KB—the maximum for the 32-bit system that I'm using. Since I plan to use this array as part of an httpd image server, I'm also going to modify my /etc/fstab to automatically mount the array with the noatime option, so that I won't waste any time storing file metadata that I'll never use.
/dev/md0 /var/spool/news ext2 defaults,noatime 1,2
ext3 Extensions for the ext2 Filesystem
ext3 is an attempt to add many of the features found in other journaling filesystems to the ext2 filesystem. Many users feel that this design approach