564 567




Using Linux:System Maintenance






-->















Previous
Table of Contents
Next




Maximizing Disk Space
Generally, it’s best not to allow free space on your hard drive to fall below 25–30 percent of your hard drive’s total capacity. The following sections examine ways to keep an eye on disk space, and (more importantly) ways to reclaim parts of a shrinking hard disk pie.

Performing System Cleanups
While the kernel and other Linux processes run, they generate a number of “housekeeping” files. Often, Linux automatically disposes of these files but sometimes you must take matters into your own hands. For instance, if you are creating your own logs, use a redirect command like >> (append); the files used by that redirect will continue to grow until removed.
Linux provides two commands to check on disk usage, df and du, described in the following two command examples:


#df
Filesystem 1024-blocks Used Available Capacity
Mounted on
/dev/hda5 128790 61203 60936 50% /
/dev/hda7 257598 172332 71962 71%
/usr
/dev/fd0 1423 471 952 33%
/mnt/floppy


df (disk free space) reports on the total number of blocks used and free on all mounted partitions. It’s good for getting an overall snapshot of the space available on the entire system. Its compatriot, du, allows you to examine individual files and directories for space usage, a little like ls with the -l option:


#du
15 ./taper_info
1 ./docs/f2
2 ./docs/x
2853 .


You can use these commands in shell scripts to automate monitoring of system space usage.

You can also use the find command with the size (-s) option to generate lists of large files that bear examining:


#find -s +1000k -print > /home/me/filemaint/bigfilelist


This command prints a list of files larger than 1 MB (1,000 KB) in the designated log file. You can also run this command using the crontab feature to receive email listing those files:


* 8 * * Mon find -s +1000k -print


This command checks for large files every Monday at 8:00 a.m. (a good way to enjoy light entertainment on Monday mornings is to see some of the gargantuan files created over the last week).

Aside from looking for files created by users, there are several places that you can check for files that need to be cleaned up. The best place to start is in the /etc/syslog.conf file. This file maintains a listing of all of the logs used by the syslogd daemon, a “system logger” started when you boot Linux:


#cat /etc/syslog.conf
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
kern.*
/dev/console
# Log anything (except mail) of level info or higher.
# Don’t log private authentication messages!
*.info;mail.none;authpriv.none /var/log/
messages
# The authpriv file has restricted access.
authpriv.*
/var/log/secure
# Log all the mail messages in one place.
mail.*
/var/log/maillog
# Everybody gets emergency messages, plus log them on another # machine.
*.emerg *
# Save mail and news errors of level err and higher in a
# special file.
uucp,news.crit
/var/log/spooler


In this file, the lines starting with # signs are comments; the other lines instruct the syslog daemon how to handle log messages. The Linux system logs a variety of messages to help with everything from lost mail to system crashes. Almost every message contains a time, machine name, and the name of the program that generated it. The syslog daemon also categorizes messages by order of importance, ranging from simple system debugging and info messages to high-priority critical and emergency (emerg) messages.
In addition to being routed by severity, messages are earmarked based on the facility (cron, mail, and so on) associated with them. So, as you can see above, mail log messages are handled differently than kernel (kern) messages. Some of these logs can be good places to look if you’re having problems with a particular feature of Linux (like mail).
You can see how, if the system were left up for some time with no other housecleaning done, some of the files might get large. Almost all of these syslogd logs are stored in /var/log, so this is a good place to check for files experiencing runaway growth:


#find /var/log -s +250k -print


It’s also worth becoming a little familiar with the Linux File System Standard to help identify other likely places to clean (the Red Hat documentation contains a description of how Red Hat’s filesystem structure conforms to the Linux File System Standard). Two candidates are the tmp directories: /tmp and /var/tmp. These directories are used as “dumping grounds” by various applications and utilities, and if the system isn’t rebooted periodically, they too can become larger than you’d like:


#ls /var/tmp
taper00291oaa
taper00291paa
taper00420caa
taper00420daa
taper01047caa
taper01047daa


The /var/tmp file contains a set of taper-related files. If you’re not sure whether taper still needs these (it probably doesn’t), move them to another directory and run a taper backup and/or restore. Assuming taper runs satisfactorily, it should be safe to remove these files.

SEE ALSO

•  For more information about the find command, see page 548.
•  For more information about the crontab utility, see page 435.
•  For more information about Linux kernel management, see page 569.
•  For more information about using the Linux mail utility, see page 179.
•  For information about Linux system daemons, see page 467.







Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
2014kwykład3część1Redox stud dpkid(567
567 572
564,6,artykul
561 564
demo cgi 567
Antyk kultura starożytnej Grecji i Rzymu (oraz innych d~567
565 567
README (564)
01 (564)
567,8,artykul
567 francuskikrokdalej1
567 (2)
01 (567)

więcej podobnych podstron