ext2文件系統 - mke2fs
阿新 • • 發佈:2018-02-13
desc name cin ever call resize problem 常用 oop 上一遍博文的重點其實將ext2整體的組織框架,我們知道了ext2文件系統由塊組組成,每個塊組裏面的組織形式。我們甚至直接把超級塊和組描述符裏面的內容,用十六進制形式展現了出來。這篇博文主要講述如何mke2fs生成合適需要的ext2 文件系統,基本就是參數選擇的問題。
mke2fs 常用的幾個參數有:
1) -b block-size .
塊大小是ext2文件系統比較重要的一個參數,目前只支持1024、2048和4096。上篇博文講到了其中的一點,就是塊大小決定了每個塊組最多管理多少個block塊。因為塊組中用1個block作為位圖來之時該塊組的某一塊是否空閑。
1024----最多有8K個塊----------塊組大小為8M字節 (1024字節/block*8K塊)
2048----最多有16K個塊---------塊組大小為32M字節
4096----最多有32K個快----------塊組大小為128M字節
說block-size重要,不光是因為他決定了塊組的一些屬性,她還決定了一個ext2文件的屬性(最大長度)。我們知道Inode中有個長度為15的數組指向文件的數據存儲的塊。前12個為直接指針,指向了數據所在的block塊。第13 個數組元素是1級間接指針,第14個數組元素為二級間接指針,第15個元素為三級間接指針,通過間接指針,ext2支持的文件最大長度獲得了極大的擴展。
文件的組織形式不是這篇博文的重點,我們掠過不細講
表 1. 各種數據塊對應的文件尋址範圍
默認情況下為1024。blocksize決定了,總的塊數也就決定了(在磁盤空間一定的情況下。比如我們空間就是500MB)。
表 1. 各種數據塊對應的文件尋址範圍
塊大小 | 直接尋址 | 間接尋址 | 二次間接尋址 | 三次間接尋址 |
1024 | 12KB | 268KB | 64.26MB | 16.06GB |
2048 | 24KB | 1.02MB | 513.02MB | 265.5GB |
4096 | 48KB | 4.04MB | 4GB | ~ 4TB |
- linux-tods:/mnt/bean # mke2fs /dev/loop0
- mke2fs 1.41.9 (22-Aug-2009)
- Filesystem label=
- OS type: Linux
- Block size=1024 (log=0)
- Fragment size=1024 (log=0)
- 128016 inodes, 512000 blocks
- 25600 blocks (5.00%) reserved for the super user
- First data block=1
- Maximum filesystem blocks=67633152
- 63 block groups
- 8192 blocks per group, 8192 fragments per group
- 2032 inodes per group
- Superblock backups stored on blocks:
- 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
- Writing inode tables: done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 26 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
- linux-tods:/mnt/bean # mke2fs -b 4096 /dev/loop0
- mke2fs 1.41.9 (22-Aug-2009)
- Filesystem label=
- OS type: Linux
- Block size=4096 (log=2)
- Fragment size=4096 (log=2)
- 128000 inodes, 128000 blocks
- 6400 blocks (5.00%) reserved for the super user
- First data block=0
- Maximum filesystem blocks=134217728
- 4 block groups
- 32768 blocks per group, 32768 fragments per group
- 32000 inodes per group
- Superblock backups stored on blocks:
- 32768, 98304
- Writing inode tables: done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 39 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
- linux-tods:/mnt/bean # mke2fs -m 10 /dev/loop0
- mke2fs 1.41.9 (22-Aug-2009)
- Filesystem label=
- OS type: Linux
- Block size=1024 (log=0)
- Fragment size=1024 (log=0)
- 128016 inodes, 512000 blocks
- 51200 blocks (10.00%) reserved for the super user
- First data block=1
- Maximum filesystem blocks=67633152
- 63 block groups
- 8192 blocks per group, 8192 fragments per group
- 2032 inodes per group
- Superblock backups stored on blocks:
- 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
- Writing inode tables: done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 23 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
點擊(此處)折疊或打開
- linux-tods:/mnt/bean # mke2fs -i 8192 /dev/loop0
- mke2fs 1.41.9 (22-Aug-2009)
- Filesystem label=
- OS type: Linux
- Block size=1024 (log=0)
- Fragment size=1024 (log=0)
- 64008 inodes, 512000 blocks
- 25600 blocks (5.00%) reserved for the super user
- First data block=1
- Maximum filesystem blocks=67633152
- 63 block groups
- ......
- linux-tods:/mnt/bean # dumpe2fs /dev/loop0
- Group 0: (Blocks 1-8192)
- Primary superblock at 1, Group descriptors at 2-3
- Reserved GDT blocks at 4-259
- Block bitmap at 260 (+259), Inode bitmap at 261 (+260)
- Inode table at 262-388 (+261)
- 7790 free blocks, 1005 free inodes, 2 directories
- Free blocks: 403-8192
- Free inodes: 12-1016
- Group 1: (Blocks 8193-16384)
- Backup superblock at 8193, Group descriptors at 8194-8195
- Reserved GDT blocks at 8196-8451
- Block bitmap at 8452 (+259), Inode bitmap at 8453 (+260)
- Inode table at 8454-8580 (+261)
- 7804 free blocks, 1016 free inodes, 0 directories
- Free blocks: 8581-16384
- Free inodes: 1017-2032
- linux-tods:/mnt/bean # mke2fs -i 1524 /dev/loop0
- mke2fs 1.41.9 (22-Aug-2009)
- Filesystem label=
- OS type: Linux
- Block size=1024 (log=0)
- Fragment size=1024 (log=0)
- 344232 inodes, 512000 blocks
- 25600 blocks (5.00%) reserved for the super user
- First data block=1
- Maximum filesystem blocks=67633152
- 63 block groups
- 8192 blocks per group, 8192 fragments per group
- 5464 inodes per group
- Superblock backups stored on blocks:
- Inode count: 128016
- Block count: 512000
- Reserved block count: 25600
- Free blocks: 493526
- Free inodes: 128005
- First block: 1
- Block size: 1024
ext2文件系統 - mke2fs