Sie sind auf Seite 1von 22

V4.

1
Student Notebook

Uempty

Unit 11. Managing file systems


What this unit is about
This unit illustrates the methods that can be used to manage the AIX file systems.

What you should be able to do


After completing this unit, you should be able to: Monitor file system growth and control growing files Manage file system disk space usage Implement basic file system integrity checks

How you will check your progress


Accountability: Checkpoint questions Exercise

References
SG24-7559 Online AIX Version 6.1 Differences Guide AIX 6.1 Operating System and device management

Note: References listed as Online above are available at the following address: http://publib.boulder.ibm.com/infocenter/pseries/v6r1/index.jsp

Copyright IBM Corp. 1997, 2008

Unit 11. Managing file systems

11-1

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Unit objectives
After completing this unit, you should be able to: Monitor file system growth and control growing files Manage file system disk space usage Implement basic file system integrity checks

Copyright IBM Corporation 2008

Figure 11-1. Unit objectives

AU1412.0

Notes:

11-2 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Space management
File systems expand upon notice, NOT automatically To keep from running into problems:
Monitor file system growth Determine causes Control growing files Manage file system space usage Control user disk usage Defragment file system

Copyright IBM Corporation 2008

Figure 11-2. Space management

AU1412.0

Notes: The need to monitor file system growth


Although AIX provides for dynamic expansion of a file system, it does not expand the file system on the fly. The system administrator must continually monitor file system growth and expand file systems as required before they get full. If a file system becomes 100% full, then the users receive out of space messages when they try to extend files.

Regular use of the df command


One useful technique is to run the df command via cron (the job scheduler) to perform a regular check of the space available in the file system and produce a report. cron is covered in a later unit.

Copyright IBM Corp. 1997, 2008

Unit 11. Managing file systems

11-3

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

The Resource Monitoring and Control (RMC) subsystem


You can also use the Resource Monitoring and Control (RMC) subsystem that is based on the Reliable Scalable Cluster Technology (RSCT) on the IBM SP platform. Use the Web-based System Manager to configure RMC. You have 84 conditions and 8 responses to predefine. The ctrmc subsystem is started in the /etc/inittab. Further discussion of RMC is not within the scope of this course, but there is a good description of this facility in the AIX 5L Differences Guide Version 5.2 Edition (SG24-5765-02).

11-4 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Listing free disk space


The df command displays information about total space and available space on a file system
# df
Filesystem /dev/hd4 /dev/hd2 /dev/hd9var /dev/hd3 /dev/hd1 /proc /dev/hd10opt /dev/hd11admin /dev/ramdisk0 512-blocks 294912 3309568 65536 131072 32768 163840 262144 8192 Free 228088 339408 37600 129352 32064 20760 261416 7848 %Used 23% 90% 43% 2% 3% 88% 1% 5% Iused 1925 36788 479 54 5 1617 5 17 %lused 7% 47% 11% 1% 1% 36% 1% 2% Mounted on / /usr /var /tmp /home /proc /opt /admin /ramdisk

Copyright IBM Corporation 2008

Figure 11-3. Listing free disk space

AU1412.0

Notes: Importance of the df command


The df command lists the free space on all mounted file systems. This is an important command to be aware of and to use frequently. If you run out of space in a file system (especially / or /tmp), system corruption could occur.

Copyright IBM Corp. 1997, 2008

Unit 11. Managing file systems

11-5

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Useful df command flags


A number of flags (options) can be used with the df command. Some of the most useful of these flags are shown in the following table:

Flag (Option) df -I

Brief Description of Output Displays information on the total number of blocks, the used space, the free space, the percentage of used space, and the mount point for the file system Information displayed is like that shown on the visual, but statistics in first two columns are given in units of 1024-byte blocks Information displayed is like that shown on the visual, but statistics in first two columns are given in units of 1 MB blocks Information displayed is like that shown on the visual, but statistics in first two columns are given in units of 1 GB blocks

df -k df -m df -g

The -m and -g flags were introduced in AIX 5L V5.2.

11-6 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Control growing files


/var/adm/wtmp /etc/security/failedlogin /var/adm/sulog /var/spool/*/* $HOME/smit.log $HOME/smit.script $HOME/websm.log $HOME/websm.script

Copyright IBM Corporation 2008

Figure 11-4. Control growing files

AU1412.0

Notes: Managing files that grow


Growing files should be monitored and cleaned out periodically. Some of the files that grow are listed on the visual.

Records of login activity


The files /var/adm/wtmp, /etc/security/failedlogin, and /var/adm/sulog are needed because they contain historical data regarding login activity. Thus, these files should always have a few days worth of login activity kept in them. If accounting is turned on, /var/adm/wtmp is kept to a reasonable size. If accounting is not turned on, to capture the data to archive it, use who -a on /var/adm/wtmp and /etc/security/failedlogin and redirect the output to a save file. Then, the log file can be purged by overwriting it with a null string. Two ways of overwriting a log file in this way are illustrated in the following examples:
Copyright IBM Corp. 1997, 2008 Unit 11. Managing file systems 11-7

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

- Example 1: # cat /dev/null > /var/adm/wtmp - Example 2: # > /etc/security/failedlogin The file /var/adm/sulog can be edited directly.

The /var/spool directory


The directory /var/spool contains cron entries, the mail, and other items that grow on an ongoing basis, along with printer files. If there is a problem with the printer files, you can try to clear the queueing subsystem by executing the following commands: 1. stopsrc -s qdaemon 2. rm /var/spool/lpd/qdir/* 3. rm /var/spool/lpd/stat/* 4. rm /var/spool/qdaemon/* 5. startsrc -s qdaemon

Records of SMIT and Web-based System Manager activity


Files such as smit.log and websm.log in the home directory of the root user and other system administration accounts can also become quite large. These files need to be monitored regularly and managed appropriately.

11-8 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

The skulker command


The skulker command cleans up file systems by removing unwanted or obsolete files Candidate files include:
Files older than a selected age Files in the /tmp directory a.out files core files ed.hup files

skulker is normally invoked daily by the cron command as part of the crontab file of the root user Modify the skulker shell script to suit local needs for the removal of files

Copyright IBM Corporation 2008

Figure 11-5. The skulker command

AU1412.0

Notes: Function of the skulker command


The shell script /usr/sbin/skulker includes a series of entries containing commands that remove unwanted or obsolete files of various types. (To analyze the commands that are executed by each entry, print out or view the contents of the /usr/sbin/skulker file.) Currently, items removed by the skulker script include the following: Old primary.output that got lost Old qdir files Files that are left in the mail queues Files in /tmp older than 24 hours and not accessed or modified in the past 24 hours Files in /var/tmp News items older than 45 days *.bak, *.bak, a.out, core, proof, galley, ed.hup files that are more than one day old Anything in a .putdir directory more than a day old

Copyright IBM Corp. 1997, 2008

Unit 11. Managing file systems

11-9

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Concerns related to skulker


A particular version of skulker is suited to the operating system and level with which it was distributed. If the operating system has been upgraded or modified, it may be inadvisable to use an old version of skulker. In addition, the skulker shell script is moderately complex. When making modifications, you should make a copy of the shell script first - just in case! Note that if skulker is modified, or if it is used on the incorrect version of the operating system, it ceases to be a supported component of AIX.

11-10 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Listing disk usage


The du command can be used to list the number of blocks used by a file or a directory

# du /home | sort -r -n 624 392 98 54 52 23 2 1 /home /home/fred /home/tom /home/mary /home/liz /home/suzy /home/guest /home/steve

To view individual file sizes, use the ls -l command


Copyright IBM Corporation 2008

Figure 11-6. Listing disk usage

AU1412.0

Notes: Use of the du command


There may be a number of files or users that are causing the increased use of space in a particular file system. The du command helps to determine which files and/or users are causing the problem.

Specifying the units du should use


By default, du gives size information in 512-byte blocks. Use the -k option to display sizes in 1 KB units, use the -m option to display sizes in 1 MB units, or use the -g option to display sizes in 1 GB units. The options -m and -g were introduced in AIX 5L V5.2.

Specifying output by file


By default, du gives information by directory. With the -a option, output is displayed by file rather than by directory.
Copyright IBM Corp. 1997, 2008 Unit 11. Managing file systems 11-11

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Using du in conjunction with sort


If the output of du is sorted numerically and in descending order (using the -n and -r flags of the sort command) by the value in the first column, this output can be an aid in determining which files/directories are the largest. Then using an ls -l, you can determine the file/directory's owner.

The -x flag
The -x flag/option is also very useful. When you use du -ax, the report only shows information from the specified file system. This is the best way to determine what file is filling a particular file system.

Using the find command to locate large files


The find command is useful for locating files that are over a certain size. For example, to find all files that contain more than 1,000,000 characters and then list them use the following command: # find . -size +1000000c -exec ls -l {} \;

11-12 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Fragmentation considerations
Without fragmentation File size = 2000 bytes
2000 bytes

4096 bytes

This free space cannot be used by another file

With fragmentation File size = 2000 bytes Fragment size = 1024 bytes
2000 bytes 1024

4096 bytes

1024

1024

1024

Considerations to be made: Disk space allocation Disk space utilization I/O activity Free space fragmentation Fragment allocation map
Copyright IBM Corporation 2008

These free fragments can be used by other files

Figure 11-7. Fragmentation considerations

AU1412.0

Notes: Benefits of a small fragment size


In JFS, as many whole fragments as necessary are used to store a file or directory's data. Consider that we have chosen to use a JFS fragment size of 4 KB and we are attempting to store file data which only partially fills a JFS fragment. Potentially, the amount of unused or wasted space in the partially filled fragment can be quite high. For example, if only 500 bytes are stored in this fragment, then 3596 bytes are wasted. However, if a smaller JFS fragment size, say 512 bytes, was used, the amount of wasted disk space would be greatly reduced - to only 12 bytes. It is, therefore, better to use small fragment sizes if efficient use of available disk space is required.

Copyright IBM Corp. 1997, 2008

Unit 11. Managing file systems

11-13

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Adverse effects of a small fragment size


Although small fragment sizes can be beneficial in reducing wasted disk space, they can have an adverse effect on disk I/O activity. For a file with a size of 4 KB stored in a single fragment of 4 KB, only one disk I/O operation would be required to either read or write the file. If the choice of the fragment size was 512 bytes, a 4 KB file would only be allocated a 4 KB block if one were available. If a single 4 KB block were not available, 512 byte fragments would be used, with a potential to allocate eight fragments for this file. If fragments are used, for a read or write to complete, several additional disk I/O operations (disk seeks, data transfers and allocation activity) would be required. Therefore, for file systems which use a fragment size of 4 KB, the number of disk I/O operations are far less than for file systems which employ a smaller fragment size. For file systems with a fragment size smaller than 4 KB, there is likely to be an increase in allocation activity when the sizes of existing files or directories are extended. Free space fragmentation can occur much more within a file system that uses smaller fragment sizes. The fragment allocation map, used to hold information about the state of each fragment for each file system, is held on the disk and in virtual memory. The use of smaller fragment sizes in file systems results in an increase in the length of these maps and therefore requires more resources to hold.

JFS2 block size


In JFS2, the block size has a function similar to that of the JFS fragment size. The default block size is 4096, but it can be altered by the system administrator.

11-14 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Defragmenting a file system


The defragfs command increases a file system's contiguous free space The file system must be mounted defragfs [-q | -r | -s] Options: -q -r Reports the current state of the file system Reports the current state of the file system and the state that would result if the defragfs command is run without either -q, -r or -s Gives short report regarding the current state of the file system
Copyright IBM Corporation 2008

filesystem

-s

Figure 11-8. Defragmenting a file system

AU1412.0

Notes: Information returned by defragfs command (JFS file systems)


Information that is returned by the defragfs command for a JFS file system includes the following: - Number of Fragments Moved: Displays the total number of fragments that have been moved - Number of Logical Blocks Moved: Displays how many logical blocks were relocated - Number of Allocation Attempts: The required number of calls to the allocation routine to defragment the file system - Number of Exact Matches: The number of times the fragments moved fit exactly in some free space

Copyright IBM Corp. 1997, 2008

Unit 11. Managing file systems

11-15

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Note: Sometimes the estimates for these items provided when running defragfs with the -q or -r option indicate results different from what is actually done when defragfs is run without any options.

Using defrags with JFS2 file systems


The defragfs command can also be used with a JFS2 file system. The information returned by defragfs in this case is quite different from that returned when using the command with a JFS file system. Refer to the entry for defragfs in the AIX 6.1 Commands Reference online for additional information regarding this topic.

11-16 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Verify a file system


Command syntax:
fsck [-p | -y | -n] [-f] [ file system ]

Checks journal log Checks inodes, indirect blocks, data blocks, free lists If no file system name is specified, the fsck command checks all file systems which have the check=true attribute set in the /etc/filesystems Orphan files are placed in the lost+found directory Unmount the file system before running fsck

Copyright IBM Corporation 2008

Figure 11-9. Verify a file system

AU1412.0

Notes: Function of the fsck command


A file system can be verified using the fsck (file system check) command. This check consists of a number of stages, including: - Check the journal log for errors - Check the blocks to ensure that each block is either allocated to a single file or is in the free list - Check file sizes - Check directory entries

The -p option
The -p (preen) option is used to check a file system and make only minor changes, without bothering the user. When fsck is run under SMIT, this option is used.
Copyright IBM Corp. 1997, 2008 Unit 11. Managing file systems 11-17

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Error reporting by fsck


If fsck encounters errors, it reports them to the screen. The -y option (yes) or -n (no) option is used to indicate a yes or a no answer to all questions ask by fsck. The yes option is typically used to recover a badly damaged file system. Using the -y option allows fsck to discard some badly damaged files. Note, however, that mounted file systems are not repaired.

The lost+found directory


If any files are found that are not allocated to a directory anywhere in the file system being checked, then fsck creates an entry for that data in the lost+found directory in the root directory of that file system. If the lost+found directory for a file system does not exist, it can be created using the AIX command mklost+found.

Running of fsck during system startup


The fsck command executes each time the system boots up (from the /etc/rc file).

Unmounting the file system


Unmount the file system before using fsck. If a file system is in use, the fsck utility can get confused and return inaccurate messages. If fsck were to try repairing a file system that is in use, it could actually create problems. Because of this, fsck refuses make corrections to a mounted file system.

11-18 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Documenting file system setup


Run the lsfs command Get the contents of the /etc/filesystems file Run the df command to check free space Check all the mounted file systems by running the mount command
File System Records

Copyright IBM Corporation 2008

Figure 11-10. Documenting file system setup

AU1412.0

Notes:

Copyright IBM Corp. 1997, 2008

Unit 11. Managing file systems

11-19

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Checkpoint
1. What command can you use to determine if a file system is full? __________

2. What two commands can be used to find the files and users that are taking the most disk space? ____________ ____________

3. True or False? It is good practice to run fsck -y on all file systems, even if they are mounted.

Copyright IBM Corporation 2008

Figure 11-11. Checkpoint

AU1412.0

Notes:

11-20 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

V4.1
Student Notebook

Uempty

Exercise 11: Managing file systems

Part 1 - Determining file system usage Part 2 - Using fragments for disk usage efficiency Part 3 - Using JFS compression Part 4 - Fixing file system problems

Copyright IBM Corporation 2008

Figure 11-12. Exercise 11: Managing file systems

AU1412.0

Notes: Introduction
The lab allows you to get some experience with the file system management tools. It also allows you to build and test file systems with different characteristics. This exercise can be found in your Student Exercises Guide

Copyright IBM Corp. 1997, 2008

Unit 11. Managing file systems

11-21

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Student Notebook

Unit summary

File system management does not just happen on the system. File systems need to be regularly monitored to ensure that they do not run out of space. To ensure the integrity of file systems, checks have to be carried out whenever file system corruption is suspected.

Copyright IBM Corporation 2008

Figure 11-13. Unit summary

AU1412.0

Notes:

11-22 AIX System Administration I

Copyright IBM Corp. 1997, 2008

Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

Das könnte Ihnen auch gefallen