Linux

ext4 fs 的 LVM 快照看起來不是很乾淨

  • September 16, 2013

我創建了一個掛載的 ext4 fs 的 LVM 快照:

lvcreate -L 10GiB -s -n "root-snapshot" "/dev/myvgname/root"

如果我然後在 /dev/myvgname/root-snapshot 上執行 e2fsck,它會說:

e2fsck 1.42.5 (29-Jul-2012)
Clearing orphaned inode 263640 (uid=0, gid=0, mode=0100600, size=0)
Clearing orphaned inode 260744 (uid=0, gid=0, mode=0100600, size=0)
Clearing orphaned inode 266864 (uid=0, gid=0, mode=0100600, size=0)
Clearing orphaned inode 261058 (uid=103, gid=107, mode=0100600, size=0)
Clearing orphaned inode 261057 (uid=103, gid=107, mode=0100600, size=0)
Clearing orphaned inode 261001 (uid=103, gid=107, mode=0100600, size=0)
Clearing orphaned inode 260918 (uid=103, gid=107, mode=0100600, size=0)
Clearing orphaned inode 260913 (uid=103, gid=107, mode=0100600, size=0)
root: clean, 52533/977280 files, 811160/3905536 blocks

為什麼要清除那些孤立的 inode?LVM 不應該使底層 fs 處於一致(乾淨)狀態嗎?

拍攝快照時,文件系統被凍結,但該狀態與完全解除安裝的文件系統的狀態並不完全相同。來自man fsfreeze

Note that even after freezing, the on-disk filesystem  can  con‐
tain  information  on  files  that  are  still in the process of
unlinking.  These files will not be unlinked until the  filesys‐
tem is unfrozen or a clean mount of the snapshot is complete.

引用自:https://serverfault.com/questions/539209