Sei sulla pagina 1di 46

PHYSICAL VOLUME (PV) Represents a hard disk (hdisk0).

PHYSICAL PARTITION (PP) The smallest allocation unit in the LVM. All PPs within
a VG are the same size, usually 4 or 8 MB.
VOLUME GROUP (VG) A set of one or more PVs which form a single storage poo
l. You can define multiple VGs on each AIX system.
LOGICAL VOLUME (LV) One or more PPs. A file system resides on top of an LV.
Only one LV is mapped to a file system. A LV can't span across a VG. Up to 255 L
Vs in a VG
LOGICAL PARITITION (LP) One or more PPs. LP represents a mirrored copy of a PP.
Up to two copies of a PP can be mirrored resulting in a LP count of three (2 mir
rors plus original).
Volume Group Descriptor Area (VGDA) Information about all the LVs and PVs wi
thin a VG. The first 64K of a PV is reserved for this area - defined in <sys/boo
trecord.h>.
The VGDA consists of
BOOTRECORD: - first 512 bytes. Allows the Read Only System (ROS) to boot system
BAD BLK DIRECTORY - found in <sys/bddir.h>
LVM RECORD - found in <lvmrec.h>
Volume Group Status Area (VGSA) Information about which PPs that are stale and w
hich PVs are missing within a VG. The LVM and SCSI driver reserves somewhere bet
ween 7-10% of the available disk space for LVM maps, etc.
Physical Volume ID
(PVID) The PVID is an amalgamation of the machines serial number (from the syste
ms EPROMs) and the date that the PVID is being generated. This combination insur
es the extremely low chance of two disks being created with the same PVID. Final
ly, when a system is booted, the disk con?gurator goes and looks at the PVID sit
ting on each disk platter and then compares that to an entry in ODM. If the entr
y is found, then the disk is given the hdiskX name that is associated with the O
DM entry for the PVID.
Quorum Quorum is a sort of sanity check that LVM uses to resolve possible data co
n?iction and prevent data corruption. Quorum
is a method by which 51% or more quorum votes must be available to a volume grou
p before LVM actions can continue.
Quorum is issued to a disk in a volume group according to how the disk was creat
ed within the volume group. When a
volume group consists of one disk, there are two VGDAs on that disk. Thus, this s
ingle disk volume group has a quorum
vote of 2. When another disk is added to the volume group with an extendvg, then t
his new disk gets one VGDA, but the
original, ?rst disk still retains the two VGDAs. When the volume group has been e
xtended to three disks, the third disk
gets the spare VGDA sitting on the ?rst disk and then each disk has a quorum vot
e of 1. Every disk after the third disk is
automatically given one VGDA, and thus one vote.
Volume Group ID (VGID) Just as the PVID is a soft serial number for a disk, the
VGID is the soft serial number for the volume group. It is this serial
number, not the volume groups ascii name, which all low level LVM commands refere
nce. Additionally, it is the basis for
the LVIDs created on that VGID.
Logical Volume Control Block (LVCB) The logical volume control block (lvcb)
consists of the ?rst 512 bytes of a logical volume. This area holds important
information such as the creation date of the logical volume, information about m
irrored copies, and possible mount points
in a journaled ?lesystem.
Logical Volume ID (LVID) The LVID is the soft serial number used to repre
sent the logical volume to the LVM libraries and low level commands. The
LVID is created from the VGID of the volume group, a decimal point, and a number
which represents the order which the
logical volume was created on the volume group.
Directories and Files
Tools
diagnostic diag - used to hot swap the disk
cfgmgr - used mak sure the new disk is seen
# to add new disk from the scsi0 controller
cfgmgr -l scsi0
Create/Remove hard disk cfgmgr -l scsi0
mkdev -c disk -l <pv>
rmdev -dl <pv>
Physical Volumes
Display lspv
lspv <pv> (detailed)
lspv -l <pv> (list logical volumes)
lspv -p <pv> (physical partition usage)
PVID chdev -l <pv> -a pv=yes
chdev -l <pv> -a pv=clear
Note: PVID's are automatically added when the disk is placed into a vg
Adding chdev -l <pv> -a pv=yes (new)
chpv -v a <pv> (adds back the removed disk)
Removing chpv -v r <pv>
change physical attributes chpv -a y <pv> (changes allocatab
le state to YES)
chpv -a n <pv> (changes allocatable state to NO)
Moving migratepv <old pv> <new pv>
Volume Groups
Display lsvg
lsvg <vg> (detailed)
lsvg -l <vg> (list all logical volumes in goup)
lsvg -p <vg> (list all physical volumes in group)
lsvg -o (lists all varied on)
lsvg -M <vg> (lists assicated disks and state)
## Details volume group info for the hard disk
lqueryvg -Atp <pv>
lqueryvg -p <disk> -v (Determine the VG ID# on disk)
lqueryvg -p <disk> -L (Show all the LV ID#/names in the VG on di
sk)
lqueryvg -p <disk> -P (Show all the PV ID# that reside in the VG
on disk)
Varyon varyonvg <vg>
varyonvg -f <vg> (force)
varyonvg -s (maintenance mode can use VG commands but lv 's cannot be opened
for i/o access)
varyoffvg <vg>
Note: the varyon command activiates the volume goup which means it is available
for use
ODM related ## Determine if the ODM and VGDA are correct (in sync)
getlvodm -u <vg>
## tries to resync VGDA, LV control blocks and ODM
synclvodm <vg>
## If the message 0516-366 lsvg: Volume group <vg> is locked is ever seen
putlvodm -K `gtlvodm -v <vg>`
Creating mkvg -y <vg> -s <PP size> <pv>
mkvg -y datavg -s 4 hdisk1
Note: the PP size will be the size of the physical partition size you want 4MB,
8MB
Extending extendvg <vg> <pv>
reducing reducevg -d <vg> <pv>
## removes the PVID from the VGDA when a disk has vanished without using the red
ucevg command
reducevg <vg> <PVID>
Removing varyoffvg <vg>
exportvg <vg>
Note: the export command nukes everything regardingthe volume goup in the ODM an
d /etc/filesystems
Checking ## check to see if underlying disk has grown in size
chvg -g <vg>
Note: use this command if you are using SAN LUN's that have increased in size
change volume attributes ## auto vary on a volume at system start
chvg -a y
# Turns on/off quorum checking on a volume group
chvg -Q [y|n] <vg>
Renaming varyoffvg <old vg name>
lsvg -p <old vg name> (obtain disk names)
exportvg <old vg name>
import -y <new vg name> <pv>
varyonvg <new vg name>
mount -a
Importing importvg -y <vg> <pv>
importvg <pv> (will use rootvg as default vg)
Exporting varyoffvg <vg>
exportvg <vg>
Note: if the volume has an active paging space this must be turned off before
Logical Volumes
Display lslv <lv>
lslv -l <lv> (list all physical volumes in logical volume)
lslv -m <lv> (list ppartition mapping)
## Display lv control block information
getlvcb -AT <lv>
Creating mklv <vg> <# of PP's> <pv>
mklv -y <lv name> <vg> <# of PP's> <pv>
## Create a mirrored named logical volume
mklv -y <lv> -c <copies 2 or 3> <vg> <# of PP's> <pv>
## create a JFSlog logical Volume
mklv -y <lv name> -t jfslog <vg> <# of PP's> <pv>
Extending extendlv <lv> <additonal # of PP's>
extendlv <lv> <size of volume in B||M|G>
reducing/resizing see filesystem below
Removing rmlv <lv>
Moving migratepv -l <lv> <old pv> <new pv>
adding a mirror to a non-mirrored volume mklvcopy -s n <lv> <copies 2 or
3> <pv>
removing a mirror copy from a mirrored volume rmlvcopy <lv> <copies 1 or 2>
rmlvcopy <lv> <copies 1 or 2> <pv> (specified pv)
unmirrorvg <vg> <pv>
synchronize logical volume syncvg -p <pv>
syncvg -v <vg>
syncvg -l <lv>
mirror any unmirrored volumes mirrorvg <vg> <pv>
change volume attributes ## Enable the bad-block relocation policy
chlv -b [y|n] <lv>
renaming chlv -n <new lv name> <old lv name>
Miscellaneous ## Initialises an LV for use as an JFSlog
logform </dev/lv>
Filesystems
display lsfs
lsfs -q <fs> (detailed)
Note: use the '-q' to see if the logical volume size is bigger than the filesyst
em size
create ## create new filesystem, -A means to mount after restart
crfs -v jfs -d <lv> -m <mountpoint> -A yes
## Create logical volume, filesystem, mountpoint, add entry to /etc/filesystems
at the specified size
crfs -v jfs2 -g <vg> -m <mountpoint> -a size=<size in 512k blocks|M|G) -A yes
Note: there are two types of filesystems jfs and jfs2, jfs2 allows you to decrea
se the filesystem size , you cannot reduce a jfs filesystem
remove rmfs <fs>
Note: if all filesystems have been removed from a logical volume then the logica
l volume is removed as well.
resize chfs -a size=<new size> <fs>
chfs -a size=1G /var (specific size, can be used to increase and decrease
)
chfs -a size=+1G /var (increase by 1GB)
chfs -a size=-1GB /var (reduce by 1GB)
Note: this will automatically increase or decrease the underlying logical volume
as well
freeze/unfreeze chfs -a freeze=<time in seconds> <fs>
chfs -a freeze=off <fs>
split mirrored copy chfs -a splitcopy=<split copy mountpoint>-a copy=2 <fs>
chfs -a splitcopy=/backup -a copy=2 /testfs
change ## Change the mountpoint
chfs -m <new mountpoint> <fs>
## Do not mount after a restart
chfs -A no <fs>
## Mount read-only
chfs -p ro <fs>
mount mount
mount [<fs>|<lv>]
mount -a
mount all
defrag defragfs -q <fs> (report defrag status)
defragfs -r <fs> (runs in report only mode - no action)
defragfs <fs> (actually defrags the filesystem)
checking and repairing fsck [-y|-n] <fs> (check a filesystem)
fsck -p <fs> (restores primary superblock from backup copy i
f corrupt)
Miscellaneous
Complete VG, LV and FS with mirroring example ## Create the volume group
mkvg -s 256 -y datavg hdisk2
## Create the jfs2 log logical volume and initialize it this for the volume grou
p
mklv -t jfs2log -y dataloglv datavg 1
logform /dev/dataloglv
## Create the logical volume
mklv -t jfs2 -y data01lv datavg 8
## Create the filesystems that will use the logical volume
crfs -v jfs -d data01lv -m /data01 -A yes
## Add an additional hard disk to the volume group
extendvg datavg hdisk3
## Now mirror both the volume group log logical volume and the logical volume
mklvcopy dataloglv 2
mklvcopy data01lv 2
## Make sure everything is sync'ed both the log and the logical volume
syncvg -v datavg
## Make sure everything is OK
lsvg -l datavg
## a quick way to perform the above in two steps
mklv -c 2 -t jfs2 -y data02lv datavg 8
crfs -v jfs -d data02lv -m /data02 -A yes
## mount everything and check
mount -a
Replaced failed mirror drive ## break the mirror (two ways to do this)
rmlvcopy <lv name> 1 <broken disk>
unmirrorvg <lv> <broken pv >
## remove the disk from the vg
reducevg <vgname> <broken pv >
## remove the hdisk from ODM
rmdev -dl <broken pv>
## physically replace the disk
diag -> function select -> task selection -> hot plug task -> scsi and scsi raid
hot plug manager -> replace/remove a device attached to an scsi hot swap enclos
ure device -> select disk and follow instructions
## configure new disk an check the new number (hopefully the same)
cfgmgr -v
lsdev -Cc <pv>
## add back to volume group
extendvg <vg> <pv>
## create mirror (two ways to do this)
mklvcopy <lv> 2 <pv>
mirrorvg <lv>
## sync mirror
syncvg -l <lv>
## If this is the rootvg there are additonal steps to take
bosboot -ad /dev/<pv>
bootlist -m normal <pv> <pv>
bootlist -m normal -o
Accidently remove a mirrored disk or SAN LUN disappeared off the network
## This procedure places back a mirror disk that you have accidently pulled or t
hat a SAN LUN disappeared off the network
## and its states is classed as "missing"
## see that the disk is in a missing state (see PV state column), also see stale
volumes
lsvg -p <vg>
lsvg -M <vg>
## To make the disk active again we use the varyonvg command
varyonvg <vg>
## see that the disk is in a active state (see PV state column)
lsvg -p <vg>
## Now re-sync the volumes in that volume group
syncvg -v <vg>
## Make sure that no volumes are stale
lsvg -M <vg>
## Determine if the ODM and VGDA are correct (in sync)
getlvodm -u <vg>
System data managed by ODM includes:
Device configuration information
o Predefined: Devices that AIX has drivers for or knows about, but are not
currently installed or active.
o Defined: Logical devices or drivers which don't map directly to a physic
al device. This includes network configuration, LVM configuration, and installed
software information.
o Available: A physical hardware device which is installed, configured, an
d in use.
Display information for SMIT (menus, selectors, and dialogs)
Vital product data for installation and update procedures
Communications configuration information
System resource information
ODM on the filesystem
ODM spreads its files over the filesystem. These three directories are all used
for storing files related to ODM:
/usr/lib/objrepos
/usr/share/lib/objrepos
/etc/objrepos
You can see which one is the default by checking the ODMDIR variable on a system
:
# echo $ODMDIR
/etc/objrepos
If you list all the files in this directory you'll see quite a list:
/etc/objrepos>ls
ATM_PVC CuDvDr FRUB PDiagTask SRCextme
th errnotify
CDiagAtt CuPath FRUB_SRC PDiagTask.vc SRCnotif
y history
CDiagAtt.vc CuPath.vc FRUs PdAt SRCodmlo
ck history.vc
CDiagDev CuPathAt FRUs_src PdAt.vc SRCsubsv
r inventory
Config_Rules CuPathAt.vc MenuGoal PdAtXtd SRCsubsy
s inventory.vc
CuAt CuVPD PDiagAtt PdAtXtd.vc SWservAt
lpp
CuAt.vc CuWxt PDiagAtt.vc PdCn SWservAt
.vc lpp.vc
CuData DAVars PDiagDev PdDv TMInput
product
CuData.vc DSMOptions PDiagDev.vc PdDv.vc config_l
ock product.vc
CuDep DSMOptions.vc PDiagRes PdPathAt crypto_m
odule
CuDv DSMenu PDiagRes.vc PdPathAt.vc crypto_m
odule.vc
There are two main sets of files, explained here:
The Pd* Files
The first set of files that you'll need to understand are the Pd* files, which c
ontain the predefined system objects. The entries in these files are loaded from
the installation tape; under normal use, they should not be edited.
PdDv
The Predefined Device object class file contains an entry for every known device
on the system. It includes definitions for all of the configurable printers, ex
pansion cards, device drivers, logical volumes, volume groups, and many more.
PdAt
The Predefined Attribute object class file contains device-dependent information
not found in the PdDv file but relevant to device configuration. These attribut
es become the default values if they are not modified. Modified attributes are w
ritten to the CuAt. The uniquetype field actually consists of the first three en
tries in the PdDv: type, class, and subclass. These entries are used to link the
attributes to the specified device. This mechanism ensures a unique name for ea
ch device.
PdCn
The Predefined Connection object class file contains information about how devic
es physically connect to the system.
The Cu* Files
The second set of files to understand are the Cu* files, which contain the custo
mized system objects.
CuAt
The Customize Attribute files contain non-default values for the specified devic
e. The default values are kept in the PdAt file. Both files must be searched to
find all of a device's attributes. A defined ethernet adapter entry would look l
ike that in the PdAt file; otherwise the entry would not exist.
CuDep
The Customize Dependency object class file contains logical dependencies between
devices. The file does not contain customized dependencies between two physical
devices. If present, these would be in the CuDv file.
CuDv
The Customize Device object class file contains physical dependencies.
CuDvDr
The Customized Device Driver object class file is managed through special device
configuration library routines to guarantee atomic changes.
CuVPD
The Customized Vital Product Data object class contains customized data recorded
on the topology disk for use by IBM Customer Engineers.
ODM Commands
This warning is from the IBM Redbook:
Note: ODM commands should be used only when traditional methods of
system maintenance, such as SMIT, are ineffective. For a beginning
system administrator, it is recommended that you perform additional
reading and exercises before using these commands. Incorrect use of
these commands may result in a disabled system. The ODM commands
are described here for introductory purposes.
Command Explaination
odmadd Adds objects to an object class. The odmadd command takes an ASCII stanz
a file as input and populates object classes with objects found in the stanza fi
le.
odmchange Changes specific objects in a specified object class.
odmcreate Creates empty object classes. The odmcreate command takes an ASC
II file describing object classes as input and produces C language .h and .c fil
es to be used by the application accessing objects in those object classes.
odmdelete Removes objects from an object class.
odmdrop Removes an entire object class.
odmget Retrieves objects from object classes and puts the object information in
to odmadd command format.
odmshow Displays the description of an object class. The odmshow command
takes an object class name as input and puts the object class information into
odmcreate command format.
ODM Errors
The error we got I mentioned before:
sudo smitty chgsys
changing:
o Maximum number of PROCESSES allowed per user
When you try this you'll get the error:
chdev: 0514-518 Cannot access the CuDv object class in the device
configuration database.
This is because of the variable ODMDIR. When you want to change the device sys0
(which is what you're doing) you need access to the CuDv database. The system ca
n find the database by the variable ODMDIR. Although the user has this variable,
you perform smitty as being root without the variables. A workaround for this p
roblem is to change directory to the value of ODMDIR (in my case /etc/objrepos)
and run the command from there. Smitty will look in the current directory for th
e CuDv database and will find it there.
Physical Volumes (PVs)
Physical volumes are a wrapper of sorts that is placed around a disk drive to al
low it to be managed. A PV normally consists of 1 distinct physical disk. But in
the case of a RAID controller, a PV consists of an entire "logical" disk, as pr
esented to the system by the RAID controller.
Volume Groups (VGs)
A pool of storage, consisting of one or more physical volumes. A volume group ma
y span multiple physical disks. A volume group can be thought of as a logical di
sk. Storage is allocated to one or more logical volumes, which can grow or shrin
k in size.
Logical Volumes (LVs)
If VGs can be thought of as disks, Logical Volumes can be thought of as partitio
ns or slices on those disks. An LV is the object that filesystems, raw partition
s, and paging space is built upon. Logical volumes can be expanded or moved from
one PV to another on the fly while the LV is in use.
Logical volumes cannot be reduced in size. If a LV must be shrunken, you will ne
ed to back up the data, remove the LV, create a new smaller LV, and then restore
the data.
JFS
The Journaled File System has several advantages over the BSD and UFS filesystem
s used in other Unixes. One disadvantage of UFS and BSD file systems is the poss
ibility of file system corruption in the event of a system crash or power failur
e. This corruption can occur when files or directories are created or removed, b
ut the system crashes before the information can be written to disk. This can le
ad to unreferenced files, missing file blocks, or file blocks belonging to multi
ple files.
This problem is much reduced in JFS file systems through the use of a log volume
for file systems. While cached data can still be lost if the system crashes bef
ore it is synced to disk, file system changes such as inode and block allocation
and freeing are logged to disk right away. In the event of a system crash, this
log file is replayed prior to bringing a file system back on-line. This allows
the file system structure to be intact even after a crash. This log replay proce
ss is much much quicker than the traditional fsck process. In a UFS file system,
all block allocation must be verified, which takes multiple passes. Multi-gigab
yte file systems can take tens of minutes to fsck. File systems in the hundreds
of gigabytes can take hours to fsck if corrupted.
In contrast, JFS logs can be replayed in tens of seconds, even for large file sy
stems. This is because only small log has to be processed rather than entire dis
ks.
JFS file systems still may occasionally need to be fsck'd, but the is a much rar
er occurrence
Creation of Filesystem:
The crfs command creates a file system on a logical volume within a previously c
reated volume group.
A new logical volume is created for the file system unless the name of an existi
ng logical volume is specified using the -d. An entry for the file system is put
into the /etc/filesystems file.
Commands
##With an existing logical volume:

# crfs -v jfs2 -d <lv> -m <mountpoint> -A yes

-v vfs type (Specifies the virtual file system type)
-d Specifies the device name of a device or logical volume on which to make th
e file system.
-m Specifies the mount point, which is the directory where the file system wil
l be made available
-A Specifies whether the file system is mounted at each system restart:
yes:File system is automatically mounted at system restart.
no:File system is not mounted at system restart (default value).
Note: start of changeThe crfs command accesses the first letter for the auto mou
nt -A option.end of change
## Create logical volume, filesystem, mountpoint, add entry to /etc/filesystems
at the specified size
# crfs -v jfs2 -g <vg> -m <mountpoint> -a size=<size in 512k blocks|M|G) -A yes
Note: there are two types of filesystems jfs and jfs2, jfs2 allows you to decrea
se the filesystem size , you cannot reduce a jfs filesystem.
) mount/unmount Filesystems:
mount is the command used to mount filesystems
mount [<fs>|<lv>]
mount -a
mount all
To unmount filesystem use "umount"
umount <fs>
Note: You can't write into or read any content from filesystem when its in unmo
unted state
-f unmount filesystem forcibly
umount -f <fs>
for v7.1 onwards you can use name for "unmount" command as well.
umountall: Unmounts groups of dismountable devices or filesystems ( applicable t
o v7.1)
3) List Filesystems:
To list filesysem use "lsfs" or "mount"
lsfs Lists all filesystems in the /etc/filesystems entry
lsfs -a To list all filesystems (default)
lsfs -q <fs> (detailed)
lsfs -q List all filesystems with detailed info (shows size of FS and LV in it.
so we can check whether size of LV=size os FS)
lsfs -l Specify the output in list format
lsfs -c Specify the output in column format
lsfs -v jfs Lists all jfs filesystems
mount (to list all mounted filesystems)
mount <fs> ( to list the mounted filesysem)
Note: use the '-q' to see if the logical volume size is bigger than the filesyst
em size
4) Display Filesystem usage:
To display information about all mounted file systems, enter: df
Command Examples
1) If your system has the /, /usr, /site, and /usr/venus file systems mounted, t
he output from the df command resembles the following:
df
Filesystem 512-blocks Free %Used Iused %Iused Mounted on
/dev/hd0 19368 9976 48% 4714 5% /
/dev/hd1 24212 4808 80% 5031 19% /usr
/dev/hd2 9744 9352 4% 1900 4% /site
/dev/hd3 3868 3856 0% 986 0% /usr/venus
2) To display information about /test file system in 1024-byte blocks, enter:
df -k /test
Filesystem 1024 blocks Free %Used Iused %Iused Mounted on
/dev/lv11 16384 15824 4% 18 1% /tmp/ravi1
This displays the file system statistics in 1024-byte disk blocks.
3) To display information about /test file system in MB blocks, enter:
df -m /test
Filesystem MB blocks Free %Used Iused %Iused Mounted on
/dev/lv11 16.00 15.46 4% 18 1% /tmp/ravi1
This displays file system statistics in MB disk blocks rounded off to nearest 2n
d decimal digit.
4) To display information about the /test file system in GB blocks, enter:
df -g /test
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/lv11 0.02 0.02 0% 18 1% /tmp/ravi1
This displays file system statistics in GB disk blocks rounded off to nearest 2n
d decimal digit.
5) Resize Filesystems:
chfs -a size=<new size> <fs>
Command Examples
chfs -a size=1G /var (specific size, can be used to increase and decrease)
chfs -a size=+1G /var (increase by 1GB)
chfs -a size=-1GB /var (reduce by 1GB)
Note1:This will automatically increase or decrease the underlying logical volume
as well.
Note2:You can't reduce jfs filesystem
6) Modify/Change Filesystems:
Command Examples
## Change the mountpoint
chfs -m <new mountpoint>
chfs -m /test /new ==>Change the mount point from /test to /new
## Do not mount after a restart
chfs -A no <fs>
## Mount read-only
chfs -p ro <fs>
## Remvoe attribute of a filesystem
Remove account attribute of /test.(from /etc/filesystems file)
chfs -d account /test
chfs -a options='rw' /shadow ==> shows with lsfs rw (I think rw is the deafault
anyway)
7) Remove Filesystems:
Command Examples
rmfs <fs>
rmfs -r /test ==>Deletes FS /test its mount point and associated LV
Note1: You need to unmount the filesyem before removing.
Note2: if all filesystems have been removed from a logical volume then the logic
al volume is removed as well.
8) Freeze File System:
If you don't want your file system to perform any writes for a period of time, m
aybe due to an admin task like a split copy or a backup, you can freeze the file
system. After the admin tasks are completed, you can thaw the file system.
chfs -a freeze=<time in seconds> <fs>
chfs -a freeze=off <fs>
9) Split mirrored copy of filesystem:
chfs -a splitcopy=<split copy mountpoint> -a copy=2 <fs>
chfs -a splitcopy=/backup -a copy=2 /testfs
This will mount the 2nd copy of mirrored filesystem testfs to /backup in read-on
ly mode for backup purpose
10) defrag fielsystem:
The defragfs command can be used to improve or report the status of contiguous s
pace within a file system.
Command Examples
defragfs /test ==>To defragment the file system /test
defragfs -q /test ==>Display the current defrag status of the file system
For example, to defragment the file system /home, use the following command:
defragfs /home
Here is an example output:
# defragfs /home
Defragmenting device /dev/hd1. Please wait.
Total allocation groups : 32
Allocation groups skipped - entirely free : 26
Allocation groups defragmented : 6
defragfs completed successfully.
Total allocation groups : 32
Allocation groups skipped - entirely free : 26
Allocation groups that are candidates for defragmenting : 6
Average number of free runs in candidate allocation groups : 1
#
11) fuser & filesystem:
Command Examples
fuser /etc/passwd lists the process numbers of local processes using the /etc/pa
sswd file
fuser -cux /var shows which processes are using the given filesystem
fuser -cuxk /var it will kill the above processes
fuser -dV /tmp shows deleted files (inode) with process ids which were open by a
process (so its space could not be freed up)
(-V: verbose will show the size of the files as well)
if we rm a file, while it is opened by a process its space will not free up.
solution: kill the process, wait for the process to finish or reboot the system
12) Checking and Repairing:
Command Examples
fsck [-y|-n] <fs> (check a filesystem)
fsck -p lt;fs> (restores primary superblock from backup copy if corrupt)
fsck -y n /dev/lv00 ==>To check the filesystem associated to /dev/lv00 assuming
response "yes"
13) Miscellaneous Filesystem Commands:
Command Examples
skulker ==> cleans up file systems by removing unwanted or obsolete files
fileplace <filename> ==> displays the placement of file blocks within logical or
physical volumes, it will show if a file fragmented
File system resides on a logical volume. So the size of the file system would be
in multiples of logical partitions. Every logical partition would be pointing t
o a physical partition.
An individual file within a file system would be allocated data blocks which is
usually 4 KB in size. In traditional UNIX systems the data block size was 512 by
tes.
The first very important component of a file system is called the superblock. Th
e superblock contains information about the file system in terms of the name of
the file system, its size, number of inodes in the file system, etc.
The superblock information is very critical and will be utilized by the system w
henever the file system has to be mounted and accessed. If the superblock goes c
orrupt, then the file system will not be able to be mounted also. So a backup co
py of the superblock is always written in block 31.
Right after the superblock are the inodes. Inodescontains information of files l
ike file permissions, file type, size, owner, group, created/modified date and t
ime and they also contain the pointers to data block.
Data block contain data. Indirect data block maintain addresses to the actual da
ta block.
Explanation:
This is the structure of the inodes. Each file on your system is represented by
a single inode. The inode for a file contains information about the file in term
s of
>Inode number for the file
>Ownership
>Access Permissions
>Type of the file
>Creation, modification and access times
>Number of links to the file
>Size
>Addresses of data blocks on disk.
Use can use the command ls with the option i to look at the contents of the inode
for that file.
Explanation:
In AIX the filesystemis broken into blocks called as data blocks. These data blo
cks 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 th
is file in the filesystem, you will require a data block (4 kb). That means file
1 occupies 1900 bytes of the data block and the rest of the space in the 4 kb da
ta 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 circu
mstances, 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 i
nto 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 b
ytes, 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 nece
ssary. Thus reducing the amount of unused and wasted space in your filesystems.
Number of bytes per inode
For how many number of bytes should a inode be generated ?
for example: nbpi=4096 would create an inode for every 4096 bytes.
Explanation:
In a Journaled File System, when ever a file is created, its respective inode al
so has to be created. The inode maintains details about the file. In earlier ver
sions of JFs, the number of inodes created for a file system was fixed and it wa
s generated for every 4 KB of disk space of that file system. That means 1024 in
odes would be generated. If the data block size also remains at 4 KB, these many
inodes was actually enough to cater to the needs of the file system.
But since fragmentation came into picture, wherein instead of sticking to 4 KB d
ata block size, the data block was able to be fragmented in smaller sizes lets s
ay 1024 ie1KB, the need for more number of inodes also increased since there wou
ld be potentially more smaller files in the file system. Here is where the nbpi
value (number of bytes per inode) can be reduced/changed to suit the requirement
s. So now nbpi=1024 would mean, please create a inode for every 1024 bytes of th
e space allocated to this file system.
Explanation:
Allocation group size concept increases the efficiency of the file system. Alloc
ation group is nothing but a logical grouping of related datablocks and the inod
e into a single group to increase the speed at which the data can be accessed wi
thin a filesystem.
The following small table gives you the Allocation Group Size and its respective
nbpi values that are supported:
Allocation Group Size NBPI
8 MB 512,1024,2048,4096,8192,16384
16 MB 1024,2048,4096,8192,16384,32768
32 MB 2048,4096,8192,16384,32768,65536
64 MB 4096,8192,16384,32768,65536,131072
Explanation:
Compressed file system save disk space by allowing a logical block to be stored
on the disk in units or fragments smaller than the full block size of 4096 bytes
.
Data compression allows all logical blocks of any sized file to be stored as one
or more contiguous fragments. On an average, data compression saves disk space
by about a factor of 2. There is no support for compression with JFS2 file syste
m.
Recommendations: The root file system must not be compressed. Compression of the
/usr file system is not recommended.
Large File Enabled File Systems
File = 132 MB
(1024 * 4 KB blocks) + (1024 * 128 KB blocks) = 132 MB
4 MB + 128 MB = 132 MB
Explanation:
Before discussing the Large File Enabled File System, Lets take a normal scenari
o of a file of size 140 MB. The default block size for this file system is 4 KB.
That means, to store a file of 140 MB size in 4 KB blocks we would require 140
MB /4 KB = 35840 number of data blocks. That means to read this file the system
has to perform 35840 I/O operations.
With Large File Enabled File System, the first 4 MB of the file will be allocate
d in 4 KB blocks and the rest of it will be allocated in 128 KB blocks. That mea
ns for the same file which is 140 MB in size, first 4 MB will be allocated using
4 KB blocks (4MB / 4 KB = 1024 blocks) and rest of the file is 136 MB will be a
llocated in 128 KB block ( 136 MB / 128 KB=1088 blocks). Totally in a Large File
Enabled File System to allocate this file of 140 MB only 1024+1088 ie 2112 data
blocks will be required and this calculation itself is an indication how a Larg
e File Enabled File System can bring in performance. ( Only 2112 I/O operations
are required to read the file instead of 35840 blocks.
Explanation:
Jfslogs are kept in /dev/hd8. The journal logs are circular logs. The size of th
e journal log is 1 PP size. The jfslog is used to ensure file system integrity b
y writing all metadata information to the jfslog immediately.
In journal log, only inode and indirect data block information is stored and not
the actual data block.
There is also a new feature called inline log that is introduced with JFS2. This
inline log allows you to log directly to the file system.
Explanation:
JFS2 (Enhanced JournaledFile System)
Is a new file system introduced in AIX5.1. The base for JFS2 is JFS file system.
At present JFS2 is the only standard file system supported on Itanium based pla
tform.
Extent Based Allocation:
JFS2 uses extent based allocation. An extent is an address length pair, which id
entifies the starting block address and the length of the extent in blocks. This
allows multiple adjacent blocks to be addressed. The advantage of extend based
allocation are high performance and large file size.
In JFS2 the inodes are created dynamically i.e. on fly whereas in JFS there was
a fixed number of inodes that was getting created during the creation of the fil
e system. An inode in JFS2 file system is of size 512 bytes when compared to the
JFS inode size of 128 bytes.
Migration issues: JFS and JFS2 can co-exist on the same system. But to migrate a
JFS into JFS2, take the backup of data on the JFS file system, create a new JFS
2 file system, restore the JFS file system backup on the new JFS2 file system.
Physical Volumes are nothing but the hard disks. These physical volumes belong t
o a volume group.
Physical Partitions (PP) is the smallest allocatableunit on your physical volume
. These physical partitions should be the same size across the entire Volume Gro
up. However, since there can be multiple Volume Groups on a single system, each
volume group can have different PP size. The PP size can be in the range 1-1024
MB.
Default number of PPs per Physical Volume is 1016 but can be increased to suit y
our requirements.
Explanation:
The command lspv which stands for list all physical volumes in the system, inter
nally uses the undocumented command getlvodm C to list the physical volumes in th
e system.
The lspv command without any parameter can be used to list the physical volume n
ame, the PV identifier, and the Volume Group name that it belongs to.
The command lspv <pvname> gives the status information, number of PPs, PP size,
to which volume group it belongs to, free PPs and its distribution in terms of i
ntra policy etc.
Explanation:
The command lspv l hdisk0 lists all the logical volumes present on a physical vol
ume. The output of the command would give information about the LV name, number
of LPs, number of PPs, Its distribution and its mount point.
Listing physical Partition map for a Physical Volume
Explanation:
The command lspv p pvname lists all the logical volumes on a disk and they physic
al partitions to which its logical partitions are mapped.
The output of the command would display, the PP number, its STATE ie whether it
s free or used up, intra region where the PP is situated, LV name, type of the L
V and mount point.
Add/Move contents of a physical volume
Add a disk -> Can be done using SMIT or by cfgmgr when the system boots up.
To move the contents of a physical volume
# migratepv l lv00 hdisk0 hdisk1
Explanation in detail:
To add a physical volume to the system, you can use the Add a Disk option from t
he fixed disks menu under Devices main menu in SMIT.
Once the disk is added to the system, it has to be made part of a volume group s
o that you can start using the disk.
Another method of adding a disk to the system is, power off the system, add the
new disk physically to the system. Power On the system during which the program
called cfgmgr will be invoked to configure the newly added disk.
Once the new disk is added, if you want to migrate a existing logical volume fro
m old disk to the new one, you can use the command called migratepv.
The syntax for migratepv command is
# migratepv l lv00 hdisk0 hdisk1
I.e. l option to specify the logical volume name that you are planning to migrate
followed by the source hard disk name and the destination hard disk name.
Documenting the Disk Storage
List of the disks on the system (PVID and volume group):
# lspv
List the volume groups:
# lsvg
List what logical volumes are contained in each volume group:
# lsvg -l vgname
List the logical volumes on each disk:
# lspv -l pvname
Logical Track Group (LTG) Size
LTG is the maximum transfer size of a logical volume
Prior to AIX 5L V5.3:
Default LTG size is 128 KB
LTG size can be changed by the -Lflag on the chvgor mkvgcommand
In AIX 5L V5.3 and above:
AIX 5L V5.3 dynamically sets the LTG size (calculated at each volume group activa
tion)
LTG size can be changed with the command: varyonvg -M <LTGsize>
The mkvg -Lflag is no longer supported
The chvg -Lflag has no effect on volume groups created in AIX 5L V5.3
Enable variable LTG on old volume groups using chvg -L 0
To display the LTG size of a disk, use the command:
# /usr/sbin/lquerypv -M <hdisk#>
LTG (Logical Track Group) size is the maximum allowed transfer size for disk I/O
operations. In the earlier versions of AIX, the LTG size that was supported was
128 kb. Many hard disks now a days support larger sizes of transfer rate. So to
take the advantage of these larger transfer rate you can change the LTG size to
the size iesupported by the disks.
# /usr/sbin/lquerypv M hdisk0
256 . -> the LTG size of the hdisk0 is 256. So the LTG size of the volume group
can be changed to this
value.
You can set the LTG size while creating the volume group ie while using the mkvg
command or after the
creation of the volume group using chvg command .
In AIX version 5.1 and above, the following values for the logical track group s
ize is supported:
a.128 kb
b.256 kb
c.512 kb
1024 kb
HOT SPARE: Is a disk or group of disks used to replace a failing disk. LVM marks
a physical volume missing due to write failures and then it starts the migratio
n of data to the hot spare disk.
For incorporating Hot Spare in the LVM, logical volumes must be mirrored, All lo
gical partitions on hot spare disks must be unallocated and hot spare disks must
have at least equal capacity to the smallest disk already in the volume group.
Hot Spare Policy:
y(lower case) -> automatically migrates partitions from one disk to one spare. T
he smallest spare which is enough to substitute for the failing disk will be use
d.
Y (upper case) -> automatically migrates partitions from a failing disk, but mig
ht use the complete pool of hot spares.
n-> No automatic migration occurs. This is the default value.
r -> Removes all disks from the pool of hot spare disks.
Hot spare synchronizing policy
y -> automatically attempts to synchronize the stale partitions.
n -> Will not automatically attempt to synchronize. This is the default
E.g.: chpvhyhdisk1-> marks hdisk1 as a hot spare.
chvghysytestvg-> sets automatic migration policy and automatic synchroniz
ing policy.
Extending and Reducing Volume Groups
Note: Will not retain current disk contents
Activate/Deactivate a Volume Group
To activate a volume group:
# varyonvg oravg
To deactivate a volume group
# varyoffvg oravg
Explanation:
The command varyonvg can be used to activate a volume group that is not activate
d at system startup.
There is also an option with varyonvg i.e. f option. This option can be used to f
orce a volume group to get activated. This may be needed if you have lost the qu
orum, but still want to varyon the VG.
The command varyoffvg can be used to deactivate a volume group. No logical Volum
es should be open when you run this command.
NOTE: Its not possible to varyoffvg the rootvg.
Importing a Volume Group
If you have a volume group on a removable disk that you want to access on anothe
r system, you must export the volume group from the current system using the exp
ortvg command. This command removes the volume group related information from th
e system (i.e. from the ODM). To export a volume group it should be inactive.
To access the exported volume group on another system it has to imported into th
e other system by using the importvg command.
Explanation:
Mirroring is when a logical partition maps to more than one physical partition o
f the same volume group.
Ideally each copy must reside on a separate disk but this restriction can be rem
oved.
There are various mirroring scheduling policies:
a.Parallel policy: Read: On each read, the system checks whether the primary is
busy. If its not busy, the read is initiated on the primary, otherwise from seco
ndary.
Write: Initiated concurrently.
b. Parallel/Sequential: Read: Always reads on primary copy.
Write: Initiated concurrently.
c. Parallel/Round robin: Read: Alternates between copies, resulting in equal uti
lization.
Write: Initiated concurrently.
d. Sequential: Read: Always reads on primary copy.
Write: initiated serially, first to the primary and then
to secondary disk
MWC ( Mirror Write Consistency)
Explanation:
MWC (Mirror Write Consistency) ensures data consistency on logical volumes in ca
se of system crashes during the mirrored writes.
There are two methods of MWC :
a.Active Method: Consistency is achieved by logging when a write occurs. LVM mak
es an update to the MWC log that identifies what areas of the disk are being upd
ated before performing the write of the data. This actually results in a perform
ance degradation during random writes.
b.Passive Method: Introduced with AIX version 5.1. Passive method reduces the pr
oblem of having to update the MWC log on the disk. This method logs that the log
ical volume has been opened but does not log writes. If the system crashes, then
the LVM starts a forced synchronization of the entire logical volume when the s
ystem restarts.
You can set MWCfor a logical volume by using the option wwith either the mklvcomm
and or with the chlv command. The various options to set for the MWC option(-w)
are:
a.y or a (Yes or Active) Each write is logged to MWC log. Default value setting.
b.P ( Passive)Use the passive method.
c.n (No)There is no MWC, if there is a crash, then the mirrored LVs are in incons
istent state.
Striping
Normal flow of data blocks when a logical volume is spread across physical volume
s:
The layout of stripe units when a logical volume is set up to stripe:

Consecutive stripe units are created on different physical volumes
Striping increases read/write sequential throughput by evenly distributing stripe
units among disks
Stripe unit size is specified at creation time
Striped Columns

Explanation:
Striping is a technique for spreading the data in a logical volume across severa
l hard disks such that I/O capacity of all disk drives can be simultaneously use
d.
In a non striped logical volume, data is accessed using the addresses to the dat
a blocks within the physical partitions.
In a striped logical volume, the data is accessed using the addresses of the str
ipe units (data of a striped logical volume is broken into units called stripe u
nits). The size of the stripe unit is usually specified during the creation time
and it could range form 4 kb to 128 kb.
To implement striping at your size, at least two physical volumes are required.
Recommendation is that the number of physical partitions allocated to a striped
logical volume must be able to be evenly distributed among the disks.
Intra-physical volume allocation policy:

Inter-physical volume allocation policy:
Maximum number of physical volumes to use
Range of physical volumes to use
Explanation:
Intra physical volume allocation policy specifies where on the physical volume t
he partitions will be allocated to the logical volume. The choices could be inne
r edge, inner middle, centre, outer middle and outer edge areas. Usually the cen
tre area generally was the area with the best performance on older disks but may
not be true with the newer disks. You may have to go through the documentation
for the hard disks to come to a conclusion.
Inter physical volume allocation policy specifies how many physical volumes can
be used to contain the physical partitions of the logical volume. It also specif
ies the range of volumes used i.e. minimum ( allocate partitions on one physical
volume or as many as there are (maximum).
Objectives for the module
1. Under the Logical Volume Manager and related Concepts like
Volume Groups
Physical Volume
Logical Volume
Physical Partitions
Logical Partitions
2. Understand File systems and Logical Volumes
Logical Volume Manager Components
Volume group (VG)
Physical volume (PV)
Physical partition (PP)
Logical volume (LV)
Logical partition (LP)
PHYSICAL STORAGE
Volume Groups

Volume Groups (VG): Is a collection of related hard disks. By default when AIX i
s installed, you will have one volume group created on your system called rootvg
.The VG where data is stored is called as datavg
A hard disk can belong to only one volume group at any given point of time. If r
equired, later you can create volume groups if necessary or you can also add the
new hard disk to the existing volume group i.e. rootvg. But suggested is to iso
late the rootvg as far as possible. There can be up to 255 VGs per system.
Physical Volumes (PV): Are nothing but hard disks. Any hard disk at any given po
int of time can belong to only one volume group. Every hard disk would be given
a unique name i.e. the logical device name and the entry for the same would be m
ade in the /dev directory.
Physical Partitions (PP): A physical partition is the basic unit of disk space a
llocation in AIX. By default the PP size is 4MB and by default there can be maxi
mum 1016 PPs in a physical volume.
Since now a days most of the hard disks are size wise larger than 4 GB, the calc
ulation of 4 MB pp size and max 1016 PPs per PV may not serve the purpose. Here
is where we can think about changing the default PP size from 4 MB to a higher s
ize. PP sizes can range from 1 to 1024 MB. There is also another mechanism to so
lve this problem. Instead of sticking to the default number of PP per PV as 1016
, even this value can be changed to 2032, 4064 and so forth.
PP size in a volume group should be of the same size and the PP size cannot be c
hanged dynamically.
Physical Storage Volume(VOLUME GROUPS)

There are three types of volume groups that you can create in AIX 5.3 or 6.1.
A Normal Volume Group, a Big Volume Group and scalable Volume Group.
1. Normal Volume Group: By default whenever you use SMIT or mkvg command, you cr
eate a normal volume group.
2. Big Volume Group: This volume group was introduced in AIX ver4.3.2. A big vol
ume group should be created using mkvg B command.
3. Scalable VG: In 5.3 and above versions of AIX IBM has added one new VG known
as Scalable volume group.
Whenever you create a volume group either using smitor high level command by def
ault the max number of PPs on a PV is fixed at 1016. If you want to change this
value ie increase it, lets say to 2032 then you may have to use the option calle
d t (called t factor) to change it. You can supply the t factor as 2 that means m
ultiply the default value ie 1016 with 2 there by increasing the max number of P
P per PV to 2032. But please remember that if you increase the max number of PP
per PV then the maximum number of PV per VG decreases.
Example: # mkvgt 2
Would means to multiply default value 1016 by 2 so that the new maximum number o
f PP per PV is 2032 and not 1016.
Volume Groups differences chart:

How volume group look like: in terms of rootvg and datavg-

Why create new volume groups?
Separate user data from operating system files
Disaster recovery
Data portability
Data integrity and security
Note: For Scalable VG you can have upto 1024 PVs and there is no limit for PPs p
er PV in this Volume group. There can be now 4096 LVs in Scalable VG. To create
a Scalable VG use option S with mkvg command i.e
#mkvg-S Hdisk#
Volume Group Descriptor Area VGDA

Volume Group Descriptor Area (VGDA): The VGDA is an area of the disk which maint
ains information about the entire VG. It contains information about number of lo
gical volumes, list of physical volumes in the VG etc. There will be at least 1
VGDA on each physical volume and some physical volumes may also have more than 1
VGDA.
Quorum: Quorum is equal to 51% or more of the VGDAs available. A quorum of VGDA
is needed to activate the volume group and make it available for use and to ensu
re data integrity.
Quorum is required whenever you need to varyonthe VG (activate) the VG. If the q
uorum is not available, the system administrator can force a volume group to act
ivate without the quorum but is not recommended.
Uses of Logical Volumes
A logical volume may contain one of the following, and only one at a time:
Journaled (JFS) or enhanced journaled file system (JFS2)
Journal log (/dev/hd8)
Paging space (/dev/hd6)
Boot logical volume (/dev/hd5)
Dump device
Nothing (raw logical volume)
Examples of JFS/JFS2 logical volumes:
/dev/hd1/home
/dev/hd2/usr
/dev/hd3/tmp
/dev/hd4/
/dev/hd9var/var
/dev/hd10opt/opt
/dev/lv00/myfilesystem)
What is JFS/JFS2 above? Read further for what is JFS.
The logical volume can contain one of the following on them:
a.File system: Logical volumes can be used to maintain data on them. That means
before storing data on them you need to apply a file system over it which helps
you to arrange and manage your files and directories. You can choose either jour
naled file system (JFS) or Enhanced Journaled File System (JFS2) as your file sy
stem. The native files system in AIX is JFS. These file systems use database jou
rnaling techniques to maintain consistency of data.
b.Paging Space: The logical volume can also be used as secondary ram area or pag
ing space which is used by the Virtual memory manager service on your system to
store inactive memory pages of your processes. The default paging space logical
volume in AIX is /dev/hd6.
c.Journal Log: The logical volume can also be used to store the journal logs of
the other files systems. The default logical volume where the journal logs are m
aintained is in the logical volume /dev/hd8.
d.Raw: Raw device is nothing but an empty logical volume. Certain applications l
ike database related packages may require these raw logical volumes.
File System Structure in AIX:

A bit of explanation needs to be done here.. it goes like this.. read on:
a. /hd4 : / (root)- It is the top level in the hierarchical structure of the fil
e tree. It contains all files and directories that are critically required for s
ystem operations. It also contains files, directories and programs that are requ
ired for boot process.
b. hd2 : /usr Operating system commands, libraries and application programs. The
contents of this file system can be shared across the network.
c.hd9var: /varVariable spool and log files. The files in this file system ievarva
ry considerably depending on the system activity.
d./hd1: /homeAll users home directories which contain the user data and files are
stored here.
e.hd3: /tmpGlobal notepad for the system. Its a file system or space accessible fo
r all users for temporary files and work space. Should be cleared and cleaned on
a regular basis.
f./proc: /procSpecial file system to support threads, or light weight processes.
This file system doesnt contain any user files.
/etc/filesystems:

To go to this screen use the command #cd /etc/filesystems
The file /etc/filesystemsmaintains details of the all the filesystemson your AIX
machine. This file is made up of stanza, wherein each stanza maintains details
about a single file system.
The various attributes in these stanzas could be:
a.check: Used by the fsckcommand to determine the default file systems to be che
cked. This option can have values TRUE or FALSE.
b.dev:identifies the logical device name of the logical volume on which the file
system resides.
c.Mount: used by the mount command to determine whether a file system should be
mounted by default or not. Valid values could be TRUE, FALSE or automatic ( file
systems should be mounted during system startup).
d.type: used to group together related file systems for easy handling.
e.vfs:specifies the type of mount. i.e. virtual file system to mount.
f.vol: specifies a label for a file system.
g.log: device to which log data is to be written.
Mount:
Mount: connects file systems to the directory hierarchy.
File systems are associated with logical volumes.
When you mount a file system, the logical volume and the contents of it is conne
cted to a directory in the tree structure
mount /dev/mylv /home/user9.
Explanation:
A file system has to be mounted, i.e. connected to a directory structure if you
want to use it. The command called mount can be used to do it. You can also unmo
unt the file system by using the umount command or even using SMIT.
If you want a particular file system to be mounted during system startup, you ca
n do it by modifying the /etc/filesystems by using the options mount=automatic o
rmount=true.
Mounting Over an Empty Directory

Mounting Over Files

Listing File systems

You can use the command lsfs to get a list of all the file systems.
The output in the above visual shows details about the file system. The various
attributes of the output are:
a.Name of the file system
b.Node Name, which is only valid if the file system is a Network file system.
c.Mount Point for the file system.
d.Virtual File System (jfs, jfs2 or cdrfs)
e.Size of the file system
f.Mount options if any, like ro(read only) or rw(read-write)
g.Auto, automatic mounting during system startup or not.
You can also use the fastpath #smit fs to get the same details.
Listing Logical Volumes

You can use the command lsvgl <VG name> to get a list of all the logical volumes
in a particular volume group.
The output would show you details of the logical volumes, volume group wise.
The output would show you:
a.Logical volume name.
b.Type of the logical volume i.e. regular file system (jfs,jfs2) or journal log
or paging space , boot etc
c.Number of Logical partitions in the logical volume
d.Number of Physical Partitions in the logical volume.
e.How many physical volumes has the logical volume spread to.
f.State of the logical volume i.e. open/closed/synchronized.
g.Mount point.
Understanding Devices

Logical devices: These are also called special files. The users and applications
use the logical devices which are the links to the physical devices.
Physical devices: Actual device connected to the system.
Device Drivers: Device drivers are software that resides in the kernel that cont
rols the activities and the data that is sent to the devices.
/dev directory: The directory which contains all of the logical devices that can
be directly accessed by the user.
Ports: The physical connectors/adapters in the system which allow
attachment of many different devices are called ports. Ports
are not only a connection point but they are also programmable by the system sof
tware.
/dev directory contents

You can get the above output when you execute the command
# lsl /dev
In the output above, you can see that there are basically two types of devices,
a.Block devices (b)
Block devices use buffering to provide a block by block access to the device and
its data.
b. Character devices (c )
Character devices are also called raw devices and are stream-oriented i.e. seque
ntial access which provides no buffering.
Usually in the fifth field where we see the size of the file, for a logical devi
ce we see a pair of values (for eg19,2). The first value is called the major num
ber and the second value is called the minor number. Major number usually specif
ies the type of the device that we are working with and the appropriate device d
river in the kernel that has to be used to work with the device and the minor nu
mber refers to the behavior of the device i.e. particular device of that particu
lar major type.
Predefined and Customized Devices

The predefined and Customized devices are the two databases that are maintained
by the AIX system in the Object Data Manager (ODM).
The predefined devices database has information about all the supported devices
on your AIX system. The customized devices database has information about all co
nfigured devices on your system.
The two states in which the devices could be in the customized devices databases
are,Defined and Available.
If you want to use a particular device, it has to be in the available state.
Listing All predefined and Customized Devices
The list of commands to list the predefined and customized devices are here..
lsdev P H-> displays all predefined devices (supported devices)
lsdev Pc disk-> displays all predefined devices of class type disk
lsdev C H-> displays all customized devices (configured devices)
lsattr EH l sys0-> display all effective attributes of the logical device sys0
Devices are classified by class, type and subclass where the Class indicates what
the device does, Type indicates what model it is, and subclass indicates how it can
be attached to the system.
The command lsdev can be used to list the devices.
There are various options available with this command, like:
a. P -> show the devices from the predefined devices database. (show the supporte
d devices)
b. -H -> Show a heading along with the output
c. -C -> Show the devices from the customized devices database (show the configu
red devices)
d. -c -> class of the device like disk, tape.
lsattr command can be used to list the attributes for a particular device. This
command comes with lots of options like :-
-E -> show only the Effective attributes.
-l -> To specify the logical device name.
Device States

The states of the devices are as follows:
Undefined: The device is a supported device on the AIX system. Its present in th
e predefined devices database.
Defined: The device is present in the customized/configured devices database and
the logical device files have been created but at present is un-available for u
se.
Available: The device information resides in the customized devices database and
the device if fully configured and is ready for use.
When the device is for the first time configured by the cfgmgr command, its put
into the available state. When you run the command rmdevl over a available device
it slips into Defined stage. When you run the command rmdevdl over a defined or
an available device, it slips into undefined state. Though there is no recogniza
ble state called Undefined, it means that the device is just a supported device on
your system and is still not configured to work.
How cfgmgr works

Cfgmgr(Configuration Manager) command configures all self-configuring devices. W
hile configuring the devices, cfgmgr checks whether the device is a supported de
vice on your AIX system by checking the Predefined database ie PdDv. Once it kno
ws that the information of the device is found in the pre-defined devices databa
se, it uses the information to complete entries into the customized devices data
base is CuDv. It also loads the appropriate device driver into the AIX kernel an
d makes the logical device entries under the /dev directory.
Most of the devices are self-configurable except for devices which are connected
via parallel or serial ports like printers, ASCII terminals, modems etc.
Working with Devices
You can use the fastpath #smit devices to manage the configuration information a
bout the devices.

Here you have all the options to configure the devices like Terminals, printers
and plotters, console, hard disks, CDROMs etc.
Device Addressing
The location code for a device is information about where exactly is that devices
connection in your machine.
Its a path from the adapter, through the bus and to the device
Location code is made up of 4 fields of information
As a system administrator some times it becomes necessary to have a good underst
anding of where exactly is a particular device connected to the system. This may
be necessary during some troubleshooting scenarios.
The location code would be referred to on the LED whenever there is a hardware f
ailure, making it easy for the administrator to figure out which device has actu
ally failed.
The location code as mentioned above consists of up to 4 fields of information.
Certain devices when listed could only show two pairs, that means this device is
just an adapter. If a devices location code is made up of four pairs of values t
hen its a physical device attached to an adapter.
Location code for a non scsi device
AB-CD-EF-GH
AB 00 -> devices attached to the processor
01 -> devices attached to the ISA bus
04 -> devices attached to the PCI bus
CD 01-99 -> pluggable cards
A-Z,0 -> integrated adapter cards
EF --> Connector ID
GH -> Port identifier, FRU for the device
ISA Industry Standard Architecture. These are the bus types. These bus types are
used in the RS/6000 to connect devices like the diskette and the keyboard.
PCI Peripheral Component Interconnect. These are the industry standard buses whic
h are used by RS/6000 to connect other devices.
Integrated adapter cards have electronics for that particular card/adapter built
it and integrated in the system planar thus making it impossible to shift to a
much better card if need arises. Whereas the advantage of a plug in card is that
they are easily removable if there is a newer card available with newer feature
s because the electronics of that card is inbuilt in the card itself.
Example: Non-scsi location code:

The picture is an example of a location code for a non-scsi device. The AIX Syst
em has a 128 port Async adapter card with 2 ports on it. To those ports are conn
ected RANs(Remote Async Nodes) which looks like a hub with 16 ports on it. The A
SCII terminals are connected to these ports of the RAN.
In the example we have an ASCII terminal connected to one of the ports of the RA
N ie port number 11 on the 1stRAN connected to the second port of the 128 port A
sync adapter card. The adapter is a plug in adapter card connected to a PCI bus
(04) and in the slot 5 (05). So the entire location code for the device would be
04 -05-21-11
i.e. on the PCI bus(04) , in the slot number 5 (05), on the port number 2 (2) an
d RAN number 1 (1) and port number 11 (11) the ASCII terminal is connected.
Location Code Format for SCSI Devices
AB-CD-EF-G,H
AB-CD - Identifies the bus and the adapter location Same as with non-SCSI device
s
EF - For a single SCSI bus - 00
For a dual SCSI bus:
Internal bus - 00
External bus - 01
G,H G= SCSI address (SCSI ID) of the device
H= Logical unit number of the device
Example: scsi Location code

The above picture is an example of location code for a scsi device. There is a s
csi adapter card plugged into your system on the PCI bus slot number 01. The scs
i adapter itself has the scsi id 7 assigned to it. To this scsi adapter, there i
s an external scsi tape drive attached. The external scsi tape drive is assigned
5 as the scsi id (either by using a jumper setting or by using a dip switch). S
o the location code for the external tape drive would be 04-01-00-5,0. That is o
n the scsi adapter whose address is 04-01, there is a scsi device attached to th
e single scsi bus (00) whose scsi id is 5 and no Logical Unit Number (LUN) (0).
Example 2: Location Code Example for SCSI Device
SCSI Devices (Disk, Tape, CD-ROM)

Listing Device Physical Locations
CuDv Customized Devices
# lsdev -C -H -F "name status physloc location description"

How to add a ASCII terminal

Most of the devices are self-configurable device which can be directly configure
d by the cfgmgr. Devices which get attached to the parallel port or the serial p
ort like the printer, ASCII terminals, modems etc are not self configurable devi
ces, so they have to configured separately.
The picture above shows an example of how to configure/add a ASCII terminal to y
our AIX system.
You can use the fastpath# smit tty to add /configure a ASCII terminal on your sy
stem.
Choose the option Add a tty
-> you may have to select the terminal type is rs232 or rs422. rs232 is the most
common tty type
-> now you may have to select the parent adapter name ie where exactly is the te
rminal attached ie serial port 1 (sa0) or serial port 2 (sa1) etc.
Adding a terminal

In this final dialog panel to add a terminal, the only mandatory field for you t
o enter is the port number. Enter the port number and you can add the ASCII term
inal on your system.
Documenting Hardware Configuration
lsdev -CH
Provides name, status, location, and description of devices
lscfg -v
Provides details of all devices including manufacturer, type and model number and
part numbers
lsattr -El sys0
Provides attributes for the name device (for example, sys0)
Run command for all devices
getconf -a
Provides the values of all system configuration variables
AIX Basics- Prerequisite
AIX short for Advanced Interactive eXecutive was first entered into the market b
y IBM in February 1990. AIX is an implementation of Unix derived from both AT&T
Unix System V and 4.3 BSD. AIX offers the Korn (ksh) shell, Bourne (sh) and C (c
sh) shells however defaults to the Korn shell. AIX primarily designed for medium
to large scale servers and mainframes. However, it can also be used in workstat
ions. It supports standard peripherals like Supports standard peripherals: PCI S
lots, SCSI, PS/2 keyboard and mouse, Ethernet.
Levels Of AIX
The AIX system is functionally organized at three levels:
- The kernel, which schedules tasks and manages storage;
- The shell, which connects and interprets users' commands, calls programs from
memory, and executes them; and
- The tools and applications that offer additional functionality to the operatin
g system.
The Kernel
The heart of the operating system, the kernel controls the hardware and turns pa
rt of the system on and off at the programmers command. If you ask the computer t
o list (ls) all the files in a directory, the kernel tells the computer to read
all the files in that directory from the disk and display them on your screen. T
he kernel itself does not interact directly with the user, but rather interacts
with the shell and other programs as well as with the hardware devices on the sy
stem, including the processor (also called the central processing unit or CPU),
memory and disk drives. The kernel is the first part of the operating system to
load into memory during booting (i.e., system startup), and it remains there for
the entire duration of the computer session because its services are required c
ontinuously. Thus it is important for it to be as small as possible while still
providing all the essential services needed by the other parts of the operating
system and by the various application programs.
When a computer crashes, it actually means the kernel has crashed. If only a sin
gle program has crashed but the rest of the system remains in operation, then th
e kernel itself has not crashed. The kernel provides basic services for all othe
r parts of the operating system, typically including memory management, process
management, file management and I/O (input/output) management (i.e., accessing t
he peripheral devices). These services are requested by other parts of the opera
ting system or by application programs through a specified set of program interf
aces referred to as system calls.
Logical Volume Manager (LVM)
LVM is a disk management mechanism that is significantly different from traditio
nal UNIX partitioning schemes. The LVM maps data between logical and physical st
orage, allowing data to be discontiguous, span multiple disks, flexible and dyna
mically expanded. One advantage is the ability to allocate additional space to a
file system without the need to rebuild the disk. The LVM controls physical dis
k resources by providing a simplified logical view of the available storage spac
e.
Volume Group, Filesystems and Logical Volumes
The logical storage structure that is the most common is called the volume group
(VG). In AIX, storage allocation is performed at the volume group level. Data c
annot span volume groups. When the AIX operating system is first installed, a vo
lume group called rootvg is created. The rootvg contains the base operating syst
em files for AIX.
Each individual disk drive is logically represented by a physical volume (PV). E
ach physical volume consists of a number of partitions called physical partition
s (PP). The physical partitions are grouped into something called a logical volu
me that contains logical partitions. The logical volume, in turn, belongs to a v
olume group. Logical volumes contain the file systems (like the Journaling File
System or JFS).
All of the logical volumes use JFS to store data. This file system uses database
journaling techniques to maintain its structural consistency. This prevents dam
age to the file system when the system is halted abnormally. Other file systems
that you might encounter on AIX may include JFS2, NFS (Network File System), and
AFS (Andrew File System). The term file system is also used to describe the hie
rarchical structure (file tree) of files and directories.
The Shell
The shell is a command interpreter that allows an end user to type in commands t
o communicate to the AIX system. By default, when a user logins, a shell process
is started. The default AIX shell is /usr/bin/ksh, which is the Korn Shell, unl
ess and until specified while creating a user. Other available shells are:
- /bin/bsh the Bourne shell
- /bin/csh the C-shell
- /bin/sh the Standard shell
Using the System
Logging in and out
After bootup, the RS/6000 displays a login prompt on what looks like a character
-based terminal, where you can enter your username and password to get into the
system. Logging in to the RS/6000 follows the typical UNIX login process: The ge
tty process provides the login screen. If a user enters an id at this getty logi
n prompt, getty starts the login process to validate the user. AIX's login progr
am checks not only /etc/passwd, which contains user names, but also a shadow pas
sword file, /etc/security/passwd, which contains the encrypted passwords of each
of the users. login then starts a login shell as defined in /etc/passwd for the
user, which by default is the KornShell (ksh). ksh then reads the user's .profi
le.
If you are in an X Window session, stopping it by choosing End Session on the Ro
ot Menu will usually log you out. However, if your system displays an ASCII scre
en with a command line prompt (usually a "$" prompt) after you stop X, then you
have to take the additional step of closing the shell by typing either the exit
command or the logout commands.
The date, cal, who and finger commands
The date command displays or set the date or time for a particular system. If the
command is run without any flag, it displays the current date and time to standa
rd output.
The cal command displays a calendar of the specified year or month.
The who command displays information about all users currently on the local system
. The information displayed when running the command is login name, tty, date an
d time of login. Typing who am i or who am I displays your login name, tty, date
and time you logged in. If the user is logged in from a remote machine, then th
e host name of that machine is displayed as well.
The finger command displays information about the users currently logged in to a h
ost.
Sending and receiving mail
You can use the mail program to create, send, reply, and forward messages to other
users or to send ASCII files to other users. An ASCII file may, for example, be
a document you have written using a preferred editor or a source file for a pro
gram. The mail program provides a line-oriented editor for creating messages. Th
is editor enables you to enter each line of the message, press the Enter key to
get a new line, and enter more text. When you create mail with the mail editor,
the date: and from: fields are automatically completed by the system. You have t
he option to complete the subject: and cc: fields. These fields are similar to t
he body of a standard business letter. Other editors can only be used by using t
he editor subcommands. You can send messages and files to a user on your local s
ystem, on your network, or to a user on another connected network. The recipient
does not need to be logged onto the system when you send the information. Mail
is sent to a user's address. The address, containing the login name and system n
ame, directs the delivery of the mail message.
The write and wall commands
The write command opens a line of communication to send messages to other users on
the system in real time.
The wall command writes a message to all users that are logged in.
Talk with another user
The talk command is used to converse with another user. It allows two users on the
same host or on different hosts to have an interactive conversation.
The clear, echo and banner commands
The clear command clears the terminal screen.
The echo command writes character strings to standard output.
The banner command writes ASCII character strings in large letters to standard out
put.
The wc command
The wc command counts the number of lines, words, bytes, or characters in a file.
Files and directories
What is a File?
A file is a collection of letters, numbers and special characters: it may be a p
rogram, a database, a dissertation, a reading list, a simple letter etc. Sometim
es you may import a file from elsewhere, for example from another computer. If y
ou want to enter your own text or data, you will start by creating a file.
Inodes
In AIX, each file system contains a superblock, inodes, and data blocks. Each fi
le has an inode containing information such as file size and time of last modifi
cation. The inodes of small files also contain the addresses of all disk blocks
that comprise the file data. A large file can use too many data blocks for an in
ode to directly address. In such a case, the inode points instead to one or more
levels of indirect blocks that are deep enough to hold all of the data block ad
dresses.
File system structure
A file system is a hierarchical structure (file tree) of files and directories.
This type of structure resembles an inverted tree with the roots at the top and
the branches at the bottom. This file tree uses directories to organize data and
programs into groups, allowing the management of many directories and files at
one time. The basic type of file system is called the Journaled File System (JFS
). This file system uses database journaling techniques to maintain its structur
al consistency. This prevents damage to the file system when the system is halte
d abnormally.
Where am I?
In order to know which directory you are currently located in, you can run the c
ommand pwd and it will display the full path where you are residing. The pwd is the
acronym for Present Working Directory.
Changing your current directory
The command used to change a directory from the existing one is cd. It sets the cu
rrent working directory of a process.
Creating and removing directories
The directories can be created using the command mkdir and can be removed using th
e command rmdir.
Listing directories
The command ls -ld is used for listing the directories.
Long listing of files
The ls -l command will give the long listing of the files.
The touch command
The touch command updates the access and modification times of each file specified
by the file parameter of each directory. If you specify a file that does not ex
ist, the touch command creates the file.
File Permissions
Overview
The file permissions determine who can read and modify the information stored in
your files. They are your primary method for protecting the data that you store
on your system.
Changing Permissions using the Symbolic notation
To specify a mode in symbolic form, you must specify three sets of flags. The fi
rst set of flags specifies who is granted or denied the specified permissions, a
s: u for File Owner, g for Group pertaining to the files group and o for All Others.
The second set of flags specifies whether the permissions are to be removed, app
lied, or set: - Removes specified permissions, + Applies specified permissions, = Clea
rs the selected permission field and sets it to the permission specified.
The third set of flags specifies the permissions that are to be removed, applied
, or set: r for Read Permission, w for Write Permission, x for Execute Permission.
Changing Permissions using the Octal notation
The chmod command also permits you to use octal notation for the mode. The numer
ic mode is the sum of one or more of the following values:
4000: Sets user ID on execution, 2000: Sets group ID on execution, 1000: Sets th
e link permission to directories or sets the save-text attribute for files, 0400
: Permits read by owner, 0200: Permits write by owner, 0100: Permits execute or
search by owner, 0040: Permits read by group, 0020: Permits write by group, 0010
: Permits execute or search by group, 0004: Permits read by others, 0002: Permit
s write by others and finally 0001: Permits execute or search by others.
The vi Editior
Starting the vi Editor
The Visual Editor (vi) is a screen editor that comes with the AIX operating syst
em. The vi program is used to create and edit text files. When you edit a file,
vi makes a copy of the file to a memory buffer. This way, if any unwanted change
s are made, the original file is not destroyed. When your work is completeed, yo
u must remeber to save the buffer which contains your changes. The visual editor
has two modes of operation: text input mode and command mode. The vi editor can
be executed by issuing the command vi <filename>. When editing a file, vi place
s a tilde (~) as the first character of lines past the end of your file. These l
ines are not part of your file, and are for display purposes only.
Adding text
The text can be added into a file by opening the file and pressing the i key on th
e keyboard for inserting the text. You can use the x key to delete an alphabet and
dd to remove a line. After adding the text, press the Esc key and save the file.
Exiting the Editor
You can exit the editor either by saving the text or without saving the text. Af
ter pressing the Esc key, you need to press : followed by wq! to save and exit or just
q! to exit without save.
Cursor Movement
There are over forty commands that can be used to move the cursor throughout the
file. The basic keys used are up, down, right and left arrow keys on the keyboard t
ve the cursor to the required place.
Deleting text
In order to delete text, you need to take the cursor to the alphabet or word you
want to delete and hit the x key till the text is deleted. If you would like to d
elete the whole line, you can move to cursor to that line and press the key d twic
e as dd. This will delete the whole line.
Searching for text pattern
To search a pattern in the vi screen, you open the file and click on the / key. Th
e / is entered at the bottom of your screen, where you can add the word to search
and hit enter. You can hit the n key to search for the same word elsewhere is the
file.
Shell Basics
The Shell
The shell is a command interpreter that allows an end user to type in commands t
o communicate to the AIX system. By default, when a user logins, a shell process
is started. The default AIX shell is /usr/bin/ksh.
Metacharacters and Wildcards
Wildcard characters provide a convenient way to specify multiple file names or d
irectory names. The wildcard characters are asterisk (*) and question mark (?).U
se the * to match any sequence or string of characters. The * means any characters
, including no characters. For example, if you have the following files in your
directory:
1test 2test afile1 afile2 bfile1 file file1 file10 file2 file3
and you want to refer to only to the files that begin with file, you would use:
file*
The files selected would be: file file1 file10 file2 file3
Use the ? to match any one character. The ? means any single character.
To refer to only the files that starts with file and end with a single character
, use:
file?
The files selected would be: file1 file2 file3
The metacharacters are open and close square brackets ([ ]), hyphen (-), and exc
lamation mark (!). To refer to only the files that end in 1 or 2, use:
*file[12]
The files selected would be: afile1 afile2 file1 file2
To refer only to the files that start with any number, use:
[0123456789]* or [0-9]*
The files selected would be: 1test 2test
To refer only to the files that don't begin with an a, use:
[!a]*
The files selected would be: 1test 2test bfile1 file file1 file10 file2 file3
Character Substitution in file names
The shell performs file name substitution by scanning each command word specifie
d by the Word variable for certain characters. If a command word includes the *)
, ? or [ characters, and the -f flag has not been set, the shell regards the wor
d as a pattern. The shell replaces the word with file names, sorted according to
the collating sequence in effect in the current locale, that match that pattern
. If the shell does not find a file name to match the pattern, it does not chang
e the word.
Input and Output Redirection
The AIX operating system allows you to manipulate the input and output (I/O) of
data to and from your system by using specific I/O commands and symbols. You can
control input by specifying the location from which to gather data. For example
, you can specify to read input while data is entered on the keyboard (standard
input) or to read input from a file. You can control output by specifying where
to display or store data. You can specify to write output data to the screen (st
andard output) or to write it to a file. Because AIX is a multitasking operating
system, it is designed to handle processes in combination with each other. Ther
e are different ways this can be performed. Few of them are listed below.
a. Standard input, standard output, and standard error files
b. Standard output redirection
c. Redirecting output to a file
d. Redirecting output to append to a file
e. Standard input redirection
f. Discarding output with the /dev/null file
g. Standard error and other output redirection
Creating file with cat
Type the command
# cat > name_of_file
Then, type in the required text and press enter to start a new line. When finish
ed typing, enter Ctrl-d. This stops the cat command and returns you to the syste
m prompt.
Pipes and Filters
You can connect two or more commands so that the standard output of one command
is used as the standard input of another command. A set of commands connected th
is way is known as a pipeline. The connection that joins the commands is known a
s a pipe. Pipes are useful because they let you tie many single-purpose commands
into one powerful command. You can direct the output from one command to become
the input for another command using a pipeline. The commands are connected by a
pipe (|) symbol.
When a command takes its input from another command, modifies it, and sends its
results to standard output, it is known as a filter. Filters can be used alone,
but they are especially useful in pipelines. The most common filters are sort, m
ore and pg.
Processes
What is a process?
The process is the entity that the operating system uses to control the use of s
ystem resources. AIX introduces the use of threads to control processor-time con
sumption, but most of the system management tools still require the administrato
r to refer to the process in which a thread is running, rather than to the threa
d itself.
Some processes run from system boot to shutdown, but most processes come and go
rapidly, as tasks start and complete. At times, a process can die a premature, s
ay, due to a crash of a system or application or a particular task.
Parent and Child Processes
Each new process is the spawn of an existing process. Further, each new process,
called a child" process, is a clone of its "parent" process, at least for an ins
tant, until the child continues execution independently.
Monitoring and Terminating Processes
A process can be monitored using the command ps. It gives the output with the ID a
ssociated to the process along with the time stamp and date when the process was
started.
When a process terminates, by calling the exit subroutine either explicitly or i
mplicitly, all threads within the process are terminated. Neither the cleanup ha
ndlers nor the thread-specific data destructors are called. The reason for this
behavior is that there is no state to leave clean and no thread-specific storage
to reclaim, because the whole process terminates, including all the threads, an
d all the process storage is reclaimed, including all thread-specific storage.
Daemons
A daemon is defined to be a process that is intended to run in the b
ackground without a controlling terminal. That is, the life span of the
daemon process does not depend on the life span of a terminal session,
the daemon life span does not depend on any control key sequences ge
nerated from a terminal session, and a daemon does not interact with
users through a terminal. A daemon can be started by the init process,
the System Resource Controller, the inetd process, or a shell.
AIX Utilities
System Management Interface Tool
The AIX System Management Interface Tool (SMIT) provides an alternative to the t
ypical method of using complex command syntax, valid parameter values, and custo
m shell path names for managing and maintaining your operating system configurat
ion. SMIT offers the following features:
a. Two modes of operation
b. An interactive, menu-driven user interface
c. User assistance
d. System management activity logging
e. Fast paths to system management tasks
f. User-added SMIT screens
The find command
The find command recursively searches the directory tree for each specified Path
parameter, seeking files that match a Boolean expression written using the term
s given in the following text. When the find command is recursively descending d
irectory structures, it will not descend into directories that are symbolically
linked into the current hierarchy. The output from the find command depends on t
he terms specified by the Expression parameter.
The grep command
The grep command search for the pattern specified by the Pattern parameter and t
hen writes each matching line to standard output. The grep command uses a compac
t non-deterministic algorithm. The grep command displays the name of the file co
ntaining the matched line if you specify more than one name in the File paramete
r. Characters with special meaning to the shell ($, *, [, |, ^, (, ), \ ) must b
e in quotation marks when they appear in the Pattern parameter. When the Pattern
parameter is not a simple string, you usually must enclose the entire pattern i
n single quotation marks. In an expression such as [a-z], the - (minus sign) cml
specifies a range, according to the current collating sequence. A collating seq
uence may define equivalence classes for use in character ranges.
The sort command
The sort command sorts lines in the files specified by the File parameter and wr
ites the result to standard output. If the File parameter specifies more than on
e file, the sort
command concatenates the files and sorts them as one file. A - (minus sign) in p
lace of a file name specifies standard input. If you do not specify any file nam
es, the command sorts standard input. An output file can be specified with the -
o flag. If no flags are specified, the sort command sorts entire lines of the in
put file based upon the collation order of the current locale.
The xargs command
The xargs command constructs parameter lists and runs commands. The xargs comman
d limits the command line length.
The which and whereis commands
The which command takes a list of program names and looks for the files that run
when these names are given as commands. The which command expands each argument
, if it is aliased, and searches for it along the user's path.
The whereis command locates the source, binary, and manuals sections for specifi
ed files.
The file command
The file command reads the files specified by the File parameter or the FileList
variable, performs a series of tests on each file, and attempts to classify the
m by type. The command then writes the file types to standard output. The file c
an be regular file, directory, FIFO(named pipe), block special, character specia
l, symbolic link or sockets type.
Comparing files using diff and cmp
The diff command compares text files. It can compare single files or the content
s of directories. The diff command only works with input files that are text fil
es. If the Directory1 and Directory2 parameters are specified, the diff command
compares the text files that have the same name in both directories. Binary file
s that differ, common subdirectories, and files that appear in only one director
y are listed. When the diff command is run on regular files, and when comparing
text files that differ during directory comparison, the diff command tells what
lines must be changed in the files to make them agree. If neither the File1 nor
File2 parameter is a directory, then either may be given as - (minus sign), in w
hich case the standard input is used. If the File1 parameter is a directory, the
n a file in that directory whose file name is the same as the File2 parameter is
used.
The cmp command compares files designated by the File1 and File2 parameters and
writes the results to standard output. If you specify a - (minus sign) for eithe
r the File1
or File2 parameter, the cmp command reads standard input for that file. Only one
file can be read from standard input. Under default conditions, the cmp command
displays nothing if the files are the same. If they differ, the cmp command dis
plays the byte and line number at which the first difference occurs.
The Networked File System (NFS) is one of a category of filesystems known as dis
tributed filesystems. It allows users to access files resident on remote systems
without even knowing that a network is involved and thus allows filesystems to
be shared among computers. These remote systems could be located in the same roo
m or could be miles away.
In order to access such files, two things must happen. First, the remote system
must make the files available to other systems on the network. Second, these fil
es must be mounted on the local system to be able to access them. The mounting p
rocess makes the remote files appear as if they are resident on the local system
. The system that makes its files available to others on the network is called a
server, and the system that uses a remote file is called a client.
NFS Server
NFS consists of a number of components including a mounting protocol, a file loc
king protocol, an export file and daemons (mountd, nfsd, biod, rpc.lockd, rpc.st
ad) that coordinate basic file services.
Systems using NFS make the files available to other systems on the network by "e
xporting" their directories to the network. An NFS server exports its directorie
s by putting the names of these directories in the /etc/exports file and executi
ng the exportfs command. In its simplest form, /etc/exports consists of lines of
the form:
pathname -option, option ...
Where pathname is the name of the file or directory to which network access is t
o be allowed; if pathname is a directory, then all of the files and directories
below it within the same filesystem are also exported, but not any filesystems m
ounted within it. The next fields in the entry consist of various options that s
pecify the type of access to be given and to whom. For example, a typical /etc/e
xports file may look like this:
/cyclop/users -access=homer:bart, root=homer
/usr/share/man -access=marge:maggie:lisa
/usr/mail
This export file permits the filesystem /cyclops/users to be mounted by homer an
d bart, and allows root access to it from homer. In addition, it lets /usr/share
/man to be mounted by marge, maggie and lisa. The filesystem /usr/mail can be mo
unted by any system on the network. Filesystems listed in the export file withou
t a specific set of hosts are mountable by all machines. This can be a sizable s
ecurity hole.
When used with the -a option, the exportfs command reads the /etc/exports file a
nd exports all the directories listed to the network. This is usually done at sy
stem startup time.
# exportfs -va
If the contents of /etc/exports change, you must tell mountd to reread it. This
can be done by re-executing the exportfs command after the export file is change
d.
The exact attributes that can be specified in the /etc/exports file vary from sy
stem to system. The most common attributes are:
-access=list : Colon-separated list of hostnames and netgroups that can mount the
filesystem.
-ro : Export read-only; no clients may write on the filesystem.
-rw=list : List enumerates the hosts allowed to mount for writing; all others mus
t mount read-only.
-root=list : Lists hosts permitted to access the filesystem as root. Without this
option, root access from a client is equivalent to access by the user nobody (u
sually UID -1).
-anon : Specifies UID that should be used for requests coming from an unknown use
r. Defaults to nobody.
-hostname : Allow hostname to mount the filesystem.
For example:
/cyclop/users -rw=moe,anon=-1 /usr/inorganic -ro
This allows moe to mount /cyclop/users for reading and writing, and maps anonymo
us users (users from other hosts that do not exist on the local system and the r
oot user from any remote system) to the UID -1. This corresponds to the nobody a
ccount, and it tells NFS not to allow such users access to anything.
NFS Clients
After the files, directories and/or filesystems have been exported, an NFS clien
t must explicitly mount them before it can use them. It is handled by the mountd
daemon (sometimes called rpc.mountd). The server examines the mount request to
be sure the client has proper authorization.
The following syntax is used for the mount command. Note that the name of the se
rver is followed by a colon and the directory to be mounted:
# mount server1:/usr/src /src
Here, the directory structure /usr/src resident on the remote system server1 is
mounted on the /src directory on the local system.
When the remote filesystem is no longer needed, it is unmounted with the umount:

# umount server1:/usr/src
The mount command can be used to establish temporary network mounts, but mounts
that are part of a system's permanent configuration should be either listed in /
etc/filesystems (for AIX) or handled by an automatic mounting service such as au
tomount or amd.
NFS Commands
lsnfsexp : Displays the characteristics of directories that are exported with the
NFS.
# lsnfsexp
software -ro
mknfsexp -d path -t ro : Exports a read-only directory to NFS clients and add it
to /etc/exports.
# mknfsexp -d /software -t ro
/software ro
Exported /software
# lsnfsexp
/software -ro
rmnfsexp -d path : Unexports a directory from NFS clients and remove it from /etc
/exports.
# rmnfsexp -d /software
lsnfsmnt : Displays the characteristics of NFS mountable file systems.
showmount -e : List exported filesystems.
# showmount -e
export list for server:
/software (everyone)
showmount -a : List hosts that have remotely mounted local systems.
# showmount -a
server2:/sourcefiles
server3:/datafiles
Start/Stop/Status NFS daemons
In the following discussion, reference to daemon implies any one of the SRC-cont
rolled daemons (such as nfsd or biod).
The NFS daemons can be automatically started at system (re)start by including th
e /etc/rc.nfs script in the /etc/inittab file.
They can also be started manually by executing the following command:
# startsrc -s Daemon or startsrc -g nfs
Where the -s option will start the individual daemons and -g will start all of t
hem.
These daemons can be stopped one at a time or all at once by executing the follo
wing command:
# stopsrc -s Daemon or stopsrc -g nfs
You can get the current status of these daemons by executing the following comma
nds:
# lssrc -s [Daemon]
# lssrc -a
If the /etc/exports file does not exist, the nfsd and the rpc.mountd daemons wil
l not start.
You can get around this by creating an empty /etc/exports file. This will allow
the nfsd and the rpc.mountd daemons to start, although no filesystems will be e
xported.
This describes how to resolve the following error when setting the bootlist:
# bootlist -m normal hdisk2 hdisk3
0514-229 bootlist: Multiple boot logical volumes found on 'hdisk2'.
Use the 'blv' attribute to specify the one from which to boot.
To resolve this: clear the boot logical volumes from the disks:
# chpv -c hdisk2
# chpv -c hdisk3
Verify that the disks can no longer be used to boot from by running:
# ipl_varyon -i
Then re-run bosboot on both disks:
# bosboot -ad /dev/hdisk2
bosboot: Boot image is 38224 512 byte blocks.
# bosboot -ad /dev/hdisk3
bosboot: Boot image is 38224 512 byte blocks.
Finally, set the bootlist again:
# bootlist -m normal hdisk2 hdisk3
Another way around it is by specifying hd5 using the blv attribute:
# bootlist -m normal hdisk2 blv=hd5 hdisk3 blv=hd5
This will set the correct boot logical volume, but the error will show up if you
ever run the bootlist command again without the blv attribute.
Topics: AIX, LVM, System Administration?
Mirrorvg without locking the volume group
When you run the mirrorvg command, you will (by default) lock the volume group i
t is run against. This way, you have no way of knowing what the status is of the
sync process that occurs after mirrorvg has run the mklvcopy commands for all t
he logical volumes in the volume group. Especially with very large volume groups
, this can be a problem.
The solution however is easy: Make sure to run the mirrorvg command with the -s
option, to prevent it to run the sync. Then, when mirrorvg has completed, run th
e syncvg yourself with the -P option.
For example, if you wish to mirror the rootvg from hdisk0 to hdisk1:
# mirrorvg -s rootvg hdisk1
Of course, make sure the new disk is included in the boot list for the rootvg:
# bootlist -m normal hdisk0 hdisk1
Now rootvg is mirrored, but not yet synced. Run "lsvg -l rootvg", and you'll see
this. So run the syncvg command yourself. With the -P option you can specify th
e number of threads that should be started to perform the sync process. Usually,
you can specify at least 2 to 3 times the number of cores in the system. Using
the -P option has an extra feature: there will be no lock on the volume group, a
llowing you to run "lsvg rootvg" within another window, to check the status of t
he sync process.
# syncvg -P 4 -v rootvg
And in another window:
# lsvg rootvg | grep STALE | xargs
STALE PVs: 1 STALE PPs: 73
Topics: AIX, LVM, System Administration?
File system creation time
To determine the time and date a file system was created, you can use the getlvc
b command. First, figure out what the logical volume is that is used for a parti
cal file system, for example, if you want to know for the /opt file system:
# lsfs /opt
Name Nodename Mount Pt VFS Size Options Auto Accounting
/dev/hd10opt -- /opt jfs2 4194304 -- yes no
So file system /opt is located on logical volume hd10opt. Then run the getlvcb c
ommand:
# getlvcb -AT hd10opt
AIX LVCB
intrapolicy = c
copies = 2
interpolicy = m
lvid = 00f69a1100004c000000012f9dca819a.9
lvname = hd10opt
label = /opt
machine id = 69A114C00
number lps = 8
relocatable = y
strict = y
stripe width = 0
stripe size in exponent = 0
type = jfs2
upperbound = 32
fs = vfs=jfs2:log=/dev/hd8:vol=/opt:free=false:quota=no
time created = Thu Apr 28 20:26:36 2011
time modified = Thu Apr 28 20:40:38 2011
You can clearly see the "time created" for this file system in the example above
.
Topics: AIX, LVM, System Administration?
Logical volumes with customized owner / group / mode
Some applications, for example Oracle when using raw logical volumes, may requir
e specific access to logical volumes. Oracle will require that the raw logical v
olume is owned by the oracle account, and it may or may not require custom permi
ssions.
The default values for a logical volume are: dev_uid=0 (owned by user root), dev
_gid=0 (owned by group system) and dev_perm=432 (mode 660). You can check the cu
rrent settings of a logical volume by using the readvgda command:
# readvgda vpath51 | egrep "lvname|dev_|Logical"
lvname: testlv (i=2)
dev_uid: 0
dev_gid: 0
dev_perm: 432
If the logical volume was create with or has been modified to use customized own
er/group/mode values, the dev_values will show the current uid/gid/perm values,
for example:
# chlv -U user -G staff -P 777 testlv
# ls -als /dev/*testlv
0 crwxrwxrwx 1 user staff 57, 3 Mar 10 14:39 /dev/rtestlv
0 brwxrwxrwx 1 user staff 57, 3 Mar 10 14:39 /dev/testlv
# readvgda vpath51 | egrep "lvname|dev_|Logical"
lvname: testlv (i=2)
dev_uid: 3878
dev_gid: 1
dev_perm: 511
When the volume group is exported, and re-imported, this information is lost:
# errpt
# exportvg testvg
# importvg -y testvg vpath51
testvg
# ls -als /dev/*testlv
0 crw-rw---- 1 root system 57, 3 Mar 10 15:11 /dev/rtestlv
0 brw-rw---- 1 root system 57, 3 Mar 10 15:11 /dev/testlv
To avoid this from happening, make sure to use the -R option, that will restore
any specific settings:
# chlv -U user -G staff -P 777 testlv
# ls -als /dev/*testlv
0 crwxrwxrwx 1 user staff 57, 3 Mar 10 15:11 /dev/rtestlv
0 brwxrwxrwx 1 user staff 57, 3 Mar 10 15:11 /dev/testlv
# readvgda vpath51 | egrep "lvname|dev_|Logical"
lvname: testlv (i=2)
dev_uid: 3878
dev_gid: 1
dev_perm: 511
# varyoffvg testvg
# exportvg testvg
importvg -Ry testvg vpath51
testvg
# ls -als /dev/*testlv
0 crwxrwxrwx 1 user staff 57, 3 Mar 10 15:14 /dev/rtestlv
0 brwxrwxrwx 1 user staff 57, 3 Mar 10 15:14 /dev/testlv
Never use the chown/chmod/chgrp commands to change the same settings on the logi
cal volume. It will work, however, the updates will not be written to the VGDA,
and as soon as the volume group is exported out and re-imported on the system, t
he updates will be gone:
# chlv -U root -G system -P 660 testlv
# ls -als /dev/*testlv
0 crw-rw---- 1 root system 57, 3 Mar 10 15:14 /dev/rtestlv
0 brw-rw---- 1 root system 57, 3 Mar 10 15:14 /dev/testlv
# chown user.staff /dev/testlv /dev/rtestlv
# chmod 777 /dev/testlv /dev/rtestlv
# ls -als /dev/*testlv
0 crwxrwxrwx 1 user staff 57, 3 Mar 10 15:14 /dev/rtestlv
0 brwxrwxrwx 1 user staff 57, 3 Mar 10 15:14 /dev/testlv
# readvgda vpath51 | egrep "lvname|dev_|Logical"
lvname: testlv (i=2)
dev_uid: 0
dev_gid: 0
dev_perm: 360
Notice above how the chlv command changed the owner to root, the group to system
, and the permissions to 660. Even after the chown and chmod commands are run, a
nd the changes are visible on the device files in /dev, the changes are not seen
in the VGDA. This is confirmed when the volume group is exported and imported,
even with using the -R option:
# varyoffvg testvg
# exportvg testvg
# importvg -Ry testvg vpath51
testvg
# ls -als /dev/*testlv
0 crw-rw---- 1 root system 57, 3 Mar 10 15:23 /dev/rtestlv
0 brw-rw---- 1 root system 57, 3 Mar 10 15:23 /dev/testlv
So, when you have customized user/group/mode settings for logical volumes, and y
ou need to export and import the volume group, always make sure to use the -R op
tion when running importvg.
Also, make sure never to use the chmod/chown/chgrp commands on logical volume bl
ock and character devices in /dev, but use the chlv command instead, to make sur
e the VGDA is updated accordingly.
Note: A regular volume group does not store any customized owner/group/mode in t
he VGDA. It is only stored for Big or Scalable volume groups. In case you're usi
ng a regular volume group with customized owner/group/mode settings for logical
volumes, you will have to use the chmod/chown/chgrp commands to update it, espec
ially after exporting and re-importing the volume group.
Topics: AIX, Backup & restore, LVM, Performance, Storage, System Administration?
Using lvmstat
One of the best tools to look at LVM usage is with lvmstat. It can report the by
tes read and written to logical volumes. Using that information, you can determi
ne which logical volumes are used the most.
Gathering LVM statistics is not enabled by default:
# lvmstat -v data2vg
0516-1309 lvmstat: Statistics collection is not enabled for
this logical device. Use -e option to enable.
As you can see by the output here, it is not enabled, so you need to actually en
able it for each volume group prior to running the tool using:
# lvmstat -v data2vg -e
The following command takes a snapshot of LVM information every second for 10 in
tervals:
# lvmstat -v data2vg 1 10
This view shows the most utilized logical volumes on your system since you start
ed the data collection. This is very helpful when drilling down to the logical v
olume layer when tuning your systems.
# lvmstat -v data2vg
Logical Volume iocnt Kb_read Kb_wrtn Kbps
appdatalv 306653 47493022 383822 103.2
loglv00 34 0 3340 2.8
data2lv 453 234543 234343 89.3
What are you looking at here?
iocnt: Reports back the number of read and write requests.
Kb_read: Reports back the total data (kilobytes) from your measured interval that
is read.
Kb_wrtn: Reports back the amount of data (kilobytes) from your measured interval
that is written.
Kbps: Reports back the amount of data transferred in kilobytes per second.
You can use the -d option for lvmstat to disable the collection of LVM statistic
s.
Topics: AIX, Backup & restore, LVM, Performance, Storage, System Administration?
Spreading logical volumes over multiple disks
A common issue on AIX servers is, that logical volumes are configured on only on
e single disk, sometimes causing high disk utilization on a small number of disk
s in the system, and impacting the performance of the application running on the
server.
If you suspect that this might be the case, first try to determine which disks a
re saturated on the server. Any disk that is in use more than 60% all the time,
should be considered. You can use commands such as iostat, sar -d, nmon and topa
s to determine which disks show high utilization. If the do, check which logical
volumes are defined on that disk, for example on an IBM SAN disk:
# lspv -l vpath23
A good idea always is to spread the logical volumes on a disk over multiple disk
. That way, the logical volume manager will spread the disk I/O over all the dis
ks that are part of the logical volume, utilizing the queue_depth of all disks,
greatly improving performance where disk I/O is concerned.
Let's say you have a logical volume called prodlv of 128 LPs, which is sitting o
n one disk, vpath408. To see the allocation of the LPs of logical volume prodlv,
run:
# lslv -m prodlv
Let's also assume that you have a large number of disks in the volume group, in
which prodlv is configured. Disk I/O usually works best if you have a large numb
er of disks in a volume group. For example, if you need to have 500 GB in a volu
me group, it is usually a far better idea to assign 10 disks of 50 GB to the vol
ume group, instead of only one disk of 512 GB. That gives you the possibility of
spreading the I/O over 10 disks instead of only one.
To spread the disk I/O prodlv over 8 disks instead of just one disk, you can cre
ate an extra logical volume copy on these 8 disks, and then later on, when the l
ogical volume is synchronized, remove the original logical volume copy (the one
on a single disk vpath408). So, divide 128 LPs by 8, which gives you 16LPs. You
can assign 16 LPs for logical volume prodlv on 8 disks, giving it a total of 128
LPs.
First, check if the upper bound of the logical volume is set ot at least 9. Chec
k this by running:
# lslv prodlv
The upper bound limit determines on how much disks a logical volume can be creat
ed. You'll need the 1 disk, vpath408, on which the logical volume already is loc
ated, plus the 8 other disks, that you're creating a new copy on. Never ever cre
ate a copy on the same disk. If that single disk fails, both copies of your logi
cal volume will fail as well. It is usually a good idea to set the upper bound o
f the logical volume a lot higher, for example to 32:
# chlv -u 32 prodlv
The next thing you need to determine is, that you actually have 8 disks with at
least 16 free LPs in the volume group. You can do this by running:
# lsvg -p prodvg | sort -nk4 | grep -v vpath408 | tail -8
vpath188 active 959 40 00..00..00..00..40
vpath163 active 959 42 00..00..00..00..42
vpath208 active 959 96 00..00..96..00..00
vpath205 active 959 192 102..00..00..90..00
vpath194 active 959 240 00..00..00..48..192
vpath24 active 959 243 00..00..00..51..192
vpath304 active 959 340 00..89..152..99..00
vpath161 active 959 413 14..00..82..125..192
Note how in the command above the original disk, vpath408, was excluded from the
list.
Any of the disks listed, using the command above, should have at least 1/8th of
the size of the logical volume free, before you can make a logical volume copy o
n it for prodlv.
Now create the logical volume copy. The magical option you need to use is "-e x"
for the logical volume commands. That will spread the logical volume over all a
vailable disks. If you want to make sure that the logical volume is spread over
only 8 available disks, and not all the available disks in a volume group, make
sure you specify the 8 available disks:
# mklvcopy -e x prodlv 2 vpath188 vpath163 vpath208 \
vpath205 vpath194 vpath24 vpath304 vpath161
Now check again with "mklv -m prodlv" if the new copy is correctly created:
# lslv -m prodlv | awk '{print $5}' | grep vpath | sort -dfu | \
while read pv ; do
result=`lspv -l $pv | grep prodlv`
echo "$pv $result"
done
The output should similar like this:
vpath161 prodlv 16 16 00..00..16..00..00 N/A
vpath163 prodlv 16 16 00..00..00..00..16 N/A
vpath188 prodlv 16 16 00..00..00..00..16 N/A
vpath194 prodlv 16 16 00..00..00..16..00 N/A
vpath205 prodlv 16 16 16..00..00..00..00 N/A
vpath208 prodlv 16 16 00..00..16..00..00 N/A
vpath24 prodlv 16 16 00..00..00..16..00 N/A
vpath304 prodlv 16 16 00..16..00..00..00 N/A
Now synchronize the logical volume:
# syncvg -l prodlv
And remove the original logical volume copy:
# rmlvcopy prodlv 1 vpath408
Then check again:
# lslv -m prodlv
Now, what if you have to extend the logical volume prodlv later on with another
128 LPs, and you still want to maintain the spreading of the LPs over the 8 disk
s? Again, you can use the "-e x" option when running the logical volume commands
:
# extendlv -e x prodlv 128 vpath188 vpath163 vpath208 \
vpath205 vpath194 vpath24 vpath304 vpath161
You can also use the "-e x" option with the mklv command to create a new logical
volume from the start with the correct spreading over disks.
# HISTFILE
# execute only if interactive
if [ -t 0 -a "${SHELL}" != "/bin/bsh" ]
then
d=`date "+%H%M.%m%d%y"`
t=`tty | cut -c6-`
u=$(ps -fp $(proctree $PPID | grep "\-ksh" | grep -v grep | \
awk '{print $1}' | head -1) | tail -1 | awk '{print $1}')
w=`who -ms | awk '{print $NF}' | sed "s/(//g" | sed "s/)//g"`
y=`tty | cut -c6- | sed "s/\//-/g"`
mkdir $HOME/.history.$LOGIN 2>/dev/null
export HISTFILE=$HOME/.history.$LOGIN/.sh_history.$LOGIN.$u.$w.$y.$d
find $HOME/.history.$LOGIN/.s* -type f -ctime +91 -exec rm {} \; \
2>/dev/null
H=`uname -n`
mywhoami=`whoami`
if [ ${mywhoami} = "root" ] ; then
PS1='${USER}@(${H}) ${PWD##/*/} # '
else
PS1='${USER}@(${H}) ${PWD##/*/} $ '
fi
fi
# Time out after 60 minutes
# Use readonly if you don't want users to be able to change it.
# readonly TMOUT=3600
TMOUT=3600
export TMOUT
Put this in /etc/environment, to turn on time stamped history files:
# Added for extended shell history
EXTENDED_HISTORY=ON

Potrebbero piacerti anche