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节点):存"