这一章 (CCD 设定) 由 Brian A. Seklecki <[email protected]> 提供
CCD 驱动程序允许使用者"串连"数个实体 硬盘成为一个虚拟的装置。CCD 也让你跨越 CMU RAIDFrame 的 限制,可以让你在 RAID0 (file system spanning across disks) 中使用不同几何数据的硬盘。CCD 也允许你使用"插页" 来改善硬盘的效能。这个范例将不包括此项特征。
要设定 CCD 需要这些步骤:
安装实质媒体
设定核心支持
对 CCD 的成员做 disklabel
设定 CCD 的设定档
初始化 CCD 装置
在新的 CCD 装置产生 4.4BSD/UFS 档案系统
挂上 CDD 档案系统
这个 CCD 的设定范例是在 NetBSD/Sparc 1.5 下作测试的。 CCD 需要 4 个 SCSI 硬盘,使用一般的 Sun 外接盒,连接到外部 的 50 针 SCSI 接头。
这个步骤依你的平台和硬件而定。
从我的 DMESG 得知:
Disk #1:
probe(esp0:0:0): max sync rate 10.00MB/s
sd0 at scsibus0 target 0 lun 0: <SEAGATE, ST32430N SUN2.1G, 0444> SCSI2 0/direct fixed
sd0: 2049 MB, 3992 cyl, 9 head, 116 sec, 512 bytes/sect x 4197405 sectors
Disk #2
probe(esp0:1:0): max sync rate 10.00MB/s
sd1 at scsibus0 target 1 lun 0: <SEAGATE, ST32430N SUN2.1G, 0444> SCSI2 0/direct fixed
sd1: 2049 MB, 3992 cyl, 9 head, 116 sec, 512 bytes/sect x 4197405 sectors
Disk #3
probe(esp0:2:0): max sync rate 10.00MB/s
sd2 at scsibus0 target 2 lun 0: <SEAGATE, ST11200N SUN1.05, 9500> SCSI2 0/direct fixed
sd2: 1005 MB, 1872 cyl, 15 head, 73 sec, 512 bytes/sect x 2059140 sectors
Disk #4
probe(esp0:3:0): max sync rate 10.00MB/s
sd3 at scsibus0 target 3 lun 0: <SEAGATE, ST11200N SUN1.05, 8808 > SCSI2 0
sd3: 1005 MB, 1872 cyl, 15 head, 73 sec, 512 bytes/sect x 2059140 sectors
接着设定核心,使它支持 CCD 装置。这在 GENERIC 核心中已经 预设了:
pseudo-device ccd 4 # concatenated disk devices
在我的核心设定档中,我也强迫指定 SCSI ID 到 /dev 装置以避免错误的发生:
sd0 at scsibus0 target 0 lun ?
# SCSI disk drives
sd1 at scsibus0 target 1 lun ?
# SCSI disk drives
sd2 at scsibus0 target 2 lun ?
# SCSI disk drives
sd3 at scsibus0 target 3 lun ?
# SCSI disk drives
sd4 at scsibus0 target 4 lun ?
# SCSI disk drives
sd5 at scsibus0 target 5 lun ?
# SCSI disk drives
sd6 at scsibus0 target 6 lun ?
# SCSI disk drives
CCD 的每一成员硬盘需要建立一个特殊的档案系统。在此 范例中,我将需要做 disklabel:
/dev/rsd0c
/dev/rsd1c
/dev/rsd2c
/dev/rsd3c
Note: 记得要 disklabel character 装置,而不是 block 装置, 例如 /dev/r{s,w}d*
Note: 在所有的平台上,c slice 是保留作为 整个 NetBSD 分割区的代号。
在 CCD 中,你可能需要移除在硬盘上现有的 disklabel。可以 使用 dd 指令:
# dd if=/dev/zero of=/dev/rsd0 bs=8k count=1
# dd if=/dev/zero of=/dev/rsd1 bs=8k count=1
# dd if=/dev/zero of=/dev/rsd2 bs=8k count=1
# dd if=/dev/zero of=/dev/rsd3 bs=8k count=1
硬盘上预设设的 disklabel 看起来像这样:
# disklabel -r /dev/rsd0c
[...snip...]
bytes/sector: 512
sectors/track: 116
tracks/cylinder: 9
sectors/cylinder: 1044
cylinders: 3992
total sectors: 4197405
[..snip...]
3 partitions:
# size offset fstype [fsize bsize cpg]
c: 4197405 0 unused 1024 8192 # (Cyl. 0 - 4020*)
你需要建立一个 "slice",使用整个 NetBSD 分割区。在分割区/硬盘中,必须至少保留一个磁柱 作为 slice 的开始,用来提供空间给 CCD disklabel 使用。 起始点应该是 1x 扇区/磁柱。因此,"size" 值应该是"全部扇区"减去 1x "扇区/磁柱"。
依此编辑你的 disklabel。要确定指明的路径是 character 装置,而不是 block 装置。
Note: 在编辑 disklabel 之前,设定 export EDITOR=[你喜爱的编辑器]。
# disklabel -e /dev/rsd0c
Note: slice 的 fstype 必须是 ccd。
因为这个分割区只有一个 slice,你可以直接使用 c slice(通常被保留不用)。 更改你的 disklabel 像这样:
3 partitions:
# size offset fstype [fsize bsize cpg]
c: 4196361 1044 ccd # (Cyl. 1 - 4020*)
选择性地,你可以设定一个有别于 c 的 slice 来使用,简单的修改像这样:
3 partitions:
# size offset fstype [fsize bsize cpg]
a: 4196361 1044 ccd # (Cyl. 1 - 4020*)
c: 4197405 0 unused 1024 8192 # (Cyl. 0 - 4020*)
在完成后确定要执行写入的动作。Disklabel 会拒绝你的动作, 并提示你是否要重新编辑。
在所有的硬盘做完适当的编辑后,你需要产生一个设定档。 设定文件预设在 /etc 目录中。 你可以建立一个新的。格式为:
#ccd ileave flags component devices
在此范例中:
# more /etc/ccd.conf
ccd0 0 none /dev/sd0c /dev/sd1c /dev/sd2c /dev/sd3c
Note: 新建的 CCD 档案系统参考 CCD 设定文件来使用装置。要确定 要使用 character 装置而不是 block 装置。
当你完成了 CCD 的设定,你可以用 ccdconfig 来初始化装置: 设定:
# ccdconfig -c -f /etc/ccd.conf
解除设定:
# ccdconfig -u -f /etc/ccd.conf
/dev/{,r}ccd#: 初始化 CCD 装置将会使用 /dev: /dev/{,r}ccd#:
# ls -la /dev/{,r}ccd0*
brw-r----- 1 root operator 9, 0 Apr 28 21:35 /dev/ccd0a
brw-r----- 1 root operator 9, 1 Apr 28 21:35 /dev/ccd0b
brw-r----- 1 root operator 9, 2 May 12 00:10 /dev/ccd0c
brw-r----- 1 root operator 9, 3 Apr 28 21:35 /dev/ccd0d
brw-r----- 1 root operator 9, 4 Apr 28 21:35 /dev/ccd0e
brw-r----- 1 root operator 9, 5 Apr 28 21:35 /dev/ccd0f
brw-r----- 1 root operator 9, 6 Apr 28 21:35 /dev/ccd0g
brw-r----- 1 root operator 9, 7 Apr 28 21:35 /dev/ccd0h
crw-r----- 1 root operator 23, 0 Jun 12 20:40 /dev/rccd0a
crw-r----- 1 root operator 23, 1 Apr 28 21:35 /dev/rccd0b
crw-r----- 1 root operator 23, 2 Jun 12 20:58 /dev/rccd0c
crw-r----- 1 root operator 23, 3 Apr 28 21:35 /dev/rccd0d
crw-r----- 1 root operator 23, 4 Apr 28 21:35 /dev/rccd0e
crw-r----- 1 root operator 23, 5 Apr 28 21:35 /dev/rccd0f
crw-r----- 1 root operator 23, 6 Apr 28 21:35 /dev/rccd0g
crw-r----- 1 root operator 23, 7 Apr 28 21:35 /dev/rccd0h
你现在可以对新的虚拟磁盘进行 disklabel。 确定使用 character 装置:
# disklabel -e /dev/rccd0c
再一次地,这将只需要一个 slice,所以你可以直接利用 c slice 或另外建立一个 slice。
# disklabel -r /dev/rccd0c
# /dev/rccd0c:
type: ccd
disk: ccd
label: default label
flags:
bytes/sector: 512
sectors/track: 2048
tracks/cylinder: 1
sectors/cylinder: 2048
cylinders: 6107
total sectors: 12508812
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0
# size offset fstype [fsize bsize cpg]
c: 12508812 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 6107*)
The filesystem will then need formatted:
# newfs /dev/rccd0c
Warning: 372 sector(s) in last cylinder unallocated
/dev/rccd0c: 12508812 sectors in 6108 cylinders of 1 tracks, 2048 sectors
6107.8MB in 382 cyl groups (16 c/g, 16.00MB/g, 3968 i/g)
super-block backups (for fsck -b #) at:
[...]
你必须在 CCD 装置上建立档案系统,可以将此档案系统挂在 系统上的任何挂入点。必须确定挂上标记档案系统类型为 ffs 或 4.4BSD 的 slice:
# mount /dev/ccd0c /mnt
Then:
# export BLOCKSIZE=1024; df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/sd6a 376155 320290 37057 89% /
/dev/ccd0c 6058800 1 5755859 0% /mnt
恭喜你,你已经有一个能够运作的 CCD 了。请参考在线手册 来了解如何在开机时,经由 RC 做初始化的动作。更进一步的 说明,请参考相关的在线手册。