Translate

Saturday 9 March 2013

File systems

File systems represent a convenient way to store and access data from a logical
volume. A file system is comprised of files, directories, and other data structures.
File systems maintain information and identify the location of a file or directory's
data.
 

File system types

The following types of file systems are supported on an AIX 5L Version 5.3 and later:
Journaled file system
This type of file system is named journaled because the
system uses journaling techniques to maintain the
integrity of control structures. Each journaled file system
must reside on a distinct jfs logical volume. Therefore, the
file system size will be a multiple of the size of a logical
partition.
Enhanced journaled file system
This is the enhanced version of the initial journalized file
system. It uses extent based allocation to allow higher
performance, larger file systems, and a larger file size.
Each enhanced journaled file system must reside on a
distinct jfs2 logical volume. When the operating system is
installed using the default options, it creates JFS2 file
systems.
Network file system
The network file system (NFS) is a distributed file system
that allows users to access files and directories located on
remote computers and use those files and directories as
though they are local.
CD-ROM file system
The CD-ROM file system (CDRFS) is a file system type
that allows you to access the contents of a CD-ROM
through the normal file system interfaces.

 

File system management

 

The follow sections describe basic file system management.
Creating a file system
Every file system in AIX 5L Version 5.3 must reside on a logical volume.
When you create a file system, if you do not specify a previously created logical
volume the system will create a logical volume with a system-generated name
that has default values for the logical volume’s characteristics. The size of the file
system is rounded up to closest multiple of the logical partition size. The size of
the file system cannot exceed the standard maximum number of logical partitions
for a logical volume. A stanza containing the details of the file system will be
added to /etc/filesystems and new data will be written to ODM.
we show how to use thecrfs command as follows:
 
lsvg -l testvg shows that testvg does not contain any logical volumes of
type jfs, jfs2, jfslog, and jfs2log.
 
crfs -v jfs -g testvg -a size=10M -m /fs1 creates, within volume group
testvg, a jfs file system of 10 MB with mounting point /fs1. There was not an
existing jfs logical volume, so the system created one and assigned it the
name lv00. There was not an existing jfs log device, so the system created
one and assigned it the name loglv00.
 
crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2 creates, within volume
group testvg, a jfs2 file system of 10 MB with mounting point /fs2 and having
read only permissions. There was not an existing jfs2 logical volume, so the
system created one and assigned it the name fslv00. There was not an
existing jfs2 log device, so the system created one and assigned it the name
loglv01.
 
lslv lv00 and lslv fslv00 shows that logical volumes were created using
their default characteristics.
 
cat /etc/filesystems|grep -ip fs1 displays the stanza from
/etc/filesystems that corresponds to fs1.
276 IBM Eserver p5 and pSeries Administration and Support for AIX 5L V5.3
 
Creating file systems without specifying logical volumes
# lsvg -l testvg
testvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
# crfs -v jfs -g testvg -a size=10M -m /fs1
Based on the parameters chosen, the new /fs1 JFS file system
is limited to a maximum size of 134217728 (512 byte blocks)
New File System size is 262144
# crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2
File system created successfully.
130864 kilobytes total disk space.
New File System size is 262144
# lsvg -l testvg
testvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv00 jfslog 1 1 1 closed/syncd N/A
lv00 jfs 1 1 1 closed/syncd /fs1
loglv01 jfs2log 1 1 1 closed/syncd N/A
fslv00 jfs2 1 1 1 closed/syncd /fs2
# lslv lv00
LOGICAL VOLUME: lv00 VOLUME GROUP: testvg
LV IDENTIFIER: 00c478de00004c0000000107d96de510.2 PERMISSION:
read/write
VG STATE: active/complete LV STATE: closed/syncd
TYPE: jfs WRITE VERIFY: off
MAX LPs: 512 PP SIZE: 128 megabyte(s)
COPIES: 1 SCHED POLICY: parallel
LPs: 1 PPs: 1
STALE PPs: 0 BB POLICY: relocatable
INTER-POLICY: minimum RELOCATABLE: yes
INTRA-POLICY: middle UPPER BOUND: 32
MOUNT POINT: /fs1 LABEL: /fs1
MIRROR WRITE CONSISTENCY: on/ACTIVE
EACH LP COPY ON A SEPARATE PV ?: yes
Serialize IO ?: NO
# lslv fslv00
LOGICAL VOLUME: fslv00 VOLUME GROUP: testvg
LV IDENTIFIER: 00c478de00004c0000000107d96de510.4 PERMISSION:
read/write
VG STATE: active/complete LV STATE: closed/syncd
TYPE: jfs2 WRITE VERIFY: off
MAX LPs: 512 PP SIZE: 128 megabyte(s)
COPIES: 1 SCHED POLICY: parallel
LPs: 1 PPs: 1
STALE PPs: 0 BB POLICY: relocatable
INTER-POLICY: minimum RELOCATABLE: yes
INTRA-POLICY: middle UPPER BOUND: 32
File systems 277
MOUNT POINT: /fs2 LABEL: /fs2
MIRROR WRITE CONSISTENCY: on/ACTIVE
EACH LP COPY ON A SEPARATE PV ?: yes
Serialize IO ?: NO
# cat /etc/filesystems|grep -ip fs1
/fs1:
dev = /dev/lv00
vfs = jfs
log = /dev/loglv00
mount = false
account = false
You can specify the name of a previously created logical volume. The type of the
logical volume must match the type of the file system. The size of the file system
is rounded up to closest multiple of the logical partition size. A stanza containing
the details of the file system will be added to /etc/filesystems and the ODM will be
updated.
we show how to use thecrfs command as follows:
lsvg -l testvg shows that jfs2 type testlv logical volume does not have any
file system associated and there is already a jfs2 log device defined. testlv
has only one partition of 128 MB.
crfs -v jfs2 -d /dev/testlv -a logname=loglv01 -m /test -a size=130M
creates a jfs2 file system located on already existing logical volume named
testlv, using jfs2 log device loglv01 and having /test as the mounting point.
Because we specified, for the file system, a size bigger than the logical
volume itself, the size parameter is ignored and the final size of the file system
will be rounded to the size of the logical volume.
cat /etc/filesystems|grep -ip test displays the stanza from
/etc/filesystems corresponding to test.
 
Creating file systems on previously defined logical volumes
# lsvg -l testvg
testvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv00 jfslog 1 1 1 closed/syncd N/A
lv00 jfs 1 1 1 closed/syncd /fs1
loglv01 jfs2log 1 1 1 closed/syncd N/A
fslv00 jfs2 1 1 1 closed/syncd /fs2
testlv jfs2 1 1 1 closed/syncd N/A
# crfs -v jfs2 -d /dev/testlv -a logname=loglv01 -m /test -a size=130M
crfs: Warning: device name given, size parameter ignored.
File system created successfully.
130864 kilobytes total disk space.
New File System size is 262144
278 IBM Eserver p5 and pSeries Administration and Support for AIX 5L V5.3
# cat /etc/filesystems|grep -ip test
/test:
dev = /dev/testlv
vfs = jfs2
log = /dev/loglv01
mount = false
account = false
Mounting and unmounting file systems
Mounting is a concept that makes file systems, files, directories, devices, and
special files available for use at a particular location. It is the only way a file
system is made accessible.
The mounting point must be created before the file system is mounted. When a
file system is mounted over a directory, the permissions of the root directory of
the mounted file system take precedence over the permissions of the mount
point.
we use the mount command as follows:
mount /dev/fslv02 /testfs tries to mount /test under a nonexisting directory
and generates an error.
mount /dev/fslv02 /test mounts the file system under an existing directory.
umount /testfs tries to unmount a nonexistent file system and generates an
error.
umount /test unmounts the /test file system.
Mounting and un-mounting file systems
# mount /dev/fslv02 /testfs
mount: 0506-324 Cannot mount /dev/fslv02 on /testfs: A file or directory in the
path name does not exist.
# umount /dev/fslv02 /test
umount: 0506-347 Cannot find anything to unmount.
# mount /dev/fslv02 /test
# umount /testf
umount: 0506-347 Cannot find anything to unmount.
# umount /test
If you want to mount all the file systems, you can use the following command to
mount all the file systems at one time:
mount {-a|all}
File systems 279
Displaying mounted file systems
You can use the mount command without any flags to display information about
all the currently mounted file systems, as shown in 7-4.
Displaying mounted file systems using the mount command
# mount
node mounted mounted over vfs date options
-------- --------------- --------------- ------ ------------ ---------------
/dev/hd4 / jfs2 Nov 27 12:36 rw,log=/dev/hd8
/dev/hd2 /usr jfs2 Nov 27 12:36 rw,log=/dev/hd8
/dev/hd9var /var jfs2 Nov 27 12:36 rw,log=/dev/hd8
/dev/hd3 /tmp jfs2 Nov 27 12:36 rw,log=/dev/hd8
/dev/hd1 /home jfs2 Nov 27 12:36 rw,log=/dev/hd8
/proc /proc procfs Nov 27 12:36 rw
/dev/hd10opt /opt jfs2 Nov 27 12:36 rw,log=/dev/hd8
/dev/testlv /test jfs2 Nov 28 19:54
rw,log=/dev/loglv01
You can use the lsfs command to display the characteristics of file systems, This command will display data about all types of file
systems
Using the lsfs command
# lsfs -a
Name Nodename Mount Pt VFS Size Options Auto
Accounting
/dev/hd4 -- / jfs2 262144 -- yes
no
/dev/hd1 -- /home jfs2 262144 -- yes
no
/dev/hd2 -- /usr jfs2 2359296 -- yes
no
/dev/hd9var -- /var jfs2 262144 -- yes
no
/dev/hd3 -- /tmp jfs2 262144 -- yes
no
/proc -- /proc procfs -- -- yes
no
/dev/hd10opt -- /opt jfs2 262144 -- yes
no
/dev/lv00 -- /fs1 jfs 262144 -- no
no
/dev/fslv00 -- /fs2 jfs2 262144 ro no
no
# lsfs -q
280 IBM Eserver p5 and pSeries Administration and Support for AIX 5L V5.3
Name Nodename Mount Pt VFS Size Options Auto
Accounting
/dev/hd4 -- / jfs2 262144 -- yes
no
(lv size: 262144, fs size: 262144, block size: 4096, sparse files: yes,
inline log: no, inline log size: 0, EAformat: v1, Quota: no, DMAPI: no, VIX:
no)
/dev/hd1 -- /home jfs2 262144 -- yes
no
(lv size: 262144, fs size: 262144, block size: 4096, sparse files: yes,
inline log: no, inline log size: 0, EAformat: v1, Quota: no, DMAPI: no, VIX:
no)
/dev/hd2 -- /usr jfs2 2359296 -- yes
no
(lv size: 2359296, fs size: 2359296, block size: 4096, sparse files: yes,
inline log: no, inline log size: 0, EAformat: v1, Quota: no, DMAPI: no, VIX:
no)
/dev/hd9var -- /var jfs2 262144 -- yes
no
(lv size: 262144, fs size: 262144, block size: 4096, sparse files: yes,
inline log: no, inline log size: 0, EAformat: v1, Quota: no, DMAPI: no, VIX:
no)
/dev/hd3 -- /tmp jfs2 262144 -- yes
no
(lv size: 262144, fs size: 262144, block size: 4096, sparse files: yes,
inline log: no, inline log size: 0, EAformat: v1, Quota: no, DMAPI: no, VIX:
no)
/proc -- /proc procfs -- -- yes
no
/dev/hd10opt -- /opt jfs2 262144 -- yes
no
(lv size: 262144, fs size: 262144, block size: 4096, sparse files: yes,
inline log: no, inline log size: 0, EAformat: v1, Quota: no, DMAPI: no, VIX:
no)
/dev/lv00 -- /fs1 jfs 262144 -- no
no
(lv size: 262144, fs size: 262144, frag size: 4096, nbpi: 4096, compress: no,
bf: false, ag: 8)
/dev/fslv00 -- /fs2 jfs2 262144 ro no
no
(lv size: 262144, fs size: 262144, block size: 4096, sparse files: yes,
inline log: no, inline log size: 0, EAformat: v1, Quota: no, DMAPI: no, VIX:
no)
File systems 281
Removing a file system
You can use the rmfs command to remove a file system. The command will
delete the corresponding stanza from the /etc/filesystems and the logical volume
used on which the file system resides.
Using the rmfs command
# lsvg -l testvg
testvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv00 jfslog 1 1 1 closed/syncd N/A
lv00 jfs 1 1 1 closed/syncd /fs1
loglv01 jfs2log 1 1 1 open/syncd N/A
fslv00 jfs2 1 1 1 closed/syncd /fs2
testlv jfs2 1 1 1 open/syncd /test
# rmfs /test
rmfs: 0506-921 /test is currently mounted.
# umount /test
# rmfs /test
rmlv: Logical volume testlv is removed.
# lsvg -l testvg
testvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv00 jfslog 1 1 1 closed/syncd N/A
lv00 jfs 1 1 1 closed/syncd /fs1
loglv01 jfs2log 1 1 1 closed/syncd N/A
fslv00 jfs2 1 1 1 closed/syncd /fs2
# cat /etc/filesystems|grep test
#
Changing the attributes of a file system
You can use the chfs command to change some of the attributes of a file system,
such as mounting point permissions, log device, or size, as shown in
Exampl. If the new size for the file system is larger than the size of the
logical volume, the logical volume will be extended to accommodate the file
system, provided that it does not exceed the maximum number of logical
partitions.
Changing attributes of a file system
# lsfs -a
Name Nodename Mount Pt VFS Size Options Auto
Accounting
/dev/hd4 -- / jfs2 262144 -- yes
no
282 IBM Eserver p5 and pSeries Administration and Support for AIX 5L V5.3
/dev/hd1 -- /home jfs2 262144 -- yes
no
/dev/hd2 -- /usr jfs2 2359296 -- yes
no
/dev/hd9var -- /var jfs2 262144 -- yes
no
/dev/hd3 -- /tmp jfs2 262144 -- yes
no
/proc -- /proc procfs -- -- yes
no
/dev/hd10opt -- /opt jfs2 262144 -- yes
no
/dev/lv00 -- /fs1 jfs 262144 -- no
no
/dev/fslv00 -- /fs2 jfs2 262144 ro no
no
# chfs -a size=250M -p rw /fs2
Filesystem size changed to 524288
# lsfs -a
Name Nodename Mount Pt VFS Size Options Auto
Accounting
/dev/hd4 -- / jfs2 262144 -- yes
no
/dev/hd1 -- /home jfs2 262144 -- yes
no
/dev/hd2 -- /usr jfs2 2359296 -- yes
no
/dev/hd9var -- /var jfs2 262144 -- yes
no
/dev/hd3 -- /tmp jfs2 262144 -- yes
no
/proc -- /proc procfs -- -- yes
no
/dev/hd10opt -- /opt jfs2 262144 -- yes
no
/dev/lv00 -- /fs1 jfs 262144 -- no
no
/dev/fslv00 -- /fs2 jfs2 524288 rw no
no
Checking file system consistency
The fsck command checks file system consistency and interactively repairs the
file system. You should not run the fsck command on a mounted file system. You
must be able to read the device file on which the file system resides. The fsck
command tries to repair file system metadata structures, displays information
about the inconsistencies found, and prompts you for permission to repair them.
File systems 283
It does not recover the data from data blocks. If you lost data, you have to restore
it from a backup.
Orphaned files and directories detected by the fsckcommand are placed under
the lost+found directory located in the root directory of the file system.
When the system boots, the fsck command is called to verify the /, /usr, /var, and
/tmp file systems. An unsuccessful result prevents the system from booting.
Log devices
The following sections describe basic information about file system logs.
Creating log devices
A dedicated log device is created on hd8 for rootvg when the system is installed.
When the size of your file system is increasing, you should consider either
increasing the size of the default log or creating new log devices.
To create a log devices, you should use the mklvcommand and specify, for the
type of the logical volume, jfslog or jfs2log.
Initializing log devices
The log devices are initialized using the logform command by clearing all log
records. The same command is used for jfslog devices, jfs2log2 devices, or inline
logs. The logform command does not affect the data itself.
To initialize the jf2log device named loglv01, use the following command:
logform /dev/loglv01
Defragmenting a file system
The use of fragments and compression, as well as the creation and deletion of a
large number of files, can decrease the amount of contiguous free disk space.
The defragfs command can be used to improve or report the status of
contiguous space within a file system. To defragment the file system /home, use
the following command:
defragfs /home
284 IBM Eserver p5 and pSeries Administration and Support for AIX 5L V5.3
Displaying information about inodes
You can use the istat command to display information regarding a particular
inode, as shown in 7-8
Using istat command
# istat /etc/passwd
Inode 66 on device 10/4 File
Protection: rw-r--r--
Owner: 0(root) Group: 7(security)
Link count: 1 Length 644 bytes
Last updated: Thu Dec 1 18:14:12 CST 2005
Last modified: Thu Dec 1 18:14:12 CST 2005
Last accessed: Mon Dec 5 17:04:17 CST 2005
Troubleshooting file system problems
This section discusses some of the problems related to file systems and how to
resolve them.
Recovering from super block errors
If you receive one of the following errors from the fsck or mount commands, the
problem may be a corrupted superblock:
fsck: Not an AIX3 file system
fsck: Not an AIXV3 file system
fsck: Not an AIX4 file system
fsck: Not an AIXV4 file system
fsck: Not a recognized file system type
mount: invalid argument
The problem can be resolved by restoring the backup of the superblock over the
primary superblock using one of the following commands:
dd count=1 bs=4k skip=31 seek=1 if=/dev/lv00 of=/dev/lv00
Once the restoration process is completed, check the integrity of the file system
using the fsck command. If this does not resolve the problem, recreate the file
system, and restore the data from a backup.
File systems 285
Cannot unmount file systems
A file system cannot be unmounted if any references are still active within that file
system. The following situations can leave open references to a mounted file
system:
Files are open within a file system. Close these files before the file system
can be unmounted. The fuser command is often the best way to determine
the process IDs for all processes that have open references within a specified
file system. The process having an open reference can be killed by using the
kill command and the unmount can be accomplished.
If the file system is still busy and not getting unmounted, this could be due to a
kernel extension that is loaded, but exists within the source file system. The
fuser command will not show these kinds of references, because a user
process is not involved. However, the genkexcommand will report on all
loaded kernel extensions.
File systems are still mounted within that file system. If any file system is
mounted within a file system, this leaves open references in the source file
system at the mount point of the other file system. Unmount all the file
systems that are mounted within the file system to be unmounted.
A user is using a directory within the file system as their current working
directory. The fuser command appends the letter “c” to the process IDs of all
processes that are using a directory as their current working directory, and the
-u flag identifies the owner of the process. It can be used with the find
command, as shown in the following :
# find /home -type d -exec fuser -u {} \;
/home:
/home/lost+found:
/home/guest:
/home/kenzie: 3548c(kenzie)