高階Linux運維工程師必備技能(掃盲篇)

weixin_33896726發表於2017-05-11

                      高階Linux運維工程師必備技能(掃盲篇)

                                            作者:尹正傑

版權宣告:原創作品,謝絕轉載!否則將追究法律責任。

 

  在瞭解檔案系統之前,我們要學習一下磁碟儲存資料的方式,大家都知道檔案從記憶體若要持久化儲存的話就得把它存到硬碟上,想畢都知道檔案存入磁碟都是二進位制存取的。那麼硬碟是如何儲存的呢?我們現在標配基本上都是1T呢,現在都是2017了,500G的硬碟都已經遭嫌棄了。
                      
1.生活小知識。
  上面是一幅圖可以看到,有磁頭,而且這個磁頭是懸浮在盤面上的,如果這個盤面有震動,很可能直接滑到盤面,導致上面寫的資料被劃掉,造成資料丟失,因此,我們在購買硬碟的時候都寫著不能強劇烈震動。硬碟在工作的時候,這個盤面一直在轉,如果訪問裡面的資料,需要一定時間,我們稱之為“平均尋道時間”。把不同盤面上的相同磁軌(可以理解就是盤面上的一個圈,整個盤面有好多個這個樣的打圈小圈形成的)劃分成同一個分割槽內部。那麼這些維護不同盤面的相同編號的磁軌我們成為柱面(cylinder).磁碟劃分實際上是按照柱面劃分的,那麼很顯然在最外層的柱面劃分出來的分割槽的效能是最好的,你可能會問為什麼?原因很簡單,就是在相同的角速度中,最外層的周長是最大(也就意味著它儲存的資料將越多)。因此我們在劃分分割槽的時候依次劃分C,D,E硬碟,最先劃分的是C盤(分割槽軟體預設把C盤劃分到最外層),因此大家都用C盤做系統盤是有原因的喲!
 
2.MBR分割槽
在整塊硬碟的最外側磁軌上,在第零("0")個扇區上,這個扇區是不能用來劃分割槽的,因為這個扇區上存放著整塊磁碟的分割槽資訊。這個分割槽通常被稱作為MBR(Master Boot Record,主開機記錄 )分割槽(現在都流行GPT分割槽了),這個扇區僅僅佔用了512個位元組(bytes),你可別小看這512bytes,
a>.它保函了引導載入器(bootloader,其佔用了446bytes);
b>.fat,即分割槽表,其佔用了64bytes,每16bytes一個分割槽,總共只能分割槽4個[據說比爾蓋茲層發表過言論:“硬碟這麼小,有誰能用到多餘4個分割槽呢?)【當時的硬碟都很小而且特別貴,只有幾百兆(M)大小】”;
c>.5A,其為十六進位制的“5A”,佔用最後2個位元組,用來標記這個MBR分割槽是否是有效資料的(2個位元組被填充了2個5A,MBR有效性標記)。
硬碟內部都是真空的,為什麼呢?因為它要旋轉,有的硬碟的轉速高達1.5w/m,如果不坐車真空的這麼高的轉速很容易和真空中的微粒發生碰撞,導致溫度過高!所以不要輕易拆開硬碟,基本上你拆開就不是真空了,即使拆開後能用,也用不了多長時間就會壞掉的。
 
3.擴充套件分割槽與邏輯分割槽
隨著硬碟的儲存資料進一步的增長,我們分割槽4個是遠遠夠用的,因此需要從4個主分割槽中拿出一個分割槽單獨,用來存放其他的分割槽資訊我們叫它為“擴充套件分割槽”,如果這個擴充套件分割槽足夠大,就可以對其進行劃分多個分割槽讓不同使用者使用。因此這個擴充套件分割槽(引用額外的分割槽表)是不能被格式化的,這樣它就不能被使用,需要額外劃分出一個或多個邏輯分割槽才能被使用。
 
4.MBR分割槽方法
a>.4個主分割槽
b>.3個主分割槽和一個擴充套件分割槽。
注意:MBR最大支援2T的硬碟。大於2TB就得使用GPT分割槽格式!
 
5.硬碟介面
DMA:Direct Memory Access (直接記憶體訪問機制)
磁碟裝置存放於/dev/資料夾下,
IDE介面的磁碟:/dev/hda、/dev/hdb、/dev/hdc、/dev/hdd
SCSI介面的磁碟:/dev/sda、/dev/sdb、/dev/sdc、/dev/sdd
/dev/XdYZ
/dev/ 表示的是一個裝置目錄
X h IDE硬碟
s SATA、SISC、U盤
Y a 第一塊硬碟
b 第二塊硬碟
c 第三塊硬碟
。。。。。。。。。。
 
Z 1-3表示主分割槽,4一般為擴充套件分割槽
5是邏輯分割槽第一個分割槽
6是邏輯分割槽第二個分割槽
。。。。。。。。。。
a>.IDE(ATA):並口,每個控制器可接兩個硬碟,master/slave,133MB/S(這個速率就是被淘汰的根部原因)
/dev/hd[a-z](注意:在Centos6.x版本以後,所有的硬碟即便是IDE介面的都被識別為sd,早起的裝置被設定為hd)
/dev//hda[1-4](標識4個主分割槽)
/dev/hda[5+](邏輯分割槽5開始)
b>.SCSI:Small Computer System Interface (小型計算機介面,在讀取資料上效率很高,因為它有單獨的SCSI控制器,容錯能力強且抗衰老【但是價格貴啊,相同儲存空間是機械硬碟的8倍價格呢!】) 速率:320mb/s 也是並口的 (有的人為了省錢用IDE做raid陣列)
c>.SATA(Serial):300Mbps,600Mbps,6Gbps
d>.SAS:6Gbps
e>.USB:2.0介面: 3.0介面:

 

6.檢視系統是如何識別磁碟分割槽的
 1 [root@yinzhengjie ~]# cat /proc/partitions  #檢視系統識別的分割槽
 2 major minor  #blocks  name
 3 
 4    8        0  292968750 sda
 5    8       16  292968750 sdb
 6    9      127  278290432 md127
 7  259        0     512000 md127p1
 8  259        1  277777408 md127p2
 9  253        0   52428800 dm-0
10  253        1   33038336 dm-1
11  253        2  192307200 dm-2
12 [root@yinzhengjie ~]# 
  注意:如果你對你的硬碟剩餘的空間進行分割槽後,新加的分割槽資訊核心是不能識別的,需要核心去重讀硬體的分割槽表,重啟是不頂事的!我在生產環境中就遇到過這麼一個坑。
 
7.根在核心
  根做為訪問檔案的入口,那麼這個根到底在硬碟上呢?還是在作業系統上呢?根實際上是在核心中,我們訪問資料都是作業系統將這個硬碟掛在到了根下,然後我們去訪問它而已。那你又會問了,那核心在哪啊?答案是在磁碟上。
實際上,在裝載核心之前,先啟動的是bootloader(核心未啟動就還沒有檔案系統存在),bootloader區磁碟上找到核心並啟動,核心啟動後會自動生成一個“/”(根),並將磁碟的檔案都掛在到“/”下,這就形成了檔案系統。
 
8.linux目錄
 1 /bin,/sbin                         #存放系統自身完成自己的啟動和基本執行機制索要提供的程式;。
 2 /usr/bin,/usr/sbin                  #存放完成作業系統基本功能的所提供的二進位制程式;
 3 /usr/local/bin,/usr/local/sbin      #存放第三方程式;
 4 /lib,/lib64,/usr/lib,/usr/lib64     #存放庫檔案的;
 5 /etc/                             #存放配置檔案的;
 6 /media,/mnt                      #用於掛在的目錄,當然你也可以自定義的;
 7 /dev                             #存放各種裝置檔案;
 8 /proc,/sys                         #存放執行中的記憶體對映資料;
 9 /home,/root                      #存放各普通使用者的家目錄,比如 /home/yinzhengjie;
10 /var                               #存放日誌的目錄;
11 /opt,/misc                         #觸發掛在目錄;
12 /srv                             #存放服務相關資料的;
13 /tmp                             #存放各種臨時檔案,每次關機時自動清理;
14 /boot                           #存放核心、引導選單等啟動檔案;
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 /:根目錄,一般根目錄下只存放目錄,不要存放檔案,/etc、/bin、/dev、/lib、/sbin應該和根目錄放置在一個分割槽中
 9 
10 /bin:/usr/bin:可執行二進位制檔案的目錄,如常用的命令ls、tar、mv、cat等。
11 
12 /boot:放置linux系統啟動時用到的一些檔案。/boot/vmlinuz為linux的核心檔案,以及/boot/gurb。建議單獨分割槽,分割槽大小200M即可
13 
14 /dev:存放linux系統下的裝置檔案,訪問該目錄下某個檔案,相當於訪問某個裝置,常用的是掛載光碟機mount /dev/cdrom /mnt。
15 
16 /etc:系統配置檔案存放的目錄,不建議在此目錄下存放可執行檔案,重要的配置檔案有/etc/inittab、/etc/fstab、/etc/init.d、/etc/X11、/etc/sysconfig、/etc/xinetd.d修改配置檔案之前記得備份。
17 
18 注:/etc/X11存放與x windows有關的設定。
19 
20 /home:系統預設的使用者家目錄,新增使用者賬號時,使用者的家目錄都存放在此目錄下,~表示當前使用者的家目錄,~test表示使用者test的家目錄。建議單獨分割槽,並設定較大的磁碟空間,方便使用者存放資料
21 
22 /lib:/usr/lib:/usr/local/lib:系統使用的函式庫的目錄,程式在執行過程中,需要呼叫一些額外的引數時需要函式庫的協助,比較重要的目錄為/lib/modules。
23 
24 /lost+fount:系統異常產生錯誤時,會將一些遺失的片段放置於此目錄下,通常這個目錄會自動出現在裝置目錄下。如載入硬碟於/disk 中,此目錄下就會自動產生目錄/disk/lost+found
25 
26 /mnt:/media:光碟預設掛載點,通常光碟掛載於/mnt/cdrom下,也不一定,可以選擇任意位置進行掛載。
27 
28 /opt:給主機額外安裝軟體所擺放的目錄。如:FC4使用的Fedora 社群開發軟體,如果想要自行安裝新的KDE 桌面軟體,可以將該軟體安裝在該目錄下。以前的 Linux 系統中,習慣放置在 /usr/local 目錄下
29 
30 /proc:此目錄的資料都在記憶體中,如系統核心,外部裝置,網路狀態,由於資料都存放於記憶體中,所以不佔用磁碟空間,比較重要的目錄有/proc/cpuinfo、/proc/interrupts、/proc/dma、/proc/ioports、/proc/net/*等
31 
32 /root:系統管理員root的家目錄,系統第一個啟動的分割槽為/,所以最好將/root和/放置在一個分割槽下。
33 
34 /sbin:/usr/sbin:/usr/local/sbin:放置系統管理員使用的可執行命令,如fdisk、shutdown、mount等。與/bin不同的是,這幾個目錄是給系統管理員root使用的命令,一般使用者只能"檢視"而不能設定和使用。
35 
36 /tmp:一般使用者或正在執行的程式臨時存放檔案的目錄,任何人都可以訪問,重要資料不可放置在此目錄下
37 
38 /srv:服務啟動之後需要訪問的資料目錄,如www服務需要訪問的網頁資料存放在/srv/www內
39 
40 /usr:應用程式存放目錄,/usr/bin存放應用程式,/usr/share存放共享資料,/usr/lib存放不能直接執行的,卻是許多程式執行所必需的一些函式庫檔案。/usr/local:存放軟體升級包。/usr/share/doc:系統說明檔案存放目錄。/usr/share/man: 程式說明檔案存放目錄,使用 man ls時會查詢/usr/share/man/man1/ls.1.gz的內容建議單獨分割槽,設定較大的磁碟空間
41 
42 /var:放置系統執行過程中經常變化的檔案,如隨時更改的日誌檔案/var/log,/var/log/message:所有的登入檔案存放目錄,/var/spool/mail:郵件存放的目錄,/var/run:程式或服務啟動後,其PID存放在該目錄下。建議單獨分割槽,設定較大的磁碟空間
43 '''
Linux目錄詳細版本,猛戳這裡!!
 
9.用來對裝置進行分割槽的命令
用於分割槽的管理工具:fdisk,sfdisk,parted
a>.檢視分割槽資訊
 1 [root@yinzhengjie ~]# fdisk -l /dev/[sh]d[a-z]  #使用檔名通配過濾掉沒有用的資訊(不是正規表示式喲),可以看出下面只有2個硬碟
 2 
 3 Disk /dev/sda: 21.5 GB, 21474836480 bytes
 4 255 heads, 63 sectors/track, 2610 cylinders
 5 Units = cylinders of 16065 * 512 = 8225280 bytes
 6 Sector size (logical/physical): 512 bytes / 512 bytes
 7 I/O size (minimum/optimal): 512 bytes / 512 bytes
 8 Disk identifier: 0x00059922
 9 
10    Device Boot(是否可引導)      Start         End      Blocks   Id(對應檔案系統的ID)  System
11 /dev/sda1   *(*表示可以引導)           1          39      307200   83  Linux
12 Partition 1 does not end on cylinder boundary.
13 /dev/sda2              39        2358    18631680   83  Linux
14 /dev/sda3            2358        2611     2031616   82  Linux swap / Solaris
15 
16 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
17 255 heads, 63 sectors/track, 1305 cylinders
18 Units = cylinders of 16065 * 512 = 8225280 bytes
19 Sector size (logical/physical): 512 bytes / 512 bytes
20 I/O size (minimum/optimal): 512 bytes / 512 bytes
21 Disk identifier: 0x00000000
22 
23 [root@yinzhengjie ~]# 
b>虛擬檔案系統
              
 
VFS:(Virtual File System)#虛擬檔案系統
基本檔案系統:Ext3,Ext3,Ext4,Reiserfs(早起的suse用的就是該檔案系統喲),xfs(支援單個巨大的檔案),JFS(日誌檔案系統,IBM開發的),vfat,NTFS
交換分割槽:swap
叢集檔案系統:GFS2(紅帽系統研發,谷歌都再用呢),OCFS2(甲骨文公司研發,用的人不多)
網路檔案系統:NFS,smbfs(window是CIFS)
光碟:iso9660
c>.對磁碟進行分割槽
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 fdisk:
 9     d 刪除分割槽
10     n:新建一個分割槽
11     p:列出已有分割槽
12     t:調至分割槽ID
13     l:列出核心支援的分割槽id
14     w:儲存退出
15     q:不儲存退出 
16     m:幫助
17 '''
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# fdisk /dev/sdb  #對第二塊硬碟進行分割槽
  9 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 10 Building a new DOS disklabel with disk identifier 0x8614a108.
 11 Changes will remain in memory only, until you decide to write them.
 12 After that, of course, the previous content won't be recoverable.
 13 
 14 Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 15 
 16 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
 17          switch off the mode (command 'c') and change display units to
 18          sectors (command 'u').
 19 
 20 Command (m for help): m  #檢視幫助
 21 Command action
 22    a   toggle a bootable flag
 23    b   edit bsd disklabel
 24    c   toggle the dos compatibility flag
 25    d   delete a partition
 26    l   list known partition types
 27    m   print this menu
 28    n   add a new partition
 29    o   create a new empty DOS partition table
 30    p   print the partition table
 31    q   quit without saving changes
 32    s   create a new empty Sun disklabel
 33    t   change a partition's system id
 34    u   change display/entry units
 35    v   verify the partition table
 36    w   write table to disk and exit
 37    x   extra functionality (experts only)
 38 
 39 Command (m for help): p  #列出已有分割槽
 40 
 41 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 42 255 heads, 63 sectors/track, 1305 cylinders
 43 Units = cylinders of 16065 * 512 = 8225280 bytes
 44 Sector size (logical/physical): 512 bytes / 512 bytes
 45 I/O size (minimum/optimal): 512 bytes / 512 bytes
 46 Disk identifier: 0x8614a108
 47 
 48    Device Boot      Start         End      Blocks   Id  System
 49 
 50 Command (m for help): n   #新建一個分割槽
 51 Command action
 52    e   extended   #擴充套件分割槽
 53    p   primary partition (1-4)  #主分割槽
 54 p  #選擇主分割槽
 55 Partition number (1-4): 1  #選擇編號
 56 First cylinder (1-1305, default 1):  #選擇分割槽的起始點,預設為1
 57 Using default value 1
 58 Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +1G  #建立一個1G的主分割槽
 59 
 60 Command (m for help): n  #再新建一個分割槽
 61 Command action
 62    e   extended
 63    p   primary partition (1-4)
 64 p   #選擇型別為主分割槽
 65 Partition number (1-4): 2  #設定編號為2
 66 First cylinder (133-1305, default 133):
 67 Using default value 133
 68 Last cylinder, +cylinders or +size{K,M,G} (133-1305, default 1305): +1G  #建立一個1G的分割槽
 69 
 70 Command (m for help): n   #再新建一個分割槽
 71 Command action
 72    e   extended
 73    p   primary partition (1-4)
 74 p #選擇型別為主分割槽
 75 Partition number (1-4): 3  #這隻編號為3
 76 First cylinder (265-1305, default 265):
 77 Using default value 265
 78 Last cylinder, +cylinders or +size{K,M,G} (265-1305, default 1305): +2G  #建立一個2G的分割槽
 79 
 80 Command (m for help): n  #再新建一個分割槽
 81 Command action
 82    e   extended
 83    p   primary partition (1-4)
 84 e  #由於已經設定了3個主分割槽了,所以我將第四個分割槽設定為擴充套件分割槽,便於我建立更多的邏輯分割槽
 85 Selected partition 4
 86 First cylinder (527-1305, default 527):
 87 Using default value 527
 88 Last cylinder, +cylinders or +size{K,M,G} (527-1305, default 1305):
 89 Using default value 1305
 90 
 91 Command (m for help): p  #列出已有分割槽
 92 
 93 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 94 255 heads, 63 sectors/track, 1305 cylinders
 95 Units = cylinders of 16065 * 512 = 8225280 bytes
 96 Sector size (logical/physical): 512 bytes / 512 bytes
 97 I/O size (minimum/optimal): 512 bytes / 512 bytes
 98 Disk identifier: 0x8614a108
 99 
100    Device Boot      Start         End      Blocks   Id  System
101 /dev/sdb1               1         132     1060258+  83  Linux   #這就是主分割槽,ID為83
102 /dev/sdb2             133         264     1060290   83  Linux
103 /dev/sdb3             265         526     2104515   83  Linux
104 /dev/sdb4             527        1305     6257317+   5  Extended  #折就是擴充套件分割槽,ID為5
105 
106 Command (m for help): n  #新建一個分割槽
107 First cylinder (527-1305, default 527):
108 Using default value 527
109 Last cylinder, +cylinders or +size{K,M,G} (527-1305, default 1305): +5G  #建立一個5G的邏輯分割槽。
110 
111 Command (m for help): P   #列出已有分割槽
112 
113 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
114 255 heads, 63 sectors/track, 1305 cylinders
115 Units = cylinders of 16065 * 512 = 8225280 bytes
116 Sector size (logical/physical): 512 bytes / 512 bytes
117 I/O size (minimum/optimal): 512 bytes / 512 bytes
118 Disk identifier: 0x8614a108
119 
120    Device Boot      Start         End      Blocks   Id  System
121 /dev/sdb1               1         132     1060258+  83  Linux   #主分割槽
122 /dev/sdb2             133         264     1060290   83  Linux
123 /dev/sdb3             265         526     2104515   83  Linux
124 /dev/sdb4             527        1305     6257317+   5  Extended  #擴充套件分割槽
125 /dev/sdb5             527        1180     5253223+  83  Linux   #這就是新建的邏輯分割槽
126 
127 Command (m for help): W  #儲存退出
128 
129 驗證是否分割槽成功:
130 [root@yinzhengjie ~]# fdisk /dev/sdb
131 
132 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
133          switch off the mode (command 'c') and change display units to
134          sectors (command 'u').
135 
136 Command (m for help): p
137 
138 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
139 255 heads, 63 sectors/track, 1305 cylinders
140 Units = cylinders of 16065 * 512 = 8225280 bytes
141 Sector size (logical/physical): 512 bytes / 512 bytes
142 I/O size (minimum/optimal): 512 bytes / 512 bytes
143 Disk identifier: 0x8614a108
144 
145    Device Boot      Start         End      Blocks   Id  System
146 /dev/sdb1               1         132     1060258+  83  Linux
147 /dev/sdb2             133         264     1060290   83  Linux
148 /dev/sdb3             265         526     2104515   83  Linux
149 /dev/sdb4             527        1305     6257317+   5  Extended
150 /dev/sdb5             527        1180     5253223+  83  Linux
151 
152 Command (m for help): q
153 
154 [root@yinzhengjie ~]#
155 '''
用fdisk 工具對磁碟進行分割槽過程
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 #讓作業系統重讀分割槽表,獲取最新的分割槽資訊。
 8 '''
 9 [root@yinzhengjie ~]# cat /proc/partitions  #檢視系統識別的分割槽,發現沒有我們的分割槽
10 major minor  #blocks  name
11 
12    8        0  292968750 sda
13    8       16  292968750 sdb
14    9      127  278290432 md127
15  259        0     512000 md127p1
16  259        1  277777408 md127p2
17  253        0   52428800 dm-0
18  253        1   33038336 dm-1
19  253        2  192307200 dm-2
20 [root@yinzhengjie ~]#
21 [root@yinzhengjie ~]# kpartx -l /dev/sdb  #列出已新增的所有分割槽資訊
22 sdb1 : 0 2120517 /dev/sdb 63
23 sdb2 : 0 2120580 /dev/sdb 2120580
24 sdb3 : 0 4209030 /dev/sdb 4241160
25 sdb4 : 0 2 /dev/sdb 8450190
26 sdb5 : 0 10506447 /dev/sdb 8450253
27 [root@yinzhengjie ~]# kpartx -af /dev/sdb   #強行新增分割槽資訊
28 [root@yinzhengjie ~]# kpartx -a /dev/sdb    #重讀分割槽表資訊
29 [root@yinzhengjie ~]#
30 [root@yinzhengjie ~]# ls /dev/sdb*          #發現系統以及識別了這幾個分割槽
31 /dev/sdb  /dev/sdb1  /dev/sdb2  /dev/sdb3  /dev/sdb4  /dev/sdb5
32 [root@yinzhengjie ~]#
33 [root@yinzhengjie ~]# cat /proc/partitions  #檢視分割槽表
34 major minor  #blocks  name
35 
36    8        0   20971520 sda
37    8        1     307200 sda1
38    8        2   18631680 sda2
39    8        3    2031616 sda3
40    8       16   10485760 sdb
41    8       17    1060258 sdb1
42    8       18    1060290 sdb2
43    8       19    2104515 sdb3
44    8       20          1 sdb4
45    8       21    5253223 sdb5
46  253        0    1060258 dm-0
47  253        1    1060290 dm-1
48  253        2    2104515 dm-2
49  253        3          1 dm-3
50  253        4    5253223 dm-4
51 [root@yinzhengjie ~]#
52 
53 '''
54 
55 
56 #提示,如果你的作業系統是Centos5的話執行以下命令就好使了
57 [root@yinzhengjie ~]# partprobe   #但是這個條命令不適合CentOs6!
用kpartx 讓系統重讀分割槽表
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# fdisk /dev/sdb
 9 
10 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
11          switch off the mode (command 'c') and change display units to
12          sectors (command 'u').
13 
14 Command (m for help): p  #檢視當前分割槽
15 
16 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
17 255 heads, 63 sectors/track, 1305 cylinders
18 Units = cylinders of 16065 * 512 = 8225280 bytes
19 Sector size (logical/physical): 512 bytes / 512 bytes
20 I/O size (minimum/optimal): 512 bytes / 512 bytes
21 Disk identifier: 0x8614a108
22 
23    Device Boot      Start         End      Blocks   Id  System
24 /dev/sdb1               1         132     1060258+  83  Linux
25 /dev/sdb2             133         264     1060290   83  Linux
26 /dev/sdb3             265         526     2104515   83  Linux
27 /dev/sdb4             527        1305     6257317+   5  Extended
28 /dev/sdb5             527        1180     5253223+  83  Linux
29 
30 Command (m for help): d  #刪除分割槽
31 Partition number (1-5): 5  #選擇相應的編號,在她給定的數值內選取喲
32 
33 Command (m for help): p #發現已經刪除成功了
34 
35 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
36 255 heads, 63 sectors/track, 1305 cylinders
37 Units = cylinders of 16065 * 512 = 8225280 bytes
38 Sector size (logical/physical): 512 bytes / 512 bytes
39 I/O size (minimum/optimal): 512 bytes / 512 bytes
40 Disk identifier: 0x8614a108
41 
42    Device Boot      Start         End      Blocks   Id  System
43 /dev/sdb1               1         132     1060258+  83  Linux
44 /dev/sdb2             133         264     1060290   83  Linux
45 /dev/sdb3             265         526     2104515   83  Linux
46 /dev/sdb4             527        1305     6257317+   5  Extended
47 
48 Command (m for help): w   #儲存配置並退出
49 The partition table has been altered!
50 
51 Calling ioctl() to re-read partition table.
52 Syncing disks.
53 [root@yinzhengjie ~]#
54 
55 
56 '''
用fdisk刪除分割槽資訊
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# fdisk /dev/sdb
  9 
 10 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
 11          switch off the mode (command 'c') and change display units to
 12          sectors (command 'u').
 13 
 14 Command (m for help): p #檢視當前分割槽資訊
 15 
 16 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 17 255 heads, 63 sectors/track, 1305 cylinders
 18 Units = cylinders of 16065 * 512 = 8225280 bytes
 19 Sector size (logical/physical): 512 bytes / 512 bytes
 20 I/O size (minimum/optimal): 512 bytes / 512 bytes
 21 Disk identifier: 0x8614a108
 22 
 23    Device Boot      Start         End      Blocks   Id  System
 24 /dev/sdb1               1         132     1060258+  83  Linux
 25 /dev/sdb2             133         264     1060290   83  Linux
 26 /dev/sdb3             265         526     2104515   83  Linux   #主分割槽
 27 /dev/sdb4             527        1305     6257317+   5  Extended
 28 
 29 Command (m for help): t  #調整分割槽ID
 30 Partition number (1-5): 3  #選擇分割槽標號
 31 Hex code (type L to list codes): L  #檢視ID對應的檔案系統型別。
 32 
 33  0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 34  1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 35  2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 36  3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 37  4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 38  5  Extended        42  SFS             86  NTFS volume set da  Non-FS data
 39  6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 40  7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 41  8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 42  9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access
 43  a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 44  b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor
 45  c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 46  e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT
 47  f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
 48 10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
 49 11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
 50 12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor
 51 14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
 52 16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS
 53 17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
 54 18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto
 55 1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep
 56 1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT
 57 1e  Hidden W95 FAT1
 58 Hex code (type L to list codes): 82  #選擇 Linux swap / So分割槽型別
 59 Changed system type of partition 3 to 82 (Linux swap / Solaris)
 60 
 61 Command (m for help): P #檢視當前型別
 62 
 63 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 64 255 heads, 63 sectors/track, 1305 cylinders
 65 Units = cylinders of 16065 * 512 = 8225280 bytes
 66 Sector size (logical/physical): 512 bytes / 512 bytes
 67 I/O size (minimum/optimal): 512 bytes / 512 bytes
 68 Disk identifier: 0x8614a108
 69 
 70    Device Boot      Start         End      Blocks   Id  System
 71 /dev/sdb1               1         132     1060258+  83  Linux
 72 /dev/sdb2             133         264     1060290   83  Linux
 73 /dev/sdb3             265         526     2104515   82  Linux swap / Solaris  #果真已經變成了交換分割槽
 74 /dev/sdb4             527        1305     6257317+   5  Extended
 75 
 76 Command (m for help): t  #修改分割槽型別
 77 Partition number (1-5): 3  #還是選擇之前修改的分割槽
 78 Hex code (type L to list codes): 83  #修改會之前的分割槽型別
 79 Changed system type of partition 3 to 83 (Linux)
 80 
 81 Command (m for help): p  #檢視分割槽情況
 82 
 83 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 84 255 heads, 63 sectors/track, 1305 cylinders
 85 Units = cylinders of 16065 * 512 = 8225280 bytes
 86 Sector size (logical/physical): 512 bytes / 512 bytes
 87 I/O size (minimum/optimal): 512 bytes / 512 bytes
 88 Disk identifier: 0x8614a108
 89 
 90    Device Boot      Start         End      Blocks   Id  System
 91 /dev/sdb1               1         132     1060258+  83  Linux
 92 /dev/sdb2             133         264     1060290   83  Linux
 93 /dev/sdb3             265         526     2104515   83  Linux
 94 /dev/sdb4             527        1305     6257317+   5  Extended
 95 
 96 Command (m for help): w  #儲存當前配置
 97 The partition table has been altered!
 98 
 99 Calling ioctl() to re-read partition table.
100 Syncing disks.
101 [root@yinzhengjie ~]#
102 '''
用fdisk修改分割槽型別
 
10.建立檔案系統
                        

 

  你可以使用2個扇區(512位元組)為一個塊(block),那麼這個一個快的大小就是1kb,4個扇區就是2kb,8個扇區就是4kb.那麼問題來了,這個每個單位的塊導師是1kb好呢?還是2kb或是4kb好呢?這就要看你儲存的資料的大小了,如果你儲存的資料是大檔案的話,當然block越大越好,這樣block儲存相同的資料block越大,用的塊數就越少,如果你儲存的是小檔案的話,當然block越小越好,因為block過大,存進去的資料卻很小就造成了浪費!(因為一個block只能儲存一個資料來源)。
  注意,在儲存資料的時候,一個block只能屬於一個檔案,不能同時屬於2個檔案。硬連線除外,其實硬連結指的還是一同一個檔案。也就是說,不同的檔案不能使用相同的磁碟塊。這些磁碟塊都有其編號的,是為了方便資料來源(主要是inode)只想儲存資料的塊(block)
  磁碟碎片,就是不是連續的塊(block)儲存著屬於同一個檔案的資料,這樣就導致了在存取的時候特別麻煩,大大的降低了磁碟的工作效率。如下圖:
                            

 

  日誌檔案系統是可以將源資料(indoe)和塊資料都寫入日誌區,等都寫入成功了在把資料分別寫入到源資料區和塊資料區,假如你才寫文件的時候,如果突然斷電,恰巧你剛剛好寫完資料,那麼他回將資料分別寫入indoe和block區域中,如果你沒有寫完,他就會對比在日誌區的inode和block對應的是否完整,如果不完整,日誌區會自動將Inode刪除,清除掉不完整的block,就完成了一次自檢模式。
                              
#!/usr/bin/env python
#_*_coding:utf-8_*_
#@author :yinzhengjie
#blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
#EMAIL:y1053419035@qq.com

'''

mke2fs:
   配置檔案:/etc/mke2fs.conf
   -t:指定檔案型別{ext2|ext3|ext4}
   -j:用於建立Ext3檔案系統,相當於-t ext3
   -L label: 指定卷標,
   -b{1024|2028|4096}:指定塊大小
   -i # :#個位元組給指定一個indone
   -N # : 直接指定預留多少個indone
   -I # : 指定Inode大小
   -m # :預留給管理員的空間百分比,預設為5
   -O :指定分割槽特性
e2label /dev/SOMEDEVICE 檢視卷標,

e2label /dev/SOMEDEVICE  Label 直接更改卷標

e2label /dev/SOMEDEVICE “”   刪除卷標

blkid 檢視UUID和TYPE 

dumpe2fs 檢視超級塊和是否有碎片 
    -h:僅顯示超級塊中儲存的資訊 


tune2fs:調整mke2fs的資訊 
     -l:檢視超級塊中的資訊 
    -L: 設定卷標 
    -m:預留管理員的空間百分比 
     -j:如果原來的檔案系統為ext2,-j能夠將其提升為ext3 
     -o:[^]mount-options[,...] 指定預設掛載選項 
     -O:[^]feature[,...] 調整分割槽特性 
    tune2fs -o 掛載選項 裝置 
    tune2fs -o ^裝置選項 取消 


fsck:檔案系統檢測 
      -t 檔案型別 裝置 
      -f 強行檢測 
      -a 自動修復錯誤 
      -r 互動式修復錯誤
      
e2fsck 
      -t 指定時間 
      -y 自動回答為yes 
      -f 強行檢測 
'
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mke2fs /dev/sdb3   #格式化該分割槽,預設為ext2檔案系統
 9 mke2fs 1.41.12 (17-May-2010)
10 Filesystem label=     #卷標
11 OS type: Linux
12 Block size=4096 (log=2)  #塊大小是4K
13 Fragment size=4096 (log=2)
14 Stride=0 blocks, Stripe width=0 blocks
15 131648 inodes, 526128 blocks  #節點書和塊數。
16 26306 blocks (5.00%) reserved for the super user   #有5.00%的block給管理用,這個比例是可以調整的
17 First data block=0
18 Maximum filesystem blocks=541065216   #最大塊數
19 17 block groups  #有17個塊組
20 32768 blocks per group, 32768 fragments per group    #
21 7744 inodes per group
22 Superblock backups stored on blocks:
23         32768, 98304, 163840, 229376, 294912
24 
25 Writing inode tables: done
26 Writing superblocks and filesystem accounting information: done
27 
28 This filesystem will be automatically checked every 39 mounts or
29 180 days, whichever comes first.  Use tune2fs -c or -i to override    #表示每39次掛載或者180天(半年)檔案系統會自動檢測一次。.
30 [root@yinzhengjie ~]#
31 [root@yinzhengjie ~]#
32 [root@yinzhengjie ~]# mke2fs -j /dev/sdb3  #格式化該分割槽,指定格式為ext3檔案系統
33 mke2fs 1.41.12 (17-May-2010)
34 Filesystem label=
35 OS type: Linux
36 Block size=4096 (log=2)
37 Fragment size=4096 (log=2)
38 Stride=0 blocks, Stripe width=0 blocks
39 131648 inodes, 526128 blocks
40 26306 blocks (5.00%) reserved for the super user
41 First data block=0
42 Maximum filesystem blocks=541065216
43 17 block groups
44 32768 blocks per group, 32768 fragments per group
45 7744 inodes per group
46 Superblock backups stored on blocks:
47         32768, 98304, 163840, 229376, 294912
48 
49 Writing inode tables: done
50 Creating journal (16384 blocks): done   #與ext2相比多出來的專案,存放日誌的區域。
51 Writing superblocks and filesystem accounting information: done
52 
53 This filesystem will be automatically checked every 38 mounts or
54 180 days, whichever comes first.  Use tune2fs -c or -i to override.  #這裡的是38次掛載或者6個月進行一次掛載,和ext2的區別。
55 [root@yinzhengjie ~]# 
56 '''
用mke2fs的-j引數格式化分割槽
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mke2fs -L Data -t ext4 /dev/sdb3  #指定卷標和檔案系統格式
 9 mke2fs 1.41.12 (17-May-2010)
10 Filesystem label=Data  #這就是卷標
11 OS type: Linux
12 Block size=4096 (log=2)
13 Fragment size=4096 (log=2)
14 Stride=0 blocks, Stripe width=0 blocks
15 131648 inodes, 526128 blocks
16 26306 blocks (5.00%) reserved for the super user
17 First data block=0
18 Maximum filesystem blocks=541065216
19 17 block groups
20 32768 blocks per group, 32768 fragments per group
21 7744 inodes per group
22 Superblock backups stored on blocks: 
23         32768, 98304, 163840, 229376, 294912
24 
25 Writing inode tables: done                            
26 Creating journal (16384 blocks): done
27 Writing superblocks and filesystem accounting information: done
28 
29 This filesystem will be automatically checked every 38 mounts or
30 180 days, whichever comes first.  Use tune2fs -c or -i to override.
31 [root@yinzhengjie ~]# 
32 '''
用mke2fs的-L用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# e2label /dev/sdb3   #檢視卷標名
 9 Data
10 [root@yinzhengjie ~]# e2label /dev/sdb3  MYDATA  #修改卷標名
11 [root@yinzhengjie ~]# e2label /dev/sdb3
12 MYDATA
13 [root@yinzhengjie ~]# 
14 '''
用e2label檢視或修改卷標名
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mke2fs -b 2048 -m 3 -t ext4 /dev/sdb3
 9 mke2fs 1.41.12 (17-May-2010)
10 Filesystem label=
11 OS type: Linux
12 Block size=2048 (log=1)  #被修改的塊大小為2048
13 Fragment size=2048 (log=1)  
14 Stride=0 blocks, Stripe width=0 blocks
15 131560 inodes, 1052256 blocks
16 31567 blocks (3.00%) reserved for the super user   #給管理員預留的block,這個就是通過上面的“-m”引數實現的。
17 First data block=0
18 Maximum filesystem blocks=538968064
19 65 block groups
20 16384 blocks per group, 16384 fragments per group
21 2024 inodes per group
22 Superblock backups stored on blocks:
23         16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
24 
25 Writing inode tables: done
26 Creating journal (32768 blocks): done
27 Writing superblocks and filesystem accounting information: done
28 
29 This filesystem will be automatically checked every 29 mounts or
30 180 days, whichever comes first.  Use tune2fs -c or -i to override.
31 [root@yinzhengjie ~]#
32 '''
mke2fs的-b與-m引數的用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# blkid /dev/sdb3   #檢視分割槽的UUID和TYPE,我們可以用uuid來進行掛載
 9 /dev/sdb3: UUID="87f7686e-09bd-4a1e-a567-4939c6a4dcab" TYPE="ext4"
10 [root@yinzhengjie ~]#
11 '''
blkid 檢視UUID和TYPE
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# dumpe2fs /dev/sdb3  
  9 dumpe2fs 1.41.12 (17-May-2010)
 10 Filesystem volume name:   <none>
 11 Last mounted on:          <not available>
 12 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
 13 Filesystem magic number:  0xEF53
 14 Filesystem revision #:    1 (dynamic)
 15 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
 16 Filesystem flags:         signed_directory_hash
 17 Default mount options:    (none)
 18 Filesystem state:         clean
 19 Errors behavior:          Continue
 20 Filesystem OS type:       Linux
 21 Inode count:              131560
 22 Block count:              1052256
 23 Reserved block count:     31567
 24 Free blocks:              998268
 25 Free inodes:              131549
 26 First block:              0
 27 Block size:               2048
 28 Fragment size:            2048
 29 Reserved GDT blocks:      512
 30 Blocks per group:         16384
 31 Fragments per group:      16384
 32 Inodes per group:         2024
 33 Inode blocks per group:   253
 34 Flex block group size:    16
 35 Filesystem created:       Thu May 11 12:42:49 2017
 36 Last mount time:          n/a
 37 Last write time:          Thu May 11 12:42:49 2017
 38 Mount count:              0
 39 Maximum mount count:      29
 40 Last checked:             Thu May 11 12:42:49 2017
 41 Check interval:           15552000 (6 months)
 42 Next check after:         Tue Nov  7 11:42:49 2017
 43 Lifetime writes:          97 MB
 44 Reserved blocks uid:      0 (user root)
 45 Reserved blocks gid:      0 (group root)
 46 First inode:              11
 47 Inode size:               256
 48 Required extra isize:     28
 49 Desired extra isize:      28
 50 Journal inode:            8
 51 Default directory hash:   half_md4
 52 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
 53 Journal backup:           inode blocks
 54 Journal features:         (none)
 55 Journal size:             64M
 56 Journal length:           32768
 57 Journal sequence:         0x00000001
 58 Journal start:            0
 59 
 60 
 61 Group 0: (Blocks 0-16383) [ITABLE_ZEROED]  #顯示組名,儲存資料的block編號,如果你的Bolck和上個組沒有連線上就說明存在磁碟碎片
 62   Checksum 0x8fce, unused inodes 2013  #沒有用的inode有多少個
 63   Primary superblock at 0, Group descriptors at 1-2
 64   Reserved GDT blocks at 3-514
 65   Block bitmap at 515 (+515), Inode bitmap at 531 (+531)
 66   Inode table at 547-799 (+547)
 67   11779 free blocks, 2013 free inodes, 2 directories, 2013 unused inodes
 68   Free blocks: 4605-16383
 69   Free inodes: 12-2024
 70 Group 1: (Blocks 16384-32767) [INODE_UNINIT, ITABLE_ZEROED]
 71   Checksum 0xd2d4, unused inodes 2024
 72   Backup superblock at 16384, Group descriptors at 16385-16386
 73   Reserved GDT blocks at 16387-16898
 74   Block bitmap at 516 (+4294951428), Inode bitmap at 532 (+4294951444)
 75   Inode table at 800-1052 (+4294951712)
 76   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
 77   Free blocks: 16899-32767
 78   Free inodes: 2025-4048
 79 Group 2: (Blocks 32768-49151) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
 80   Checksum 0x209d, unused inodes 2024
 81   Block bitmap at 517 (+4294935045), Inode bitmap at 533 (+4294935061)
 82   Inode table at 1053-1305 (+4294935581)
 83   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
 84   Free blocks: 32768-49151
 85   Free inodes: 4049-6072
 86 Group 3: (Blocks 49152-65535) [INODE_UNINIT, ITABLE_ZEROED]
 87   Checksum 0x595b, unused inodes 2024
 88   Backup superblock at 49152, Group descriptors at 49153-49154
 89   Reserved GDT blocks at 49155-49666
 90   Block bitmap at 518 (+4294918662), Inode bitmap at 534 (+4294918678)
 91   Inode table at 1306-1558 (+4294919450)
 92   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
 93   Free blocks: 49667-65535
 94   Free inodes: 6073-8096
 95 Group 4: (Blocks 65536-81919) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
 96   Checksum 0x4c65, unused inodes 2024
 97   Block bitmap at 519 (+4294902279), Inode bitmap at 535 (+4294902295)
 98   Inode table at 1559-1811 (+4294903319)
 99   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
100   Free blocks: 65536-81919
101   Free inodes: 8097-10120
102 Group 5: (Blocks 81920-98303) [INODE_UNINIT, ITABLE_ZEROED]
103   Checksum 0x86c0, unused inodes 2024
104   Backup superblock at 81920, Group descriptors at 81921-81922
105   Reserved GDT blocks at 81923-82434
106   Block bitmap at 520 (+4294885896), Inode bitmap at 536 (+4294885912)
107   Inode table at 1812-2064 (+4294887188)
108   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
109   Free blocks: 82435-98303
110   Free inodes: 10121-12144
111 Group 6: (Blocks 98304-114687) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
112   Checksum 0x8dba, unused inodes 2024
113   Block bitmap at 521 (+4294869513), Inode bitmap at 537 (+4294869529)
114   Inode table at 2065-2317 (+4294871057)
115   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
116   Free blocks: 98304-114687
117   Free inodes: 12145-14168
118 Group 7: (Blocks 114688-131071) [INODE_UNINIT, ITABLE_ZEROED]
119   Checksum 0x5fe4, unused inodes 2024
120   Backup superblock at 114688, Group descriptors at 114689-114690
121   Reserved GDT blocks at 114691-115202
122   Block bitmap at 522 (+4294853130), Inode bitmap at 538 (+4294853146)
123   Inode table at 2318-2570 (+4294854926)
124   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
125   Free blocks: 115203-131071
126   Free inodes: 14169-16192
127 Group 8: (Blocks 131072-147455) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
128   Checksum 0x0451, unused inodes 2024
129   Block bitmap at 523 (+4294836747), Inode bitmap at 539 (+4294836763)
130   Inode table at 2571-2823 (+4294838795)
131   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
132   Free blocks: 131072-147455
133   Free inodes: 16193-18216
134 Group 9: (Blocks 147456-163839) [INODE_UNINIT, ITABLE_ZEROED]
135   Checksum 0xb130, unused inodes 2024
136   Backup superblock at 147456, Group descriptors at 147457-147458
137   Reserved GDT blocks at 147459-147970
138   Block bitmap at 524 (+4294820364), Inode bitmap at 540 (+4294820380)
139   Inode table at 2824-3076 (+4294822664)
140   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
141   Free blocks: 147971-163839
142   Free inodes: 18217-20240
143 Group 10: (Blocks 163840-180223) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
144   Checksum 0x544a, unused inodes 2024
145   Block bitmap at 525 (+4294803981), Inode bitmap at 541 (+4294803997)
146   Inode table at 3077-3329 (+4294806533)
147   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
148   Free blocks: 163840-180223
149   Free inodes: 20241-22264
150 Group 11: (Blocks 180224-196607) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
151   Checksum 0x3e65, unused inodes 2024
152   Block bitmap at 526 (+4294787598), Inode bitmap at 542 (+4294787614)
153   Inode table at 3330-3582 (+4294790402)
154   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
155   Free blocks: 180224-196607
156   Free inodes: 22265-24288
157 Group 12: (Blocks 196608-212991) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
158   Checksum 0x407e, unused inodes 2024
159   Block bitmap at 527 (+4294771215), Inode bitmap at 543 (+4294771231)
160   Inode table at 3583-3835 (+4294774271)
161   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
162   Free blocks: 196608-212991
163   Free inodes: 24289-26312
164 Group 13: (Blocks 212992-229375) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
165   Checksum 0x3bb2, unused inodes 2024
166   Block bitmap at 528 (+4294754832), Inode bitmap at 544 (+4294754848)
167   Inode table at 3836-4088 (+4294758140)
168   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
169   Free blocks: 212992-229375
170   Free inodes: 26313-28336
171 Group 14: (Blocks 229376-245759) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
172   Checksum 0x0dce, unused inodes 2024
173   Block bitmap at 529 (+4294738449), Inode bitmap at 545 (+4294738465)
174   Inode table at 4089-4341 (+4294742009)
175   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
176   Free blocks: 229376-245759
177   Free inodes: 28337-30360
178 Group 15: (Blocks 245760-262143) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
179   Checksum 0x7e95, unused inodes 2024
180   Block bitmap at 530 (+4294722066), Inode bitmap at 546 (+4294722082)
181   Inode table at 4342-4594 (+4294725878)
182   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
183   Free blocks: 245760-262143
184   Free inodes: 30361-32384
185 Group 16: (Blocks 262144-278527) [INODE_UNINIT, ITABLE_ZEROED]
186   Checksum 0x0990, unused inodes 2024
187   Block bitmap at 262144 (+0), Inode bitmap at 262160 (+16)
188   Inode table at 262176-262428 (+32)
189   12304 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
190   Free blocks: 266224-278527
191   Free inodes: 32385-34408
192 Group 17: (Blocks 278528-294911) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
193   Checksum 0xcd8f, unused inodes 2024
194   Block bitmap at 262145 (+4294950913), Inode bitmap at 262161 (+4294950929)
195   Inode table at 262429-262681 (+4294951197)
196   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
197   Free blocks: 278528-294911
198   Free inodes: 34409-36432
199 Group 18: (Blocks 294912-311295) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
200   Checksum 0xdf82, unused inodes 2024
201   Block bitmap at 262146 (+4294934530), Inode bitmap at 262162 (+4294934546)
202   Inode table at 262682-262934 (+4294935066)
203   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
204   Free blocks: 294912-311295
205   Free inodes: 36433-38456
206 Group 19: (Blocks 311296-327679) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
207   Checksum 0xd576, unused inodes 2024
208   Block bitmap at 262147 (+4294918147), Inode bitmap at 262163 (+4294918163)
209   Inode table at 262935-263187 (+4294918935)
210   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
211   Free blocks: 311296-327679
212   Free inodes: 38457-40480
213 Group 20: (Blocks 327680-344063) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
214   Checksum 0xfb98, unused inodes 2024
215   Block bitmap at 262148 (+4294901764), Inode bitmap at 262164 (+4294901780)
216   Inode table at 263188-263440 (+4294902804)
217   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
218   Free blocks: 327680-344063
219   Free inodes: 40481-42504
220 Group 21: (Blocks 344064-360447) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
221   Checksum 0x57e5, unused inodes 2024
222   Block bitmap at 262149 (+4294885381), Inode bitmap at 262165 (+4294885397)
223   Inode table at 263441-263693 (+4294886673)
224   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
225   Free blocks: 344064-360447
226   Free inodes: 42505-44528
227 Group 22: (Blocks 360448-376831) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
228   Checksum 0xee70, unused inodes 2024
229   Block bitmap at 262150 (+4294868998), Inode bitmap at 262166 (+4294869014)
230   Inode table at 263694-263946 (+4294870542)
231   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
232   Free blocks: 360448-376831
233   Free inodes: 44529-46552
234 Group 23: (Blocks 376832-393215) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
235   Checksum 0x420d, unused inodes 2024
236   Block bitmap at 262151 (+4294852615), Inode bitmap at 262167 (+4294852631)
237   Inode table at 263947-264199 (+4294854411)
238   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
239   Free blocks: 376832-393215
240   Free inodes: 46553-48576
241 Group 24: (Blocks 393216-409599) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
242   Checksum 0xb3ac, unused inodes 2024
243   Block bitmap at 262152 (+4294836232), Inode bitmap at 262168 (+4294836248)
244   Inode table at 264200-264452 (+4294838280)
245   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
246   Free blocks: 393216-409599
247   Free inodes: 48577-50600
248 Group 25: (Blocks 409600-425983) [INODE_UNINIT, ITABLE_ZEROED]
249   Checksum 0xaab1, unused inodes 2024
250   Backup superblock at 409600, Group descriptors at 409601-409602
251   Reserved GDT blocks at 409603-410114
252   Block bitmap at 262153 (+4294819849), Inode bitmap at 262169 (+4294819865)
253   Inode table at 264453-264705 (+4294822149)
254   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
255   Free blocks: 410115-425983
256   Free inodes: 50601-52624
257 Group 26: (Blocks 425984-442367) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
258   Checksum 0xab55, unused inodes 2024
259   Block bitmap at 262154 (+4294803466), Inode bitmap at 262170 (+4294803482)
260   Inode table at 264706-264958 (+4294806018)
261   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
262   Free blocks: 425984-442367
263   Free inodes: 52625-54648
264 Group 27: (Blocks 442368-458751) [INODE_UNINIT, ITABLE_ZEROED]
265   Checksum 0x28a7, unused inodes 2024
266   Backup superblock at 442368, Group descriptors at 442369-442370
267   Reserved GDT blocks at 442371-442882
268   Block bitmap at 262155 (+4294787083), Inode bitmap at 262171 (+4294787099)
269   Inode table at 264959-265211 (+4294789887)
270   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
271   Free blocks: 442883-458751
272   Free inodes: 54649-56672
273 Group 28: (Blocks 458752-475135) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
274   Checksum 0x73c6, unused inodes 2024
275   Block bitmap at 262156 (+4294770700), Inode bitmap at 262172 (+4294770716)
276   Inode table at 265212-265464 (+4294773756)
277   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
278   Free blocks: 458752-475135
279   Free inodes: 56673-58696
280 Group 29: (Blocks 475136-491519) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
281   Checksum 0xb9dd, unused inodes 2024
282   Block bitmap at 262157 (+4294754317), Inode bitmap at 262173 (+4294754333)
283   Inode table at 265465-265717 (+4294757625)
284   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
285   Free blocks: 475136-491519
286   Free inodes: 58697-60720
287 Group 30: (Blocks 491520-507903) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
288   Checksum 0xef7a, unused inodes 2024
289   Block bitmap at 262158 (+4294737934), Inode bitmap at 262174 (+4294737950)
290   Inode table at 265718-265970 (+4294741494)
291   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
292   Free blocks: 491520-507903
293   Free inodes: 60721-62744
294 Group 31: (Blocks 507904-524287) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
295   Checksum 0xa124, unused inodes 2024
296   Block bitmap at 262159 (+4294721551), Inode bitmap at 262175 (+4294721567)
297   Inode table at 265971-266223 (+4294725363)
298   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
299   Free blocks: 507904-524287
300   Free inodes: 62745-64768
301 Group 32: (Blocks 524288-540671) [INODE_UNINIT, ITABLE_ZEROED]
302   Checksum 0xcb02, unused inodes 2024
303   Block bitmap at 524288 (+0), Inode bitmap at 524304 (+16)
304   Inode table at 524320-524572 (+32)
305   12304 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
306   Free blocks: 528368-540671
307   Free inodes: 64769-66792
308 Group 33: (Blocks 540672-557055) [INODE_UNINIT, ITABLE_ZEROED]
309   Checksum 0x1cd5, unused inodes 2024
310   Block bitmap at 524289 (+4294950913), Inode bitmap at 524305 (+4294950929)
311   Inode table at 524573-524825 (+4294951197)
312   0 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
313   Free blocks:
314   Free inodes: 66793-68816
315 Group 34: (Blocks 557056-573439) [INODE_UNINIT, ITABLE_ZEROED]
316   Checksum 0x0ed8, unused inodes 2024
317   Block bitmap at 524290 (+4294934530), Inode bitmap at 524306 (+4294934546)
318   Inode table at 524826-525078 (+4294935066)
319   0 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
320   Free blocks:
321   Free inodes: 68817-70840
322 Group 35: (Blocks 573440-589823) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
323   Checksum 0x17e4, unused inodes 2024
324   Block bitmap at 524291 (+4294918147), Inode bitmap at 524307 (+4294918163)
325   Inode table at 525079-525331 (+4294918935)
326   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
327   Free blocks: 573440-589823
328   Free inodes: 70841-72864
329 Group 36: (Blocks 589824-606207) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
330   Checksum 0x390a, unused inodes 2024
331   Block bitmap at 524292 (+4294901764), Inode bitmap at 524308 (+4294901780)
332   Inode table at 525332-525584 (+4294902804)
333   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
334   Free blocks: 589824-606207
335   Free inodes: 72865-74888
336 Group 37: (Blocks 606208-622591) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
337   Checksum 0x9577, unused inodes 2024
338   Block bitmap at 524293 (+4294885381), Inode bitmap at 524309 (+4294885397)
339   Inode table at 525585-525837 (+4294886673)
340   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
341   Free blocks: 606208-622591
342   Free inodes: 74889-76912
343 Group 38: (Blocks 622592-638975) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
344   Checksum 0x2ce2, unused inodes 2024
345   Block bitmap at 524294 (+4294868998), Inode bitmap at 524310 (+4294869014)
346   Inode table at 525838-526090 (+4294870542)
347   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
348   Free blocks: 622592-638975
349   Free inodes: 76913-78936
350 Group 39: (Blocks 638976-655359) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
351   Checksum 0x809f, unused inodes 2024
352   Block bitmap at 524295 (+4294852615), Inode bitmap at 524311 (+4294852631)
353   Inode table at 526091-526343 (+4294854411)
354   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
355   Free blocks: 638976-655359
356   Free inodes: 78937-80960
357 Group 40: (Blocks 655360-671743) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
358   Checksum 0x713e, unused inodes 2024
359   Block bitmap at 524296 (+4294836232), Inode bitmap at 524312 (+4294836248)
360   Inode table at 526344-526596 (+4294838280)
361   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
362   Free blocks: 655360-671743
363   Free inodes: 80961-82984
364 Group 41: (Blocks 671744-688127) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
365   Checksum 0x7bca, unused inodes 2024
366   Block bitmap at 524297 (+4294819849), Inode bitmap at 524313 (+4294819865)
367   Inode table at 526597-526849 (+4294822149)
368   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
369   Free blocks: 671744-688127
370   Free inodes: 82985-85008
371 Group 42: (Blocks 688128-704511) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
372   Checksum 0x69c7, unused inodes 2024
373   Block bitmap at 524298 (+4294803466), Inode bitmap at 524314 (+4294803482)
374   Inode table at 526850-527102 (+4294806018)
375   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
376   Free blocks: 688128-704511
377   Free inodes: 85009-87032
378 Group 43: (Blocks 704512-720895) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
379   Checksum 0xf9dc, unused inodes 2024
380   Block bitmap at 524299 (+4294787083), Inode bitmap at 524315 (+4294787099)
381   Inode table at 527103-527355 (+4294789887)
382   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
383   Free blocks: 704512-720895
384   Free inodes: 87033-89056
385 Group 44: (Blocks 720896-737279) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
386   Checksum 0xb154, unused inodes 2024
387   Block bitmap at 524300 (+4294770700), Inode bitmap at 524316 (+4294770716)
388   Inode table at 527356-527608 (+4294773756)
389   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
390   Free blocks: 720896-737279
391   Free inodes: 89057-91080
392 Group 45: (Blocks 737280-753663) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
393   Checksum 0x7b4f, unused inodes 2024
394   Block bitmap at 524301 (+4294754317), Inode bitmap at 524317 (+4294754333)
395   Inode table at 527609-527861 (+4294757625)
396   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
397   Free blocks: 737280-753663
398   Free inodes: 91081-93104
399 Group 46: (Blocks 753664-770047) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
400   Checksum 0x2de8, unused inodes 2024
401   Block bitmap at 524302 (+4294737934), Inode bitmap at 524318 (+4294737950)
402   Inode table at 527862-528114 (+4294741494)
403   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
404   Free blocks: 753664-770047
405   Free inodes: 93105-95128
406 Group 47: (Blocks 770048-786431) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
407   Checksum 0x63b6, unused inodes 2024
408   Block bitmap at 524303 (+4294721551), Inode bitmap at 524319 (+4294721567)
409   Inode table at 528115-528367 (+4294725363)
410   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
411   Free blocks: 770048-786431
412   Free inodes: 95129-97152
413 Group 48: (Blocks 786432-802815) [INODE_UNINIT, ITABLE_ZEROED]
414   Checksum 0x8a8c, unused inodes 2024
415   Block bitmap at 786432 (+0), Inode bitmap at 786448 (+16)
416   Inode table at 786464-786716 (+32)
417   12304 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
418   Free blocks: 790512-802815
419   Free inodes: 97153-99176
420 Group 49: (Blocks 802816-819199) [INODE_UNINIT, ITABLE_ZEROED]
421   Checksum 0x5d7a, unused inodes 2024
422   Backup superblock at 802816, Group descriptors at 802817-802818
423   Reserved GDT blocks at 802819-803330
424   Block bitmap at 786433 (+4294950913), Inode bitmap at 786449 (+4294950929)
425   Inode table at 786717-786969 (+4294951197)
426   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
427   Free blocks: 803331-819199
428   Free inodes: 99177-101200
429 Group 50: (Blocks 819200-835583) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
430   Checksum 0x5c9e, unused inodes 2024
431   Block bitmap at 786434 (+4294934530), Inode bitmap at 786450 (+4294934546)
432   Inode table at 786970-787222 (+4294935066)
433   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
434   Free blocks: 819200-835583
435   Free inodes: 101201-103224
436 Group 51: (Blocks 835584-851967) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
437   Checksum 0x566a, unused inodes 2024
438   Block bitmap at 786435 (+4294918147), Inode bitmap at 786451 (+4294918163)
439   Inode table at 787223-787475 (+4294918935)
440   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
441   Free blocks: 835584-851967
442   Free inodes: 103225-105248
443 Group 52: (Blocks 851968-868351) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
444   Checksum 0x7884, unused inodes 2024
445   Block bitmap at 786436 (+4294901764), Inode bitmap at 786452 (+4294901780)
446   Inode table at 787476-787728 (+4294902804)
447   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
448   Free blocks: 851968-868351
449   Free inodes: 105249-107272
450 Group 53: (Blocks 868352-884735) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
451   Checksum 0xd4f9, unused inodes 2024
452   Block bitmap at 786437 (+4294885381), Inode bitmap at 786453 (+4294885397)
453   Inode table at 787729-787981 (+4294886673)
454   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
455   Free blocks: 868352-884735
456   Free inodes: 107273-109296
457 Group 54: (Blocks 884736-901119) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
458   Checksum 0x6d6c, unused inodes 2024
459   Block bitmap at 786438 (+4294868998), Inode bitmap at 786454 (+4294869014)
460   Inode table at 787982-788234 (+4294870542)
461   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
462   Free blocks: 884736-901119
463   Free inodes: 109297-111320
464 Group 55: (Blocks 901120-917503) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
465   Checksum 0xc111, unused inodes 2024
466   Block bitmap at 786439 (+4294852615), Inode bitmap at 786455 (+4294852631)
467   Inode table at 788235-788487 (+4294854411)
468   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
469   Free blocks: 901120-917503
470   Free inodes: 111321-113344
471 Group 56: (Blocks 917504-933887) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
472   Checksum 0x30b0, unused inodes 2024
473   Block bitmap at 786440 (+4294836232), Inode bitmap at 786456 (+4294836248)
474   Inode table at 788488-788740 (+4294838280)
475   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
476   Free blocks: 917504-933887
477   Free inodes: 113345-115368
478 Group 57: (Blocks 933888-950271) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
479   Checksum 0x3a44, unused inodes 2024
480   Block bitmap at 786441 (+4294819849), Inode bitmap at 786457 (+4294819865)
481   Inode table at 788741-788993 (+4294822149)
482   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
483   Free blocks: 933888-950271
484   Free inodes: 115369-117392
485 Group 58: (Blocks 950272-966655) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
486   Checksum 0x2849, unused inodes 2024
487   Block bitmap at 786442 (+4294803466), Inode bitmap at 786458 (+4294803482)
488   Inode table at 788994-789246 (+4294806018)
489   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
490   Free blocks: 950272-966655
491   Free inodes: 117393-119416
492 Group 59: (Blocks 966656-983039) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
493   Checksum 0xb852, unused inodes 2024
494   Block bitmap at 786443 (+4294787083), Inode bitmap at 786459 (+4294787099)
495   Inode table at 789247-789499 (+4294789887)
496   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
497   Free blocks: 966656-983039
498   Free inodes: 119417-121440
499 Group 60: (Blocks 983040-999423) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
500   Checksum 0xf0da, unused inodes 2024
501   Block bitmap at 786444 (+4294770700), Inode bitmap at 786460 (+4294770716)
502   Inode table at 789500-789752 (+4294773756)
503   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
504   Free blocks: 983040-999423
505   Free inodes: 121441-123464
506 Group 61: (Blocks 999424-1015807) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
507   Checksum 0x3ac1, unused inodes 2024
508   Block bitmap at 786445 (+4294754317), Inode bitmap at 786461 (+4294754333)
509   Inode table at 789753-790005 (+4294757625)
510   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
511   Free blocks: 999424-1015807
512   Free inodes: 123465-125488
513 Group 62: (Blocks 1015808-1032191) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
514   Checksum 0x6c66, unused inodes 2024
515   Block bitmap at 786446 (+4294737934), Inode bitmap at 786462 (+4294737950)
516   Inode table at 790006-790258 (+4294741494)
517   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
518   Free blocks: 1015808-1032191
519   Free inodes: 125489-127512
520 Group 63: (Blocks 1032192-1048575) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
521   Checksum 0x2238, unused inodes 2024
522   Block bitmap at 786447 (+4294721551), Inode bitmap at 786463 (+4294721567)
523   Inode table at 790259-790511 (+4294725363)
524   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
525   Free blocks: 1032192-1048575
526   Free inodes: 127513-129536
527 Group 64: (Blocks 1048576-1052255) [INODE_UNINIT, ITABLE_ZEROED]
528   Checksum 0xb5ee, unused inodes 2024
529   Block bitmap at 1048576 (+0), Inode bitmap at 1048592 (+16)
530   Inode table at 1048608-1048860 (+32)
531   3425 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
532   Free blocks: 1048577-1048591, 1048593-1048607, 1048861-1052255
533   Free inodes: 129537-131560
534 [root@yinzhengjie ~]#
535 '''
用dumpe2fs 檢視超級塊和是否有碎片
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# dumpe2fs -h /dev/sdb3  #僅顯示超級塊中儲存的資訊
 9 dumpe2fs 1.41.12 (17-May-2010)
10 Filesystem volume name:   <none>  #檔案系統卷標名稱
11 Last mounted on:          <not available>   #上一次上面時候掛載的
12 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
13 Filesystem magic number:  0xEF53  #檔案的魔術號
14 Filesystem revision #:    1 (dynamic)
15 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize  #支援的預設屬性
16 Filesystem flags:         signed_directory_hash
17 Default mount options:    (none)
18 Filesystem state:         clean
19 Errors behavior:          Continue
20 Filesystem OS type:       Linux
21 Inode count:              131560
22 Block count:              1052256
23 Reserved block count:     31567
24 Free blocks:              998268
25 Free inodes:              131549
26 First block:              0
27 Block size:               2048
28 Fragment size:            2048
29 Reserved GDT blocks:      512
30 Blocks per group:         16384
31 Fragments per group:      16384
32 Inodes per group:         2024
33 Inode blocks per group:   253
34 Flex block group size:    16
35 Filesystem created:       Thu May 11 12:42:49 2017
36 Last mount time:          n/a
37 Last write time:          Thu May 11 12:42:49 2017
38 Mount count:              0
39 Maximum mount count:      29
40 Last checked:             Thu May 11 12:42:49 2017
41 Check interval:           15552000 (6 months)
42 Next check after:         Tue Nov  7 11:42:49 2017
43 Lifetime writes:          97 MB
44 Reserved blocks uid:      0 (user root)
45 Reserved blocks gid:      0 (group root)
46 First inode:              11
47 Inode size:               256
48 Required extra isize:     28
49 Desired extra isize:      28
50 Journal inode:            8
51 Default directory hash:   half_md4
52 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
53 Journal backup:           inode blocks
54 Journal features:         (none)
55 Journal size:             64M
56 Journal length:           32768
57 Journal sequence:         0x00000001
58 Journal start:            0
59 
60 [root@yinzhengjie ~]#
61 '''
dumpe2fs的-h引數用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# tune2fs -l /dev/sdb3  #檢視超級塊中的資訊。
 9 tune2fs 1.41.12 (17-May-2010)
10 Filesystem volume name:   <none>
11 Last mounted on:          <not available>
12 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
13 Filesystem magic number:  0xEF53
14 Filesystem revision #:    1 (dynamic)
15 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
16 Filesystem flags:         signed_directory_hash 
17 Default mount options:    (none)
18 Filesystem state:         clean
19 Errors behavior:          Continue
20 Filesystem OS type:       Linux
21 Inode count:              131560
22 Block count:              1052256
23 Reserved block count:     31567
24 Free blocks:              998268
25 Free inodes:              131549
26 First block:              0
27 Block size:               2048
28 Fragment size:            2048
29 Reserved GDT blocks:      512
30 Blocks per group:         16384
31 Fragments per group:      16384
32 Inodes per group:         2024
33 Inode blocks per group:   253
34 Flex block group size:    16
35 Filesystem created:       Thu May 11 12:42:49 2017
36 Last mount time:          n/a
37 Last write time:          Thu May 11 12:42:49 2017
38 Mount count:              0
39 Maximum mount count:      29
40 Last checked:             Thu May 11 12:42:49 2017
41 Check interval:           15552000 (6 months)
42 Next check after:         Tue Nov  7 11:42:49 2017
43 Lifetime writes:          97 MB
44 Reserved blocks uid:      0 (user root)
45 Reserved blocks gid:      0 (group root)
46 First inode:              11
47 Inode size:               256
48 Required extra isize:     28
49 Desired extra isize:      28
50 Journal inode:            8
51 Default directory hash:   half_md4
52 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
53 Journal backup:           inode blocks
54 [root@yinzhengjie ~]# 
55 [root@yinzhengjie ~]#
56 '''
用tune2fs檢視超級塊中的資訊。
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# tune2fs -l /dev/sdb3  #檢視/dev/sdb3 超級塊中的資訊
  9 tune2fs 1.41.12 (17-May-2010)
 10 Filesystem volume name:   <none>
 11 Last mounted on:          <not available>
 12 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
 13 Filesystem magic number:  0xEF53
 14 Filesystem revision #:    1 (dynamic)
 15 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize  #含有分割槽特性“huge_file”
 16 Filesystem flags:         signed_directory_hash
 17 Default mount options:    (none)
 18 Filesystem state:         not clean
 19 Errors behavior:          Continue
 20 Filesystem OS type:       Linux
 21 Inode count:              131560
 22 Block count:              1052256
 23 Reserved block count:     31567
 24 Free blocks:              998268
 25 Free inodes:              131549
 26 First block:              0
 27 Block size:               2048
 28 Fragment size:            2048
 29 Reserved GDT blocks:      512
 30 Blocks per group:         16384
 31 Fragments per group:      16384
 32 Inodes per group:         2024
 33 Inode blocks per group:   253
 34 Flex block group size:    16
 35 Filesystem created:       Thu May 11 12:42:49 2017
 36 Last mount time:          n/a
 37 Last write time:          Thu May 11 13:04:33 2017
 38 Mount count:              0
 39 Maximum mount count:      29
 40 Last checked:             Thu May 11 12:42:49 2017
 41 Check interval:           15552000 (6 months)
 42 Next check after:         Tue Nov  7 11:42:49 2017
 43 Lifetime writes:          97 MB
 44 Reserved blocks uid:      0 (user root)
 45 Reserved blocks gid:      0 (group root)
 46 First inode:              11
 47 Inode size:               256
 48 Required extra isize:     28
 49 Desired extra isize:      28
 50 Journal inode:            8
 51 Default directory hash:   half_md4
 52 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
 53 Journal backup:           inode blocks
 54 [root@yinzhengjie ~]# tune2fs -O ^huge_file /dev/sdb3   #關閉/dev/sdb3的huge_file分割槽特性
 55 tune2fs 1.41.12 (17-May-2010)
 56 
 57 Please run e2fsck on the filesystem.
 58 
 59 [root@yinzhengjie ~]# tune2fs -l /dev/sdb3
 60 tune2fs 1.41.12 (17-May-2010)
 61 Filesystem volume name:   <none>
 62 Last mounted on:          <not available>
 63 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
 64 Filesystem magic number:  0xEF53
 65 Filesystem revision #:    1 (dynamic)
 66 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super uninit_bg dir_nlink extra_isize  #果真huge_file的分割槽特性沒了
 67 Filesystem flags:         signed_directory_hash
 68 Default mount options:    (none)
 69 Filesystem state:         not clean
 70 Errors behavior:          Continue
 71 Filesystem OS type:       Linux
 72 Inode count:              131560
 73 Block count:              1052256
 74 Reserved block count:     31567
 75 Free blocks:              998268
 76 Free inodes:              131549
 77 First block:              0
 78 Block size:               2048
 79 Fragment size:            2048
 80 Reserved GDT blocks:      512
 81 Blocks per group:         16384
 82 Fragments per group:      16384
 83 Inodes per group:         2024
 84 Inode blocks per group:   253
 85 Flex block group size:    16
 86 Filesystem created:       Thu May 11 12:42:49 2017
 87 Last mount time:          n/a
 88 Last write time:          Thu May 11 13:04:49 2017
 89 Mount count:              0
 90 Maximum mount count:      29
 91 Last checked:             Thu May 11 12:42:49 2017
 92 Check interval:           15552000 (6 months)
 93 Next check after:         Tue Nov  7 11:42:49 2017
 94 Lifetime writes:          97 MB
 95 Reserved blocks uid:      0 (user root)
 96 Reserved blocks gid:      0 (group root)
 97 First inode:              11
 98 Inode size:               256
 99 Required extra isize:     28
100 Desired extra isize:      28
101 Journal inode:            8
102 Default directory hash:   half_md4
103 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
104 Journal backup:           inode blocks
105 [root@yinzhengjie ~]# tune2fs -O huge_file /dev/sdb3  #開啟/dev/sdb3的huge_file分割槽特性
106 tune2fs 1.41.12 (17-May-2010)
107 [root@yinzhengjie ~]# tune2fs -l /dev/sdb3
108 tune2fs 1.41.12 (17-May-2010)
109 Filesystem volume name:   <none>
110 Last mounted on:          <not available>
111 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
112 Filesystem magic number:  0xEF53
113 Filesystem revision #:    1 (dynamic)
114 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize  #/dev/sdb3的huge_file分割槽特性又有了
115 Filesystem flags:         signed_directory_hash
116 Default mount options:    (none)
117 Filesystem state:         not clean
118 Errors behavior:          Continue
119 Filesystem OS type:       Linux
120 Inode count:              131560
121 Block count:              1052256
122 Reserved block count:     31567
123 Free blocks:              998268
124 Free inodes:              131549
125 First block:              0
126 Block size:               2048
127 Fragment size:            2048
128 Reserved GDT blocks:      512
129 Blocks per group:         16384
130 Fragments per group:      16384
131 Inodes per group:         2024
132 Inode blocks per group:   253
133 Flex block group size:    16
134 Filesystem created:       Thu May 11 12:42:49 2017
135 Last mount time:          n/a
136 Last write time:          Thu May 11 13:05:00 2017
137 Mount count:              0
138 Maximum mount count:      29
139 Last checked:             Thu May 11 12:42:49 2017
140 Check interval:           15552000 (6 months)
141 Next check after:         Tue Nov  7 11:42:49 2017
142 Lifetime writes:          97 MB
143 Reserved blocks uid:      0 (user root)
144 Reserved blocks gid:      0 (group root)
145 First inode:              11
146 Inode size:               256
147 Required extra isize:     28
148 Desired extra isize:      28
149 Journal inode:            8
150 Default directory hash:   half_md4
151 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
152 Journal backup:           inode blocks
153 [root@yinzhengjie ~]#
154 '''
tune2fs的對特性的開啟與關閉用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# fsck -t ext4 /dev/sdb3  #對檔案系統檢測
 9 fsck from util-linux-ng 2.17.2
10 e2fsck 1.41.12 (17-May-2010)
11 /dev/sdb3 was not cleanly unmounted, check forced.
12 Pass 1: Checking inodes, blocks, and sizes  #檢測 inodes, blocks, and sizes
13 Pass 2: Checking directory structure        #檢測目錄機構
14 Pass 3: Checking directory connectivity     #檢測目錄連整性
15 Pass 4: Checking reference counts           #引用的次數
16 Pass 5: Checking group summary information  #檢查組彙總資訊
17 /dev/sdb3: 11/131560 files (0.0% non-contiguous), 53988/1052256 blocks
18 [root@yinzhengjie ~]#
19 '''
用fsck進行檔案型別檢查

 

11.建立交換分割槽

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8     如果實體記憶體不夠用時,可以將那些最近很少使用的頁面資料(Page)置換出去,即切換到硬碟上,但是要注意的是內
 9 存檔案的格式和硬碟中檔案的格式是不一樣的,所以這個分割槽必須格式化成跟記憶體相容的模式不能轉換成檔案的格式。以便
10 把記憶體的page直接存入這個分割槽,方便記憶體直接呼叫。而這個頁面(page)資料對於32位的作業系統一個page大概是4K左右,
11 對於64位作業系統這個page大小是可變的,4k-2M的大小都是比較常見的。事實上到底能使用多大的頁面(page)取決於CPU
12 而不取決於記憶體喲!這就是虛擬記憶體的概念。在linux上我們稱之為交換分割槽。記住,虛擬記憶體必須是一個單獨的分割槽。
13 
14 那麼問題來了:虛擬記憶體能代替實體記憶體執行程式嗎?
15     答案是否定的,只是使用虛擬記憶體暫時儲存資料,而不是代替實體記憶體執行程式。
16     虛擬記憶體的作用是這樣的:
17         當執行某個大程式、大遊戲,需要的記憶體超過空閒記憶體但小於實體記憶體總量時,會暫時把記憶體裡這些資料放到磁碟
18     上的虛擬記憶體裡,空出實體記憶體執行遊戲。等退出遊戲後,又會把虛擬記憶體裡的東西讀出來,放回實體記憶體。所以,虛擬
19     記憶體,並不是用來虛擬實體記憶體的,而是暫存資料的。如果對記憶體的需求大於實體記憶體總量,那虛擬記憶體設多大都不管用。
20     電腦記憶體太低,根本的方法還是增加實體記憶體,才能流暢。虛擬記憶體機制上就不管用,即使管用,比實體記憶體低100倍的速
21     度,也管不上什麼實際的作用。所以,虛擬記憶體大了是沒用的,反而白佔用磁碟空間。
22 '''
23 
24 '''
25 交換分割槽:
26       mkswap 格式化為虛擬記憶體
27       -L label 指定卷標
28       swapon 啟動虛擬記憶體
29       -a 啟動所有的虛擬分割槽
30       -p:指定優先順序
31       swapoff 關閉虛擬記憶體
32       更多引數請參考man mkswap
33 ''' 
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# fdisk /dev/sdb  #對第二塊硬碟進行分割槽調整
  9 
 10 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
 11          switch off the mode (command 'c') and change display units to
 12          sectors (command 'u').
 13 
 14 Command (m for help): p  #檢視當前分割槽情況
 15 
 16 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 17 255 heads, 63 sectors/track, 1305 cylinders
 18 Units = cylinders of 16065 * 512 = 8225280 bytes
 19 Sector size (logical/physical): 512 bytes / 512 bytes
 20 I/O size (minimum/optimal): 512 bytes / 512 bytes
 21 Disk identifier: 0x8614a108
 22 
 23    Device Boot      Start         End      Blocks   Id  System
 24 /dev/sdb1               1         132     1060258+  83  Linux
 25 /dev/sdb2             133         264     1060290   83  Linux
 26 /dev/sdb3             265         526     2104515   83  Linux
 27 /dev/sdb4             527        1305     6257317+   5  Extended
 28 /dev/sdb5             527         919     3156741   83  Linux
 29 /dev/sdb6             920        1181     2104483+  83  Linux    #我想講第6個分割槽弄成交換分割槽。
 30 
 31 Command (m for help): t  #調整分割槽ID
 32 Partition number (1-6): 6  #選擇分割槽編號為6
 33 Hex code (type L to list codes): L   #檢視分割槽型別所對應的ID號,我們發現“82”就是交換分割槽的編號
 34 
 35  0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 36  1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 37  2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 38  3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 39  4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 40  5  Extended        42  SFS             86  NTFS volume set da  Non-FS data
 41  6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 42  7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 43  8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 44  9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access
 45  a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 46  b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor
 47  c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 48  e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT
 49  f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
 50 10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
 51 11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
 52 12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor
 53 14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
 54 16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS
 55 17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
 56 18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto
 57 1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep
 58 1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT
 59 1e  Hidden W95 FAT1
 60 Hex code (type L to list codes): 82   #設定該分割槽的標號
 61 Changed system type of partition 6 to 82 (Linux swap / Solaris)
 62 
 63 Command (m for help): P   #檢視當前分割槽情況
 64 
 65 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 66 255 heads, 63 sectors/track, 1305 cylinders
 67 Units = cylinders of 16065 * 512 = 8225280 bytes
 68 Sector size (logical/physical): 512 bytes / 512 bytes
 69 I/O size (minimum/optimal): 512 bytes / 512 bytes
 70 Disk identifier: 0x8614a108
 71 
 72    Device Boot      Start         End      Blocks   Id  System
 73 /dev/sdb1               1         132     1060258+  83  Linux
 74 /dev/sdb2             133         264     1060290   83  Linux
 75 /dev/sdb3             265         526     2104515   83  Linux
 76 /dev/sdb4             527        1305     6257317+   5  Extended
 77 /dev/sdb5             527         919     3156741   83  Linux
 78 /dev/sdb6             920        1181     2104483+  82  Linux swap / Solaris
 79 
 80 Command (m for help): W  #儲存並退出
 81 The partition table has been altered!
 82 
 83 Calling ioctl() to re-read partition table.
 84 Syncing disks.
 85 [root@yinzhengjie ~]#
 86 [root@yinzhengjie ~]# fdisk -l /dev/sdb  #檢視分割槽資訊
 87 
 88 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 89 255 heads, 63 sectors/track, 1305 cylinders
 90 Units = cylinders of 16065 * 512 = 8225280 bytes
 91 Sector size (logical/physical): 512 bytes / 512 bytes
 92 I/O size (minimum/optimal): 512 bytes / 512 bytes
 93 Disk identifier: 0x8614a108
 94 
 95    Device Boot      Start         End      Blocks   Id  System
 96 /dev/sdb1               1         132     1060258+  83  Linux
 97 /dev/sdb2             133         264     1060290   83  Linux
 98 /dev/sdb3             265         526     2104515   83  Linux
 99 /dev/sdb4             527        1305     6257317+   5  Extended
100 /dev/sdb5             527         919     3156741   83  Linux
101 /dev/sdb6             920        1181     2104483+  82  Linux swap / Solaris
102 [root@yinzhengjie ~]# 
103 '''
調整分割槽為交換分割槽(swap)格式
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# kpartx -af /dev/sdb
 9 [root@yinzhengjie ~]# partx -a /dev/sdb   #重讀分割槽表資訊,其實也可以不用敲擊這些命令的如果你是一塊新硬碟的話。
10 BLKPG: Device or resource busy
11 error adding partition 1
12 BLKPG: Device or resource busy
13 error adding partition 2
14 BLKPG: Device or resource busy
15 error adding partition 3
16 BLKPG: Device or resource busy
17 error adding partition 4
18 BLKPG: Device or resource busy
19 error adding partition 5
20 BLKPG: Device or resource busy
21 error adding partition 6
22 [root@yinzhengjie ~]# 
23 '''
用partx 重讀一下分割槽表,避免系統未識別最新分割槽資訊。
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mkswap /dev/sdb6  #將分割槽格式化成swap格式
 9 Setting up swapspace version 1, size = 2104476 KiB
10 no label, UUID=41687bb2-c775-489c-9b32-1e4be73c233b   #看見沒有,這裡是“no label”,是因為我沒有定義卷標名。
11 [root@yinzhengjie ~]# 
12 [root@yinzhengjie ~]# mkswap -L myswap /dev/sdb6   #用-L引數定義一個卷標名。
13 Setting up swapspace version 1, size = 2104476 KiB
14 LABEL=myswap, UUID=0553b99a-ee75-4476-8eda-70c591206467  #看見沒,“LABEL=myswap”這就是我定義的卷標名稱。
15 [root@yinzhengjie ~]# 
16 '''
用mkswap定義卷標名稱
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# cat /proc/meminfo | grep "^S"   #檢視當前交換分割槽大小
 9 SwapCached:            0 kB
10 SwapTotal:       2031612 kB  #目前交換分割槽大小為2G
11 SwapFree:        2031612 kB  #表示空閒交換分割槽大小
12 Shmem:              1444 kB
13 Slab:              75020 kB
14 SReclaimable:      15620 kB
15 SUnreclaim:        59400 kB
16 [root@yinzhengjie ~]#
17 [root@yinzhengjie ~]# swapon /dev/sdb6   #啟用我們已經格式化好的交換分割槽“/dev/sdb”
18 [root@yinzhengjie ~]# cat /proc/meminfo | grep "^S"   #再次檢視當前交換分割槽大小
19 SwapCached:            0 kB
20 SwapTotal:       4136088 kB   #我們發現交換分割槽大小變大了2G
21 SwapFree:        4136088 kB
22 Shmem:              1444 kB
23 Slab:              75148 kB
24 SReclaimable:      15656 kB
25 SUnreclaim:        59492 kB
26 [root@yinzhengjie ~]#
27 [root@yinzhengjie ~]# swapoff /dev/sdb6  #關閉交換分割槽“/dev/sdb”
28 [root@yinzhengjie ~]#
29 [root@yinzhengjie ~]# cat /proc/meminfo | grep "^S"  #驗證是否關閉成功
30 SwapCached:            0 kB
31 SwapTotal:       2031612 kB   #發現的確是少了2G的空間
32 SwapFree:        2031612 kB
33 Shmem:              1444 kB
34 Slab:              75068 kB
35 SReclaimable:      15636 kB
36 SUnreclaim:        59432 kB
37 [root@yinzhengjie ~]#
38 
39 '''
swapon和swapoff的用法展示

 

12.獲取IDE磁碟的相關資訊

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 hdparm
 9     -i 從作業系統讀取
10     -I 直接從硬碟讀取
11     -g 顯示硬碟的佈局資訊
12     -t 測試硬碟的效能
13     -T 測試硬碟的效能
14 
15 '''
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8      一個磁頭一次可以讀取128位資訊,系統就會認為它被虛擬成128個磁頭(heads)。所以兩個磁頭(一個碟片有兩個面,
 9 一個盤面有一個磁頭,所以說一個碟片有2個磁頭)就是256個虛擬磁頭(heads)。
10 [root@yinzhengjie ~]#
11 [root@yinzhengjie ~]# fdisk -l /dev/sdb  #我們可以看出來磁碟的資訊
12 
13 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
14 255 heads, 63 sectors/track, 1305 cylinders  #這裡有255個磁頭其實是工業生產導致,理論上就是256大家知道即可。
15 Units = cylinders of 16065 * 512 = 8225280 bytes
16 Sector size (logical/physical): 512 bytes / 512 bytes
17 I/O size (minimum/optimal): 512 bytes / 512 bytes
18 Disk identifier: 0x8614a108
19 
20    Device Boot      Start         End      Blocks   Id  System
21 /dev/sdb1               1         132     1060258+  83  Linux
22 /dev/sdb2             133         264     1060290   83  Linux
23 /dev/sdb3             265         526     2104515   83  Linux
24 /dev/sdb4             527        1305     6257317+   5  Extended
25 /dev/sdb5             527         919     3156741   83  Linux
26 /dev/sdb6             920        1181     2104483+  82  Linux swap / Solaris
27 [root@yinzhengjie ~]#
28 '''
29 
30 '''
31 [root@yinzhengjie ~]# hdparm -i /dev/sdb  #從作業系統讀取
32 
33 /dev/sdb:
34 SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
35  HDIO_GET_IDENTITY failed: Invalid argument
36 [root@yinzhengjie ~]#
37 [root@yinzhengjie ~]# hdparm -I /dev/sdb  #直接從硬碟讀取
38 
39 /dev/sdb:
40 SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
41 
42 ATA device, with non-removable media
43 Standards:
44         Likely used: 1
45 Configuration:
46         Logical         max     current
47         cylinders       0       0
48         heads           0       0
49         sectors/track   0       0
50         --
51         Logical/Physical Sector size:           512 bytes
52         device size with M = 1024*1024:           0 MBytes
53         device size with M = 1000*1000:           0 MBytes
54         cache/buffer size  = unknown
55 Capabilities:
56         IORDY not likely
57         Cannot perform double-word IO
58         R/W multiple sector transfer: not supported
59         DMA: not supported
60         PIO: pio0
61 [root@yinzhengjie ~]#
62 [root@yinzhengjie ~]# hdparm -g /dev/sdb  #顯示硬碟的佈局資訊
63 
64 /dev/sdb:
65  geometry      = 1305(柱面數)/255(磁頭,heads)/63(每磁軌的扇區數), sectors = 20971520(總的扇區數), start = 0(從第幾個扇區開始)
66 [root@yinzhengjie ~]#
67 
68 '''
hdparm用法展示

 

13.掛載

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 掛載分類:
 9     手動掛載
10     按需掛載(autofs,這種效率比較低,當用的時候才去掛載,需要等待時間。)
11     開機自動掛載
12 
13 mount[options] -t 檔案型別 -o option 裝置 掛載點
14      [options] : 命令的選項
15            -n:不更新/etc/mtab檔案
16            --bind:dir1 dir2 將目錄掛載到目錄上,使得dir2也能訪問dir1的檔案
17            -t fstype
18            -r 只讀掛載
19            -w:讀寫掛載
20            -L lable 以卷標指定,也可以使用LABLE="lable"
21            -U UUID:使用UUID掛載,也可以使用 UUID="uuid"
22                -o options:掛載時啟動分割槽特性
23                          async:非同步I/O
24                          sync:同步I/O
25                          noatime/atime 是否更新檔案時間戳,不是特別重要的檔案,建議noatime
26                          auto: 是否能夠被mount -a 自動掛載所有(/etc/fstab中)的檔案自動掛載
27                          dev/nodev:是否能建立裝置檔案
28                          diratime/nodirtime:是否更新目錄的時間戳
29                          exec/noexec:是否允許執行二進位制程式
30                          _netdev:網路裝置
31                          remount:重新掛載
32                          relatime/norelatime 是否實時更新
33                          acl 檔案訪問控制列表
34 
35 掛載點:掛載以後原始資料將被隱藏
36    1、選擇空閒目錄
37    2、必須事先存在
38 解除安裝:
39    1、空閒時可以解除安裝
40    2、其實也可以強行解除安裝
41 umount 裝置|掛載點
42 
43 直接使用mount可以顯示當前系統的掛載資訊,也可以檢視/proc/mounts或者/etc/mtab
44 
45 光碟:
46  /dev/cdrom /dev/dvdrom /dev/sr0
47  [-t iso9660]
48 '''
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# cat /proc/filesystems  #檢視核心能識別的檔案系統型別
 9 nodev   sysfs  #其中“nodev”表示非裝置檔案系統,即偽檔案系統,後面的引數是“sysfs”。
10 nodev   rootfs
11 nodev   bdev
12 nodev   proc
13 nodev   cgroup
14 nodev   cpuset
15 nodev   tmpfs
16 nodev   devtmpfs
17 nodev   binfmt_misc
18 nodev   debugfs
19 nodev   securityfs
20 nodev   sockfs
21 nodev   usbfs
22 nodev   pipefs
23 nodev   anon_inodefs
24 nodev   inotifyfs
25 nodev   devpts
26 nodev   ramfs
27 nodev   hugetlbfs
28         iso9660  #這就是裝置檔案系統,光碟
29 nodev   pstore
30 nodev   mqueue
31 nodev   selinuxfs
32         ext4    #這個也是裝置檔案系統,前面沒有“nodev”進行標識。
33 nodev   vmhgfs
34 nodev   fuse
35         fuseblk
36 nodev   fusectl
37 [root@yinzhengjie ~]#
38 '''
檢視核心能識別的檔案系統型別
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mkdir /yinzhengjie  #建立一個掛載目錄
 9 [root@yinzhengjie ~]# mount   #檢視當前的掛載資訊
10 /dev/sda2 on / type ext4 (rw)
11 proc on /proc type proc (rw)
12 sysfs on /sys type sysfs (rw)
13 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
14 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
15 /dev/sda1 on /boot type ext4 (rw)
16 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
17 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
18 [root@yinzhengjie ~]# mount /dev/sdb1 /yinzhengjie/  #將第二塊裝置的第一個分割槽掛載到"/yinzhengjie"目錄下。
19 [root@yinzhengjie ~]# 
20 [root@yinzhengjie ~]# mount   #再次檢視掛載資訊,發現多出來了最後一項
21 /dev/sda2 on / type ext4 (rw)
22 proc on /proc type proc (rw)
23 sysfs on /sys type sysfs (rw)
24 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
25 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
26 /dev/sda1 on /boot type ext4 (rw)
27 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
28 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
29 /dev/sdb1 on /yinzhengjie type ext4 (rw)  #發現了掛載的目錄
30 [root@yinzhengjie ~]# ll /yinzhengjie/ #檢視掛載點資訊,出現了“lost+found”目錄表示掛載成功
31 total 16
32 drwx------. 2 root root 16384 May 12 04:31 lost+found
33 [root@yinzhengjie ~]# cd /yinzhengjie/
34 [root@yinzhengjie yinzhengjie]# touch {1..5}.txt  #我們建立5個檔案看看
35 [root@yinzhengjie yinzhengjie]# ll  #發現也能成功建立檔案,檔名是存在掛載目錄下的。
36 total 16
37 -rw-r--r--. 1 root root     0 May 12 04:36 1.txt
38 -rw-r--r--. 1 root root     0 May 12 04:36 2.txt
39 -rw-r--r--. 1 root root     0 May 12 04:36 3.txt
40 -rw-r--r--. 1 root root     0 May 12 04:36 4.txt
41 -rw-r--r--. 1 root root     0 May 12 04:36 5.txt
42 drwx------. 2 root root 16384 May 12 04:31 lost+found
43 [root@yinzhengjie yinzhengjie]# cd  #回到自己的家目錄去
44 [root@yinzhengjie ~]# umount /yinzhengjie/  #解除安裝掛載點
45 [root@yinzhengjie ~]# mount  #再一次檢視掛載資訊,發現之前的掛載點不見了。
46 /dev/sda2 on / type ext4 (rw)
47 proc on /proc type proc (rw)
48 sysfs on /sys type sysfs (rw)
49 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
50 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
51 /dev/sda1 on /boot type ext4 (rw)
52 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
53 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
54 [root@yinzhengjie ~]# 
55 [root@yinzhengjie ~]# ll /yinzhengjie/  #發現這個目錄的檔案也沒有了,原因是解除安裝成功了,資料還存在那塊裝置上。
56 total 0
57 [root@yinzhengjie ~]# 
58 '''
mount的基本使用展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# ll /yinzhengjie/  #檢視目錄為空。
 9 total 0
10 [root@yinzhengjie ~]# mount  #先檢視掛載之前的資訊
11 /dev/sda2 on / type ext4 (rw)
12 proc on /proc type proc (rw)
13 sysfs on /sys type sysfs (rw)
14 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
15 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
16 /dev/sda1 on /boot type ext4 (rw)
17 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
18 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
19 [root@yinzhengjie ~]#
20 [root@yinzhengjie ~]# tune2fs -L yinzhengjie /dev/sdb1  #給這個分割槽設定一個卷標名稱。
21 tune2fs 1.41.12 (17-May-2010)
22 [root@yinzhengjie ~]# e2label /dev/sdb1 #檢視這個卷標名稱
23 yinzhengjie
24 [root@yinzhengjie ~]#
25 [root@yinzhengjie ~]# mount LABEL="yinzhengjie"  /yinzhengjie/  #把卷標名稱為"yinzhengjie" 的裝置掛載到“/yinzhengjie/”這個目錄下來。
26 [root@yinzhengjie ~]# mount  #檢視掛載後的資訊
27 /dev/sda2 on / type ext4 (rw)
28 proc on /proc type proc (rw)
29 sysfs on /sys type sysfs (rw)
30 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
31 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
32 /dev/sda1 on /boot type ext4 (rw)
33 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
34 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
35 /dev/sdb1 on /yinzhengjie type ext4 (rw)  #這裡有記錄,說明掛載成功了。
36 [root@yinzhengjie ~]# ll /yinzhengjie/  #看一下掛載目錄,果真是訪問到了資料
37 total 16
38 -rw-r--r--. 1 root root     0 May 12 04:36 1.txt
39 -rw-r--r--. 1 root root     0 May 12 04:36 2.txt
40 -rw-r--r--. 1 root root     0 May 12 04:36 3.txt
41 -rw-r--r--. 1 root root     0 May 12 04:36 4.txt
42 -rw-r--r--. 1 root root     0 May 12 04:36 5.txt
43 drwx------. 2 root root 16384 May 12 04:31 lost+found
44 [root@yinzhengjie ~]#
45 '''
mount命令基於卷標掛載用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# ll /yinzhengjie/
 9 total 0
10 [root@yinzhengjie ~]#
11 [root@yinzhengjie ~]# mount  #檢視掛載資訊
12 /dev/sda2 on / type ext4 (rw)
13 proc on /proc type proc (rw)
14 sysfs on /sys type sysfs (rw)
15 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
16 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
17 /dev/sda1 on /boot type ext4 (rw)
18 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
19 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
20 [root@yinzhengjie ~]#
21 [root@yinzhengjie ~]# blkid /dev/sdb1  #先檢視裝置的UUID資訊
22 /dev/sdb1: LABEL="yinzhengjie" UUID="768fe361-9425-4928-b2d9-641064d1052a" TYPE="ext4"
23 [root@yinzhengjie ~]# mount UUID="768fe361-9425-4928-b2d9-641064d1052a" /yinzhengjie/  #將上面查閱到的UUID=
24 "768fe361-9425-4928-b2d9-641064d1052a"賦值下來,它就是“/dev/sdb1”這塊裝置,我們將它掛載到"/yinzhengjie"目錄下。
25 [root@yinzhengjie ~]#
26 [root@yinzhengjie ~]# mount  #檢視掛載資訊
27 /dev/sda2 on / type ext4 (rw)
28 proc on /proc type proc (rw)
29 sysfs on /sys type sysfs (rw)
30 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
31 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
32 /dev/sda1 on /boot type ext4 (rw)
33 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
34 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
35 /dev/sdb1 on /yinzhengjie type ext4 (rw)
36 [root@yinzhengjie ~]# ll /yinzhengjie/  #發現能夠成功範圍資料。
37 total 16
38 -rw-r--r--. 1 root root     0 May 12 04:36 1.txt
39 -rw-r--r--. 1 root root     0 May 12 04:36 2.txt
40 -rw-r--r--. 1 root root     0 May 12 04:36 3.txt
41 -rw-r--r--. 1 root root     0 May 12 04:36 4.txt
42 -rw-r--r--. 1 root root     0 May 12 04:36 5.txt
43 drwx------. 2 root root 16384 May 12 04:31 lost+found
44 [root@yinzhengjie ~]#
45 '''
mount命令基於UUID進行掛載用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mount  #檢視掛載資訊
 9 /dev/sda2 on / type ext4 (rw)
10 proc on /proc type proc (rw)
11 sysfs on /sys type sysfs (rw)
12 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
13 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
14 /dev/sda1 on /boot type ext4 (rw)
15 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
16 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
17 /dev/sdb1 on /yinzhengjie type ext4 (rw)  #發現這個裝置的掛載的許可權是"讀寫(rw)"模式
18 [root@yinzhengjie ~]#
19 [root@yinzhengjie ~]# mount -o remount,ro /dev/sdb1  #我們對其進行重新掛載,並將掛載後許可權設定為只讀模式。
20 [root@yinzhengjie ~]# mount
21 /dev/sda2 on / type ext4 (rw)
22 proc on /proc type proc (rw)
23 sysfs on /sys type sysfs (rw)
24 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
25 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
26 /dev/sda1 on /boot type ext4 (rw)
27 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
28 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
29 /dev/sdb1 on /yinzhengjie type ext4 (ro) #過著,許可權變成了只讀(ro)了。
30 [root@yinzhengjie ~]#
31 
32 '''
mount命令的remount重新掛載用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mount
 9 /dev/sda2 on / type ext4 (rw)
10 proc on /proc type proc (rw)
11 sysfs on /sys type sysfs (rw)
12 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
13 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
14 /dev/sda1 on /boot type ext4 (rw)
15 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
16 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
17 /dev/sdb1 on /yinzhengjie type ext4 (ro) #許可權是隻讀
18 [root@yinzhengjie ~]# mount -o remount,rw,acl /dev/sdb1 #啟用檔案訪問控制列表功能(acl)
19 [root@yinzhengjie ~]# mount
20 /dev/sda2 on / type ext4 (rw)
21 proc on /proc type proc (rw)
22 sysfs on /sys type sysfs (rw)
23 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
24 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
25 /dev/sda1 on /boot type ext4 (rw)
26 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
27 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
28 /dev/sdb1 on /yinzhengjie type ext4 (rw,acl) #發現真的有acl和rw許可權了。
29 [root@yinzhengjie ~]#
30 
31 '''
mount命令啟動acl功能用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# tune2fs -o acl /dev/sdb1  #給該分割槽新增ACL熟悉,讓其掛載的時候預設就支援ACL
 9 tune2fs 1.41.12 (17-May-2010)
10 [root@yinzhengjie ~]# tune2fs -l /dev/sdb1 | grep ^D  #檢視該分割槽資訊
11 Default mount options:    acl  #我們發現是啟用了acl功能的,在mount的選項的時候它會自動支援該引數。
12 Desired extra isize:      28
13 Default directory hash:   half_md4
14 Directory Hash Seed:      63cd7ef0-15f3-4e20-978a-82472a392459
15 [root@yinzhengjie ~]#
16 [root@yinzhengjie ~]# mount /dev/sdb1 /yinzhengjie/
17 [root@yinzhengjie ~]# mount
18 /dev/sda2 on / type ext4 (rw)
19 proc on /proc type proc (rw)
20 sysfs on /sys type sysfs (rw)
21 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
22 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
23 /dev/sda1 on /boot type ext4 (rw)
24 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
25 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
26 /dev/sdb1 on /yinzhengjie type ext4 (rw)  #注意這裡儘管沒有acl顯示,但是它還是有acl屬性的,因為那個分割槽本身就支援acl,是我們們給配置的。
27 [root@yinzhengjie ~]#
28     如果你想取消mount這個引數咋辦呢?很簡單,只要加一個“^”這個符號就好使了,如下:
29 [root@yinzhengjie ~]# tune2fs -o ^acl /dev/sdb1
30 tune2fs 1.41.12 (17-May-2010)
31 [root@yinzhengjie ~]# tune2fs -l /dev/sdb1 | grep ^D
32 Default mount options:    (none)  #發現該屬性的確是沒有啦!為空!
33 Desired extra isize:      28
34 Default directory hash:   half_md4
35 Directory Hash Seed:      63cd7ef0-15f3-4e20-978a-82472a392459
36 [root@yinzhengjie ~]#
37 '''
利用tune2fs給mount新增預設acl功能用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mkdir -p /media/yinzhengjie/cdrom  #建立掛載點
 9 [root@yinzhengjie ~]# ls -l /dev/cdrom  #檢視媒體檔案所對應的連結
10 lrwxrwxrwx. 1 root root 3 May 12 02:38 /dev/cdrom -> sr0
11 [root@yinzhengjie ~]# ls -l /dev/sr0
12 brw-rw----+ 1 root cdrom 11, 0 May 12 02:38 /dev/sr0
13 [root@yinzhengjie ~]# ls -l /dev/dvd
14 lrwxrwxrwx. 1 root root 3 May 12 02:38 /dev/dvd -> sr0
15 [root@yinzhengjie ~]#
16 [root@yinzhengjie ~]# mount -o ro /dev/cdrom /media/yinzhengjie/cdrom/  #以只讀(ro)的方式掛載,等價於:mount -r /dev/cdrom /media/yinzhengjie/cdrom/
17 [root@yinzhengjie ~]# mount
18 /dev/sda2 on / type ext4 (rw)
19 proc on /proc type proc (rw)
20 sysfs on /sys type sysfs (rw)
21 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
22 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
23 /dev/sda1 on /boot type ext4 (rw)
24 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
25 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
26 /dev/sdb1 on /yinzhengjie type ext4 (rw)
27 /dev/sr0 on /media/yinzhengjie/cdrom type iso9660 (ro)
28 [root@yinzhengjie ~]# ll /media/yinzhengjie/cdrom/
29 total 712
30 -r--r--r--. 2 root root     14 Oct 24  2014 CentOS_BuildTag
31 dr-xr-xr-x. 3 root root   2048 Oct 24  2014 EFI
32 -r--r--r--. 2 root root    212 Nov 27  2013 EULA
33 -r--r--r--. 2 root root  18009 Nov 27  2013 GPL
34 dr-xr-xr-x. 3 root root   2048 Oct 24  2014 images
35 dr-xr-xr-x. 2 root root   2048 Oct 24  2014 isolinux
36 dr-xr-xr-x. 2 root root 686080 Oct 24  2014 Packages
37 -r--r--r--. 2 root root   1354 Oct 19  2014 RELEASE-NOTES-en-US.html
38 dr-xr-xr-x. 2 root root   4096 Oct 24  2014 repodata
39 -r--r--r--. 2 root root   1706 Nov 27  2013 RPM-GPG-KEY-CentOS-6
40 -r--r--r--. 2 root root   1730 Nov 27  2013 RPM-GPG-KEY-CentOS-Debug-6
41 -r--r--r--. 2 root root   1730 Nov 27  2013 RPM-GPG-KEY-CentOS-Security-6
42 -r--r--r--. 2 root root   1734 Nov 27  2013 RPM-GPG-KEY-CentOS-Testing-6
43 -r--r--r--. 1 root root   3380 Oct 24  2014 TRANS.TBL
44 [root@yinzhengjie ~]#
45 '''
mount命令用只讀的方式掛載光碟
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# umount /dev/sr0  #解除安裝給裝置報錯了
 9 umount: /media/yinzhengjie/cdrom: device is busy.
10         (In some cases useful info about processes that use
11          the device is found by lsof(8) or fuser(1))  #說是用lsof和fuser命令可以找到這個裝置被誰使用
12 [root@yinzhengjie ~]#
13 [root@yinzhengjie ~]# fuser /media/yinzhengjie/cdrom/ #看一下是哪個程式再訪問這個裝置
14 /media/yinzhengjie/cdrom/:  2420c
15 [root@yinzhengjie ~]#
16 [root@yinzhengjie ~]# fuser -v /media/yinzhengjie/cdrom/  #檢視詳細資訊,到底是哪個使用者和對應的程式在訪問該裝置。
17                      USER        PID ACCESS COMMAND
18 /media/yinzhengjie/cdrom/:
19                      root       2420 ..c.. bash
20 [root@yinzhengjie ~]# who  #其實是我自己開了2個裝置在測試呢!
21 root     pts/0        2017-05-12 03:08 (172.16.3.210)
22 root     pts/1        2017-05-12 05:42 (172.16.3.210)
23 [root@yinzhengjie ~]#
24 [root@yinzhengjie ~]# fuser -km /media/yinzhengjie/cdrom/  #將正在訪問的該裝置的使用者踢出去。
25 /media/yinzhengjie/cdrom/:  2420c
26 [root@yinzhengjie ~]# who  #執行了上個命令,哪個使用者就被提出終端了!
27 root     pts/1        2017-05-12 05:42 (172.16.3.210)
28 [root@yinzhengjie ~]# 
29 [root@yinzhengjie ~]# umount /dev/sr0  #再一次執行解除安裝,發現沒有報錯
30 [root@yinzhengjie ~]# mount   #也成功解除安裝掉了
31 /dev/sda2 on / type ext4 (rw)
32 proc on /proc type proc (rw)
33 sysfs on /sys type sysfs (rw)
34 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
35 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
36 /dev/sda1 on /boot type ext4 (rw)
37 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
38 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
39 [root@yinzhengjie ~]#
40 '''
umount解除安裝報錯解決方案展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8     其實mount命令是通過“/proc/mounts[也是和核心相關的檔案喲]”這個檔案獲取到當前系統上正在掛載的相關資訊,只不過mount用了比較讓我們易
 9 讀的方式輸出出來而已。
10 [root@yinzhengjie ~]# cat /proc/mounts
11 rootfs / rootfs rw 0 0
12 proc /proc proc rw,relatime 0 0
13 sysfs /sys sysfs rw,seclabel,relatime 0 0
14 devtmpfs /dev devtmpfs rw,seclabel,relatime,size=490820k,nr_inodes=122705,mode=755 0 0
15 devpts /dev/pts devpts rw,seclabel,relatime,gid=5,mode=620,ptmxmode=000 0 0
16 tmpfs /dev/shm tmpfs rw,seclabel,relatime 0 0
17 /dev/sda2 / ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
18 none /selinux selinuxfs rw,relatime 0 0
19 devtmpfs /dev devtmpfs rw,seclabel,relatime,size=490820k,nr_inodes=122705,mode=755 0 0
20 /proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0
21 /dev/sda1 /boot ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
22 none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
23 vmware-vmblock /var/run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other 0 0
24 /dev/sdb1 /yinzhengjie ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
25 [root@yinzhengjie ~]#
26     我們知道mount命令可以讓我們用來掛載以及檢視相關相信,但是最終的資料存放在哪裡呢?當然是要有一個配置檔案了,其中“/etc/mtab ”就是一個用來存放
27 掛載資訊的。
28 [root@yinzhengjie ~]# cat /etc/mtab
29 /dev/sda2 / ext4 rw 0 0
30 proc /proc proc rw 0 0
31 sysfs /sys sysfs rw 0 0
32 devpts /dev/pts devpts rw,gid=5,mode=620 0 0
33 tmpfs /dev/shm tmpfs rw,rootcontext="system_u:object_r:tmpfs_t:s0" 0 0
34 /dev/sda1 /boot ext4 rw 0 0
35 none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
36 vmware-vmblock /var/run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,default_permissions,allow_other 0 0
37 /dev/sdb1 /yinzhengjie ext4 rw 0 0
38 [root@yinzhengjie ~]#
39     讓我們來做個測試,我們解除安裝一個掛載點,看這個配置檔案是否也發生變化。
40 [root@yinzhengjie ~]# umount /dev/sdb1  #我們解除安裝之前手動掛載的分割槽
41 [root@yinzhengjie ~]# cat /etc/mtab  #再次檢視該配置檔案,果不其然,隨著mount命令將掛載資訊刪除了。
42 /dev/sda2 / ext4 rw 0 0
43 proc /proc proc rw 0 0
44 sysfs /sys sysfs rw 0 0
45 devpts /dev/pts devpts rw,gid=5,mode=620 0 0
46 tmpfs /dev/shm tmpfs rw,rootcontext="system_u:object_r:tmpfs_t:s0" 0 0
47 /dev/sda1 /boot ext4 rw 0 0
48 none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
49 vmware-vmblock /var/run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,default_permissions,allow_other 0 0
50 [root@yinzhengjie ~]# 
51 '''
擴充套件:mount的前世今生

 

14.檢視磁碟資訊命令

a>.df 磁碟空間使用狀態報告

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# df #預設是以KB為單位的
 8 Filesystem     1K-blocks    Used Available Use% Mounted on
 9 /dev/sda2       18208184 2504904  14771696  15% /
10 tmpfs             502172      72    502100   1% /dev/shm
11 /dev/sda1         289293   28473    245460  11% /boot
12 [root@yinzhengjie ~]# df -m  #以MB為空間
13 Filesystem     1M-blocks  Used Available Use% Mounted on
14 /dev/sda2          17782  2447     14426  15% /
15 tmpfs                491     1       491   1% /dev/shm
16 /dev/sda1            283    28       240  11% /boot
17 [root@yinzhengjie ~]# df -h  #將檔案大小顯示易讀格式
18 Filesystem      Size  Used Avail Use% Mounted on
19 /dev/sda2        18G  2.4G   15G  15% /
20 tmpfs           491M   72K  491M   1% /dev/shm
21 /dev/sda1       283M   28M  240M  11% /boot
22 [root@yinzhengjie ~]# df -i  #顯示inode數量
23 Filesystem      Inodes IUsed   IFree IUse% Mounted on
24 /dev/sda2      1164592 98347 1066245    9% /
25 tmpfs           125543     3  125540    1% /dev/shm
26 /dev/sda1        76912    38   76874    1% /boot
27 [root@yinzhengjie ~]# df -ih #划算成一度單位,注意下面的M或者K表示的不是檔案的大小,而是表示的數字K=1000,M=1000000
28 Filesystem     Inodes IUsed IFree IUse% Mounted on
29 /dev/sda2        1.2M   97K  1.1M    9% /
30 tmpfs            123K     3  123K    1% /dev/shm
31 /dev/sda1         76K    38   76K    1% /boot
32 [root@yinzhengjie ~]# df -P  #全部顯示,就是當Filesystem名稱過長的時候,不會換行顯示。
33 Filesystem     1024-blocks    Used Available Capacity Mounted on
34 /dev/sda2         18208184 2504908  14771692      15% /
35 tmpfs               502172      72    502100       1% /dev/shm
36 /dev/sda1           289293   28473    245460      11% /boot
37 [root@yinzhengjie ~]# df -Ph #將檔案大小顯示易讀格式且每行資訊不換行顯示。
38 Filesystem      Size  Used Avail Use% Mounted on
39 /dev/sda2        18G  2.4G   15G  15% /
40 tmpfs           491M   72K  491M   1% /dev/shm
41 /dev/sda1       283M   28M  240M  11% /boot
42 [root@yinzhengjie ~]# df -Ph /dev/sda1  #可以單獨檢視一個分割槽情況。
43 Filesystem      Size  Used Avail Use% Mounted on
44 /dev/sda1       283M   28M  240M  11% /boot
45 [root@yinzhengjie ~]#
46 [root@yinzhengjie ~]# df -T     #顯示時顯示檔案型別
47 Filesystem     Type  1K-blocks    Used Available Use% Mounted on
48 /dev/sda2      ext4   18208184 2504920  14771680  15% /
49 tmpfs          tmpfs    502172      72    502100   1% /dev/shm
50 /dev/sda1      ext4     289293   28473    245460  11% /boot
51 [root@yinzhengjie ~]#
52 '''

b>.du 顯示檔案佔用磁碟的情況

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# ls -ldh /etc/  #檢視目錄大小,很明顯不準確!
 8 drwxr-xr-x. 102 root root 4.0K May 12 05:48 /etc/
 9 [root@yinzhengjie ~]# du -s /etc/  #用du檢視檔案大小,預設為K.
10 39788   /etc/
11 [root@yinzhengjie ~]# du -sh /etc/  #用du檢視目錄大小,預設為M
12 39M     /etc/
13 [root@yinzhengjie ~]# du -sh /etc/sysconfig/network-scripts/ifcfg-eth0  #我們也可以檢視檔案的大小 
14 4.0K    /etc/sysconfig/network-scripts/ifcfg-eth0
15 [root@yinzhengjie ~]# 
16 
17 '''

 

15.開機自動掛載

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 開機自動掛載
 8    /etc/rc.d/rc.sysinit:系統初始化指令碼
 9       其中一個功能:掛載/etc/fstab檔案中定義的檔案系統掛載點
10 [root@yinzhengjie ~]# cat  /etc/fstab
11 
12 #
13 # /etc/fstab
14 # Created by anaconda on Tue Apr 11 05:43:15 2017
15 #
16 # Accessible filesystems, by reference, are maintained under '/dev/disk'
17 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
18 #
19 UUID=421dd611-48a1-4a71-9f06-60605f68ef0d /                       ext4    defaults        1 1
20 UUID=003bdf87-a068-4553-b506-f174b1f82ed6 /boot                   ext4    defaults        1 2
21 UUID=1020e7eb-2f17-4a4d-b8bf-36776dcbf547 swap                    swap    defaults        0 0
22 tmpfs                   /dev/shm                tmpfs   defaults        0 0
23 devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
24 sysfs                   /sys                    sysfs   defaults        0 0
25 proc                    /proc                   proc    defaults        0 0
26 [root@yinzhengjie ~]#
27 我們看以下掛載的格式,從左往右一次又6列引數,那麼這6列引數是啥意思呢?請看以下分析:
28 1>.要掛載的裝置:裝置檔案、LABEL=”ladel” UUID
29 2>.掛載點:有的檔案系統沒有掛載點  swap沒有掛載點,掛載點為swap
30 3>.檔案系統型別:
31 4>.掛載選項:多個選項間使用逗號分隔
32 5>.轉儲頻率:
33     0:從不備份
34     1:每日備份
35     2:每隔一天備份
36 6>.自檢次序
37     1:首先自檢,通常只能被/使用
38     2-9:順序
39     0:從不自檢
40 '''
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# vim + /etc/fstab  #編輯mount配置檔案,並將游標移動在最後一行,“+”參數列示最後一行
 8 [root@yinzhengjie ~]# cat /etc/fstab  #在最後一行新增你需要開機掛載的裝置和目錄。
 9 
10 #
11 # /etc/fstab
12 # Created by anaconda on Tue Apr 11 05:43:15 2017
13 #
14 # Accessible filesystems, by reference, are maintained under '/dev/disk'
15 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
16 #
17 UUID=421dd611-48a1-4a71-9f06-60605f68ef0d /                       ext4    defaults        1 1
18 UUID=003bdf87-a068-4553-b506-f174b1f82ed6 /boot                   ext4    defaults        1 2
19 UUID=1020e7eb-2f17-4a4d-b8bf-36776dcbf547 swap                    swap    defaults        0 0
20 tmpfs                   /dev/shm                tmpfs   defaults        0 0
21 devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
22 sysfs                   /sys                    sysfs   defaults        0 0
23 proc                    /proc                   proc    defaults        0 0
24 /dev/sdb1               /yinzhengjie            ext4    defaults,acl    0 0  #這就是我們新加的一行。
25 [root@yinzhengjie ~]# mount     #檢視當前掛載項。
26 /dev/sda2 on / type ext4 (rw)
27 proc on /proc type proc (rw)
28 sysfs on /sys type sysfs (rw)
29 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
30 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
31 /dev/sda1 on /boot type ext4 (rw)
32 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
33 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
34 [root@yinzhengjie ~]# mount -a  #重新載入“ /etc/fstab”把fstab裡面沒有掛載的資訊進行掛載,其功效等同於重做作業系統時進行的自動掛載。或者執行“init 6”再檢視配置檔案是否生效。
35 [root@yinzhengjie ~]# mount  #再次檢視當前掛載項。
36 /dev/sda2 on / type ext4 (rw)
37 proc on /proc type proc (rw)
38 sysfs on /sys type sysfs (rw)
39 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
40 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
41 /dev/sda1 on /boot type ext4 (rw)
42 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
43 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
44 /dev/sdb1 on /yinzhengjie type ext4 (rw,acl)  #發現最後一行多出了一行掛載資訊。說明你操作成功了。
45 [root@yinzhengjie ~]#
46 
47 '''
修改 /etc/fstab配置檔案進行開機自動掛載展示

 

16.檢視記憶體空間使用狀態

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# cat /proc/meminfo  #檢視記憶體資訊
 8 MemTotal:        1004348 kB
 9 MemFree:          671056 kB
10 Buffers:           18764 kB
11 Cached:           126240 kB
12 SwapCached:            0 kB
13 Active:           108700 kB
14 Inactive:         110672 kB
15 Active(anon):      74616 kB
16 Inactive(anon):     1184 kB
17 Active(file):      34084 kB
18 Inactive(file):   109488 kB
19 Unevictable:           0 kB
20 Mlocked:               0 kB
21 SwapTotal:       4136088 kB
22 SwapFree:        4136088 kB
23 Dirty:               164 kB
24 Writeback:             0 kB
25 AnonPages:         74376 kB
26 Mapped:            42396 kB
27 Shmem:              1440 kB
28 Slab:              75132 kB
29 SReclaimable:      15608 kB
30 SUnreclaim:        59524 kB
31 KernelStack:        1560 kB
32 PageTables:        10916 kB
33 NFS_Unstable:          0 kB
34 Bounce:                0 kB
35 WritebackTmp:          0 kB
36 CommitLimit:     4638260 kB
37 Committed_AS:     336672 kB
38 VmallocTotal:   34359738367 kB
39 VmallocUsed:      156112 kB
40 VmallocChunk:   34359567284 kB
41 HardwareCorrupted:     0 kB
42 AnonHugePages:     12288 kB
43 HugePages_Total:       0
44 HugePages_Free:        0
45 HugePages_Rsvd:        0
46 HugePages_Surp:        0
47 Hugepagesize:       2048 kB
48 DirectMap4k:        6144 kB
49 DirectMap2M:     1042432 kB
50 DirectMap1G:           0 kB
51 [root@yinzhengjie ~]# free -m  #其實free命令的資料時取自“/proc/meminfo”檔案的,知識為了易讀性可以用free -m引數檢視記憶體使用情況
52              total       used       free     shared    buffers     cached
53 Mem:           980        325        655          1         18        123
54 -/+ buffers/cache:        183        797 #這一行才是正點,其他的都是虛的,實際使用記憶體為183,實際空餘記憶體為797
55 Swap:         4039          0       4039
56 [root@yinzhengjie ~]# free -g  #這個引數是以GB為單位,列出磁碟中記憶體資訊,空餘檢視記憶體比較大的時候用,如果你的記憶體不深就很少的話就會跟我一樣出現下面的尷尬引數了。
57              total       used       free     shared    buffers     cached
58 Mem:             0          0          0          0          0          0
59 -/+ buffers/cache:          0          0
60 Swap:            3          0          3
61 [root@yinzhengjie ~]# 
62 
63 '''

 

17.dd命令常用引數展示:

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 dd命令:
 9    bs:一次讀多大的資料量
10    count:讀取次數
11    if:輸入檔案
12    of:輸出檔案
13    dd if=input_file of=output_file
14    dd if=input_file of=output_file bs=#[b|k|m|g] count=#
15    cat /dev/cdrom > /tmp/linux.iso #製作光碟
16 /dev/zero:吐01的
17 '''
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# cat /etc/issue
 8 CentOS release 6.6 (Final)
 9 Kernel \r on an \m
10 
11 
12         This is Yin Zhengjie's server
13 
14 
15 
16 
17 
18 [root@yinzhengjie ~]# 
19 [root@yinzhengjie ~]# dd if=/etc/issue of=/tmp/issue.dd
20 0+1 records in #讀了多少個
21 0+1 records out #輸出了多少個
22 84 bytes (84 B) copied, 0.00011992 s, 700 kB/s  #多少位元組被複制,一共花了多長時間,每秒鐘傳輸資料的平局速度。
23 [root@yinzhengjie ~]# cat /tmp/issue.dd  #檢視內容的確被複制
24 CentOS release 6.6 (Final)
25 Kernel \r on an \m
26 
27 
28         This is Yin Zhengjie's server
29 
30 
31 
32 
33 
34 [root@yinzhengjie ~]#
35 
36 
37 '''
利用dd拷貝檔案效率要高與cp命令

  其實dd相比cp是一個更低階的命令,跟語言一樣,語言越高階越接近使用者,處理速度就越慢,語言越低階就越接近機器,處理速度就越快,那麼為什麼dd命令處理速度要相比cp更快呢?其實很簡單,cp命令才拷貝檔案的時候,先通過VFS系統(即虛擬檔案系統)將源資料通通的讀取出來,然後在將這些資料傳給VFS,並通過檔案系統在重新生成一份一模一樣的資料才完成了拷貝功能,但是dd命令就不一樣了,他繞過了VFS系統,直接找到源資料的inode所對應的blocks,直接將這些blocks記憶體中拷貝一份,這就是兩者的差距。

                 

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# dd if=/dev/zero of=/yinzhengjie.swapfile bs=1M count=100  #建立一個100M的檔案
 8 100+0 records in
 9 100+0 records out
10 104857600 bytes (105 MB) copied, 0.145994 s, 718 MB/s
11 [root@yinzhengjie ~]#
12 [root@yinzhengjie ~]# ll -h / | grep yinzhengjie  #驗證檔案是否建立成功
13 drwxr-xr-x.   3 root root 4.0K May 12 04:36 yinzhengjie
14 -rw-r--r--.   1 root root 100M May 12 10:46 yinzhengjie.swapfile  #發現有這個100M的檔案
15 [root@yinzhengjie ~]#
16 [root@yinzhengjie ~]# mkswap -f /yinzhengjie.swapfile #強制將這個檔案格式化成交換分割槽
17 Setting up swapspace version 1, size = 102396 KiB
18 no label, UUID=f5896342-dd1f-4980-8806-2086ae3fec90
19 [root@yinzhengjie ~]# free -m  #先檢視記憶體資訊
20              total       used       free     shared    buffers     cached
21 Mem:           980        890         90          1        451        227
22 -/+ buffers/cache:        212        768
23 Swap:         4039          0       4039 #我們發現現在的total=4039
24 [root@yinzhengjie ~]# swapon /yinzhengjie.swapfile #開啟這個檔案的交換分割槽
25 [root@yinzhengjie ~]# free -m #發現果然多了100M的swap分割槽
26              total       used       free     shared    buffers     cached
27 Mem:           980        890         90          1        451        227
28 -/+ buffers/cache:        212        768
29 Swap:         4139          0       4139  #我們發現現在的total=4139
30 [root@yinzhengjie ~]# 
31 '''
利用dd命令建立一個swap分割槽檔案,但是不到玩不得不要用!

以下是dd生產環節中常用的幾個案例:

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 linux製作光碟的2種方式:
 9 [root@yinzhengjie ~]# dd if=/dev/cdrom of=/yinzhengjie/linux.iso                #利用dd命令製作光碟,方法一
10 [root@yinzhengjie ~]# cat /dev/cdrom > /yinzhengjie/linux.iso                   #利用cat命令製作光碟,方法二
11 linux中的磁碟對拷貝:
12 [root@yinzhengjie ~]# dd if=/dev/sda of=/dev/sdb                                #即將/dev/sda裝置的資訊拷貝一份到/dev/sdb上去。
13 [root@yinzhengjie ~]# dd if=/dev/sda of=/tmp/myfile bs=512 count=1              #講/dev/sda的MBR分割槽進行備份,當分割槽表破壞時,可以用/tmp/myfile進行還原。
14 [root@yinzhengjie ~]# dd if=/dev/zero of=/dev/sdb bs=512 count=1                #刪除/dev/sdb的分割槽資訊,當然裡面的資料還是可以找回來的,可以通過專業的資料恢復工具。
15 [root@yinzhengjie ~]# dd if=/dev/zero of=/yinzhengjie.swapfile bs=1M count=100  #建立一個100M的本地迴環裝置,可以用來做分割槽格式化的(當然得需要一些額外的操作)
16 '''
17 
18 #這裡只是dd命令的冰山一角,想要了解dd命令更多的用法,請參考man幫助,在哪裡或許你能找到你感興趣的引數。

 

18.巧記歸檔命令

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 
 8 '''
 9 檔案連結
10    ln 原始檔 目標檔案
11     硬連結:
12          不能跨分割槽,
13      指向同一個indone的兩個位置
14          不能對目錄建立硬連結
15      硬連結會改變檔案被連結的次數
16     符號連結:
17         ln -s
18      符號連結可以跨分割槽
19      符號連結檔案跟原始檔不同一個inode
20      可以對目錄建立符號連結
21      符號連結不會改變原始檔被連結的次數
22 
23 
24 dev 第一個表示主裝置號 第二個表示次裝置號
25 
26 壓縮工具
27    zip:
28    gzip:gunzip= gzip -d,zcat
29    字尾:.gz
30    -c 指定要壓縮的檔案
31    bzip2,bunzip2
32    -k 保留原始檔
33    字尾 .bz
34    xz
35      字尾.xz
36    -#:指定壓縮比 1-9,預設的為6
37 
38 
39 歸檔工具:
40    tar [options] file.tar file1....
41     -c:建立歸檔
42     -x:展開歸檔
43     -t:不展開而直接檢視被歸檔的檔案
44     -z:使用gzip壓縮
45     -j:使用bz2壓縮
46     -J:使用xz壓縮
47 
48 
49 '''

 

 

相關文章