Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commands related to xfs file system in linux

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what are the commands related to the xfs file system in linux. It is very detailed and has a certain reference value. Friends who are interested must finish reading it!

Create a XFS file system

The mkfs.xfs command is used to create a xfs file system. No special parameters are required, and the output is as follows:

Root@kerneltalks # mkfs.xfs / dev/xvdfmeta-data=/dev/xvdf isize=512 agcount=4, agsize=1310720 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0data = bsize=4096 blocks=5242880 Imaxpct=25 = sunit=0 swidth=0 blksnaming = version 2 bsize=4096 ascii-ci=0 ftype=1log = internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime = none extsz=4096 blocks=0, rtextents=0

Note: once the XFS file system is created, it can not be reduced but can only be expanded.

Adjust the capacity of the XFS file system

You can only expand the capacity of XFS, not reduce it. We use xfs_growfs to expand capacity. You need to use the-D parameter to specify the new capacity of the mount point. -D accepts a numeric parameter that specifies the number of file system blocks. If you do not provide the-D parameter, xfs_growfs will extend the file system to *.

Root@kerneltalks # xfs_growfs / dev/xvdf-D 256meta-data=/dev/xvdf isize=512 agcount=4, agsize=720896 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=2883584 Imaxpct=25 = sunit=0 swidth=0 blksnaming = version 2 bsize=4096 ascii-ci=0 ftype=1log = internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime = none extsz=4096 blocks=0, rtextents=0data size 256 too small, old size is 2883584

Look at the * line in the output above. Because the capacity I allocated is less than the current capacity. It tells you not to shrink the XFS file system. You can only expand it.

Root@kerneltalks # xfs_growfs / dev/xvdf-D 2883840meta-data=/dev/xvdf isize=512 agcount=4, agsize=720896 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=2883584 Imaxpct=25 = sunit=0 swidth=0 blksnaming = version 2 bsize=4096 ascii-ci=0 ftype=1log = internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime = none extsz=4096 blocks=0, rtextents=0data blocks changed from 2883584 to 2883840

Now I have allocated more space for 1GB and have successfully expanded the capacity.

How 1GB blocks are calculated:

The current file system bsize is 4096, which means the size of the block is 4MB. We need 1GB, which is 256 blocks. So add 2883584 to the current number of blocks to get 2883840. So I pass the parameter 2883840 for-D.

Repair the XFS file system

You can use the xfs_repair command to check and repair file system consistency. Using the-n parameter does not make any substantial changes to the file system. It only searches for and reports on changes to be made. Without the-n parameter, the file system is modified to ensure the purity of the file system.

Please note that you need to unmount the XFS file system before checking. Or you'll make a mistake.

Root@kerneltalks # xfs_repair-n / dev/xvdfxfs_repair: / dev/xvdf contains a mounted filesystemxfs_repair: / dev/xvdf contains a mounted and writable filesystem fatal error-- couldn't initialize XFS library

Run the check command after uninstalling.

Root@kerneltalks # xfs_repair-n / dev/xvdfPhase 1-find and verify superblock...Phase 2-using internal log-zero log... -scan filesystem freespace and inode maps... -found root inode chunkPhase 3-for each AG... -scan (but don't clear) agi unlinked lists... -process known inodes and perform inode discovery... -agno = 0-agno = 1-agno = 2-agno = 3-agno = 4-process newly discovered inodes...Phase 4-check for duplicate blocks... -setting up duplicate extent list... -check for inodes claiming duplicate blocks... -agno = 0-agno = 1-agno = 2-agno = 3-agno = 4No modify flag set, skipping phase 5Phase 6-check inode connectivity... -traversing filesystem...-traversal finished...-moving disconnected inodes to lost+found... Phase 7-verify link counts...No modify flag set, skipping filesystem flush and exiting.

As you can see, at each stage, the command shows the possible changes that may be made to make the file system healthy. If you want the command to actually apply these changes during the scan, run the command without any parameters.

Root @ kerneltalks # xfs_repair / dev/xvdf Phase 1-find and verify superblock. . Phase 2-using internal log-zero log. . . -scan filesystem freespace and inode maps. . . -found root inode chunkPhase 3-for each AG. . . -scan and clear agi unlinked lists. . . -process known inodes and perform inode discovery. . . -agno = 0-agno = 1-agno = 2-agno = 3-agno = 4-process newly discovered inodes. . . Phase 4-check for duplicate blocks. . . -setting up duplicate extent list. . . -check for inodes claiming duplicate blocks. . . -agno = 0-agno = 1-agno = 2-agno = 3-agno = 4 Phase 5-rebuild AG headers and trees. . . -reset superblock. . Phase 6-check inode connectivity. . . -resetting contents of realtime bitmap and summary inodes-traversing filesystem. . . -traversal finished. . . -moving disconnected inodes to lost + found. . Phase 7-verify and correct link counts. . . Done

You will find that the xfs_repair command has made changes to the file system to make it healthy.

View the XFS version and its details

It is easy to see the xfs file system version. Just run xfs_info with the-V parameter plus the mount point.

Root@kerneltalks # xfs_info-V / shrikantxfs_info version 4.5.0

To view the details of the XFS file system, such as how many blocks need to be added when you want to expand the XFS file system, and need to know the block size and the number of blocks, run xfs_info plus the mount point without any option.

Root@kerneltalks # xfs_info / shrikantmeta-data=/dev/xvdf isize=512 agcount=5, agsize=720896 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=2883840 Imaxpct=25 = sunit=0 swidth=0 blksnaming = version 2 bsize=4096 ascii-ci=0 ftype=1log = internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime = none extsz=4096 blocks=0, rtextents=0

All the details of the XFS file system are displayed, just as the information displayed when the XFS file system was created.

The above is all the contents of the article "what are the commands related to the xfs file system in linux?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report