Linux #3 : File & File System Management

Cheking Support Filesystem

$ cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   cpuset
nodev   binfmt_misc
nodev   debugfs
nodev   securityfs
nodev   sockfs
nodev   usbfs
nodev   pipefs
nodev   futexfs
nodev   tmpfs
nodev   inotifyfs
nodev   eventpollfs
nodev   devpts
ext2
nodev   ramfs
nodev   hugetlbfs
iso9660
nodev   mqueue
ext3
nodev   rpc_pipefs
nodev   nfs
nodev   nfs4

nodev는 block device에 Mount 되어 있지 않다는 것을 표시합니다.

또한, 아래 Command를 통해서 실제 Kernel Module로서 준비되어 있는 filesystem 확인이 가능합니다. NTFS의 경우, FUSE(Filesystem in Userspa)를 이용하기 때문에 아래 Command로도 표시되지 않습니다.

$ modprobe -l -t kernel/fs
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/autofs4/autofs4.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/cachefiles/cachefiles.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/cifs/cifs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/configfs/configfs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/cramfs/cramfs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/dlm/dlm.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/ecryptfs/ecryptfs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/exportfs/exportfs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/ext3/ext3.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/fat/fat.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/freevxfs/freevxfs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/fscache/fscache.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/gfs2/gfs2.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/hfs/hfs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/hfsplus/hfsplus.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/jbd/jbd.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/jffs2/jffs2.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/gfs2/locking/dlm/lock_dlm.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/gfs2/locking/nolock/lock_nolock.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/lockd/lockd.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/msdos/msdos.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nfs/nfs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nfs_common/nfs_acl.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nfsd/nfsd.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp1250.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp1251.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp1255.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp737.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp775.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp850.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp852.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp855.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp857.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp860.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp861.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp862.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp863.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp864.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp865.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp866.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp869.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp874.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp932.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp936.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp949.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_cp950.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_euc-jp.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-1.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-13.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-14.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-15.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-2.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-3.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-4.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-5.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-6.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-7.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_iso8859-9.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_koi8-r.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_koi8-ru.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_koi8-u.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/nls/nls_utf8.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/squashfs/squashfs.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/udf/udf.ko
/lib/modules/2.6.18-92.1.22.el5/kernel/fs/vfat/vfat.ko

FileSystem Benchmark : IOzone (http://www.iozone.org/)

source나 binary로 직접 설치가능하고, 일부 OS는 rpm version로도 설치 할 수 있다.  설치 후 아래와 같은 명령어로 측정이 가능하다.

$ iozone -i 1 -i 2 -Rab bmt.xls

각 Option들에 대한 설명을 덧붙이면,

Option Detail
-a 자동 Test Mode
-b 출력 File의 이름을 지정
-i 숫자 Test 내용을 지정
0
write/rewrite
1
read/re-read
2
random-read/write
3
Read-backwards
4
Re-write-record
5
stride-read
6
fwrite/re-fwrite
7
fread/Re-fread
8
random mix
9
pwrite/Re-pwrite
10
pread/Re-pread
11
pwritev/Re-pwritev
12
preadv/Repreadv
-R Excel로 결과를 출력

Checking i-Node Information

i-Node는 file의 소유권 및 Size, Access 권한, 작성일시, Data 영역으로의 Pointer등의 각종 정보가 기록되는 영역이다. UNIX계열의 OS는 file의 실제 영역을 Data와 i-Node로 구분하고 있다.

Linux에서 일반적으로 사용하는 ext2, ext3등은 file system 작성 시 i-Node size가 최대치로 결정되고 있다. i-Node가 100%가 되는 경우는 그다지 많지 않지만, 경우에 따라 실제 사용량이 적더라도 i-Node가 부족하게 되어 문제가 발생하는 경우가 가끔 있다.

$ df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/cciss/c0d0p2    10487712  241540 10246172    3% /
/dev/cciss/c0d0p6    41779200   48899 41730301    1% /home
/dev/cciss/c0d0p1      26104      39   26065    1% /boot
tmpfs                 505813       1  505812    1% /dev/shm

여기서 Inodes는 할당 가능한 i-Node 수, IUsed는 이미 할당된 i-Node수, IFree는 아직 할당되지 않은 i-Node수이다.

특정 file이나 directory의 i-Node 정보를 확인 할 때에는 “stat” command가 유리하다.

$ stat vpd.properties
File: `vpd.properties'
Size: 1557            Blocks: 8          IO Block: 4096   regular file
Device: 6802h/26626d    Inode: 68927       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2009-10-13 16:22:20.000000000 -0700
Modify: 2009-10-13 16:23:14.000000000 -0700
Change: 2009-10-13 16:23:14.000000000 -0700

Disk 사용량이 높은 Directory의 확인

du와 sort를 조합하면 가능하다.

$ du -S | sort -n
8       ./archive
8       ./cache
8       ./exports
8       ./lib_ext
8       ./tmp
20      ./lib_ext/xml
24      ./upgrade
76      ./images
80      ./lib_ext/graidle
236     ./lib_int
264     ./lib_ext/pclzip
356     .
608     ./lib_ext/fonts

File System Check Timing의 표시 및 변경

ext3의 경우 Mount/Unmount를 일정 횟수 이상 행하면, 자동적으로 e2fsck에 의한 file system check가 이루어 진다. Mount 횟수는 Super Block(file system의 관리정보를 기록하는 장소)의 Mount count에 보존되어 있고,  check를 행하는 Timing은 Maximum mount count에 보존되어 Mount count = Maximum mount count일 경우 check를 행한다.

Mount count나 Maximum mount count의 현재 상태를 확인 할 경우 “tune2fs” command를 사용한다.

$ tune2fs -l /dev/cciss/c0d0p6
tune2fs 1.39 (29-May-2006)
Filesystem volume name:   /home
Last mounted on:          <not available>
Filesystem UUID:          e2b6586f-7c2c-419c-8728-47f6cb400cfc
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              41779200
Block count:              41758951
Reserved block count:     2087947
Free blocks:              32709952
Free inodes:              41754947
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1014
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         32768
Inode blocks per group:   1024
Filesystem created:       Wed Aug  5 14:03:26 2009
Last mount time:          Mon Sep 28 15:21:23 2009
Last write time:          Mon Sep 28 15:21:23 2009
Mount count:              6    <= Mount 횟수
Maximum mount count:      -1   <= Check를 실시하는 Mount 횟수
Last checked:             Wed Aug  5 14:03:26 2009
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8
First orphan inode:       9961478
Default directory hash:   tea
Directory Hash Seed:      943c992f-8347-46dd-b47f-a26f4c9882c4
Journal backup:           inode blocks

dumpe2fs -h [Device Name]으로도 동일한 결과를 얻을 수 있다. Check Timing을 변경할 시, tune2fs에 -c 횟수 Option을 넣는다.

$ tune2fs -c 10 /dev/cciss/c0d0p6

/etc/fstab에 기입되어 있는 숫자의 의미

System 기동시에 Mount되는 Device는 /etc/fstab에 설정된다.

$ more /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/home             /home                   ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SW-cciss/c0d0p3   swap                    swap    defaults        0 0
LABEL=SW-cciss/c0d0p5   swap                    swap    defaults        0 0

첫번째 열은 Mount할 Block Device나 Label 등이, 두번째 열은 Mount Location, 세번째 열은 File system의 종류, 네번째 열은 Mount 시의 Option이된다.

다섯번째, 여섯번째는 숫자가 기입되어 있는데, 전자의 숫자는 File system을 dump할 필요가 있는지의 유무이고(0:Zero이거나 기술이 없는 경우 dump 불필요), 후자의 숫자는 System 기동시 fsck check를 행할 지의 유무로 0:Zero의 경우 check를 하지 않는다. root file system의 경우는 check를 할 경우 1로 설정, 그 외 file system의 경우는 2일경우 check를 행한다.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.