xfs文件系统挂载大容量磁盘
公司新购了台存储,24块SATA盘,每块2T,用22块做了两组RAID6,剩余两块为热备;两组RAID6的物理卷放进了一个逻辑卷,由此这个逻辑卷直达32T。
OS版本:centos 6.3
# lvdisplay
--- Logical volume ---
LV Path /dev/VolGroup01/LogVol00
LV Name LogVol00
VG Name VolGroup01
LV UUID Ts6MOq-etKx-GDPU-0AHF-jIMi-pqrz-cssj7v
LV Write Access read/write
LV Creation host, time ,
LV Status available
# open 0
LV Size 32.70 TiB
Current LE 8570874
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
以前从来没格式化过这么大空间的卷,尝试用ext4,做了好多遍都没能成功;改用xfs,终于搞定,在此记一笔。
1、修改yum配置文件,找到centosplus将enabled=0改为1
#vim /etc/yum.repos.d/CentOS-Base.repo
[centosplus]
enabled=1
2、添加xfs需要的用户组
#useradd mockbuild
3、安装xfs相关包,挂载xfs内核
# yum install xfsprogs kmod-xfs xfsdump xfsprogs-devel
# modprobe xfs
# lsmod |grep xfs
xfs 1042331 0
exportfs 4236 1 xfs
4、看看mkfs.xfs的参数选项
# mkfs.xfs --help
mkfs.xfs: invalid option -- '-'
unknown option --
Usage: mkfs.xfs
/* blocksize */ [-b log=n|size=num]
/* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num,
(sunit=value,swidth=value|su=num,sw=num),
sectlog=n|sectsize=num
/* inode size */ [-i log=n|perblock=n|size=num,maxpct=n,attr=0|1|2,
projid32bit=0|1]
/* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n
sunit=value|su=num,sectlog=n|sectsize=num,
lazy-count=0|1]
/* label */ [-L label (maximum 12 characters)]
/* naming */ [-n log=n|size=num,version=2|ci]
/* prototype file */ [-p fname]
/* quiet */ [-q]
/* realtime subvol */ [-r extsize=num,size=num,rtdev=xxx]
/* sectorsize */ [-s log=n|size=num]
/* version */ [-V]
devicename
<devicename> is required unless -d name=xxx is given.
<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
<value> is xxx (512 byte blocks).
5、开始格式化
# mkfs.xfs -f -i size=512 -l size=128m,lazy-count=1 -d agcount=16 /dev/VolGroup01/LogVol00
agsize (548535936 blocks) too big, maximum is 268435455 blocks
提示agsize太大了,增大agcount到32试试
# mkfs.xfs -f -b size=16384 -i size=512 -l size=128m,lazy-count=1 -d agcount=32 /dev/VolGroup01/LogVol00
agsize (68566992 blocks) too big, maximum is 67108863 blocks
还是提示agsize太大,不过68566992 blocks已经不比maximum值大多少了,再增大agcount一倍试试
# mkfs.xfs -f -i size=512 -l size=128m,lazy-count=1 -d agcount=64 /dev/VolGroup01/LogVol00
meta-data=/dev/VolGroup01/LogVol00 isize=512 agcount=64, agsize=137133984 blks
= sectsz=512 attr=2, projid32bit=0
data = bsize=4096 blocks=8776574976, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=32768, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
以上显示已经格式化成功,块大小是默认大小4K;下面mount到/data下,挂载成功!
# mount -t xfs /dev/VolGroup01/LogVol00 /data
期间尝试过将块大小设大一点,比如16K,格式化可以完成,但挂载时总是报错;
# mkfs.xfs -f -b size=16384 -i size=512 -l size=128m,lazy-count=1 -d agcount=64 /dev/VolGroup01/LogVol00
meta-data=/dev/VolGroup01/LogVol00 isize=512 agcount=64, agsize=34283496 blks
= sectsz=512 attr=2, projid32bit=0
data = bsize=16384 blocks=2194143744, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=16384 ascii-ci=0
log =internal log bsize=16384 blocks=8192, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=16384 blocks=0, rtextents=0
# mount -t xfs /dev/VolGroup01/LogVol00 /data
mount: Function not implemented
# pagesize
4096
在XFS官网文档里貌似找到了答案:
mkfs - Allocation Block Size
Specify the fundamental allocation block size of the filesystem.
The default value is 4KB, the minimum is 512 bytes, and the maximum is 64KB
XFS on Linux currently only supports pagesize or smaller blocks.
To create a filesystem with a block size of 2048 bytes you would use:
mkfs.xfs -b size=2048 device
Smaller block sizes reduce wasted space for lots of small files.
就是说格式化的时候块大小要小于等于操作系统pagesize