在Linux下安装XFS文件系统

2009年05月13日 作者: 大头刚 

XFS 最初是由 Silicon Graphics,Inc. 于 90 年代初开发的。那时,SGI 发现他们的现有文件系统(existing filesystem,EFS)正在迅速变得不适应当时激烈的计算竞争。为解决这个问题,SGI 决定设计一种全新的高性能 64 位文件系统,而不是试图调整 EFS在先天设计上的某些缺陷。因此,XFS 诞生了,并于 1994 年随 IRIX 5.3 的发布而应用于计算。它至今仍作为 SGI 基于 IRIX 的产品(从工作站到超级计算机)的底层文件系统来使用。现在,XFS 也可以用于 Linux。XFS 的 Linux 版的到来是激动人心的,首先因为它为 Linux 社区提供了一种健壮的、优秀的以及功能丰富的文件系统,并且这种文件系统所具有的可伸缩性能够满足最苛刻的存储需求。

1、首先确定自己的平台和版本,以redhat4为例
[root@snparty1 ~]# uname -a
Linux 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:00:54 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux

2、根据自己的平台到官方网站下载XFS以及相关包。

kernel-module-xfs-2.6.9-22.EL-0.1-1.src.rpm	v0.1, for kernels before 2.6.9-42
kernel-module-xfs-2.6.9-42.0.2.EL-0.2-1.src.rpm v0.2, for kenrels at and after 2.6.9-42
dmapi-2.2.8-1.el4.centos.x86_64.rpm
kernel-module-xfs-2.6.9-22.EL-0.1-1.src.rpm
kernel-module-xfs-2.6.9-42.0.2.EL-0.2-1.src.rpm
xfsdump-2.2.46-1.el4.centos.x86_64.rpm
xfsprogs-2.9.4-1.el4.centos.x86_64.rpm

3、编译安装

rpmbuild --rebuild --target x86_64 --define \
"kernel_topdir  /lib/modules/2.6.9-22.EL/build" \
kernel-module-xfs-2.6.9-22.EL-0.1-1.src.rpm    
 
To rebuild, do something like this:
 
rpmbuild --rebuild --target i686 --define "kernel_topdir /lib/modules/2.6.9-22.EL/build" \
kernel-module-xfs-2.6.9-22.EL-0.1-1.src.rpm
 
rpmbuild --rebuild --target x86_64 -define \
"kernel_topdir /lib/modules/2.6.9-42.ELsmp/build" \
kernel-module-xfs-2.6.9-42.0.2.EL-0.2-1.src.rpm
 
cd /usr/src/redhat/RPMS/x86_64
[root@nslave200 x86_64]# rpm -ivh kernel-module-xfs-2.6.9-42.ELsmp-0.2-1.x86_64.rpm
Preparing...                ########################################### [100%]
   1:kernel-module-xfs-2.6.9########################################### [100%]
#################################################################
#                                                               #
#                        NOTICE                                 #
# This xfs module rpm is reasonably tested, but problems may    #
# still exist.  In particular, you may have issues with the     #
# 4KSTACKS option on RHEL4 ia32 kernels, depending on your IO   #
# hardware, layering, nfs usage, etc.                           #
#                                                               #
# Please do NOT report any problems with this module, or with   #
# the kernel when this module is loaded, to Red Hat.            #
# You may report issues to the linux-xfs@oss.sgi.com list, or   #
# to the packager, Eric Sandeen <sandeen-centos@sandeen.net>    #
# (Please also report successes!)                               #
#                                                               #
#################################################################
 
 
 
rpm -ivh xfsprogs-2.9.4-1.el4.centos.x86_64.rpm
warning: xfsprogs-2.9.4-1.el4.centos.x86_64.rpm: V3 DSA signature: NOKEY, key ID 443e1821
Preparing...                ########################################### [100%]
   1:xfsprogs               ########################################### [100%]
 
 
rpm -ivh dmapi-2.2.8-1.el4.centos.x86_64.rpm 
warning: dmapi-2.2.8-1.el4.centos.x86_64.rpm: V3 DSA signature: NOKEY, key ID 443e1821
Preparing...                ########################################### [100%]
   1:dmapi                  ########################################### [100%]
 
rpm -ivh xfsdump-2.2.46-1.el4.centos.x86_64.rpm 
warning: xfsdump-2.2.46-1.el4.centos.x86_64.rpm: V3 DSA signature: NOKEY, key ID 443e1821
Preparing...                ########################################### [100%]
   1:xfsdump                ########################################### [100%]
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
 
 
/sbin/mkfs.xfs -V
mkfs.xfs version 2.9.4

4、将需要安装的磁盘转化成XFS

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p6      95G   43G   48G  48% /u01
/dev/cciss/c0d0p5      15G  688M   14G   5% /var
 
umount /dev/cciss/c0d0p6
#格式化/dev/cciss/c0d0p6,如果有重要数据先备份
/sbin/mkfs.xfs  -f /dev/cciss/c0d0p6 
meta-data=/dev/cciss/c0d0p6      isize=256    agcount=16, agsize=1579891 blks
         =                       sectsz=512   attr=0
data     =                       bsize=4096   blocks=25278256, imaxpct=25
         =                       sunit=0      swidth=0 blks, unwritten=1
naming   =version 2              bsize=4096  
log      =internal log           bsize=4096   blocks=12342, version=1
         =                       sectsz=512   sunit=0 blks, lazy-count=0
realtime =none                   extsz=4096   blocks=0, rtextents=0
 mount /dev/cciss/c0d0p6 /u01
 df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p5
              ext3     15G  688M   14G   5% /var
/dev/cciss/c0d0p6
               xfs     97G   42G   55G  44% /u01

修改/etc/fstab启动的时候自动挂载

cat /etc/fstab 
#LABEL=/u01              /u01                    ext3    defaults        1 2
/dev/cciss/c0d0p6       /u01                    xfs      defaults        1 2

OK,至此安装全部完成。

  • Comments (2)
  • Trackbacks (1)
Leave a comment Trackback

  • higkoo 1F

    09月 20th, 2009 at 10:11

    写得非常好!

    很容易理解和阅读,支持一下!

  • Nova 2F

    10月 2nd, 2009 at 16:55

    顶一下,src不如rpm省事。。