Adjusting the XFS file system size only supports online expansion and does not support shrinkage. 1. Before expanding capacity, you need to back up data, check the disk partition structure and confirm that the underlying device has been expanded; 2. Use the xfs_growfs command to expand the file system, which can be operated online without uninstalling; 3. If you use LVM, you need to expand the logical volume first and then execute xfs_growfs; 4. XFS does not support shrinkage. If you need shrinkage, you can only achieve it by backing up, rebuilding a small-capacity file system and restoring data.
Resizing the XFS file system is not as mysterious as it sounds, but it does require careful operation. XFS is a high-performance log file system that is widely used in Linux, especially in CentOS, RHEL, and other enterprise-level distributions. Although it does not support shrinking, it supports online expansion (provided that you have available space). Let’s take a look at how to operate it in detail.
Preparations before expansion
Before starting capacity expansion, there are several key points that must be confirmed:
- Make sure the data is backed up : Any file system operation is risky, especially in production environments.
- Check the current disk and partitioning situation : Use
df -Th
to view the file system type, and uselsblk
orfdisk -l
to confirm the disk partition structure. - Confirm whether the underlying device has expanded : If you are operating on a virtual machine or cloud platform, such as AWS or VMware, make sure the disk capacity has expanded first.
For example: Suppose you have an XFS file system mounted on /data
, and the logical volume or disk you are in has expanded by 10GB, and you can then expand the file system level.
Extend file system using xfs_growfs
XFS provides a special tool called xfs_growfs
, which is specifically used to extend the file system. It is very simple to use and can be executed under the file system mount state.
The command format is as follows:
xfs_growfs /mount/point
For example, if your file system is mounted in /data
, run:
xfs_growfs /data
This extends the file system to the full available space of its underlying device. If you want to only expand to a specific size, you can add the -D
parameter to specify the number of blocks, but in most cases, it can be directly expanded to the upper limit of the underlying device.
Note: This command does not require uninstalling the file system, it is an "online" operation and is suitable for production environments.
If using LVM, expand the logical volume first and then expand the file system
If your XFS file system is built on LVM (Logical Volume Management), the process will be one more step:
- Expand the physical volume (PV) or confirm that there is enough space;
- Extended volume group (VG);
- Extended Logical Volume (LV):
lvextend -L 10G /dev/vgname/lvname
- Finally, use
xfs_growfs
to extend the file system. - Leave some margin when allocating disk space;
- If you really need to reduce the capacity, the only way to do this is:
- Back up data;
- Format a new, smaller file system;
- Recover data.
Only by doing this step by step can the entire expansion process be safely completed.
Shrink? Don't think about it, XFS does not support it
Currently XFS does not support minification operations . In other words, you can expand the capacity, but not shrink it. If you misoperate and reduce the underlying device, or try to force it, it may cause file system corruption or even data loss.
So suggestion:
Basically that's it. As long as you follow the steps, expanding XFS is not complicated, but it is also easy to cause problems due to negligence.
The above is the detailed content of How to resize an XFS filesystem?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

In Linux system, using the usermod command to add users to the secondary group is: 1. Execute the sudousermod-a-G group name username command to add, where -a means append to avoid overwriting the original secondary group; 2. Use groups username or grep group name /etc/group to verify whether the operation is successful; 3. Note that the modification only takes effect after the user logs in again, and the main group modification should use the -g parameter; 4. You can also manually edit the /etc/group file to add users, but be careful to avoid system abnormalities caused by format errors.

To migrate from CentOS8 to AlmaLinux or RockyLinux, follow the clear steps. First, choose AlmaLinux (suitable for long-term enterprise support) or RockyLinux (emphasizing exactly the same as RHEL) according to your needs. Secondly, prepare the system environment: update the software package, back up key data, check third-party repositories and disk space. Then, the conversion is automatically completed using the official migration script. RockyLinux needs to clone the repository and run the switch-to-rocky.sh script. AlmaLinux replaces the repository and upgrades with one click through the remote deployment script. Finally, verify system information, clean up residual packets, and update GRUB and ini if ??necessary

To correctly install the local RPM file and handle dependencies, you should first use dnf to install it directly, because it can automatically obtain the required dependencies from the configured repository; if the system does not support dnf, you can use yum's localinstall command instead; if the dependency cannot be resolved, you can manually download and install all related packages; finally, you can also forcefully ignore the dependency installation, but this method is not recommended. 1. Use sudodnfinstall./package-name.rpm to automatically resolve dependencies; 2. If there is no dnf, you can use sudoyumlocalinstall./package-name.rpm; 3. Force installation and execute sudorpm-ivh--nod

How to set a static IP address using nmcli on CentOS8 or 9? 1. First run the nmcliconnectionshow and ipa commands to view the current network interface and its configuration; 2. Use the nmcliconnectionmodify command to modify the connection configuration, specify parameters such as ipv4.methodmanual, ipv4.addresses (such as 192.168.1.100/24), ipv4.gateway (such as 192.168.1.1), and ipv4.dns (such as 8.8.8.8). 3. Run the nmcliconnectiondown and up commands to restart the connection to make the changes take effect, or

The method to prevent software package updates in Linux systems varies from distribution to distribution. It can be mainly implemented in the following ways: 1. Use sudoapt-markhold package name to lock the package version in Ubuntu/Debian, and use sudoapt-markunhold package name to restore updates; 2. When temporarily updated in CentOS/Fedora, skip specific packages through the --exclude= package name parameter, or edit /etc/yum.conf to add exclude= package name to achieve permanent exclusion; 3. Advanced users can use APT's pinning mechanism to set source priority to control the installation version; 4. Note that third-party package managers such as snap and flatpak need to be handled separately

AminimalinstallofCentOSisalightweightsetupthatincludesonlyessentialcomponents,makingitidealforserversorsystemsrequiringfullcontrol.Itcontainscoreutilitieslikebash,yum/dnf,networkingtools,andsecuritypackages,whileexcludingdesktopenvironments,webserver

The current running mode of SELinux can be viewed through the command line. Use getenforce command to directly display the current status, and the output is Enforcing, Permissive or Disabled; view the /etc/selinux/config file to know the default startup mode; temporarily change the mode can be setenforce1 (enforcing) or setenforce0 (permissive), but restore the configuration file settings after restart; in actual applications, you need to pay attention to service compatibility issues, and switch modes to troubleshoot problems if necessary.

To grant sudo permissions to Linux users, there are two main methods: one is to modify the /etc/sudoers file through visudo to add authorization rules, and the other is to add the user to the default sudo group. 1. Use the visudo command to add "usernameALL=(ALL)ALL" to grant full permissions. If you need to exempt password, add NOPASSWD option, but you should use it with caution; 2. Use the "usermod-aGsudousername" command to add the user to the sudo group. The operation is simple and safer. After the change, the user needs to log in again to take effect. After the configuration is completed, you can execute "sudols/
