Thursday, January 18, 2018

xfs file system commands with examples

https://kerneltalks.com/commands/xfs-file-system-commands-with-examples

Learn xfs file system commands to create, grow, repair xfs file system along with command examples. 
Learn xfs file system commands
Learn xfs commands with examples

In our another article we walked you through what is xfs, features of xfs etc. In this article we will see some frequently used xfs administrative commands. We will see how to create xfs filesystem, how to grow xfs filesystem, how to repair xfs file system and check xfs filesystem along with command examples.

Create XFS filesystem

mkfs.xfs command is used to create xfs filesystem. Without any special switches command output looks like one below –
Note : Once XFS filesystem is created it can not be reduced. It can only be extended to bigger size.

Resize XFS file system

In XFS, you can only extend file system and can not reduce it. To grow XFS file system use xfs_growfs. You need to specify new size of mount point along with -D switch. -D takes argument number as file system blocks. If you dont supply -D switch, xfs_growfs will grow filesystem to maximum available limit on that device.
In above output, observe last line. Since I supplied new size smaller than the existing size, xfs_growfsdidnt change filesystem. This show you can not reduce XFS file system. You can only extend it.
Now, I supplied new size 1GB  extra and it successfully grew the file system.
1GB blocks calculation :
Current filesystem has bsize=4096 i.e. block size of 4MB. We need 1 GB i.e. 256 blocks. So add 256 in current number of blocks i.e. 2883584 which gives you 2883840. So I used 2883840 as argument to -D switch.

Repair XFS file system

File system consistency check and repair of XFS can be performed using xfs_repair command. You can run command with -n switch so that it will not modify anything on filesystem. It will only scans and reports which modification to be done. If you are running it without -n switch, it will modify file system wherever necessary to make it clean.
Please note that you need to un-mount XFS filesystem before you can run checks on it. Otherwise you will see below error.
Once successfully un-mounting file system you can run command on it.
In above output you can observe, in each phase command shows possible modification which can be done to make file system healthy. If you want command to do those modification during scan then run command without any switch.
In above output you can observer xfs_repair command is executing possible filesystem modification as well to make it healthy.

Check XFS version and details

Checking xfs file system version is easy. Run xfs_info command with -V switch on mount point.
To view details of XFS file system like block size and number of blocks which helps you in calculating new block number for growing XFS file system, use xfs_info without any switch.
It displays all details as it shows while creating XFS file system

There are another XFS file system management commands which alters and manages its metadata. We will cover them in another article.

No comments:

Post a Comment