search
HomeSystem TutorialLINUXCapacity expansion of xfs file system in LVM

Capacity expansion of xfs file system in LVM

Dec 28, 2023 pm 09:41 PM
linuxlinux tutorialRed Hatlinux systemlinux commandlinux certificationred hat linuxlinux video

Introduction I have never been exposed to CentOS 7 before and do not understand the features it has changed. I accidentally came into contact with LVM in centos 7. The method of creating LVM is the same as that in 6, but the expansion of LVM is a little different. However, the expansion using the previous method never took effect. It took me a long time to figure out the expansion method. Xfs is the default file system type of CentOS7, and different file system types have different creation, inspection, and adjustment commands.

Xfs is the default file system type of CentOS7, and different file system types have different creation, inspection, and adjustment commands.

Capacity expansion of xfs file system in LVM

In the xfs file system, the partition can only be increased but not reduced.

[root@localhost ~]# ls /lib//modules/3.10.0-229.20.1.el7.x86_64/kernel/fs   #查看内核所支持的所有文件系统类型
binfmt_misc.ko  ceph    dlm    fat      gfs2   lockd       nfs_common  overlayfs  udf
btrfs           cifs    exofs  fscache  isofs  mbcache.ko  nfsd        pstore     xfs
cachefiles      cramfs  ext4   fuse     jbd2   nfs         nls         squashfs

I have previously created a new partition and added it to vg, and the physical boundaries have also been expanded.

When extending the logical boundary, the error is reported as follows:

[root@localhost ~]# resize2fs -p /dev/mapper/centos-root     
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block 当尝试打开 /dev/mapper/centos-root 时
找不到有效的文件系统超级块.

First I thought of using fsck to repair it, but it didn’t work. After seeing the error message, I realized that the xfs file needs to be repaired using xfs_repair

[root@localhost ~]# fsck /dev/mapper/centos-root      
fsck,来自 util-linux 2.23.2
If you wish to check the consistency of an XFS filesystem or
repair a damaged filesystem, see xfs_repair(8).

Then try to repair it, but it doesn't work. You need to uninstall it to repair it. This file system is mounted under /, so don't even think about it.

[root@localhost ~]# xfs_repair /dev/mapper/centos-root 
xfs_repair: /dev/mapper/centos-root contains a mounted filesystem
xfs_repair: /dev/mapper/centos-root contains a mounted and writable filesystem
 
fatal error -- couldn't initialize XFS library

Finally, after some research on the Internet, I found out that after the logical expansion of the xfs file system, there is still one more step to complete:

[root@localhost ~]# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 95.00g                                                    
  swap centos -wi-ao----  3.88g             
[root@localhost ~]# df  -lh
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   46G   42G  4.5G   91% /   ------------>46G
devtmpfs                 1.9G     0  1.9G    0% /dev
tmpfs                    1.9G  164K  1.9G    1% /dev/shm
tmpfs                    1.9G  8.7M  1.9G    1% /run
tmpfs                    1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda1                497M  208M  290M   42% /boot                                       
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root      #执行调整,扩展后需要执行此步骤
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=2987776 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=11951104, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=5835, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 11951104 to 24903680
 
[root@localhost ~]# df -lh
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   95G   42G   54G   44% /      ------------>已经完成扩展
devtmpfs                 1.9G     0  1.9G    0% /dev
tmpfs                    1.9G  164K  1.9G    1% /dev/shm
tmpfs                    1.9G  8.7M  1.9G    1% /run
tmpfs                    1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda1                497M  208M  290M   42% /boot

xfs related common commands

xfs_admin: 调整 xfs 文件系统的各种参数  
xfs_copy: 拷贝 xfs 文件系统的内容到一个或多个目标系统(并行方式)  
xfs_db: 调试或检测 xfs 文件系统(查看文件系统碎片等)  
xfs_check: 检测 xfs 文件系统的完整性  
xfs_bmap: 查看一个文件的块映射  
xfs_repair: 尝试修复受损的 xfs 文件系统  
xfs_fsr: 碎片整理  
xfs_quota: 管理 xfs 文件系统的磁盘配额  
xfs_metadump: 将 xfs 文件系统的元数据 (metadata) 拷贝到一个文件中  
xfs_mdrestore: 从一个文件中将元数据 (metadata) 恢复到 xfs 文件系统  
xfs_growfs: 调整一个 xfs 文件系统大小(只能扩展)  
xfs_freeze    暂停(-f)和恢复(-u)xfs 文件系统
xfs_logprint: 打印xfs文件系统的日志  
xfs_mkfile: 创建xfs文件系统  
xfs_info: 查询文件系统详细信息  
xfs_ncheck: generate pathnames from i-numbers for XFS  
xfs_rtcp: XFS实时拷贝命令   
xfs_io: 调试xfs I/O路径

Notice:
After using the mke2fs command on the Xfs file system, it becomes ext2. You need to modify the corresponding file system type in the file /etc/fstab!

The above is the detailed content of Capacity expansion of xfs file system in LVM. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:Linux就该这么学. If there is any infringement, please contact admin@php.cn delete
Explain the open-source nature of Linux and how it contrasts with Windows.Explain the open-source nature of Linux and how it contrasts with Windows.Apr 28, 2025 am 12:03 AM

The open source nature of Linux makes it better than Windows in terms of community participation, performance, security, etc., but Windows is better in user-friendliness and software ecosystem. 1) Linux encourages community contribution and has a fast development speed; 2) Better performance in servers and embedded systems; 3) Open source nature makes it safer; 4) Windows user interface is friendly and the software ecosystem is extensive.

Top 5 Linux Tools for Monitoring Disk I/O PerformanceTop 5 Linux Tools for Monitoring Disk I/O PerformanceApr 27, 2025 pm 04:45 PM

This guide explores essential Linux tools for monitoring and troubleshooting disk I/O performance, a crucial metric impacting server speed and application responsiveness. Disk I/O performance directly affects how quickly data is read from and written

4 Ways to Find Plugged USB Device Name in Linux4 Ways to Find Plugged USB Device Name in LinuxApr 27, 2025 pm 04:44 PM

For new Linux users, identifying connected devices is crucial, especially USB drives. This guide provides several command-line methods to determine a USB device's name, essential for tasks like formatting. While USB drives often auto-mount (e.g., /

How to Fix 'No Space Left on Device” on Root (/) PartitionHow to Fix 'No Space Left on Device” on Root (/) PartitionApr 27, 2025 pm 04:43 PM

One of the most common problems with Linux systems, especially those with limited disk space, is the exhaustion of root partition (/) space. When this problem occurs, you may encounter the following error: No space left on device Don’t panic! This just means that your root directory (/partition) is full, which is a common problem, especially on systems with limited disk space or servers running 24/7. When this happens, you may encounter the following problems: The package cannot be installed or upgraded. System startup failed. The service cannot be started. Unable to write to logs or temporary files. This article walks you through practical steps to identify problems, clean up space safely, and prevent them from happening again. These instructions are suitable for beginners

Top 16 Notepad   Replacements for Linux in 2025Top 16 Notepad Replacements for Linux in 2025Apr 27, 2025 pm 04:42 PM

This article explores top-notch Notepad alternatives for Linux users. Notepad , while excellent on Windows, lacks a Linux version. This guide offers a diverse range of options to suit various needs and preferences. Top Notepad Alternatives for

How to Create and Run New Service Units in SystemdHow to Create and Run New Service Units in SystemdApr 27, 2025 pm 04:41 PM

Several days ago, I encountered a 32-bit CentOS 8 distribution and decided to test it on an older 32-bit system. Post-boot, I discovered a network connectivity issue; the connection would drop, requiring manual restoration after each reboot. This pr

How to Check for Bad Sectors on a Hard Disk in LinuxHow to Check for Bad Sectors on a Hard Disk in LinuxApr 27, 2025 pm 04:40 PM

Let's clarify what constitutes a bad sector or bad block: it's a portion of a hard drive or flash memory that's become unreadable or unwritable, typically due to physical damage to the disk surface or malfunctioning flash memory transistors. Accumul

How to Force cp Command to Overwrite Files Without PromptHow to Force cp Command to Overwrite Files Without PromptApr 27, 2025 pm 04:39 PM

The cp command, short for "copy," is a fundamental tool in Linux and other Unix-like systems for duplicating files and directories. While efficient for local file transfers, for network-based copies, scp (secure copy) is preferred due to i

See all articles

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

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function