ループバックデバイスでイメージファイルをマウント
10MB のファイルを作成。
root@ru:~# dd if=/dev/zero of=disk bs=1M count=10 10+0 records in 10+0 records out 10485760 bytes (10 MB) copied, 0.0160953 seconds, 651 MB/s
root@ru:~# mkfs.ext3 -b 4096 -i 8192 mke2fs 1.40.2 (12-Jul-2007) disk is not a block special device. Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 1280 inodes, 2560 blocks 128 blocks (5.00%) reserved for the super user First data block=0 1 block group 32768 blocks per group, 32768 fragments per group 1280 inodes per group Writing inode tables: 0/1done Creating journal (1024 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 33 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
root@ru:~# ls -l disk -rw-rw-r-- 1 root root 10485760 2008-03-02 12:14 disk
マウント。
root@ru:~# mount -o loop -t ext3 disk /mnt/hoge root@ru:~# cd /mnt/hoge root@ru:/mnt/hoge# ls -li 合計 24 2 drwxr-xr-x 3 root root 4096 2008-03-02 12:14 ./ 3424257 drwxr-xr-x 3 root root 4096 2008-03-02 11:48 ../ 11 drwx------ 2 root root 16384 2008-03-02 12:14 lost+found/
i-node 3 から 10 は?
→ e2fsprogs の ext2_fs.h によれば
/* * Special inode numbers */ #define EXT2_BAD_INO 1 /* Bad blocks inode */ #define EXT2_ROOT_INO 2 /* Root inode */ #define EXT2_ACL_IDX_INO 3 /* ACL inode */ #define EXT2_ACL_DATA_INO 4 /* ACL inode */ #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ #define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */ #define EXT2_JOURNAL_INO 8 /* Journal inode */ /* First non-reserved inode for old ext2 filesystems */ #define EXT2_GOOD_OLD_FIRST_INO 11
とのこと。9 と 10 は未使用っぽい。
root@ru:/mnt/hoge# for i in `set 1 10000`; do touch $i;done touch: cannot touch `1270': No space left on device touch: cannot touch `1271': No space left on device touch: cannot touch `1272': No space left on device ...
root@ru:/mnt/hoge# ls -li | sort -n +1 11 drwx------ 2 root root 16384 2008-03-02 12:14 lost+found 12 -rw-rw-r-- 1 root root 0 2008-03-02 12:15 1 13 -rw-rw-r-- 1 root root 0 2008-03-02 12:15 2 14 -rw-rw-r-- 1 root root 0 2008-03-02 12:15 3 … 1279 -rw-rw-r-- 1 root root 0 2008-03-02 12:15 1268 1280 -rw-rw-r-- 1 root root 0 2008-03-02 12:15 1269 合計 16
きっちり 1280 まで。
root@ru:/mnt/hoge# stat 1 File: `1' Size: 0 Blocks: 0 IO Block: 4096 通常の空ファイル Device: 700h/1792d Inode: 12 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2008-03-02 12:15:15.000000000 +0900 Modify: 2008-03-02 12:15:15.000000000 +0900 Change: 2008-03-02 12:15:15.000000000 +0900
root@ru:/mnt/hoge# df Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 ... /root/disk 10064 4144 5408 44% /mnt/hoge
fsck してみる。fsck disk だとダメだけと絶対パスで指定すると成功する。
# umount してから root@ru:~# fsck `realpath disk` fsck 1.40.2 (12-Jul-2007) e2fsck 1.40.2 (12-Jul-2007) /root/disk: clean, 1280/1280 files, 1076/2560 blocks
dumpe2fs してみる。
root@ru:~# dumpe2fs disk dumpe2fs 1.40.2 (12-Jul-2007) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: 93d69b34-2a4f-48e5-adb9-3802fe8de5f3 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal resize_inode dir_index filetype needs_recovery sparse_super large_file Filesystem flags: signed directory hash Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 1280 Block count: 2560 Reserved block count: 128 Free blocks: 125 Free inodes: 1 First block: 0 Block size: 4096 Fragment size: 4096 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 1280 Inode blocks per group: 40 Filesystem created: Sun Mar 2 12:14:23 2008 Last mount time: Sun Mar 2 13:08:04 2008 Last write time: Sun Mar 2 13:08:04 2008 Mount count: 2 Maximum mount count: 33 Last checked: Sun Mar 2 12:14:23 2008 Check interval: 15552000 (6 months) Next check after: Fri Aug 29 12:14:23 2008 Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Journal inode: 8 Default directory hash: tea Directory Hash Seed: 06d74b6f-3b0c-4c42-9cbb-29258cc81c9c Journal backup: inode blocks Journal size: 4104k Group 0: (Blocks 0-2559) Primary superblock at 0, Group descriptors at 1-1 Block bitmap at 2 (+2), Inode bitmap at 3 (+3) Inode table at 4-43 (+4) 1484 free blocks, 1270 free inodes, 1 directories Free blocks: 45-48, 1080-2559 Free inodes: 11-1280
ブロック 49 から 1079 は?
lost+found も含め、全てのファイルを削除した状態:
/root/disk 9904 4112 5280 44% /mnt/hoge
minfree 5%(128 blocks=512KB)。9904 = 4112 + 5280 + 512
root@ru:/mnt/hoge3# dd if=/dev/zero of=1 bs=1K count=5268 /root/disk 9904 9392 0 100% /mnt/hoge
minfree まで使い切った状態:
/root/disk 9904 9904 0 100% /mnt/hoge
root@ru:/mnt/hoge# dd if=/dev/zero of=2 bs=4K count=100 dd: writing `2': No space left on device
ディレクトリエントリの追加はまだできる。
root@ru:/mnt/hoge# touch hoge
でももうデータブロックは使えない。
root@ru:/mnt/hoge# echo hogehoge > hoge -su: echo: write error: No space left on device