溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

linux中xfs文件系統(tǒng)相關(guān)命令有哪些

發(fā)布時間:2021-10-23 17:45:59 來源:億速云 閱讀:622 作者:小新 欄目:系統(tǒng)運維

這篇文章主要介紹linux中xfs文件系統(tǒng)相關(guān)命令有哪些,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

創(chuàng)建 XFS 文件系統(tǒng)

mkfs.xfs 命令用來創(chuàng)建 xfs 文件系統(tǒng)。無需任何特別的參數(shù),其輸出如下:

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

注意:一旦 XFS 文件系統(tǒng)創(chuàng)建完畢就不能在縮容而只能進(jìn)行擴(kuò)容了。

調(diào)整 XFS 文件系統(tǒng)容量

你只能對 XFS 進(jìn)行擴(kuò)容而不能縮容。我們使用 xfs_growfs 來進(jìn)行擴(kuò)容。你需要使用 -D 參數(shù)指定掛載點的新容量。-D 接受一個數(shù)字的參數(shù),指定文件系統(tǒng)塊的數(shù)量。若你沒有提供 -D 參數(shù),則 xfs_growfs 會將文件系統(tǒng)擴(kuò)到***。

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

觀察上面的輸出中的***一行。由于我分配的容量要小于現(xiàn)在的容量。它告訴你不能縮減 XFS 文件系統(tǒng)。你只能對它進(jìn)行擴(kuò)展。

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

現(xiàn)在我多分配了 1GB 的空間,而且也成功地擴(kuò)增了容量。

1GB 塊的計算方式:

當(dāng)前文件系統(tǒng) bsize 為 4096,意思是塊的大小為 4MB。我們需要 1GB,也就是 256 個塊。因此在當(dāng)前塊數(shù),2883584 上加上 256 得到 2883840。因此我為 -D 傳遞參數(shù) 2883840。

修復(fù) XFS 文件系統(tǒng)

可以使用 xfs_repair 命令進(jìn)行文件系統(tǒng)一致性檢查和修復(fù)。使用 -n 參數(shù)則并不對文件系統(tǒng)做出什么實質(zhì)性的修改。它只會搜索并報告要做哪些修改。若不帶 -n 參數(shù),則會修改文件系統(tǒng)以保證文件系統(tǒng)的純凈。

請注意,在檢查之前,你需要先卸載 XFS 文件系統(tǒng)。否則會報錯。

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

卸載后運行檢查命令。

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.

你可以看到,命令在每個階段都顯示出了為了文件系統(tǒng)變得健康可能做出的修改。若你希望命令在掃描時實際應(yīng)用這些修改,則不帶任何參數(shù)運行命令即可。

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

你會發(fā)現(xiàn) xfs_repair 命令對文件系統(tǒng)做出了修改讓其變得健康。

查看 XFS 版本以及它的詳細(xì)信息

查看 xfs 文件系統(tǒng)版本很簡單。使用 -V 參數(shù)運行 xfs_info 再加上掛載點就行了。

root@kerneltalks # xfs_info -V /shrikantxfs_info version 4.5.0

若要查看 XFS 文件系統(tǒng)的詳細(xì)信息,比如想計算擴(kuò)容 XFS 文件系統(tǒng)時要新增多少個塊,需要了解塊大小,塊的個數(shù)等信息,則不帶任何選項運行 xfs_info 加上掛載點。

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

則會顯示 XFS 文件系統(tǒng)的所有詳細(xì)信息,就跟創(chuàng)建 XFS 文件系統(tǒng)時顯示的信息一樣。

以上是“l(fā)inux中xfs文件系統(tǒng)相關(guān)命令有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI