佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > Centos的Inode和Block的相關(guān)知識

Centos的Inode和Block的相關(guān)知識

熱門標(biāo)簽:硅谷的囚徒呼叫中心 外呼系統(tǒng) 服務(wù)器配置 電話機器人搭建 百度競價點擊價格的計算公式 解決方案 美團 家政服務(wù)網(wǎng)絡(luò)

本經(jīng)驗均在CentOSrelease6.7(Final)下操作,如知識有欠缺之處 歡迎批評指正。

linux 的inode及block的相關(guān)知識:

1> Linux系統(tǒng)分區(qū)格式化文件系統(tǒng)之后,系統(tǒng)會分為Inode及Block兩部分:

1)Inode為系統(tǒng)文件的屬性信息(ls -l的結(jié)果)及指向文件實體的指針,但是沒有存放文件名,一般在上級目錄里的Block。

2)Block為存放數(shù)據(jù)的,ext3/ext4一般為1k,2k,4k,一般默認4k

3)一個文件不論多大至少占用一個Inode和一個Block,一個Block只能存放一個文件的內(nèi)容,block的數(shù)量大于Inode的數(shù)量,多個文件可以占用同一個 inode(硬鏈接) 。

4)訪問文件, 通過文件-->inode(驗證權(quán)限)--->blocks.

5)inode 一般情況默認256B,block大小1k,2k,4k,默認4k,注意,引導(dǎo)分區(qū)等特殊分區(qū)除外。

6)通過df -i 查看inode的數(shù)量及使用情況,dumpe2fs /dev/sda1  查看inode及block的大小和數(shù)量。

7)一個block只能 被一個文件使用 ,如果一個文件很小block太大,剩余空間浪費,無法繼續(xù)被其他文件使用。

8)block不是越大越好,根據(jù)業(yè)務(wù)的文件大小進行選擇,一般就是默認 4k。

9)可以在格式化的時候改變inode及block的大小,使用mkfs.ext4 -b 2048 -I 1024  /dev/sdb2

2>Linux中df命令的功能是用來檢查linux服務(wù)器的文件系統(tǒng)的磁盤空間占用情況??梢岳迷撁顏慝@取硬盤被占用了多少空間,目前還剩下多少空間等信息。

1.命令格式:

df [選項] [文件]

2.參數(shù) :

df -i  查看參數(shù)多少個

[root@techW ~]# df -i
Filesystem            Inodes IUsed   IFree IUse% Mounted on
/dev/mapper/vg_techw-lv_root
                     1152816 55846 1096970    5% /
tmpfs                 125596     1  125595    1% /dev/shm
/dev/sda1             128016    38  127978    1% /boot

df -h 查看磁盤大小:

[root@techW ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_techw-lv_root
                       18G  1.5G   15G   9% /
tmpfs                 491M     0  491M   0% /dev/shm
/dev/sda1             477M   36M  416M   8% /boot

查看當(dāng)前系統(tǒng)分區(qū)的Inode及Block的總量及使用量:

[root@techW ~]# dumpe2fs  /dev/sda1 | grep -i "block size"
dumpe2fs 1.41.12 (17-May-2010)
Block size:               1024
[root@techW ~]# 
[root@techW ~]# 
[root@techW ~]# dumpe2fs  /dev/sda1 | grep -i "inode size"
dumpe2fs 1.41.12 (17-May-2010)
Inode size:               128    ###boot分區(qū)為128,常規(guī)分區(qū)為256
[root@techW ~]# 
[root@techW ~]# 
[root@techW ~]# dumpe2fs  /dev/sda1 | grep -i "inode count"
dumpe2fs 1.41.12 (17-May-2010)
Inode count:              128016
[root@techW ~]# 
[root@techW ~]# dumpe2fs  /dev/sda1 | grep -i "block count"
dumpe2fs 1.41.12 (17-May-2010)
Block count:              512000
Reserved block count:     25600

3>添加一塊磁盤,格式化,改變Inode及 Block的大小,掛載查看硬盤的Inode及Block數(shù)量:

1)添加一塊5G的磁盤,為方便區(qū)分設(shè)置為/dev/sdb,fdisk分區(qū),然后mkfs.ext4格式化

(虛擬機增加一塊5G的硬盤,分區(qū),格式化)

[root@techW ~]# fdisk  /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x2d37eabe.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').
Command (m for help):  n ### add a new partition
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2  ### 為做區(qū)分,選擇2
First cylinder (1-652, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): 
Using default value 652
Command (m for help): w   ###  write table to disk and exit
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

分區(qū)時的參數(shù)命令:

a   toggle a bootable flag
b   edit bsd disklabel
c   toggle the dos compatibility flag
d   delete a partition
l   list known partition types
m   print this menu
n   add a new partition
o   create a new empty DOS partition table
p   print the partition table
q   quit without saving changes
s   create a new empty Sun disklabel
t   change a partition's system id
u   change display/entry units
v   verify the partition table
w   write table to disk and exit
x   extra functionality (experts only)
[root@techW ~]# mkfs.ext4 /dev/sdb2
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)    ###默認的Block的大小為4096
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1309289 blocks
65464 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done                            
Creating journal (32768 blocks): 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.

2)###inode的大小范圍為128-2048,block的大小范圍為1024-4096####

3)將Block和Inode的大小都改為2048:

[root@techW ~]# mkfs.ext4 -b 2048 -I 2048 /dev/sdb2
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
326400 inodes, 2618578 blocks
130928 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=540016640
160 block groups
16384 blocks per group, 16384 fragments per group
2040 inodes per group
Superblock backups stored on blocks: 
        16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816, 1327104, 
        2048000
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

4)使用dumpe2fs命令查詢Inode和Block的大?。?/p>

[root@techW ~]# dumpe2fs  /dev/sdb2 | grep "Inode size"
dumpe2fs 1.41.12 (17-May-2010)
Inode size:               2048  ###大小更改成功
[root@techW ~]# 
s  /dev/sdb2 | grep "Block size"
dumpe2fs 1.41.12 (17-May-2010)
Block size:               2048  ###大小更改成功

標(biāo)簽:防城港 北海 韶關(guān) 烏蘭察布 邢臺 南昌 臨沂 撫州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Centos的Inode和Block的相關(guān)知識》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    永寿县| 静海县| 襄樊市| 普定县| 祁连县| 南木林县| 礼泉县| 宝丰县| 高州市| 青岛市| 东丽区| 筠连县| 铁岭市| 万安县| 梁河县| 大同市| 金华市| 十堰市| 边坝县| 砀山县| 东平县| 普格县| 手机| 赞皇县| 新平| 建平县| 安福县| 平顶山市| 长沙市| 登封市| 兴宁市| 衡阳县| 稷山县| 靖远县| 循化| 甘洛县| 福建省| 濮阳县| 平乐县| 琼结县| 庄浪县|