xfsについて調べた
XFSとは
XFSは、Silicon Graphics
という会社が自社のIRIXというUNIXOS向けに開発されたジャーナルファイルシステムで、巨大なファイルシステムなどに対応する目的で開発されたもの。
RHEL7で採用されているらしいです。
XFS の主な特徴
- XFS は、より迅速にクラッシュリカバリを行うメタデータジャーナリングに対応しています。
- XFS ファイルシステムは、マウントされてアクティブな際にデフラグおよび拡張できます。
- また、Red Hat Enterprise Linux 7 は XFS に固有のユーティリティのバックアップと復元に対応しています。
とのこと
参考:
第3章 XFS ファイルシステム Red Hat Enterprise Linux 7 | Red Hat Customer Portal
まず使用できるか確認してみる
modprobe xfs grep xfs /proc/filesystems xfs
XFSファイルシステムを作成
家に転がっていた4GのHDDを使います。
ディスク /dev/sdb: 4 GiB, 4327464960 バイト, 8452080 セクタ 単位: セクタ (1 * 512 = 512 バイト) セクタサイズ (論理 / 物理): 512 バイト / 512 バイト I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト ディスクラベルのタイプ: gpt ディスク識別子:
mkfs.xfs
または mkfs -t xfs
で、作成します。
sudo mkfs -t xfs /dev/sdb1 mkfs.xfs: /dev/sdb1 appears to contain an existing filesystem (ext4). mkfs.xfs: Use the -f option to force overwrite.
すでに、ファイルシステムが含まれていると警告を出し、続行できないので -f
で上書きます。
sudo mkfs -t xfs -f /dev/sdb1 meta-data=/dev/sdb1 isize=512 agcount=4, agsize=264000 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=0, rmapbt=0, reflink=0 data = bsize=4096 blocks=1056000, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
マウントする
特に指定無しで、マウントできました。
sudo mount /dev/sdb1 /mnt/disk/ sudo bash -c "echo test > /mnt/disk/test.txt" # 一応、読み書きできるか確認 cat /mnt/disk/test.txt test sudo umount /dev/sdb1
ファイルシステムのチェック
xfs_repair
で、ファイルシステムのチェック・修復を行います。
ext系で言うと、それぞれ fsck
, e2fsck
コマンドにあたります。
修復を行わず、チェックだけの場合は、-n
コマンドを使います。
xfs_check
というコマンドもあるようなのですが、どうやらチェックのスピードが遅い関係で、非推奨になっているようです。
sudo xfs_repair /dev/sdb1 Phase 1 - find and verify superblock... Phase 2 - using internal log - zero log... - scan filesystem freespace and inode maps... - found root inode chunk Phase 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 - 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 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
ファイルシステムのパラメータ変更
ファイルシステムのパラメータ変更は、xfs_admin
を使います。
ext系で言うと、 tune2fs
コマンドにあたります。
xfs_admin -u デバイス名
・・・ UUIDを表示xfs_admin -U デバイス名
・・・ UUIDを設定xfs_admin -l デバイス名
・・・ ラベルを表示xfs_admin -L デバイス名
・・・ ラベルを設定
sudo xfs_admin -U `uuidgen` /dev/sdb1 Clearing log and setting UUID writing all SBs new UUID = 6774ad78-fd02-417d-b717-f08c2b29214f sudo xfs_admin -L "test" /dev/sdb1 writing all SBs new label = "test" sudo xfs_admin -ul /dev/sdb1 UUID = 6774ad78-fd02-417d-b717-f08c2b29214f label = "test"
ファイルシステムの情報を表示
ファイルシステムの情報を表示は、xfs_info
を使います。
ext系で言うと、 dumpe2fs
コマンドにあたります。
xfs_info /dev/sdb1 meta-data=/dev/sdb1 isize=512 agcount=4, agsize=264000 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1 spinodes=0 rmapbt=0 = reflink=0 data = bsize=4096 blocks=1056000, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
ファイルシステムのバックアップ・リストア
ファイルシステムの情報を表示は、xfsdump
xfsrestore
を使います。
(xfsのあとにハイフンはつかないので注意)
ext系で言うと、 dump
restore
コマンドにあたります。
バックアップ
sudo xfsdump -l 0 -L test -f /tmp/test /dev/sdb1 xfsdump: using file dump (drive_simple) strategy xfsdump: version 3.1.6 (dump format 3.0) - type ^C for status and control xfsdump: level 0 dump of XXXXXXXXXXXXX:/mnt/disk xfsdump: dump date: Tue Oct 15 00:29:24 2019 xfsdump: session id: xfsdump: session label: "test" xfsdump: ino map phase 1: constructing initial dump list xfsdump: ino map phase 2: skipping (no pruning necessary) xfsdump: ino map phase 3: skipping (only one dump stream) xfsdump: ino map construction complete xfsdump: estimated dump size: 25216 bytes xfsdump: /var/lib/xfsdump/inventory created ============================= media label dialog ============================= please enter label for media in drive 0 (timeout in 300 sec) -> test media label entered: "test" --------------------------------- end dialog --------------------------------- xfsdump: creating dump session media file 0 (media 0, file 0) xfsdump: dumping ino map xfsdump: dumping directories xfsdump: dumping non-directory files xfsdump: ending media file xfsdump: media file size 21880 bytes xfsdump: dump size (non-dir files) : 544 bytes xfsdump: dump complete: 6 seconds elapsed xfsdump: Dump Summary: xfsdump: stream 0 /tmp/test.txt OK (success) xfsdump: Dump Status: SUCCESS
リストア
xfsrestore -f /tmp/test -L test /tmp/restore/test xfsrestore: using file dump (drive_simple) strategy xfsrestore: version 3.1.6 (dump format 3.0) - type ^C for status and control xfsrestore: using online session inventory xfsrestore: searching media for directory dump xfsrestore: examining media file 0 xfsrestore: reading directories xfsrestore: 1 directories and 1 entries processed xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: 0 seconds elapsed xfsrestore: Restore Summary: xfsrestore: stream 0 /tmp/test OK (success) xfsrestore: Restore Status: SUCCESS ls /tmp/res/ test.txt
XFSとext系ファイルシステムの管理コマンドの比較
こちらのページに見やすい比較表がありました。 http://www.intellilink.co.jp/article/column/oss-rh02.html