作者:h2appy
轉載請註明出處。
網上有些文章說XFS不用做磁碟重組,其實是錯誤的。XFS用延遲寫入等技術確實可以減少片段的出現,但是如果伺服器用了幾年,並且檔案操作比較頻繁,還是會出現片段的,應該整理。注意:在Debian中XFS相關命令在xfsprogs包中,而xfs_fsr命令是在xfsdump包中的。所以要用xfs_fsr整理片段,記得安裝xfsdump包。 其他Linux發行版本中,包含xfs相關命令的包也應該叫類似的名字,自己google一下。
xfsdump - Administrative utilities for the XFS filesystem
xfslibs-dev - XFS filesystem-specific static libraries and headers
xfsprogs - Utilities for managing the XFS filesystem
一、查看片段
1、查看/dev/sdc1的片段情況:
# xfs_db -c frag -r /dev/sdc1
actual 93133, ideal 8251, fragmentation factor 91.14%
這個應該整理一下片段了
2、查看/dev/sdb1的片段情況:
# xfs_db -c frag -r /dev/sdb1
actual 905607, ideal 900507, fragmentation factor 0.56%
這個不用做磁碟重組。
3、另一種命令形式:
# xfs_db -r /dev/sdd1
xfs_db> frag
actual 117578, ideal 116929, fragmentation factor 0.55%
4、也可以通過xfs_bmap命令瞭解某個檔案的情況:
# xfs_bmap -v case19.dat
case19.dat:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL
0: [0..9551]: 592061576..592071127 1 (103696496..103706047) 9552
1: [9552..86039]: 599312816..599389303 1 (110947736..111024223) 76488
2: [86040..170399]: 599655400..599739759 1 (111290320..111374679) 84360
3: [170400..256799]: 599751632..599838031 1 (111386552..111472951) 86400
4: [256800..340079]: 1185490752..1185574031 2 (208760592..208843871) 83280
5: [340080..592703]: 1185577976..1185830599 2 (208847816..209100439) 252624
二、整理片段
# xfs_fsr /dev/sdc1
三、他從xfs_fsr得到了好處:) (摘自http://www.linux.com/feature/141404 )
Wow! Thanks. That'l teach me to use a non-default tech without researching it.
Over the years, my MythTV box had gotten inexplicably slow with lots of disk access for many operations like starting playback of a recorded video. With the advice here, I measured 98.6% fragmentation. A few sample files I checked that were 1-6GB captured MPEG-2 videos were stored on over 30,000 extents!
After 2 nights of de-fragmenting, I'm down to 17% fragmented and startup time of playing a video is noticeably faster with less hard drive activity.
四、參考
http://www.linux.com/feature/141404
http://www.nekochan.net/wiki/index.php/XFS_defragmentation
http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fname=/usr/share/catman/a_man/cat1/fsr_xfs.z