Linux成立和挂载XFS文件系统测试实践

XFS文件系统简介

 

维基百科关于XFS的简介如下:

 

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一种高品质的日志文件系统,最早于19九三年,由Silicon
Graphics为她们的IEvoqueIX操作系统而付出,是I索罗德IX
5.3版的暗中同意文件系统。两千年3月,Silicon Graphics以GNU通用公共许可证发表那套系统的源代码,之后被移植到Linux 内核上。XFS
特别擅长处理大文件,同时提供平滑的数目传输。

 

 

XFS比较于其余文件系统(ext三、ext4等)的利弊:

 

 

XFS是高品质文件系统,由于它的高质量,XFS成为了重重商户级系统的首要选取,越发是有雅量数据,必要结构化伸缩性和安乐的。例如,TucsonHEL/CentOS 七 和Oracle Linux将XFS作为私下认可文件系统,SUSE/openSUSE已经为XFS做了许久支撑。

 

XFS有无数新鲜的质量提高功用使他从诸多文件系统中突兀而起,像可伸缩/并行 IO,元数据日志,热碎片整理,IO 暂停/苏醒,延迟分配等。

 

XFS
文件系统有1对通病,例如它不能够减小,删除大量文件时质量低下

 

 

 

创建XFS文件系统

 

 

倘诺系统并未有XFS系统工具集,那就亟须必须设置(命令如下):

 

#sudo
yum install xfsprogs

 

实则过多Linux系统将XFS作为暗许文件系统,所以不要安装,如下所示,
Centos 7.叁就无需安装

 

[root@mylnx008
~]# more /etc/redhat-release

CentOS
Linux release 7.3.1611 (Core)

 

 

创制XFS格式分区,如下测试所示,
新增了3个300多G的磁盘

 

 

[root@mylnx008 ~]# fdisk -l

 

Disk /dev/sdb: 323.2 GB, 323196289024 bytes, 631242752 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

 

 

Disk /dev/sda: 33.3 GB, 33285996544 bytes, 65011712 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x000c1fec

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     1026047      512000   83  Linux

/dev/sda2         1026048    62914559    30944256   83  Linux

 

Disk /dev/sdc: 145.0 GB, 144955146240 bytes, 283115520 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk label type: dos

Disk identifier: 0x034b6e5c

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1            2048   283113471   141555712   83  Linux

 

[root@mylnx008 ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0xafc7c358.

 

Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): p

Partition number (1-4, default 1): 1

First sector (2048-631242751, default 2048): 

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-631242751, default 631242751): 

Using default value 631242751

Partition 1 of type Linux and of size 301 GiB is set

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

格式化分区为XFS,使用mkfs.xfs命令。假如已有任何文件系统创制在此分区,必须抬高”-f”参数来覆盖它。

 

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

meta-data=/dev/sdb               isize=512    agcount=4, agsize=19726336 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0, sparse=0

data     =                       bsize=4096   blocks=78905344, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal log           bsize=4096   blocks=38528, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

 

[root@mylnx008 ~]# df -T /dev/sdb

Filesystem     Type     1K-blocks  Used Available Use% Mounted on

devtmpfs       devtmpfs   1746644     0   1746644   0% /dev

[root@mylnx008 ~]# 

 

 

挂载XFS文件系统

 

 

[root@mylnx008 ~]# mkdir /mysql

[root@mylnx008 ~]# mount  -t  xfs  /dev/sdb  /mysql

[root@mylnx008 ~]#  df -T /dev/sdb

Filesystem     Type 1K-blocks  Used Available Use% Mounted on

/dev/sdb       xfs  315467264 32944 315434320   1% /mysql

[root@mylnx008 ~]# 

[root@mylnx008 ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda2        30G   22G  8.2G  73% /

devtmpfs        1.7G     0  1.7G   0% /dev

tmpfs           1.7G     0  1.7G   0% /dev/shm

tmpfs           1.7G   25M  1.7G   2% /run

tmpfs           1.7G     0  1.7G   0% /sys/fs/cgroup

/dev/sda1       497M   62M  436M  13% /boot

/dev/sdc1       133G  4.2G  122G   4% /mnt/resource

tmpfs           344M     0  344M   0% /run/user/1000

/dev/sdb        301G   33M  301G   1% /mysql

 

上边命令只对现阶段条件有效,要是要在运转时自动挂载XFS分区在/mysql上,必须配置/etc/fstab配置文件

 

[root@mylnx008 ~]# vi /etc/fstab

 

#

# /etc/fstab

# Created by anaconda on Mon Sep 25 21:44:42 2017

#

# 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=b7559ac5-b3a4-4b00-b98a-a2a2611806d0 /                       xfs     defaults        0 0

UUID=b98659b2-5f8c-493e-9304-658905ef1391 /boot                   xfs     defaults        0 0

/dev/sdb                                  /mysql                  xfs     defaults        0 0 

 

当如你也足以应用UUID替换对应的装置,如下所示,先找到呼应装备的UUID,然后修改/etc/fastab

 

[root@mylnx008 ~]# blkid  /dev/sdb

/dev/sdb: UUID="6fcc5417-3c1b-4c71-aac7-344bac7654a4" TYPE="xfs" 

[root@mylnx008 ~]# blkid  /dev/sda2

/dev/sda2: UUID="b7559ac5-b3a4-4b00-b98a-a2a2611806d0" TYPE="xfs" 

[root@mylnx008 ~]# 

[root@mylnx008 ~]# vi /etc/fstab 

 

#

# /etc/fstab

# Created by anaconda on Mon Sep 25 21:44:42 2017

#

# 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=b7559ac5-b3a4-4b00-b98a-a2a2611806d0 /                       xfs     defaults        0 0

UUID=b98659b2-5f8c-493e-9304-658905ef1391 /boot                   xfs     defaults        0 0

UUID=6fcc5417-3c1b-4c71-aac7-344bac7654a4 /mysql                  xfs     defaults        0 0  

 

 

 

参考资料:

 

https://linux.cn/article-4245-1.html

相关文章