Thursday, 28 July 2011

Working with AIX filesystem PART 3

Today we shall see something about managing file-systems in IBM AIX.

Managing File Systems

Objective:

•File system integrity
•Manage/Monitor
–File system growth
–File growth
–File system space usage

How/Why Space Management ?


How ?

•Find the causes
•keep track of growing files
•check file system space usage
•check disk space

Explanation:


•If a File System reaches its full capacity, that means it cannot take any more data onto it. The filesystem size in these cases has to be increased because the file system size doesn‟t automatically increase.

•Our duty as system administrators is to use commands and techniques to find the causes for the increase in the file system size. This may involve tasks like keeping track of the growing files in the file system. Keep checking the file system space usage and decide whether to increase the size or not.

•The files that could keep growing at high speed are:

a./var/adm/wtmp-> Which keeps track of successful login information
b./etc/security/failedlogin-> which keeps track of failed login attempts.
c./var/spool-> directory which keeps cronentries, mails etc
d.$HOME/smit.log and smit.script-> smitrelated log files
e.$HOME/websm.log and websm.script-> WSM related log files
f./var/adm/sulog-> Keeps track of sucommand usage.

•Many of the above files are required files as they contain very useful information of activities going performed on the system. Completely removing them of may not be a recommended strategy but keeping eye on their increasing size and timely cropping them and removing old entries would be the maintenance task that could be done by the Administrators.

Free Disk Space




Explanation:


•You can use the dfcommand to display useful information about the statistics pertaining to the free disk information. The output of this command would show all the file systems, their sizes and out of the total size, how much is used and how much is free.

•Please refer to the man pages on df command to look at some useful options that you could use with df.

•There is also a very useful command called skulker.The skulker command is under /usr/sbin.

•The skulker command can be used to clean up the file systems by removing unwanted or old files. You can modify this skulker shell script by using an editor and configure it according to your environment.


Disk Usage

Explanation:


•The Disk Usage command (du) can be used to list the files and how many number of data blocks are utilized by them.

•If you look at the above example, the du command is giving the information of the file name, and how many number of 512 byte blocks has been allocated to that particular file. So by looking at this output you can make out as to which files are using more data blocks and take actions if required.

•du command comes with lots of very useful options like –x , -k etc. If you want more details on the various options that can be used with the du command, please look at the man pages for the same.


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

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.outfiles
–corefiles
–ed.hupfiles

•skulker is normally invoked daily by the cron command as part of the crontab file of the root user

•Modify the skulkershell script to suit local needs for the removal of files

Listing Disk Usage


•The ducommand can be used to list the number of blocks used by a file or a directory

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

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

Fragmentation Considerations


Without fragmentation
File size = 2000 bytes

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

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

Explanation:

•In AIX the filesystem is broken into blocks called as data blocks. These data blocks by default are 4 kb in size i.e. 4096 bytes in size.

•Lets imagine you have a file called file1 which is about 1900 bytes. To store this file in the filesystem, you will require a data block (4 kb). That means file1 occupies 1900 bytes of the data block and the rest of the space in the 4 kb data block is empty. But even though rest of the space is empty, this space cannot be utilized by the file system to allocate it any other file. So in these circumstances, potentially you could have more amount of unused or wasted space.

•Here is where we can get an intro to the concept of  “Fragmentation”.

•Fragmentation is a concept wherein a single data block can be broken logically into smaller fragments of size ranging from 512 bytes to 4 kb. Lets say I choose a fragment size of 1kb, that means the data block of 4 kb size is broken into 4 fragments.This would ensure that if there was a small file lets say about 1900 bytes, to store this particular file, I would potentially use up only 2 fragments of the data block and the other two fragments can be allocated to files if necessary. Thus reducing the amount of unused and wasted space in your filesystems.

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] filesystem

Options:
-q Reports the current state of the file system
-r 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
-s Gives short report regarding the current stateof the file system

Explanation:

•Although fragmenting decreases the amount of unused or wasted space, this can actually cause some performance related problems also.

•For example: Lets imagine that the fragment size is 4 kb. There is file of 4 kb size. So 1 data block (fragment) would be assigned to the file. If I want to read this file there would be 1 I/O operating that needs to be done to read the content of the file (disk I/O happens in terms of fragment size).

•Lets say I have the same 4 kb file, but the fragment size instead of 4 kb, I‟ve changed it to 1 kb. That means to allocate space to this particular file I may require 4 1kb blocks. That means if I want to read the same file now there would be 4 disk I/O operations that needs to happen. Which would be time consuming.

•Defragmentation of the filesystemincreases the file systems contigous free space by rearranging the fragments in such a way that files get more contigousspace for allocation.

•The command:
•# /usr/bin/defragfs (-q –r ) filesystem

•can be used to report the current status of the file system and also report what would be the state of the file system after defragmentation is done.

•The file system should be mounted when you run this command.


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

Complete explanation:

•File system check or fsckcan be used to verify a file system and check for its consistency. It basically checks the journal log to determine if any activity was pending, it checks the inodes, direct and indirect data block against the free lists.

•fsck command comes with lots of options:-
•-p-> stands for „preen‟. That means do not ask for any confirmation, do any minor changes required. Some people also call this option “silent” that is don‟t disturb me….
•-y-> The answer would be yes for all the questions asked during fsck
•-n-> The answer would be No for all the questions asked during fsck
•-f-> to specify the file system to conduct fsck.

•If no filesystemname is specified with the fsckcommand, all the file systems that have the option check=truespecified in the configuration file /etc/ filesystemswill be checked.


++++++++++++END++++++++++++++










No comments:

Post a Comment