How to use XFS file system in Linux environment
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. |
Main features include the following:
Data integrityUsing 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 characteristicsThe 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.
ScalabilityXFS 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 bandwidthXFS 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 kernelDownload 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 systemAfter 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
#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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

Troubleshooting steps for failed Docker image build: Check Dockerfile syntax and dependency version. Check if the build context contains the required source code and dependencies. View the build log for error details. Use the --target option to build a hierarchical phase to identify failure points. Make sure to use the latest version of Docker engine. Build the image with --t [image-name]:debug mode to debug the problem. Check disk space and make sure it is sufficient. Disable SELinux to prevent interference with the build process. Ask community platforms for help, provide Dockerfiles and build log descriptions for more specific suggestions.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.
