FILE SYSTEMS
*file system types jfs,enhanced jfs, nfs, cdrom fs.
A)File system structure
>Superblock
Contains control info about a filesystem
-overall size of fs in 512 byte blocks.
-filesystem name
-filesystem log device - the version number
-number of inodes
-free inodes
-free data blocks
-date & time of creation
-filesystem state
All this data is stored in the first logical block of the filesystem. Corruption of this data may render the filesystem unusable . This is why the system keeps a second copy of the superblock on logical block 31
-->dd count=1 bs=4k skip=31 seek=1 if=/dev/hdn of=/dev/hdn
>Allocation group
Allocation group consists of inodes & its corresponding data blocks.
>inodes
Contains information about the file
-type
-size
-owner
-data&time
when the file was created ,modified, or last accessed.
-Contains pointers to data blocks that store the actual data of the file.
-Every file has a corresponding inode
Fof jfs filesystem, the maximum number of inodes, & hence the maximum number of files is determined by the nbpi value(during installation)(number of bytes per inode), which is specified when the filesystem is created. For every nbpi bytes of your filesystem, there will be an inode created.
The total number of inodes is fixed.
The nbpi values needs to be correlated with allocation group size.
JFS restricts all filesystems to 16MB (2 rest to 24) indoes.
JFS2 file system manages the necessary space for inodes dynamically so there is no need of any nbpi parameter.
>Data blocks
Data blocks store the actual data of the file or pointers ot other data blocks , The default value for disk block size is 4 kB
>Fragments -for jfs filesystems only
Fragments of logical blocks can be used to support files smaller than the standard size of the logical block(4KB). This rule applies only to the last block of a file smaller than 32kB.
Also you have the option to use compression to allow all logical blocks of a file to be stored as a sequence of contiguous fragments.
These features can be useful to support a large number of small files. Fragment size must be specified for a filesystem at installation time.
Different filesystems can have different fragment sizes.
>Device logs
The journaled filesystem log stores transactional information about file system metadata changes.
Data from data blocks are not journaled. Log devices ensure filesystem integrity not data integrity.
This data can be used to roll back incomplete operations if the machine crashes.
JFS-jfslog
JFS2-jfs2log
After the operating system is installed, all file systems within the rootvg use logical volume hd8 as a common log.
You can create a JFS2 filesystem that can use inline logs. This means the log data is written into the same logical volume as the filesystem and not into the log logical volume.
B)Filesystem difference
Function jfs jfs2
maximum filesystem size 1TB 4PB
max file size 64GB 4PB
number of inodes fixed Dynamic
inode size 128bytes 512bytes
fragment size 512b 512b
block size 4096b 4096b
Directory Org linear B-tree
compression yes no
jfs log external(hd8) external+natv
default ownership
at creation sys.sys root system
sgid of deflt filemode sgid=on sgid=off
quotas yes yes
file system shrink not possible possible 5.3+
*If you have to migrate data from a jfs filesystem to a jfs2 filesystem you have to backup the jfs filesystem & resotre the data on the jfs2 filesystem.
C)Filesystem management
>Create a filesystem
1)-->crfs -v jfs -g testvg -a size=10M -m /fs1
creates within volume group testvg,
jfs-filesystem-10MB
mount point =/fs1
if there is no existing jfs logical volume then it will be create now.
If there is no existing jfs log device , the system will create it now.
2)-->crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2
in testvg
jfs2 filesystem of 10MB
mounting point /fs2
permission -read only
If there is no jfs2 logical volume, it will be created now.
-->cat /etc/filesystems | grep fs1 /grep fs2
/fs1
dev=/dev/lv00
vfs=jfs
log=/dev/loglv00
mount=false (dont mount at reboot)
account=false
3)Use crfs
-->lsvg -l testvg
testlv logical volume, jfs2 , existed but not associated with any fs, size=128MB, 1pp
-There is a jfs2 log device defined not attached with fs.
so using already existed components we create jfs2 filesystem located on already existing logical volume named testlv, using jfs2 log device loglv01 and having /test as the mounting point.
-->crfs -v jfs2 -d /dev/testlv -a logname=loglv01 -m /test -a size=130M
Though here we have specified for the filesystem, a size bigger than the logical volume itsef, the size parameter is ignored and the final size of the filesystem will be rounded to the size of the logical volume.
>Mounting and unmounting fs
Mounting is the only way a filesystem is made accessible.
When a filesystem is mounted over a directory, the permissions of the root directory of the mounted filesystem take precedence over the permissions of the mount point.
Means whatever permissions on filesystem will be automatically apply on mount point directory.
-->mount /dev/fslv02 /test
-->umount /test
+Display mounted filesystems using the mount command
-->mount
+Display the characteristics of filesystems
-->lsfs -a
-->lsfs -q
>Removing a filesystem
Unmount the filesystem before deletion, rmfs command will delete the corresponding stanza from the /etc/filesystems and the logical volume on which the filesystem resides.
-->rmfs /test
error: if still mounted
-->umount /test
-->rmfs /test
-->cat /etc/filesystems | grep test
>Changing the attribute of a filesystem
USe chfs command to change attributes of a file system, such as -mounting point permission
-log device
-size
-->lsfs -a
/dev/fslv00 --/fs2 jfs2 243322 ro no
-->chfs -a size=250M -p rw /fs2
filesystem size changed to 512M
If the new size for the filesystem is larger than the size of the logical volume, the logical volume will be extended to accommodate the filesystem, provided that it does not exceed the maximum number of logical partitions.
>Checking filesystem consistency
-fsck command checks filesystem consistency & interactively repairs the filesystem
**Do not run fsck command on mounted filesystem.
-you must be able to read the device file on which the filesystem resides.
-fsck command tries to repair filesystem metadata structure, display information about inconsistencies, prompts you for permission to repair them.
-fsck does not recover the data from datablocks,
If you lost data, you have to restore it from a backup.
-when the system boots, theh fsck command is called to verify the /, /usr, /var, /tmp filesytems.
An unsuccessfull result prevents the system from booting
--at boottime
-->fsck -f /, /var, /usr, /tmp
check repair fs metadata
doesn't recover data
>Log Devices
+Creating log devices
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
Use mklv command to specify type of logical volume,jfslog or jfs2log
+Initializing log devices
The log devices are initialized using the logform command by clearing all log records, such as jfslog, jfs2log or inline logs.
The logform command does not affect the data itself.
To initialize the jfs2log device named loglv01
-->logform /dev/loglv01
D) Defragmenting a filesystem
The use of fragments and compression , as well as the creation and deletion of a large number of files, can decreses the amount of contiguous free disk space.
-->defragfs /home
To improve the status of contiguous space within a filesystem.
E)Displaying info. about inodes
-->istat filename
-->istat /etc/passwd
f)Troubleshooting filesystems problems
>Superblock errors Recovery
Errors: fsck : not an aix3 fs
fsck: not an aix4 fs
fsck : not a recognized filesystem type
mount:invalid argument
Solution :Restore the backup of the superblock ovre the primary superblock
dd count=1 bs=4k skip=31 seek=1 if=/dev/lv00 of=/dev/lv00
-->fsck -f /dev/lv00
if still not solved then recreate filesystem, restore the data from a backup.
>Cannot unmount filesystems
A filesystem cannot be unmounted if any refrences are still active within that filesystem.
The following situations can leave open references to a mounted filesystem.
+files are open within a filesystem
-->fuser /fs
Shows the running processes within fs
-->kill PID
+Running kernel extension
-->genkex
report on all loaded kernel extensions
+Filesystems are still mounted within that file system
-Unmount all the filesystems that are mounted within the filesystem to be unmounted
+A user is using a directory within the filesystems as their cwd.
-->find /home -type d -exec fuser -u {} \;
/home/prashant: 3548c(prashant)
Fuser appends the letter "c" to the process ID's of all processes that are using a directory as their cwd. The -u flag shows owner of process.
>Full filesystems
-->df
-->du
*file system types jfs,enhanced jfs, nfs, cdrom fs.
A)File system structure
>Superblock
Contains control info about a filesystem
-overall size of fs in 512 byte blocks.
-filesystem name
-filesystem log device - the version number
-number of inodes
-free inodes
-free data blocks
-date & time of creation
-filesystem state
All this data is stored in the first logical block of the filesystem. Corruption of this data may render the filesystem unusable . This is why the system keeps a second copy of the superblock on logical block 31
-->dd count=1 bs=4k skip=31 seek=1 if=/dev/hdn of=/dev/hdn
>Allocation group
Allocation group consists of inodes & its corresponding data blocks.
>inodes
Contains information about the file
-type
-size
-owner
-data&time
when the file was created ,modified, or last accessed.
-Contains pointers to data blocks that store the actual data of the file.
-Every file has a corresponding inode
Fof jfs filesystem, the maximum number of inodes, & hence the maximum number of files is determined by the nbpi value(during installation)(number of bytes per inode), which is specified when the filesystem is created. For every nbpi bytes of your filesystem, there will be an inode created.
The total number of inodes is fixed.
The nbpi values needs to be correlated with allocation group size.
JFS restricts all filesystems to 16MB (2 rest to 24) indoes.
JFS2 file system manages the necessary space for inodes dynamically so there is no need of any nbpi parameter.
>Data blocks
Data blocks store the actual data of the file or pointers ot other data blocks , The default value for disk block size is 4 kB
>Fragments -for jfs filesystems only
Fragments of logical blocks can be used to support files smaller than the standard size of the logical block(4KB). This rule applies only to the last block of a file smaller than 32kB.
Also you have the option to use compression to allow all logical blocks of a file to be stored as a sequence of contiguous fragments.
These features can be useful to support a large number of small files. Fragment size must be specified for a filesystem at installation time.
Different filesystems can have different fragment sizes.
>Device logs
The journaled filesystem log stores transactional information about file system metadata changes.
Data from data blocks are not journaled. Log devices ensure filesystem integrity not data integrity.
This data can be used to roll back incomplete operations if the machine crashes.
JFS-jfslog
JFS2-jfs2log
After the operating system is installed, all file systems within the rootvg use logical volume hd8 as a common log.
You can create a JFS2 filesystem that can use inline logs. This means the log data is written into the same logical volume as the filesystem and not into the log logical volume.
B)Filesystem difference
Function jfs jfs2
maximum filesystem size 1TB 4PB
max file size 64GB 4PB
number of inodes fixed Dynamic
inode size 128bytes 512bytes
fragment size 512b 512b
block size 4096b 4096b
Directory Org linear B-tree
compression yes no
jfs log external(hd8) external+natv
default ownership
at creation sys.sys root system
sgid of deflt filemode sgid=on sgid=off
quotas yes yes
file system shrink not possible possible 5.3+
*If you have to migrate data from a jfs filesystem to a jfs2 filesystem you have to backup the jfs filesystem & resotre the data on the jfs2 filesystem.
C)Filesystem management
>Create a filesystem
1)-->crfs -v jfs -g testvg -a size=10M -m /fs1
creates within volume group testvg,
jfs-filesystem-10MB
mount point =/fs1
if there is no existing jfs logical volume then it will be create now.
If there is no existing jfs log device , the system will create it now.
2)-->crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2
in testvg
jfs2 filesystem of 10MB
mounting point /fs2
permission -read only
If there is no jfs2 logical volume, it will be created now.
-->cat /etc/filesystems | grep fs1 /grep fs2
/fs1
dev=/dev/lv00
vfs=jfs
log=/dev/loglv00
mount=false (dont mount at reboot)
account=false
3)Use crfs
-->lsvg -l testvg
testlv logical volume, jfs2 , existed but not associated with any fs, size=128MB, 1pp
-There is a jfs2 log device defined not attached with fs.
so using already existed components we create jfs2 filesystem located on already existing logical volume named testlv, using jfs2 log device loglv01 and having /test as the mounting point.
-->crfs -v jfs2 -d /dev/testlv -a logname=loglv01 -m /test -a size=130M
Though here we have specified for the filesystem, a size bigger than the logical volume itsef, the size parameter is ignored and the final size of the filesystem will be rounded to the size of the logical volume.
>Mounting and unmounting fs
Mounting is the only way a filesystem is made accessible.
When a filesystem is mounted over a directory, the permissions of the root directory of the mounted filesystem take precedence over the permissions of the mount point.
Means whatever permissions on filesystem will be automatically apply on mount point directory.
-->mount /dev/fslv02 /test
-->umount /test
+Display mounted filesystems using the mount command
-->mount
+Display the characteristics of filesystems
-->lsfs -a
-->lsfs -q
>Removing a filesystem
Unmount the filesystem before deletion, rmfs command will delete the corresponding stanza from the /etc/filesystems and the logical volume on which the filesystem resides.
-->rmfs /test
error: if still mounted
-->umount /test
-->rmfs /test
-->cat /etc/filesystems | grep test
>Changing the attribute of a filesystem
USe chfs command to change attributes of a file system, such as -mounting point permission
-log device
-size
-->lsfs -a
/dev/fslv00 --/fs2 jfs2 243322 ro no
-->chfs -a size=250M -p rw /fs2
filesystem size changed to 512M
If the new size for the filesystem is larger than the size of the logical volume, the logical volume will be extended to accommodate the filesystem, provided that it does not exceed the maximum number of logical partitions.
>Checking filesystem consistency
-fsck command checks filesystem consistency & interactively repairs the filesystem
**Do not run fsck command on mounted filesystem.
-you must be able to read the device file on which the filesystem resides.
-fsck command tries to repair filesystem metadata structure, display information about inconsistencies, prompts you for permission to repair them.
-fsck does not recover the data from datablocks,
If you lost data, you have to restore it from a backup.
-when the system boots, theh fsck command is called to verify the /, /usr, /var, /tmp filesytems.
An unsuccessfull result prevents the system from booting
--at boottime
-->fsck -f /, /var, /usr, /tmp
check repair fs metadata
doesn't recover data
>Log Devices
+Creating log devices
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
Use mklv command to specify type of logical volume,jfslog or jfs2log
+Initializing log devices
The log devices are initialized using the logform command by clearing all log records, such as jfslog, jfs2log or inline logs.
The logform command does not affect the data itself.
To initialize the jfs2log device named loglv01
-->logform /dev/loglv01
D) Defragmenting a filesystem
The use of fragments and compression , as well as the creation and deletion of a large number of files, can decreses the amount of contiguous free disk space.
-->defragfs /home
To improve the status of contiguous space within a filesystem.
E)Displaying info. about inodes
-->istat filename
-->istat /etc/passwd
f)Troubleshooting filesystems problems
>Superblock errors Recovery
Errors: fsck : not an aix3 fs
fsck: not an aix4 fs
fsck : not a recognized filesystem type
mount:invalid argument
Solution :Restore the backup of the superblock ovre the primary superblock
dd count=1 bs=4k skip=31 seek=1 if=/dev/lv00 of=/dev/lv00
-->fsck -f /dev/lv00
if still not solved then recreate filesystem, restore the data from a backup.
>Cannot unmount filesystems
A filesystem cannot be unmounted if any refrences are still active within that filesystem.
The following situations can leave open references to a mounted filesystem.
+files are open within a filesystem
-->fuser /fs
Shows the running processes within fs
-->kill PID
+Running kernel extension
-->genkex
report on all loaded kernel extensions
+Filesystems are still mounted within that file system
-Unmount all the filesystems that are mounted within the filesystem to be unmounted
+A user is using a directory within the filesystems as their cwd.
-->find /home -type d -exec fuser -u {} \;
/home/prashant: 3548c(prashant)
Fuser appends the letter "c" to the process ID's of all processes that are using a directory as their cwd. The -u flag shows owner of process.
>Full filesystems
-->df
-->du
No comments:
Post a Comment