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

How to use XFS file system in Linux environment

Jan 07, 2024 pm 01:42 PM
linux linux tutorial Red Hat linux system linux command linux certification red hat linux linux video

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
Copy after login

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
Copy after login

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对用户使用磁盘空间大小管理
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login
Load XFS file system
#mount –t xfs /dev/sda6 /xfs
Copy after login

##/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 - )
Copy after login

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

# cp –dpR / /mnt/temp
Copy after login

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

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

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

$ mkfs -t xfs /dev/hda2
Copy after login

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

$ mount -t xfs /dev/hda2 /mnt/temp
Copy after login

在根分区下,运行

$ cd /

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

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

/dev/hda2 / xfs defaults 1 1
Copy after login

将新建的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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

See all articles