Objective 2: Maintaining a Linux Filesystem
This Objective has major overlaps with Chapter 6, Objective 2. You may wish to review the section "Maintain the Integrity of Filesystems" there. Here we'll just touch on the fine points of some tune2fs settings, when and how to force fsck to save your system, and how to resize filesystems.
Fortunately, Linux filesystems require very little maintenance. For example, Linux's allocation strategies lead to very little disk fragmentation , so defragmentation tools, while they exist, are not used much. Fragmentation does increase, though, if the disk becomes excessively full, so monitoring free space is a very good idea. Maintenance tasks are mostly restricted to watching fsck do its work automatically after a crash.
tune2fs
It's important, despite the availability nowadays of journaling (see the next Objective) and RAID, to run fsck on all filesystems from time to time. The two parameters for controlling how often a fsck of a filesystem is forced are: -i and -c. The default for a filesystem is shown when it is created:
This filesystem will be automatically checked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
If you find that your disk systems are very reliable and experience very few corruption problems, you can increase the period between forced filesystem checks. To change the number of mounts between checks (the filesystem typically gets mounted once for each boot), use the -c option. It is relatively ...
Get LPI Linux Certification in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.