Home  >  Article  >  System Tutorial  >  How to use XFS file system in Linux environment

How to use XFS file system in Linux environment

WBOY
WBOYforward
2024-01-07 13:42:011122browse
Introduction XfS file system is an advanced log file system developed by SGI. XFS is extremely scalable and robust. Fortunately, SGI has ported it to Linux systems. In a linux environment. The latest XFS file system currently available is version 1.2, which works well under the 2.4 core.
Introduction to XFS file system

Main features include the following:

Data integrity

Using the XFS file system, when unexpected downtime occurs, first of all, because the file system has the log function enabled, the files on your disk will no longer be destroyed due to unexpected downtime. No matter how many files and data are currently stored in the file system, the file system can quickly restore the disk file contents in a very short time based on the recorded logs.

Transmission characteristics

The XFS file system uses an optimization algorithm, and logging has very little impact on overall file operations. XFS queries and allocates storage space very quickly. The xfs file system can continuously provide fast response times. The author has tested XFS, JFS, Ext3, and ReiserFS file systems, and the performance of the XFS file system is quite outstanding.

Scalability

XFS is a full 64-bit file system that can support millions of Tbytes of storage space. The support for both extra-large files and small-sized files is outstanding, and it supports an extremely large number of directories. The maximum supported file size is 263 = 9 x 1018 = 9 exabytes, and the maximum file system size is 18 exabytes.

XFS uses a tall table structure (B-tree) to ensure that the file system can quickly search and allocate space quickly. XFS can continuously provide high-speed operations, and the performance of the file system is not limited by the number of directories and files in the directory.

Transmission bandwidth

XFS can store data with performance close to raw device I/O. In the test of a single file system, its throughput can reach up to 7GB per second, and for read and write operations on a single file, its throughput can reach 4GB per second.

Usage of XFS file system Download and compile the kernel

Download the corresponding version of the kernel patch, unzip the patch package, and patch the system core

Download address: ftp://oss.sgi.com/projects/xfs/d ... .4.18-all.patch.bz2

Patch the core. After downloading and decompressing, you will get a file: xfs-1.1-2.4.18-all.patch file.

Patch the core as follows:

# cd /usr/src/linux

# patch -p1 < /path/to/xfs-1.1-2.4.18-all.patch

After the patching work is completed, the next step is to compile the core and compile XFS into the Linux kernel.

First run the following command to select the core support XFS file system:

#make menuconfig

Select in the "File System" menu:

<*> SGI XFS filesystem support ##Description: Compile XFS file system support into the core or SGI XFS filesystem support ##Description: Support XFS file system by dynamically loading modules

There are two other options:

Enable XFS DMAPI ##说明:对磁盘管理的API,存储管理应用程序使用

Enable XFS Quota ##说明:支持配合Quota对用户使用磁盘空间大小管理

After completing the above work, exit and save the core selection configuration

After that, compile the kernel and install the core:

#make bzImage

#make module

#make module_install

#make install

If you are impatient or unsure about the above complicated and tedious work, you can download the patched core directly from the SGI website, and its version is 2.4.18. It is an rpm package that you simply install. There are two cores submitted by SGI, which are used by SMP and single-processor machines respectively.

Create XFS file system

After completing the compilation of the core, you should also download the supporting XFSprogs tool package, that is, the mkfs.xfs tool. Otherwise, we cannot complete the formatting of the partition: that is, we cannot format a partition into the format of the XFS file system. Package name to download: xfsprogs-2.0.3.

Extract the downloaded XFSProgs tool and install it. mkfs.xfs will be automatically installed in the /sbin directory.

#tar –xvf xfsprogs-2.0.3.src.tar.gz

#cd xfsprogs-2.0.3src

#./configure

#make

#make install

Use mkfs.xfs to format the disk as an xfs file system. The method is as follows:

# /sbin/mkfs.xfs /dev/sda6 #说明:将分区格式化为xfs文件系统,以下为显示内容:

meta-data=/dev/sda6 isize=256 agcount=8, agsize=128017 blks

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

= sunit=0 swidth=0 blks, unwritten=0

naming =version 2 bsize=4096

log =internal log bsize=4096 blocks=1200

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

When formatting a disk, if mkfs.xfs prompts you that the partition has been formatted to another file system, you can use the parameter -f to force format:

#/sbin/mkfs.xfs –f /dev/sda6
Load XFS file system
#mount –t xfs /dev/sda6 /xfs

##/xfs is a directory under the main partition/.

最后,为了让系统启动后就自动加载,应该更改/etc/fstab,这样系统启动后就会自动加载xfs分区而不必每次都手工加载。

要说明的一点是目前的xfs由于受linux内存页限制,在x86版本中,只能实现文件系统的块尺寸为4K。另外,XFS文件系统可以不同的方式 mount,即允许文件系统以读方式加载,也允许以读写方式加载。这是因为xfs文件系统用作根文件系统时,为了安全要以只读方式加载。

文件系统的迁移

要使得系统中的其它分区使用XFS文件系统,还有一步是迁移文件系统。建议在迁移文件系统时,首先将磁盘上的数据、文件先备份,以免发生不可挽回的损失,在进行文件系统转换之间,最好能将整个系统进行完全备份。这一步有很多种方法,本文仅就笔者的迁移方法加以描述。各位可以按照自己习惯的方式去完成

如果你想得到一个纯的xfs系统(系统的所有文件系统均采用XFS文件系统)话,还得将根文件系统也格式化为xfs文件系统。这实际上是比较繁杂的一步。因为根文件系统不能被umount,所以,必须首先创建一个分区,其文件系统为ext2文件系统,然后将目前的根分区上的所有文件与目录,原原本本地复制到这一个分区,然后更改/etc/fstab文件,替换原来的根分区。

方法如下:

$ mkfs -t ext2 /dev/hda4

$ mkdir /mnt/temp

$ mount -t ext2 /dev/hda4 /mnt/temp

$ cd /

$ tar lcvf - .|(cd /mnt/temp; tar xpvf - )

以上操作是将根分区上的所有文件打包,复制到新建立的分区。当然,你也可以直接使用以下命令复制文件。

# cp –dpR / /mnt/temp

接着,将下次启动的根分区更改到/dev/hda4分区,更改/etc/fstab文件及/etc/lilo.conf ,然后,运行 lilo.

重新启动后,新的根分区就已经为/dev/hda4。

接下来,创建一个xfs文件系统的分区:

$ mkfs -t xfs /dev/hda2

加载此分区,采用两样的方法,将根分区的内容复制到此分区

$ mount -t xfs /dev/hda2 /mnt/temp

在根分区下,运行

$ cd /

$ tar lcvf - .|(cd /mnt/temp; tar xpvf - )

再次更改/etc/fstab、/etc/lilo.conf,用新建的xfs分区替换原来的ext2主分区。如下所示:

/dev/hda2 / xfs defaults 1 1

将新建的xfs分区用作根分区,保存以上设置。再次检查配置文件内容,确认无误后再重新启动系统。如果你的设置全部正确,那么系统成功启动后,你就拥有一个纯XFS文件系统的系统了。

The above is the detailed content of How to use XFS file system in Linux environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete