You are on page 1of 30

File systems administration

Copyright IBM Corporation 2009


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

5.2

Unit objectives
IBM Power Systems

After completing this unit, you should be able to:


Identify the components of an AIX file system
Work with enhanced Journaled file systems
Add, list, change, and delete

Monitor file system disk space usage


Manage file system growth and control growing files
Implement basic file system integrity checks

Journaled file system support in AIX


IBM Power Systems

Two types supported:


Journaled File System (JFS)
Enhanced JFS, commonly referred to as JFS2

JFS is the original AIX file system.


JFS2 was introduced in AIX 5.1 and is now the default file
system (since AIX 5.3).
Journaling:
Before writing actual data, a journaling file system logs the metadata
to a circular JFS log on disk.
In the event of an OS crash, journaling restores consistency by
processing the information in the JFS log file.

There is no migration path from JFS to JFS2.


Conversion can only be achieved through backup and restore.

Advantages of enhanced JFS (JFS2)


IBM Power Systems

Increased performance
Increased flexibility

Filesystems can be dynamically increased and decreased.


Support for larger enabled filesystems
Internal or external JFS logging
Data encryption
Support for snapshots

JFS2 structural components


IBM Power Systems

Superblock

The superblock maintains information about the entire file


system.

i-nodes

Each file and directory has an i-node that contains access


information such as file type, access permissions, owner's ID,
and number of links to that file.

Data blocks

Contains file data


Each file system has a user settable fixed block size attribute
512, 1024, 2048, or 4096 bytes

Allocation maps

Record the location and allocation of all i-nodes and the


allocation state of each data block.

Allocation groups

Responsible for dividing the file system space into chunks so


related data blocks and i-nodes can be clustered together to
achieve good locality

Listing i-node and block size information


IBM Power Systems

To view i-node information:


## ls
ls -li
-li

total
total 33
12309
12309 -rw-r-----rw-r----12307
12307 -rwxr-----rwxr----12308
12308 -rw-------rw-------

11 adminusr
adminusr security
security
11 adminusr
adminusr security
security
11 adminusr
adminusr security
security

119
119 12
12 Feb
Feb 19:43
19:43 datafile1
datafile1
254
254 27
27 Jan
Jan 18:19
18:19 .profile
.profile
156
156 28
28 Jan
Jan 14:31
14:31 .sh_history
.sh_history

## istat
istat datafile1
datafile1

Inode
File
Inode 12309
12309 on
on device
device 10/8
10/8
File
Protection:
rw-r----Protection: rw-r----Owner:
Group:
Owner: 211(adminusr)
211(adminusr)
Group: 7(security)
7(security)
Link
count:
1
Length
119
Link count:
1
Length 119 bytes
bytes

inode
number

Last
Last updated:
updated: Thu
Thu 12
12 Feb
Feb 19:44:09
19:44:09 2009
2009
Last
modified:
Thu
12
Feb
19:43:42
Last modified: Thu 12 Feb 19:43:42 2009
2009
Last
Last accessed:
accessed: Thu
Thu 12
12 Feb
Feb 19:43:42
19:43:42 2009
2009

To view file system block size information:


## lsfs
lsfs cq
cq /data
/data

#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
/data:/dev/fslv00:jfs2:::204800:rw:no:no
/data:/dev/fslv00:jfs2:::204800:rw:no:no
(lv
(lv size
size 204800:fs
204800:fs size
size 204800:block
204800:block size
size 4096
4096

Blocksize.
(Some
output
removedfor
clarity.)

Creating a JFS2 file system (1 of 2)


IBM Power Systems

# smit crfs_j2
# crfs -v jfs2 -g datavg -a size=1G m /data
Add
Add an
an Enhanced
Enhanced Journaled
Journaled File
File System
System
Volume
Volume group
group name
name
SIZE
of
SIZE of file
file system
system
Unit
Unit Size
Size
**
Number
Number of
of units
units
** MOUNT
POINT
MOUNT POINT
Mount
Mount AUTOMATICALLY
AUTOMATICALLY at
at system
system restart?
restart?
PERMISSIONS
PERMISSIONS
Mount
Mount OPTIONS
OPTIONS
Block
Block Size
Size (bytes)
(bytes)
Logical
Logical Volume
Volume for
for Log
Log
Inline
Log
size
Inline Log size (MBytes)
(MBytes)
Extended
Extended Attribute
Attribute Format
Format
ENABLE
Quota
ENABLE Quota Management?
Management?
Enable
Enable EFS?
EFS?
Allow
Allow internal
internal snapshots?
snapshots?

[Entry
[Entry Fields]
Fields]
datavg
datavg
Gigabytes
Gigabytes
[1]
[1]
[/data]
[/data]
No
No
read/write
read/write
[]
[]
4096
4096
[]
[]
no
no
no
no
no
no

++
##
++
++
++
++
++
##
++
++
++
++

Creating a JFS2 file system (2 of 2)


IBM Power Systems

When the file system is created, the lsfs command will display
the characteristics of the file system.
## crfs
crfs -v
-v jfs2
jfs2 -g
-g datavg
datavg -a
-a size=1G
size=1G -m
-m /data
/data
File
system
created
successfully.
File system created successfully.
1048340
1048340 kilobytes
kilobytes total
total disk
disk space.
space.
New
File
System
size
is
2097152
New File System size is 2097152
## lsfs
lsfs /data
/data
Name
Name
/dev/fslv00
/dev/fslv00

Nodename
Nodename
---

## lsvg
lsvg -l
-l datavg
datavg
datavg:
datavg:
LV
TYPE
LV NAME
NAME
TYPE
POINT
POINT
loglv00
jfs2log
loglv00
jfs2log
fslv00
jfs2
fslv00
jfs2

Mount
Mount Pt
Pt
/data
/data

VFS
Options
VFS Size
Size
Options
jfs2
2097152
jfs2 2097152 ---

LPs
LPs

PPs
PPs

PVs
PVs LV
LV STATE
STATE

11
256
256

11
256
256

11
11

MOUNT
MOUNT

closed/syncd
closed/syncd N/A
N/A
closed/syncd
closed/syncd /data
/data

JFSlogautomatically
created,1LPinsize
(ifonedoesnotalready
exist)fortheVG.

Auto
Auto
no
no

Mounting a file system and the /etc/filesystems file


IBM Power Systems

When a file system is created, the device and mount point


information is stored in the /etc/filesystems file.
## grep
grep -p
-p /data
/data /etc/filesystems
/etc/filesystems
/data:
/data:
dev
== /dev/fslv00
dev
/dev/fslv00
vfs
== jfs2
vfs
jfs2
log
== /dev/loglv00
log
/dev/loglv00
mount
== false
mount
false
account
== false
account
false

## mount
mount /data
/data

Themountcommandreadsthe
stanzainthe
/etc/filesystemsfile,so
onlythemountpointis
required.

## mount
mount |egrep
|egrep '(/data|node)'
'(/data|node)'
node
mounted
mounted
node mounted
mounted over
over vfs
vfs
/dev/fslv00
/data
jfs2
/dev/fslv00 /data
jfs2

date
options
date
options
13
Feb
10:32
13 Feb 10:32 rw,log=/dev/loglv00
rw,log=/dev/loglv00

JFS2 logging options


IBM Power Systems

For JFS2 file systems, there are three logging options:


Use the global JFS log for the volume group.
Create a specific JFS log for each file system.
1 LP in size
Format the log using the logform command.
## mklv
mklv y
y my_jfs2_log
my_jfs2_log t
t jfs2log
jfs2log datavg
datavg 11
## logform
logform /dev/my_jfs2_log
/dev/my_jfs2_log
logform:
logform: destroy
destroy /dev/rmy_jfs2_log
/dev/rmy_jfs2_log (y)?y
(y)?y
## crfs
crfs -v
-v jfs2
jfs2 -g
-g datavg
datavg -a
-a size=1G
size=1G -m
-m /data
/data -a
-a logname=my_jfs2_log
logname=my_jfs2_log

Create an inline log inside the file system.


0.4% of the file system space will be reserved for this option.
## crfs
crfs -v
-v jfs2
jfs2 -g
-g datavg
datavg -a
-a size=1G
size=1G -m
-m /data
/data -a
-a logname=INLINE
logname=INLINE //
-a
logsize=<value
in
MB>
-a logsize=<value in MB>

Creating a file system on a previously defined logical


volume

IBM Power Systems

# smit crfs_j2
# crfs -v jfs2 d lv_for_data m /data2 A yes
Add
Add an
an Enhanced
Enhanced Journaled
Journaled File
File System
System
** LOGICAL
LOGICAL VOLUME
VOLUME name
name
** MOUNT
POINT
MOUNT POINT
Mount
Mount AUTOMATICALLY
AUTOMATICALLY at
at system
system restart?
restart?
PERMISSIONS
PERMISSIONS
Mount
Mount OPTIONS
OPTIONS
Block
Block Size
Size (bytes)
(bytes)
Logical
Logical Volume
Volume for
for Log
Log
Inline
Log
size
Inline Log size (MBytes)
(MBytes)
Extended
Extended Attribute
Attribute Format
Format
ENABLE
Quota
ENABLE Quota Management?
Management?
Enable
Enable EFS?
EFS?
Allow
Allow internal
internal snapshots?
snapshots?

[Entry
[Entry Fields]
Fields]
lv_for_data
lv_for_data
[/data2]
[/data2]
yes
yes
read/write
read/write
[]
[]
4096
4096
[]
[]
no
no
no
no
No
No

++
++
++
++
++
++
##
++
++
++
++

Changing the size of a JFS2 file system


IBM Power Systems

To increase the size of a file system:


## chfs
chfs -a
-a size=+1G
size=+1G /data2
/data2
Filesystem
Filesystem size
size changed
changed to
to 2179072
2179072

To shrink the size of a file system:


## chfs
chfs -a
-a size=-500M
size=-500M /data2
/data2
Filesystem
Filesystem size
size changed
changed to
to 1155072
1155072

Using SMIT: # smit chjfs2


Change
Change // Show
Show Characteristics
Characteristics of
of an
an Enhanced
Enhanced Journaled
Journaled File
File System
System
File
File system
system name
name
NEW
mount
NEW mount point
point
SIZE
SIZE of
of file
file system
system
Unit
Unit Size
Size
Number
Number of
of units
units
Note:
Note: Advanced
Advanced options
options removed.
removed.

[Entry
[Entry Fields]
Fields]
/data2
/data2
[/data2]
[/data2]
Gigabytes
Gigabytes
[10]
[10]

##

++

Removing a JFS2 file system


IBM Power Systems

The file system must first be unmounted.


Using SMIT: # smitty rmfs2
# rmfs /data2
Remove
Remove an
an Enhanced
Enhanced Journaled
Journaled File
File System
System
** FILE
FILE SYSTEM
SYSTEM name
name
Remove
Remove Mount
Mount Point
Point

[Entry
[Entry Fields]
Fields]
/data2
++
/data2
no
++
no

File system space management


IBM Power Systems

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
Block size considerations
Fragmentation considerations

Listing file system utilization


IBM Power Systems

The df command displays information about total space and


available space on a file system.
# df [-k] [-m] [-g]
## df
df -g
-g
Filesystem
GB
Filesystem
GB blocks
blocks
/dev/hd4
1.44
/dev/hd4
1.44
/dev/hd2
2.50
/dev/hd2
2.50
/dev/hd9var
0.31
/dev/hd9var
0.31
/dev/hd3
0.12
/dev/hd3
0.12
/proc
-/proc
/dev/hd10opt
0.25
/dev/hd10opt
0.25
/dev/fslv00
8.00
/dev/fslv00
8.00
/dev/fslv01
9.00
/dev/fslv01
9.00
/dev/lv00
0.12
/dev/lv00
0.12
/dev/hd11admin
0.12
/dev/hd11admin
0.12
/dev/hd1
0.62
/dev/hd1
0.62
grumpy:/nimback
25.00
grumpy:/nimback
25.00

Free
Free %Used
%Used
1.10
1.10 24%
24%
0.10
0.10 97%
97%
0.24
0.24 25%
25%
0.12
6%
0.12
6%
--0.03
0.03 88%
88%
1.40
1.40 83%
83%
2.33
2.33 75%
75%
0.12
4%
0.12
4%
0.12
4%
0.12
4%
0.16
0.16 75%
75%
3.26
3.26 87%
87%

Iused
Iused %Iused
%Iused Mounted
Mounted on
on
9896
2%
/
9896
2% /
49616
8%
49616
8% /usr
/usr
1308
2%
1308
2% /var
/var
128
1%
128
1% /tmp
/tmp
--- /proc
/proc
4567
7%
4567
7% /opt
/opt
6888
3%
6888
3% /export
/export
4059
1%
4059
1% /aix
/aix
20
1%
20
1% /audit
/audit
18
1%
18
1% /admin
/admin
270
1%
270
1% /home
/home
99
1%
1% /mnt
/mnt

Monitoring file system growth


IBM Power Systems

A simple script using the df command, which can be run at


regular intervals to warn against file systems becoming full
#!/bin/ksh
#!/bin/ksh
df
df || egrep
egrep -v
-v '(used|proc)'
'(used|proc)' || awk
awk '{print
'{print $4"
$4" "$7}'
"$7}' \\
|| sed
's:%::g'
|
while
read
LINE
sed 's:%::g' | while read LINE
do
do
PERC=`echo
PERC=`echo $LINE
$LINE || awk
awk '{print
'{print $1}'`
$1}'`
FILESYSTEM=`echo
$LINE
|
FILESYSTEM=`echo $LINE | awk
awk '{print
'{print $2}'`
$2}'`
if
if [[ $PERC
$PERC -gt
-gt 70
70 ]]
then
then
mail
mail -s
-s "Filesystem
"Filesystem check
check on
on box:
box: `hostname`"
`hostname`" \\
admin@ibm.com
<<
EOF
admin@ibm.com << EOF
$FILESYSTEM
$FILESYSTEM is
is $PERC%
$PERC% full,
full, please
please check
check
EOF
EOF
fi
fi
done
done

Listing disk usage


IBM Power Systems

The du command lists the number of blocks used by a file or a


directory.
/export
/export ## du
du -sg
-sg ..
6.59
.
6.59 .
/export
/export ## du
du gethmc.sh
gethmc.sh
88
FirstBoot.sh
FirstBoot.sh
/export
/export ## du
du sm
sm ** || sort
sort -rn
-rn
2131.16
2131.16 mksysbaix53
mksysbaix53
1846.36
1846.36 mksysbaix61
mksysbaix61
1373.11
1373.11 mksysbaix61.light
mksysbaix61.light
248.52
248.52 spot
spot
0.01
nim
0.01
nim
0.01
bosinst.data
0.01
bosinst.data
0.00
FirstBoot.sh
0.00
FirstBoot.sh
0.00
BUILD.sh
0.00
BUILD.sh

Control growing files


IBM Power Systems

/var/adm/wtmp
/etc/security/failedlogin
/var/adm/sulog
/var/spool/*/*
/var/tmp/*
$HOME/smit*
$HOME/websm*

The skulker command


IBM Power Systems

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, /var/spool, /var/tmp, /var/news directories
a.out, *.bak, core, ed.hup files

skulker is normally invoked daily by the cron command as


part of the crontab file of the root user.
Disabled by default

Modify the skulker shell script to suit local needs for the
removal of files.
Test carefully !!

Block size considerations


IBM Power Systems

Default block size for a JFS2 filesystem is 4K


Possible values are: 512, 1024, 2048, 4096 bytes

If a directory structure is to contain many small files, it is


beneficial to store them in a separate file system with a small
block size.
Otherwise, the file system may fill up and still contain lots of free
space.
4096 bytes
2000 bytes

4096 bytes
2000 bytes
1024

This free space cannot


be used by another file.

1024

1024

1024

These free blocks can


be used by other files.

Fragmentation considerations
IBM Power Systems

Over time, due to data relocation, extensions, reductions, and


deletions, contiguous free space can run out and data can
become fragmented.
File system

Used block

FileA

Free block

There are three options to deal with this situation.


Try to increases a file systems contiguous free space using the
defragfs command.
Backup, delete, recreate the file system and restore the data.
Create a new file system and migrate the data.

Verify and repair a file system


IBM Power Systems

fsck command
Checks file system consistency and interactively repairs the file
system
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.


## fsck
fsck /data
/data
The
The current
current volume
volume is:
is: /dev/fslv00
/dev/fslv00
Primary
superblock
is
Primary superblock is valid.
valid.
J2_LOGREDO:log
J2_LOGREDO:log redo
redo processing
processing for
for /dev/fslv00
/dev/fslv00
Primary
superblock
is
valid.
Primary superblock is valid.
***
*** Phase
Phase 11 -- Initial
Initial inode
inode scan
scan
***
Phase
2
Process
remaining
*** Phase 2 - Process remaining directories
directories
***
*** Phase
Phase 33 -- Process
Process remaining
remaining files
files
***
*** Phase
Phase 44 -- Check
Check and
and repair
repair inode
inode allocation
allocation map
map
***
Phase
5
Check
and
repair
block
allocation
*** Phase 5 - Check and repair block allocation map
map
File
File system
system is
is clean.
clean.

Documenting file system setup


IBM Power Systems

Run the lsfs command.


Save the contents of the /etc/filesystems file.
Run the df command to check space allocation.
Check all the mounted file systems by running the mount
command.

File System Records

System storage review


IBM Power Systems

LogicalVolume
volume
storage
Logical
Structure

hd2
hd4
hd6
hd8

/usr

/usr

hd3

Page Space
log

hd5

free

hd2

/(root)

hd1

hd2

hd9var

free

free

hd1

/home

/home

hd1

/home

/home

/tmp

hd61

free

hd1

/usr

lv00

Page Space

lv00

free

free

lv00

special DB

special DB

lv00

/blv

/var

special DB

special DB

hdisk0

hdisk1

hdisk2

hdisk3

rootvg

datavg

File Systems

/(root)
File System

File Systems

Directories

/bin

/dev

/etc

/lib

/usr

/tmp

/var

/home

Checkpoint (1 of 2)
IBM Power Systems

1.

What command will display the i-node information for


a file? ____________

2.

Does the size of the file system change when the size
of the logical volume it is on is increased? ________

3.

If you remove a file system, is the logical volume on


which it sits removed as well? ___________

4.

When a file system is created, what needs to be done


in order to make it available for use? _____________

5.

What size should an external JFS log be set to?


___________

Checkpoint solutions (1 of 2)
IBM Power Systems

1.

What command will display the i-node information for


a file? istat

2.

Does the size of the file system change when the size
of the logical volume it is on is increased? No

3.

If you remove a file system, is the logical volume on


which it sits removed as well? Yes

4.

When a file system is created, what needs to be done


in order to make it available for use? The file system
must be mounted using the mount command.

5.

What size should an external JFS log be set to?


1 LP

Checkpoint (2 of 2)
IBM Power Systems

6.

A file system is 2 GB. How would you do the following?


Add 1 GB _____________________________
Set the size to 5 GB ______________________

7.

What command can you use to determine if a file


system is full? __________

8.

What command can produce a report listing the size in


MB, of all the files and directories contained in a
specific location?

____________
9.

What command checks and interactively repairs


inconsistent file systems? ______________

Checkpoint solutions (2 of 2)
IBM Power Systems

6.

A file system is 2 GB. How would you do the following?

7.

What command can you use to determine if a file


system is full? df

8.

What command can produce a report listing the size in


MB, of all the files and directories contained in a
specific location?
du

9.

What command checks and interactively repairs


inconsistent file systems? fsck

Add 1 GB
chfs a size=+1G <file system>
Set the size to 5 GB
chfs a size=5G <file system>

Exercise 9
IBM Power Systems

File system
administration

Unit summary
IBM Power Systems

Having completed this unit, you should be able to:


Identify the components of an AIX file system
Work with enhanced Journaled file systems
Add, list, change, and delete

Monitor file system disk space usage


Manage file system growth and control growing files
Implement basic file system integrity checks

You might also like