萬盛學電腦網

 萬盛學電腦網 >> Solaris介紹 >> Solaris系統硬盤分區知識

Solaris系統硬盤分區知識

Solaris下,一個磁盤包含8個分區,標記為0-7。此信息可以通過format命令,然後選擇一個硬盤來看到,例如,在我自己的系統中(Solaris 9,Ultra 60),顯示出來的信息如下: # format Searching for disks...done AVAILABLE D

Solaris下,一個磁盤包含8個分區,標記為0-7。此信息可以通過format命令,然後選擇一個硬盤來看到,例如,在我自己的系統中(Solaris 9,Ultra 60),顯示出來的信息如下:
# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
0. c0t0d0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>;
/pci@1f,4000/scsi@3/sd@0,0
Specify disk (enter its number): 0
selecting c0t0d0
[disk formatted]
Warning: Current Disk has mounted partitions.

FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd>; - execute <cmd>;, then return
quit
format>; p


PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
!<cmd>; - execute <cmd>;, then return
quit
partition>;
不要看到內容這麼多,就被嚇住了,其實,format命令之後0. c0t0d0 < SUN18G cyl 7506 alt 2 hd 19 sec 248>;/pci@1f,4000/scsi@3/sd@0,0所顯示出來的含義很簡單,0. c0t0d0就代表這台Ultra 60裡面只裝了一個硬盤(至於c0t0d0的具體含義,稍後會介紹),< SUN18G cyl 7506 alt 2 hd 19 sec 248>;代表的是這個硬盤的大小和柱面信息,/pci@1f, 4000/scsi@3/sd@0,0所代表的,就是這個硬盤的實際物理地址。這些信息看起來很復雜,其實一般都只需要看看format命令抓出來的硬盤數量,是不是我們裝在系統上的數量,例如你裝了兩個硬盤,但是這裡只有一個硬盤的信息,就需要認真面對了。
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd>; - execute <cmd>;, then return
quit
format>; p
這裡所列出來的,是可以使用的命令,比如我在最下面format>;,就是用了p這個命令(慢點,上面沒有p這個命令啊?其實,這裡p就是partition的簡寫),然後,列出了以下內容:
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
!<cmd>; - execute <cmd>;, then return
quit
partition>;
OK,到這裡,我們的目的也達到了,這些信息應該很清楚的證明了:Solaris下,一個磁盤包含8個分區,標記為0-7。後面的仍然是一些可以用到的命令,這些命令的具體含義,大家可以看命令後面的英文介紹,至於怎麼使用,以後再說。下面我們將進入今天的重點。
向一塊硬盤寫入數據之前,首先需要將其分區和格式化,這個過程一般可以分為3個步驟:
1. 物理格式化,也就是通常所說的低級格式化(Low-Level Formatting,LLF);
2. 分區;
3. 邏輯格式化,也就是通常所說的高級格式化(High-Level Formatting,HLF)
低級格式化的時候,硬盤被分成若干個磁道,這些磁道又被分成若干個扇區,每個扇區填充了隨機數據。幾乎所有的硬盤在出廠前都已經被低級格式化過,所以,用戶只要對硬盤進行下面兩個步驟(分區和邏輯格式化)就可以了。
分區的動作將硬盤分成幾個部分,成為分區或者是分片(注意:前面的“分區”是動詞,後面的是名詞哦)。每個分區/分片由若干個柱面組成。絕大多數下,Solaris中的一個分區一一對應一個文件系統。一個分區不能包含多個文件系統;同樣,一個文件系統也不能跨越多個分區。Solaris中,對硬盤進行分區,就是使用我們開始的時候使用過的format命令。
當Solaris進行高級格式化的時候,將每個分區分成許多柱面組,每個柱面組包括了幾個連續的柱面。文件系統在這些柱面組中建立文件和目錄,並盡量將同一個文件的數據保存在同一個柱面組中。這樣的機制能夠保證磁頭讀取數據的時候移動最少,從而加快數據的讀取速度。Solaris中使用 newfs命令來實現高級格式化,默認的文件系統是UNIX文件系統(UFS:Unix File System),它使用下列類型的塊:
1. 引導塊:存儲系統啟動時所需的信息
2. 超級塊:存儲文件系統信息
3. 索引節點(i節點):存儲文件系統中的單個文件信息
4. 存儲塊/數據塊:存儲文件數據

下面來詳細介紹一下這幾種類型的塊。
引導塊:
引導塊存儲系統啟動時所需的信息。引導塊總是位於硬盤的第一個柱面組,占用分區的前8KB。

超級塊:
超級塊存儲文件系統信息,它包含了下列信息:
1. 文件系統中總塊數(文件系統大小)
2. 文件系統中數據塊的數目
3. 索引節點的數目
4. 柱面組的數目
5. 塊的大小
6. 磁盤碎片的

copyright © 萬盛學電腦網 all rights reserved