Linux下的磁盘碎片整理

Linux下的磁盘碎片整理

网上有些帖子说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
&nbsp, nike tn;          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
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值