daimoway
作者daimoway·2012-11-28 15:37
软件开发工程师·dearwears

AIX基础笔记(8) File systems administration

字数 41973阅读 4061评论 0赞 1

*JFS2 structural components

  - Superblock: The superblock maintains informaition about the entire file system.

  - i-nodes: Each file and directory has an i-node that contains access information such as file type, access permissions, owner's ID, and number of links to that file.

  - Data blocks: Contains file data; Each file system has a user settable fixed block size attribute -- 512, 1024, 2048 or 4096 bytes.

  - Allocation maps: Record the location and allocation of all i-nodes and the allocation state of each data block.

  - Allocation groups: Responsible for dividing the file system space into chunks so related data blocks and i-nodes can be clustered together to achieve good locality.

 

*Listing i-node and block size information

(1) To view i-node information:

# ls -li

total 0

73863 -rw-rw-r--    1 root     system            0 Mar 26 16:06 newfile

# istat newfile

Inode 73863 on device 10/7      File

Protection: rw-rw-r--

Owner: 0(root)          Group: 0(system)

Link count:   1         Length 0 bytes

 

Last updated:   Mon Mar 26 16:16:05 GMT+08:00 2012

Last modified:  Mon Mar 26 16:06:59 GMT+08:00 2012

Last accessed:  Mon Mar 26 16:06:59 GMT+08:00 2012

(2) To view file system block size informaiton:

# lsfs -cq /

#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct

/:/dev/hd4:jfs2::bootfs:155189248:rw:yes:no

  (lv size 155189248:fs size 155189248:block size 4096:sparse files yes:inline log no:inline log size 0:EAformat v1:Quota no:DMAPI no:VIX yes:EFS no:ISNAPSHOT no:MAXEXT 0)

 

*Creating a JFS2 file system

# crfs -v jfs2 -g datavg -a size=1G -m /pdmdata   (or)

# smitty crfs_j2

                     Add an Enhanced Journaled File System

 

Type or select values in entry fields.

Press Enter AFTER making all desired changes.

 

                                                        [Entry Fields]

  Volume group name                                   datavg

  SIZE of file system

          Unit Size                                   Gigabytes              +

*         Number of units                            [1]                      #

* MOUNT POINT                                        [/pdmdata]

  Mount AUTOMATICALLY at system restart?              no                     +

  PERMISSIONS                                         read/write             +

  Mount OPTIONS                                      []                      +

  Block Size (bytes)                                  4096                   +

  Logical Volume for Log                                                     +

  Inline Log size (MBytes)                           []                       #

  Extended Attribute Format                                                  +

  ENABLE Quota Management?                            no                     +

  Enable EFS?                                         no                     +

  Allow internal snapshots?                           no                     +

  Mount GROUP                                        []

# lsfs /pdmdata

Name            Nodename   Mount Pt               VFS   Size    Options    Auto Accounting

/dev/fslv01     --         /pdmdata               jfs2  629145600 --         no   no

# lsvg -l datavg

datavg:

LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT

datelv01            jfs2       600     600     1    closed/syncd  N/A

loglv00             jfs2log    1       1       1    closed/syncd  N/A

fslv01              jfs2       1200    1200    2    closed/syncd  /pdmdata

 

*Mounting a file system and the /etc/filesystems file

# grep -p /pdmdata /etc/filesystems

/pdmdata:

        dev             = /dev/fslv01

        vfs             = jfs2

        log             = /dev/loglv00

        mount           = false

        account         = false

 

# mount /pdmdata

# mount | egrep '(/pdmdata|node)'

  node       mounted        mounted over    vfs       date        options

         /dev/fslv01      /pdmdata         jfs2   Mar 27 14:32 rw,log=/dev/loglv00

 

*JFS2 logging options

For JFS2 file systems, there are three logging options:

(1) Use the global JFS log for the volume group.

(2) Create a specific JFS log for each file system.

    - 1 LP in size

    - Format the log using the logform command.

# mklv -y my_jfs2_log -t jfs2log datavg 1

# logform /dev/my_jfs2_log

logform: destroy /dev/my_jfs2_log (y) ? y

# crfs -v jfs2 -g datavg -a size=1G -m /data -a logname=my_jfs2_log

(3) Create an inline log inside the file system: 0.4% of the file system space will be reserved for this option.

# crfs -v jfs2 -g datavg -a size=1G -m /data -a logname=INLINE  [(or) -a logsize=<value in MB>]

 

*Creating a file system on a previously defined logical volume

# crfs -v jfs2 -d lv_for_data -m /data2 -A yes   (or)

# smitty crfs_j2

                     Add an Enhanced Journaled File System

 

Type or select values in entry fields.

Press Enter AFTER making all desired changes.

 

                                                        [Entry Fields]

* LOGICAL VOLUME name                                 lv_for_data              +

* MOUNT POINT                                        [/data2]

  Mount AUTOMATICALLY at system restart?              no                     +

  PERMISSIONS                                         read/write             +

  Mount OPTIONS                                      []                      +

  Block Size (bytes)                                  4096                   +

  Logical Volume for Log                                                     +

  Inline Log size (MBytes)                           []                       #

  Extended Attribute Format                                                  +

  ENABLE Quota Management?                            no                     +

  Enable EFS?                                         no                     +

  Allow internal snapshots?                           no                     +

  Mount GROUP                                        []

 

*Changing the size of a JFS2 file system

  - To increase the size of a file system:

# chfs -a size=+1G /data2

  - To shrink the size of a file system:

# chfs -a size=-500M /data2

  - Using SMIT:

# smitty chjfs2

       Change / Show Characteristics of an Enhanced Journaled File System

 

Type or select values in entry fields.

Press Enter AFTER making all desired changes.

 

                                                        [Entry Fields]

  File system name                                    /pdmdata

  NEW mount point                                    [/pdmdata]

  SIZE of file system

          Unit Size                                   Gigabytes              +

          Number of units                            [600]                    #

  Mount GROUP                                        []

  Mount AUTOMATICALLY at system restart?              no                     +

  PERMISSIONS                                         read/write             +

  Mount OPTIONS                                      []                      +

  Start Disk Accounting?                              no                     +

  Block Size (bytes)                                  4096

  Inline Log?                                         no

  Inline Log size (MBytes)                           [0]                      #

  Extended Attribute Format                          [v1]

  ENABLE Quota Management?                            no                     +

  Allow Small Inode Extents?                          yes                    +

  Enable EFS?                                         no                     +

 

*Removing a JFS2 file system

(1) The file system must first be unmounted

(2) Using SMIT:

# smitty rmfs

                    Remove an Enhanced Journaled File System

 

Type or select values in entry fields.

Press Enter AFTER making all desired changes.

 

                                                        [Entry Fields]

* FILE SYSTEM name                                    /data2                   +

  Remove Mount Point                                  no                     +

(3) The syntax of the rmfs command:

rmfs [-r] [-i] Filesystem

-r : Removes the mountpoint of the file system

-i : Displays warning and prompts the user before removing the file system

 

*File system space management

(1) File systems expand upon notice, not automatically.

(2) To keep from running into problems:

  - Monitor file system growth

  - Determine causes

  - Control growing files

  - Manage file system space usage

  - Control user disk usage

  - Block size considerations

  - Fragmentation considerations

 

*Listing file system utilization

# df -g

Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on

/dev/hd4          74.00      5.33   93%   153333    11% /

/dev/hd2          10.00      6.56   35%    57099     4% /usr

/dev/hd9var       10.00      9.72    3%     4477     1% /var

/dev/hd3          10.00      6.35   37%     2509     1% /tmp

/dev/fwdump        1.00      1.00    1%       13     1% /var/adm/ras/platform

/dev/hd1          39.50     19.70   51%      278     1% /home

/dev/hd11admin      0.50      0.50    1%        5     1% /admin

/proc                 -         -    -         -     -  /proc

/dev/hd10opt      10.00      8.86   12%    13436     1% /opt

/dev/livedump      0.50      0.50    1%        4     1% /var/adm/ras/livedump

/dev/fslv00      100.00     50.01   50%   234694     2% /ptc

/dev/fslv02       60.00     49.62   18%    51120     1% /oracle

/dev/fslv03       10.00      2.98   71%     2503     1% /ftp

x3550-PC:print     70.70     58.23   18%        0     0% /ptc/Windchill/temp/print

/dev/fslv01      300.00    277.70    8%    24176     1% /pdmdata

# df -k

Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on

/dev/hd4         77594624   5593508   93%   153333    11% /

/dev/hd2         10485760   6881712   35%    57099     4% /usr

/dev/hd9var      10485760  10193892    3%     4477     1% /var

/dev/hd3         10485760   6653388   37%     2509     1% /tmp

/dev/fwdump       1048576   1046916    1%       13     1% /var/adm/ras/platform

/dev/hd1         41418752  20656480   51%      278     1% /home

/dev/hd11admin      524288    523848    1%        5     1% /admin

/proc                   -         -    -         -     -  /proc

/dev/hd10opt     10485760   9293388   12%    13436     1% /opt

/dev/livedump      524288    523880    1%        4     1% /var/adm/ras/livedump

/dev/fslv00     104857600  52437892   50%   234694     2% /ptc

/dev/fslv02      62914560  52025260   18%    51120     1% /oracle

/dev/fslv03      10485760   3120960   71%     2503     1% /ftp

x3550-PC:print    74136572  61054548   18%        0     0% /ptc/Windchill/temp/print

/dev/fslv01     314572800 291192540    8%    24176     1% /pdmdata

# df -m

Filesystem    MB blocks      Free %Used    Iused %Iused Mounted on

/dev/hd4       75776.00   5462.41   93%   153333    11% /

/dev/hd2       10240.00   6720.42   35%    57099     4% /usr

/dev/hd9var    10240.00   9954.97    3%     4477     1% /var

/dev/hd3       10240.00   6497.45   37%     2509     1% /tmp

/dev/fwdump     1024.00   1022.38    1%       13     1% /var/adm/ras/platform

/dev/hd1       40448.00  20172.34   51%      278     1% /home

/dev/hd11admin    512.00    511.57    1%        5     1% /admin

/proc                 -         -    -         -     -  /proc

/dev/hd10opt   10240.00   9075.57   12%    13436     1% /opt

/dev/livedump    512.00    511.60    1%        4     1% /var/adm/ras/livedump

/dev/fslv00   102400.00  51208.88   50%   234694     2% /ptc

/dev/fslv02    61440.00  50805.92   18%    51120     1% /oracle

/dev/fslv03    10240.00   3047.81   71%     2503     1% /ftp

x3550-PC:print  72399.00  59623.58   18%        0     0% /ptc/Windchill/temp/print

/dev/fslv01   307200.00 284367.71    8%    24176     1% /pdmdata

# df -i

Filesystem    512-blocks      Free %Used    Iused %Iused Mounted on

/dev/hd4       155189248  11187016   93%   153333    11% /

/dev/hd2        20971520  13763424   35%    57099     4% /usr

/dev/hd9var     20971520  20387784    3%     4477     1% /var

/dev/hd3        20971520  13306776   37%     2509     1% /tmp

/dev/fwdump      2097152   2093832    1%       13     1% /var/adm/ras/platform

/dev/hd1        82837504  41312960   51%      278     1% /home

/dev/hd11admin    1048576   1047696    1%        5     1% /admin

/proc                  -         -    -         -     -  /proc

/dev/hd10opt    20971520  18586776   12%    13436     1% /opt

/dev/livedump    1048576   1047760    1%        4     1% /var/adm/ras/livedump

/dev/fslv00    209715200 104875736   50%   234694     2% /ptc

/dev/fslv02    125829120 104050520   18%    51120     1% /oracle

/dev/fslv03     20971520   6241920   71%     2503     1% /ftp

x3550-PC:print  148273144 122109096   18%        0     0% /ptc/Windchill/temp/print

/dev/fslv01    629145600 582385080    8%    24176     1% /pdmdata

# df -I

Filesystem    512-blocks      Used      Free %Used Mounted on

/dev/hd4       155189248 144002232  11187016   93% /

/dev/hd2        20971520   7208096  13763424   35% /usr

/dev/hd9var     20971520    583736  20387784    3% /var

/dev/hd3        20971520   7664744  13306776   37% /tmp

/dev/fwdump      2097152      3320   2093832    1% /var/adm/ras/platform

/dev/hd1        82837504  41524544  41312960   51% /home

/dev/hd11admin    1048576       880   1047696    1% /admin

/proc                  -         -         -    -  /proc

/dev/hd10opt    20971520   2384744  18586776   12% /opt

/dev/livedump    1048576       816   1047760    1% /var/adm/ras/livedump

/dev/fslv00    209715200 104839728 104875472   50% /ptc

/dev/fslv02    125829120  21778600 104050520   18% /oracle

/dev/fslv03     20971520  14729600   6241920   71% /ftp

x3550-PC:print  148273144  26164048 122109096   18% /ptc/Windchill/temp/print

/dev/fslv01    629145600  46760520 582385080    8% /pdmdata

 

*Monitoring file system growth

A simple script using the df command, which can be run at regular intervals to warn against file systems becoming full

#!/bin/ksh

 

df | egrep -v '(used|proc)' | awk '{print $4" "$7}'

 | sed 's:%::g' | while read LINE

do

  PERC=`echo $LINE | awk '{print $1}'`

  FILESYSTEM=`echo $LINE | awk '{print $2}'`

 

  if [ $PERC -gt 70 ]

  then

        mail -s "Filesystem check on box: `hostname`"

                seven.hpf@hotmai.com <<EOF

        $FILESYSTEM is $PERC% full, please check

EOF

  fi

done

 

*Listing disk usage

du [-k] [-m] [-g] [-]

# du -sg .

0.00    .

# du newfile.sh

8       newfile.sh

# du -sm * | sort -rn

0.00    newfile.sh

# du -ax

560     ./Snap.20110927.135433.4259858.0003.trc

608     ./Snap.20111007.101649.4063266.0003.trc

560     ./Snap.20111007.164235.3866898.0003.trc

1104    ./Snap.20111011.163558.5832924.0008.trc

48      ./Snap.20111011.163558.5832924.0009.trc

48      ./Snap.20111011.163558.5832924.0010.trc

48      ./Snap.20111011.163558.5832924.0011.trc

768     ./Snap.20111011.170913.5767352.0003.trc

4694016 ./core.20111007.101649.4063266.0001.dmp

5093808 ./core.20111011.170913.5767352.0001.dmp

19296   ./heapdump.20110927.135433.4259858.0001.phd

19560   ./heapdump.20111007.164235.3866898.0001.phd

844264  ./heapdump.20111011.163558.5832924.0001.phd

844264  ./heapdump.20111011.163558.5832924.0002.phd

844256  ./heapdump.20111011.163558.5832924.0003.phd

844256  ./heapdump.20111011.163558.5832924.0004.phd

1440    ./javacore.20110927.135433.4259858.0002.txt

2352    ./javacore.20111007.101649.4063266.0002.txt

1416    ./javacore.20111007.164235.3866898.0002.txt

5016    ./javacore.20111011.163558.5832924.0005.txt

5016    ./javacore.20111011.163558.5832924.0006.txt

5008    ./javacore.20111011.163558.5832924.0007.txt

5008    ./javacore.20111011.163558.5832924.0012.txt

6416    ./javacore.20111011.170913.5767352.0002.txt

8       ./mvlogs.sh

8       ./start_DS.sh

8       ./start_all_root.sh

8       ./start_apache.sh

8       ./start_windchill.sh

8       ./stop_DS.sh

8       ./stop_all_root.sh

8       ./stop_apache.sh

8       ./stop_windchill.sh

13239216        .

# find / -size +1000000c

 

*Control growing files

(1) Growing files should be monitored and cleaned out periodically. Some of the files that grow are listed below:

-- /var/adm/wtmp

-- /etc/security/failedlogin

-- /var/adm/sulog           //can be edited directly

 

-- /var/spool/*/*

-- /var/tmp/*

 

-- $HOME/smit*

-- $HOME/websm*

(2) Two ways of overwriting a log file :

Example 1:

# cat test1

just a test!

# touch test2

# cat test2 > test1

# cat test1

#

Example 2:

# cat test3

just a test!

# > test3

# cat test3

#

(3) The /var/spool directory

The directory /var/spool contains cron entries, the mail, and other items that grow on an ongoing basis, along with printer files. If there is a problem with the printer files, you can try to clear the queuing subsystem by executing the following commands:

Stopsrc -s qdaemon

rm /var/spool/lpd/qdir/*

rm /var/spool/lpd/stat/*

rm /var/spool/qdaemon/*

startsrc -s qdaemon

 

*The skulker command

  - The skulker command cleans up file systems by removing unwanted or obsolete files.

  - Candidate files include:

     (1) Files older than a selected age

     (2) Files in the /tmp, /var/spool, /var/tmp, /var/news directories

     (3) a.out, *.bak, core, ed.hup files

  - skulker is normally invoked daily by the cron command as part of the crontab file of the root user. (Disabled by default)

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

 

*Verify and repair a file system

(1) fsck command

-- Checks file system consistency and interactively repairs the file system

-- If no file system name is specified, the fsck command checks all file systems which have the check=true attribute set in the /etc/filesystems.

-- Orphan files are placed in the lost+found directory.

(2) Unmount the file system before running fsck.

# fsck /data

 

*Documenting file system setup

-- Run the lsfs command.

-- Save the contents of the /etc/filesystems file.

-- Run the df command to check space allocation.

-- Check all the mounted file systems by running the mount command.

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

1

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广