Subject: Example of using ccd for concatenation and striping
To: None <port-sparc@NetBSD.ORG>
From: Marshall Midden <m4@unet.umn.edu>
List: port-sparc
Date: 03/11/1996 13:29:17
Since I had lots of difficulty understanding how to get ccd to work
correctly on the sparc port (only one I'm using netbsd on...), I decided
an example might be useful for other people. Perhaps it could be cleaned
up and shoved into some documentation some place.
There are three ways to use the concatenated device driver.
a) mirroring
b) striping, also called interleaving (write to many disks at once, data
spread all over.)
c) concatenated (fill one disk, move to next one, etc.)
I'm going to give one example for the striping and one for concatenated on the
sparc port.
First, the man pages to read and the information to gather from them:
a) man 4 ccd
The four important things to get out of this is
1) Leave a cylinder free on your disk for the ccd disk label.
2) Configure the kernel to have "pseudo-device ccd 4".
3) If you lose a disk on striping or concatenated, the file system is
gone.
4) If necessary: "cd /dev; ./MAKEDEV ccd0 ccd1 ccd2 ccd3"
b) man 8 ccdconfig
Things that I gathered and retained as useful information.
1) What I consider useful options:
A) ccdconfig -C
Use /etc/ccd.conf to create ccd configuration.
B) ccdconfig -g
Display what ccd's are currently configured.
C) ccdconfig -U
Unconfigure all ccd devices listed in the /etc/ccd.conf file.
2) There is a bunch of weird stuff that will only confuse you.
3) You will probably never understand the right interleave to use
for striping. 16 and 32 appear to work well on SCSI devices, and
with an 8k filesystem (8*1024/512 bytes/sector = 16).
4) "ccdconfig -C" is called near the top of /etc/rc -- for rebooting.
5) It doesn't appear possible to stripe the root or swap partitions.
c) There isn't anymore, and looking at the file /usr/include/dev/ccdvar.h
will probably confuse you even more, as will looking at the source
in /sys/dev/ccd.c.
For a striped disk, the conditions, and procedure I followed (and tested as I
am writing this):
a) Figure out what disks you want to stripe.
I've got three six year old cdc wren 6's (660mb 5 1/4" form factor) in
external cases. I've got a kernel were the disks are specifically
associated with their SCSI id's. Don't want a disk not being powered
up causing incredible problems. I.e.:
sd0 at scsibus? target 3 lun ?
sd1 at scsibus? target 1 lun ?
sd2 at scsibus? target 2 lun ?
sd3 at scsibus? target 0 lun ?
sd4 at scsibus? target 4 lun ?
sd5 at scsibus? target 5 lun ?
sd6 at scsibus? target 6 lun ?
The disks are sd0, sd2, sd3.
A fourth disk is on sd5, but it is an five year old cdc Wren 8 (1.4gb
5 1/4" form factor). It has root, swap, and /usr set up for backup
booting. The idea of adding this to the striping is to enable
understanding of what is really going on.
b) Create /dev/ccd.conf and the disklabels.
1) This is pretty much a joint step.
Since a cylinder must left available for the new ccd label, you
can't just use the "c" partition on the disks. You gotta create
another one.
A) "disklabel -e sd5" # complicated one first! (abbreviated)
If it uses "vi", upon saving and exiting [I use ":x"] it checks
for somewhat reasonable input.
bytes/sector: 512 sectors/cylinder: 1305 cylinders: 2116
8 partitions:
# size offset fstype [fsize bsize cpg]
a: 150075 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 114)
b: 130500 150075 swap # (Cyl. 115 - 214)
c: 2761380 0 unknown # (Cyl. 0 - 2115)
g: 430650 280575 4.2BSD 1024 8192 16 # (Cyl. 215 - 544)
h: 2050155 711225 4.2BSD 1024 8192 16 # (Cyl. 545 - 2115)
B) Desire to use the "h" partition, but forgot to find out how big
a wren 6 really is after it's partitioning.
C) "disklabel -e sd0"
Get rid of everything but the "c" partition, add a "g" back.
Since a cylinder is 795 sectors, the offset on a sun must be 795.
1294260-795 = 1293465 (and hence the size of the "g" partition).
The fstype seems to need to be set "sometimes". So I just set all
the parameters to reasonable default. The '# (Cyl.' stuff is
just a comment, and need not be set. Next "disklabel -e sd0"
will set them. If you have a "*" after either of the cylinder
numbers, then you blew the calculations and didn't fill up a
cylinder.
bytes/sector: 512
sectors/track: 53
tracks/cylinder: 15
sectors/cylinder: 795
cylinders: 1628
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0
track-to-track seek: 0
drivedata:0
8 partitions:
# size offset fstype [fsize bsize cpg]
c: 1294260 0 unknown # (Cyl. 0 - 1627)
g: 1293465 795 4.2BSD 1024 8192 16 # (Cyl. 1 - 1627)
D) Set up sd2 and sd3 the same way.
E) Back to "disklabel -e sd5". Since the wren 6's are only 1293465
worth of useful information for striping, and all disk drives
should be the same size, the "h" partition should be shortened to
1293465. (I'm not doing it to see what happens.)
F) Check no ccd devices are configured.
"ccdconfig -g".
no concatenated disks configured.
G) Set up /etc/ccd.conf. Edit and insert:
ccd0 16 none /dev/sd0g /dev/sd2g /dev/sd3g /dev/sd5h
H) "ccdconfig -C" to set it up, then "ccdconfig -g" to check it took.
2) Create the disklabel for the striped disk.
"disklabel -e ccd0"
You have absolute garbage. You get to fix it up to something
reasonable. 1627 cylinders on a wren 6, times 4 makes it 6508.
bytes/sector: 512
sectors/track: 53
tracks/cylinder: 15
sectors/cylinder: 795
cylinders: 6508
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0
track-to-track seek: 0
drivedata:0
3 partitions:
# size offset fstype [fsize bsize cpg]
c: 5173860 0 unknown # (Cyl. 0 - 6507)
3) If you get it really wrong, the disklabel program may ask for a "y"
to re-edit. The numbers for sectors, tracks, cylinders are all
pretty much not used by "ccd". Just get everything to match for the
calculations.
4) You could create other partitions, not just a "c" -- but since you
are probably trying to get a faster (and bigger ) disk that probably
is not desired.
c) Create the new file system. "newfs /dev/rccd0c"
2.5gb ... not bad for old disk drives... .
d) Mount the new file system.
"mount /dev/ccd0c /mnt"
"df /mnt"
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ccd0c 2502251 1 2377137 0% /mnt
e) Does it work? "cp /netbsd /mnt/netbsd" All lights flashing at same
time.
For a concatenated disk, the conditions, and procedure I followed (and tested
as I am writing this):
a) Figure out what disks you want to concatenate.
Read above for striping for kernel associating of SCSI id and disk.
Disks:
sd0 CDC Wren 6 (660mb)
sd1 CDC Wren 9 (1897mb) root, swap, /usr, /usr/src, extra (875mb)
sd2 CDC Wren 6 (660mb)
sd3 CDC Wren 6 (660mb)
sd5 CDC Wren 7 (1413mb) altroot, swap, alt/usr, extra (1049mb)
sd6 Seagate ST12550N (2138mb)
The disklabel for sd1d shows:
bytes/sector: 512 sectors/cylinder: 1440 cylinders: 2574
# size offset
d: 1709280 1997280 4.2BSD ...... #(Cyl. 1387 - 2573)
The disklabel for sd5h shows:
bytes/sector: 512 sectors/cylinder: 1305 cylinders: 2116
# size offset
h: 2050155 711225 4.2BSD ...... #(Cyl. 545 - 2115)
b) Create disklabels on the disks. "sd1d" and "sd1h" above.
Number of blocks given for each.
Create a "g" partition for use in concatenation, as with striping on
others -- leaving one cylinder free for fake disklabel.
sd0g 1293465
sd1d 1709280
sd2g 1293465
sd3g 1293465
sd5h 2050155
sd6g 4174464
Total: 11814294 blocks, or 6048.918528mb.
b) Create /dev/ccd.conf.
1) Check no ccd devices are configured.
"ccdconfig -g".
no concatenated disks configured.
2) Set up /etc/ccd.conf. Edit and insert:
ccd0 0 none /dev/sd0g /dev/sd2g /dev/sd3g /dev/sd6g /dev/sd5h /dev/sd1d
3) "ccdconfig -C" to set it up, then "ccdconfig -g" to check it took.
c) Create the disklabel for the concatenated disk.
"disklabel -e ccd0"
You have absolute garbage. You get to fix it up to something
reasonable. You need numbers that fit in 16 bits... .
/usr/games/factor 11814294 gives 2*3*1969049
/usr/games/factor 11814292 gives 2*2*7*7*7*79*109 which sounds nice.
bytes/sector: 512
sectors/track: 79 # 79
tracks/cylinder: 49 # 7*7
sectors/cylinder: 3871 # 79*49
cylinders: 3052 # 109*7*4
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0
track-to-track seek: 0
drivedata:0
3 partitions:
# size offset fstype [fsize bsize cpg]
c: 11814292 0 unknown # (Cyl. 0 - 3051)
3) If you get it really wrong, the disklabel program may ask for a "y"
to re-edit. The numbers for sectors, tracks, cylinders are all
pretty much not used by "ccd". Just get everything to match for the
calculations.
4) You could create other partitions, not just a "c" -- but since you
are probably trying to get a bigger disk that probably is not desired.
d) Create the new file system. "newfs /dev/rccd0c"
5768.7mb ... not bad for several smaller disk drives.
e) Mount the new file system.
"mount /dev/ccd0c /mnt"
"df /mnt"
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ccd0c 5729879 1 5443384 0% /mnt
f) Does it work? "cp /netbsd /mnt/netbsd" Not all lights flashing at
same time.