自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

通過案例學(xué)習(xí)xfs文件系統(tǒng)相關(guān)命令

系統(tǒng) Linux
在我們另一篇文章中,我?guī)I(lǐng)略了一下什么是 xfs,xfs 的相關(guān)特性等內(nèi)容。本文我們來看一些常用的 xfs 管理命令。我們將會通過幾個例子來講解如何創(chuàng)建 xfs 文件系統(tǒng),如何對 xfs 文件系統(tǒng)進行擴容,如何檢測并修復(fù) xfs 文件系統(tǒng)。

[[220434]]

在我們另一篇文章中,我?guī)I(lǐng)略了一下什么是 xfs,xfs 的相關(guān)特性等內(nèi)容。本文我們來看一些常用的 xfs 管理命令。我們將會通過幾個例子來講解如何創(chuàng)建 xfs 文件系統(tǒng),如何對 xfs 文件系統(tǒng)進行擴容,如何檢測并修復(fù) xfs 文件系統(tǒng)。

 

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

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

  1. root@kerneltalks # mkfs.xfs /dev/xvdf
  2. meta-data=/dev/xvdf isize=512 agcount=4, agsize=1310720 blks
  3. = sectsz=512 attr=2, projid32bit=1
  4. = crc=1 finobt=0, sparse=0
  5. data = bsize=4096 blocks=5242880, imaxpct=25
  6. = sunit=0 swidth=0 blks
  7. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
  8. log =internal log bsize=4096 blocks=2560, version=2
  9. = sectsz=512 sunit=0 blks, lazy-count=1
  10. realtime =none extsz=4096 blocks=0, rtextents=0

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

 

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

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

  1. root@kerneltalks # xfs_growfs /dev/xvdf -D 256
  2. meta-data=/dev/xvdf isize=512 agcount=4, agsize=720896 blks
  3. = sectsz=512 attr=2, projid32bit=1
  4. = crc=1 finobt=0 spinodes=0
  5. data = bsize=4096 blocks=2883584, imaxpct=25
  6. = sunit=0 swidth=0 blks
  7. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
  8. log =internal bsize=4096 blocks=2560, version=2
  9. = sectsz=512 sunit=0 blks, lazy-count=1
  10. realtime =none extsz=4096 blocks=0, rtextents=0
  11. data size 256 too small, old size is 2883584

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

  1. root@kerneltalks # xfs_growfs /dev/xvdf -D 2883840
  2. meta-data=/dev/xvdf isize=512 agcount=4, agsize=720896 blks
  3. = sectsz=512 attr=2, projid32bit=1
  4. = crc=1 finobt=0 spinodes=0
  5. data = bsize=4096 blocks=2883584, imaxpct=25
  6. = sunit=0 swidth=0 blks
  7. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
  8. log =internal bsize=4096 blocks=2560, version=2
  9. = sectsz=512 sunit=0 blks, lazy-count=1
  10. realtime =none extsz=4096 blocks=0, rtextents=0
  11. data blocks changed from 2883584 to 2883840

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

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

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

  1. root@kerneltalks # xfs_repair -n /dev/xvdf
  2. xfs_repair: /dev/xvdf contains a mounted filesystem
  3. xfs_repair: /dev/xvdf contains a mounted and writable filesystem
  4.  
  5. fatal error -- couldn't initialize XFS library

卸載后運行檢查命令。

  1. root@kerneltalks # xfs_repair -n /dev/xvdf
  2. Phase 1 - find and verify superblock...
  3. Phase 2 - using internal log
  4. - zero log...
  5. - scan filesystem freespace and inode maps...
  6. - found root inode chunk
  7. Phase 3 - for each AG...
  8. - scan (but don't clear) agi unlinked lists...
  9. - process known inodes and perform inode discovery...
  10. - agno = 0
  11. - agno = 1
  12. - agno = 2
  13. - agno = 3
  14. - agno = 4
  15. - process newly discovered inodes...
  16. Phase 4 - check for duplicate blocks...
  17. - setting up duplicate extent list...
  18. - check for inodes claiming duplicate blocks...
  19. - agno = 0
  20. - agno = 1
  21. - agno = 2
  22. - agno = 3
  23. - agno = 4
  24. No modify flag set, skipping phase 5
  25. Phase 6 - check inode connectivity...
  26. - traversing filesystem ...
  27. - traversal finished ...
  28. - moving disconnected inodes to lost+found ...
  29. Phase 7 - verify link counts...
  30. No modify flag set, skipping filesystem flush and exiting.

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

  1. root @ kerneltalks # xfs_repair /dev/xvdf
  2.  
  3. Phase 1 - find and verify superblock . . .
  4. Phase 2 - using internal log
  5. - zero log . . .
  6. - scan filesystem freespace and inode maps . . .
  7. - found root inode chunk
  8. Phase 3 - for each AG . . .
  9. - scan and clear agi unlinked lists . . .
  10. - process known inodes and perform inode discovery . . .
  11. - agno = 0
  12. - agno = 1
  13. - agno = 2
  14. - agno = 3
  15. - agno = 4
  16. - process newly discovered inodes . . .
  17. Phase 4 - check for duplicate blocks . . .
  18. - setting up duplicate extent list . . .
  19. - check for inodes claiming duplicate blocks . . .
  20. - agno = 0
  21. - agno = 1
  22. - agno = 2
  23. - agno = 3
  24. - agno = 4
  25. Phase 5 - rebuild AG headers and trees . . .
  26. - reset superblock . . .
  27. Phase 6 - check inode connectivity . . .
  28. - resetting contents of realtime bitmap and summary inodes
  29. - traversing filesystem . . .
  30. - traversal finished . . .
  31. - moving disconnected inodes to lost + found . . .
  32. Phase 7 - verify and correct link counts . . .
  33. done

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

 

查看 XFS 版本以及它的詳細信息

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

  1. root@kerneltalks # xfs_info -V /shrikant
  2. xfs_info version 4.5.0

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

  1. root@kerneltalks # xfs_info /shrikant
  2. meta-data=/dev/xvdf isize=512 agcount=5, agsize=720896 blks
  3. = sectsz=512 attr=2, projid32bit=1
  4. = crc=1 finobt=0 spinodes=0
  5. data = bsize=4096 blocks=2883840, imaxpct=25
  6. = sunit=0 swidth=0 blks
  7. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
  8. log =internal bsize=4096 blocks=2560, version=2
  9. = sectsz=512 sunit=0 blks, lazy-count=1
  10. realtime =none extsz=4096 blocks=0, rtextents=0

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

此外還有一些 XFS 文件系統(tǒng)管理命令可以修改并管理 XFS 的元數(shù)據(jù)。我們將在另一篇文章中來講解。 

責(zé)任編輯:龐桂玉 來源: Linux中國
相關(guān)推薦

2018-01-02 11:55:59

Linux文件系統(tǒng)FSCK命令

2013-10-22 16:18:55

RHEL 6XFS

2010-03-16 14:42:16

linux環(huán)境

2011-03-07 09:11:23

2020-01-15 09:10:13

LinuxWindowsmacOS

2010-03-05 17:43:00

Linux XFS文件

2010-03-02 13:27:17

LinuxXFS文件系

2010-03-05 17:20:23

Linux XFS文件

2009-12-10 09:42:07

2012-02-07 09:41:46

XFSext4文件系統(tǒng)

2025-03-28 09:44:17

2010-04-26 17:34:37

Unix文件

2010-01-26 15:08:11

Android根文件系

2009-12-18 17:27:06

Fedora proc

2009-11-25 17:48:18

PHP文件系統(tǒng)相關(guān)函數(shù)

2019-07-23 18:00:45

Linux 開源操作系統(tǒng)

2023-09-27 23:19:04

Linuxmount

2010-07-16 16:09:05

Perl文件

2020-07-22 14:53:06

Linux系統(tǒng)虛擬文件

2021-03-10 08:02:58

Findmnt命令系統(tǒng)
點贊
收藏

51CTO技術(shù)棧公眾號