Contents
- Creation of Filesystem
- Mount/Unmount Filesystem
- List Filesystems
- Display Filesystem usage
- Resize Filesystems
- Modify/Change Filesystem
- Remove Filesystems
- Freeze File System
- Split mirrored copy from FS
- defrag filesystem
- fuser & file systems
- Filesystem Checking & Repairing
- Miscellaneous Filesystem Commands
1) Creation of Filesystem:
The crfs command creates a file system on a logical volume within a previously created volume group.A new logical volume is created for the file system unless the name of an existing 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 the file system.
-m Specifies the mount point, which is the directory where the file system will 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 mount -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 reduce/shrink the filesystem size but you cannot reduce a jfs filesystem.
# 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 the file system.
-m Specifies the mount point, which is the directory where the file system will 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 mount -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 reduce/shrink the filesystem size but you cannot reduce a jfs filesystem.
2) mount/unmount Filesystems:
mount is the command used to mount filesystemsmount [<fs>|<lv>] mount -a mount allTo unmount filesystem use "umount"
umount <fs> Note: You can't write into or read any content from filesystem when its in unmounted 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 to 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 filesystem 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, the 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 2nd 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 2nd decimal digit.
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 2nd 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 2nd 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
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)
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 logical volume is removed as well.
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 logical 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, maybe 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>
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-only mode for backup purpose
chfs -a splitcopy=/backup -a copy=2 /testfs
This will mount the 2nd copy of mirrored filesystem testfs to /backup in read-only mode for backup purpose
10) defrag fielsystem:
The defragfs command can be used to improve or report the status of contiguous space 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
#
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/passwd 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
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"
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
fileplace <filename> ==> displays the placement of file blocks within logical or physical volumes, it will show if a file fragmented
No comments:
Post a Comment