XFS文件系統


XFS WIKI介紹

XFS is a high-performance 64-bit journaling file system created by Silicon Graphics, Inc (SGI) in 1993.[6] It was the default file system in SGI's IRIX operating system starting with its version 5.3. XFS was ported to the Linux kernel in 2001; as of June 2014, XFS is supported by most Linux distributions, some of which use it as the default file system.

XFS excels in the execution of parallel input/output (I/O) operations due to its design, which is based on allocation groups (a type of subdivision of the physical volumes in which XFS is used- also shortened to AGs). Because of this, XFS enables extreme scalability of I/O threads, file system bandwidth, and size of files and of the file system itself when spanning multiple physical storage devices. XFS ensures the consistency of data by employing metadata journaling and supporting write barriers. Space allocation is performed via extents with data structures stored in B+ trees, improving the overall performance of the file system, especially when handling large files. Delayed allocation assists in the prevention of file system fragmentation; online defragmentation is also supported. A feature unique to XFS is the pre-allocation of I/O bandwidth at a pre-determined rate; this is suitable for many real-time applications. However, this feature was supported only on IRIX, and only with specialized hardware.

A notable XFS user, NASA Advanced Supercomputing Division, takes advantage of these capabilities deploying two 300+ terabyte XFS filesystems on two SGI Altix archival storage servers, each of which is directly attached to multiple Fibre Channel disk arrays.[7]

XFS優缺點

XFS是高性能文件系統,由於它的高性能,XFS成為了許多企業級系統的首選,特別是有大量數據,需要結構化伸縮性和穩定性的。例如,RHEL/CentOS 7 和Oracle Linux將XFS作為默認文件系統,SUSE/openSUSE已經為XFS做了長期支持。

XFS有許多獨特的性能提升功能使他從眾多文件系統中脫穎而出,像可伸縮/並行 IO,元數據日志,熱碎片整理,IO 暫停/恢復,延遲分配等。

XFS 文件系統有一些缺陷,例如它不能壓縮,刪除大量文件時性能低下

XFS工具集安裝

yum install xfsprogs

Linux 7以上版本,系統將XFS作為默認文件系統。

[root@localhost ~]# lsb_release -d
Description:    CentOS Linux release 7.5.1804 (Core)

我在虛擬層划分了一塊磁盤500G,/dev/sdb給與虛擬機。

XFS文件系統裝載

查看已經划分好的/dev/sdb磁盤

[root@localhost ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk 
sda      8:0    0   40G  0 disk 
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0 29.8G  0 part /
└─sda3   8:3    0   10G  0 part [SWAP]
sdb      8:16   0  500G  0 disk /data
sr0     11:0    1 1024M  0 rom

xfx文件系統格式化

[root@mylnx008 ~]# mkfs.xfs -f  /dev/sdb

掛載XFS文件系統

[root@mylnx008 ~]# mkdir /data
[root@mylnx008 ~]# mount  -t  xfs  /dev/sdb  /data
[root@localhost ~]# df -h
文件系統        容量  已用  可用 已用% 掛載點
/dev/sda2        30G  1.4G   27G    5% /
devtmpfs        1.9G     0  1.9G    0% /dev
tmpfs           1.9G     0  1.9G    0% /dev/shm
tmpfs           1.9G  8.8M  1.9G    1% /run
tmpfs           1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda1       190M  139M   38M   79% /boot
tmpfs           380M     0  380M    0% /run/user/0
/dev/sdb        500G   33M  500G    1% /data

配置/etc/fstab文件

[root@localhost ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Thu Jun 28 13:45:55 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=f9c28539-1313-4a49-a3ed-475f43dd6bad /                       ext4    defaults        1 1
UUID=cabeff84-ec5d-45d0-b74b-b19499a8608f /boot                   ext4    defaults        1 2
UUID=8a13be64-ef16-4acd-9988-38b9df9b8273 swap                    swap    defaults        0 0
/dev/sdb                                  /data                   xfs     defaults        0 0

XFS擴容

由於XFS可以橫向擴展.
在虛擬層/dev/sdb擴展到2TB。

查看命令

[root@localhost ~]# xfs_info /data
meta-data=/dev/sdb               isize=512    agcount=8, agsize=32768000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=262144000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=64000, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

可以看到/data目錄的掛載點是/dev/sdb

在線動態擴展

[root@localhost ~]# xfs_growfs /data
meta-data=/dev/sdb               isize=512    agcount=8, agsize=32768000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=262144000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=64000, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 262144000 to 536870912
[root@localhost ~]# df -h
文件系統        容量  已用  可用 已用% 掛載點
/dev/sda2        30G  1.4G   27G    5% /
devtmpfs        1.9G     0  1.9G    0% /dev
tmpfs           1.9G     0  1.9G    0% /dev/shm
tmpfs           1.9G  8.8M  1.9G    1% /run
tmpfs           1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda1       190M  139M   38M   79% /boot
/dev/sdb        2.0T   33M  2.0T    1% /data
tmpfs           380M     0  380M    0% /run/user/0

可以看到/data目錄擴展到2TB了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM