13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C H A P T E R 5■ ■ ■Working with FilesystemsFilesystems are the backbone of a <strong>Linux</strong> system (after all, in <strong>Linux</strong>, absolutely everything is a file). Thischapter discusses how to tune and make changes to the default <strong>Linux</strong> filesystems, how to resize yourfilesystems when you find yourself running out of space (something that seems to happen howevermuch room you think you’ve given yourself!), RAID arrays, and alternative filesystems.5-1. Changing ext2 to ext3 with tune2fsThe ext2 and ext3 filesystems, which are the filesystems that you’re most likely to be using on your <strong>Linux</strong>systems, have various parameters set at the time of creation. (ext3 is the default on most modern distrosnow.) One of these is the journaling parameter, which is the fundamental difference between an ext2filesystem and an ext3 filesystem. tune2fs enables you to change these parameters on the fly.By turning an ext2 filesystem into an ext3 filesystem, you can add journaling to the filesystem on thefly. Journaling filesystems log changes to a journal area before committing them to the main disk, whichavoids potential data inconsistencies in the event of a crash. In general, disk operations in <strong>Linux</strong> willrequire more than one write event (for example, removing a file directory entry and then also markingthe space as free), so if there’s a power failure or other problem when only one part of a disk operationhas been completed, the filesystem will be in an inconsistent state. In a non-journaled filesystem, yourun fsck or a similar tool to walk the whole filesystem looking for (and ideally fixing) inconsistencies. Ina journaled filesystem, the journal is instead used to rerun all recent operations until the filesystem isconsistent again. This is much quicker and more reliable.The basic command to create a journal for an ext2 filesystem is as follows:tune2fs -j /dev/hda1This will create an immutable journal file (one whose state cannot be manually altered, so it’s safefrom accidental deletion) for the filesystem. On the next reboot, this file will be moved to a special inode.You may want to reboot sooner rather than later to make sure this happens (and thus that the journal filecan’t be accidentally lost).119Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!