[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Install OpenBSD on a RAIDFrame mirror.



I wrote a short howto on how to install OpenBSD onto a RAIDFrame mirror.
Comments are very welcome.

Sven
-------------------------------------------------------------
Q: I have two disks in my system and would like to
   install OpenBSD on these two disks and use them as
   a RAID 1 mirror. I do not have a temporary third disk
   to install the system on and move it later onto the
   mirror. Is there a way to do it anyway?

A: Yes, there is a way. Install OpenBSD on the first of
   your two disks. Do not use the second disk.

   You need a system which is capable of building a kernel
   or you have to install everything which is required to
   build a kernel on this system.

   Start installing the system the same way you alwas
   install an OpenBSD box. When you have to create the
   disklabel do it the following way.

   Slice a will later become your / slice. At the moment
   (OpenBSD 3.0), / can not be on a mirror. Slice b,
   of course, is swap. If you would like to put swap on a
   mirror I would suggest to use a dedicated mirror only
   for swapping because after a reboot the parity will
   always be dirty. Slice p is the only slice we are going
   to use for the installation and will hold / during
   the installation. Later we transfer slice p into the
   mirror.

     > a a
     offset: [63] <Enter>
     size: [4226662] 100m
     Rounding to nearest cylinder: 204789
     FS type: [4.2BSD] <Enter>
     mount point: [none] <Enter>
     > a b offset: [204852] <Enter>
     size: [4021873] 300m
     Rounding to nearest cylinder: 614556
  FS type: [swap] <Enter>
     > a p
     offset: [819408] <Enter>
     size: [3407317] <Enter>
  FS type: [4.2BSD] <Enter>
     mount point: [none] /
     > p
     device: /dev/rsd0c
     type: SCSI
     disk: SCSI disk
     label: DCAS-32160W
     bytes/sector: 512
     sectors/track: 172
     tracks/cylinder: 3
     sectors/cylinder: 516
     cylinders: 8188
     total sectors: 4226725
     free sectors: 0
     rpm: 3600

     16 partitions:
     #        size   offset    fstype   [fsize bsize   cpg]
       a:   204789       63    4.2BSD     1024  8192    16
       b:   614556   204852      swap
       c:  4226725        0    unused        0     0
       p:  3407317   819408    4.2BSD     1024  8192    16  # /
     > w
     > q
     No label changes.

   Now install the system like you always do.

   Your system will not come up for the first reboot. At the
   boot> prompt type

     boot> hd0p:/bsd

   to boot your system from slice p.

   Now you have to build a kernel with an enabled RAIDFrame
   driver and fixed devices (For more information, see raid(4).).
   You either have to do this on the system you are installing at
   the moment or you may use another OpenBSD box to build the
   kernel. If you do it on another system I assume you can adjust
   this example on your own.

     # cd /usr/src/sys/arch/$(uname -m)/conf
     # cp GENERIC GENERIC_RAID

   This example is designed for two SCSI disks. If you have more
   disks or use IDE disks you have to asjust it. Even if you have
   two SCSI disks you have to change the devices to what you really
   have.

  # dmesg | grep "^sd[0-9] "
  sd0 at scsibus0 targ 0 lun 0: <IBM, DCAS-32160W, S65A> SCSI2 0/direct fixed
     sd1 at scsibus0 targ 1 lun 0: <IBM, DCAS-32160W, S65A> SCSI2 0/direct fixed

   Add the following lines to your kernel config file (GENERIC_RAID).

     sd0     at scsibus0 target 0 lun ?
     sd1     at scsibus0 target 1 lun ?

   The lines have to be in front of the line which reads:

     sd*     at scsibus? target ? lun ?      # SCSI disk drives

   The devices are attached to scsibus0.

     # dmesg | grep ^scsibus0
  scsibus0 at ahc1: 16 targets

   Now, replace the line which reads:

     scsibus* at ahc?

   with:

     scsibus0 at ahc1

   It is very important, that you _replace_ the original line and not only add
   the new entry.

   The scsibus0 is provided by ahc1.

     # dmesg | grep "^ahc1 "
     ahc1 at pci0 dev 12 function 0 "Adaptec AHA-2940U" rev 0x01: irq 11

   Add the following entry to the kernel config file. pci can be left
   floating around.

     ahc1  at pci? dev 12 function 0

   The entry has to be in front of the line which reads:

     ahc*    at pci? dev ? function ?

   And do not forget to enable the driver itself. Remove the # sign
   in front of the line:

     pseudo-device   raid            4

   Now build the kernel.

     # config GENERIC_RAID
  # cd ../compile/GENERIC_RAID
  # make clean && make depend && make
  # cp /bsd /bsd.old
  # cp bsd /bsd

   Boot the system with the RAID kernel. We have to boot from
   slice p once again.

   We write a new MBR to the second disk.

     # fdisk -i sd1

   We now have to label the second disk with the same layout we used
   on the other disk.

     # disklabel sd0 | disklabel -R sd1 /dev/fd/0

     # disklabel sd1
     16 partitions:
     #        size   offset    fstype   [fsize bsize   cpg]
       a:   204789       63    4.2BSD     1024  8192    16   # (Cyl.    0*- 396)
       b:   614556   204852      swap                        # (Cyl.  397 - 1587)
       c:  4226725        0    unused        0     0         # (Cyl.    0 - 8191*)
       p:  3407317   819408    4.2BSD                        # (Cyl. 1588 - 8191*)

   No create the RAIDFrame config file. The second disk specified
   (/dev/sd2e in our example) has to be a valid device file but
   the associated disk MAY NOT exist in your system.

     # vi /etc/raid1.conf
     START array
     # numRow numCol numSpare
     1 2 0

     START disks
     /dev/sd1p
     /dev/sd2p

     START layout
     # sectPerSU SUsPerParityUnit SUsPerReconUnit RAID_level_1
     32 1 1 1

     START queue
     fifo 100

     # raidctl -C /etc/raid1.conf raid1

   You will get errors about a nonexisting drive sd2.

     # raidctl -I 112341 raid1

   Now we have a running mirror made out of our second disk in
   the system and a nonexisting disk. We can verify that with:

  # raidctl -s raid1
  Components:
             /dev/sd1p: optimal
             /dev/sd2p: failed
     No spares.
     Parity status: clean
     Reconstruction is 100% complete.
     Parity Re-write is 100% complete.
     Copyback is 100% complete.


   Now you can label the raid device however you like.

  # fdisk -e raid1
  fdisk: 1> edit 3
           Starting       Ending
   #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
  ------------------------------------------------------------------------
  *3: A6    0   1   1 - 1023   7  32 [        32 -    3407072] OpenBSD
  Partition id ('0' to disable)  [0 - FF]: [A6] (? for help)
  Do you wish to edit in CHS mode? [n]
  Partition offset [0 - 3407232]: [32] 0
  Partition size [1 - 3407232]: [3407072] 3407232
  Only LBA values are valid in ending cylinder for partition #3.
  fdisk:*1> p
  Disk: raid1     geometry: 13309/8/32 [3407232 sectors]
  Offset: 0       Signatures: 0xAA55,0x0
           Starting       Ending
   #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
  ------------------------------------------------------------------------
   0: 00    0   0   0 -    0   0   0 [         0 -          0] unused
   1: 00    0   0   0 -    0   0   0 [         0 -          0] unused
   2: 00    0   0   0 -    0   0   0 [         0 -          0] unused
  *3: A6    0   0   1 - 1023   3  32 [         0 -    3407232] OpenBSD
  fdisk:*1> w
  Writing MBR at offset 0.
  fdisk: 1> q
  #

     # disklabel -E raid1
  disklabel: Can't get bios geometry: Device not configured

  Initial label editor (enter '?' for help at any prompt)
  > p
  device: /dev/rraid1c
  type: RAID
  disk: raid
  label: fictitious
  bytes/sector: 512
  sectors/track: 32
  tracks/cylinder: 8
  sectors/cylinder: 256
  cylinders: 13309
  total sectors: 3407232
  free sectors: 3407232
  rpm: 3600

  16 partitions:
  #        size   offset    fstype   [fsize bsize   cpg]
    c:  3407232        0    unused        0     0         # (Cyl.    0 - 13309*)
  > a d
  offset: [0] <Enter>
  size: [3407232] 80m
  FS type: [4.2BSD] <Enter>
  > a e
  offset: [163840] <Enter>
  size: [3243392] 80m
  FS type: [4.2BSD] <Enter>
  > a g
  offset: [327680] <Enter>
  size: [3079552] 350m
  FS type: [4.2BSD] <Enter>
  > a h
  offset: [1044480] <Enter>
  size: [2362752] <Enter>
  FS type: [4.2BSD] <Enter>
  > p
  device: /dev/rraid1c
  type: RAID
  disk: raid
  label: fictitious
  bytes/sector: 512
  sectors/track: 32
  tracks/cylinder: 8
  sectors/cylinder: 256
  cylinders: 13309
  total sectors: 3407232
  free sectors: 0
  rpm: 3600

  16 partitions:
  #        size   offset    fstype   [fsize bsize   cpg]
       c:  3407232        0    unused        0     0         # (Cyl.    0 - 13309*)
       d:   163840        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 639)
       e:   163840   163840    4.2BSD     1024  8192    16   # (Cyl.  640 - 1279)
       g:   716800   327680    4.2BSD     1024  8192    16   # (Cyl. 1280 - 4079)
       h:  2362752  1044480    4.2BSD     1024  8192    16   # (Cyl. 4080 - 13309*)
  > w
  > q
  No label changes.

   Create the filesystems on the raid device

  # newfs /dev/sd0a
  # newfs /dev/raid1d
  # newfs /dev/raid1e
  # newfs /dev/raid1g
  # newfs /dev/raid1h

     # mount /dev/sd0a /mnt
     # cd /mnt
     # mkdir tmp var usr home
     # mount /dev/raid1d tmp
     # mount /dev/raid1e var
     # mount /dev/raid1g usr
     # mount /dev/raid1h home

     # df -k
     Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
     /dev/sd0p     1647467   158512  1406582    10%    /
     /dev/sd0a       98977        5    94024     0%    /mnt
     /dev/raid1d     78703        1    74767     0%    /mnt/tmp
     /dev/raid1e     78703        1    74767     0%    /mnt/var
     /dev/raid1g    344381        1   327161     0%    /mnt/usr
     /dev/raid1h   1135190        1  1078430     0%    /mnt/home

  # cd /; dump 0f - . | (cd /mnt; restore -rf - )
  # rm /mnt/restoresymtable

  # df -k
     Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
     /dev/sd0p     1647467   158514  1406580    10%    /
     /dev/sd0a       98977    23493    70536    25%    /mnt
     /dev/raid1d     78703        1    74767     0%    /mnt/tmp
     /dev/raid1e     78703     4414    70354     6%    /mnt/var
     /dev/raid1g    344381   130608   196554    40%    /mnt/usr
     /dev/raid1h   1135190        1  1078430     0%    /mnt/home
     #


     # vi /mnt/etc/fstab
     /dev/sd0a / ffs rw 1 1
     /dev/raid1d /tmp ffs rw 1 1
     /dev/raid1e /var ffs rw 1 1
     /dev/raid1g /usr ffs rw 1 1
     /dev/raid1h /home ffs rw 1 1


   We change the faked disk sd2 in the raid1.conf file to the real
   sd0 disk. It is very important that the disk sd1p (the disk
   containing the raid at the moment) is mentioned before the
   disk sd0p (the disk onto which we installed the system).
   Otherwise the raid device can not be started and you will
   have problems fixing /etc/raid1.conf without vi.

     # vi /mnt/etc/raid1.conf
  START array
  # numRow numCol numSpare
  1 2 0

  START disks
  /dev/sd1p
  /dev/sd0p

  START layout
  # sectPerSU SUsPerParityUnit SUsPerReconUnit RAID_level_1
  32 1 1 1

  START queue
     fifo 100

   Let's check if the system will come up. This time, we let the
   system come up normally and do not enter anything after the
   boot> prompt.

     # umount /mnt/home /mnt/usr /mnt/var /mnt/tmp /mnt
  # shutdown -r now

   If it worked the system should now look like this.

     # df -k
     Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
     /dev/sd0a       98977    23494    70535    25%    /
     /dev/raid1d     78703        1    74767     0%    /tmp
     /dev/raid1e     78703     4297    70471     6%    /var
     /dev/raid1g    344381    75850   251312    23%    /usr
     /dev/raid1h   1135190        1  1078430     0%    /home
     #

   We make the system bootable from sd0a. (This time the system
   came up with /boot from sd0p which will soon be overwritten.)

     # /usr/mdec/installboot -v /boot /usr/mdec/biosboot sd0

   During the boot the raid device was be started but disk sd0p
   is marked as failed. We sync the data onto sd0p with the
   following command.

  # raidctl -R /dev/sd0p raid1

   Now we set the system up to daily mirror the root device.

  # newfs /dev/sd1a
  # vi /etc/fstab
  /dev/sd1a /altroot ffs xx 1 1

     # crontab -e
  ROOTBACKUP=1

   If you omit the next step the sync automatically takes place
   during the night

  # ROOTBACKUP=1 /bin/sh /etc/daily

   We make the second disk bootable. You have to repeat this step
   every time you change /boot on the first disk (after the sync
   is done).

     # mkdir /mnt
  # mount /dev/sd1a /mnt
  # /usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot sd1
  # umount /mnt


   As last step we have to modify the fstab on sd1a every day
   after the sync to use sd1a as root instead of sd0a. What is the
   best way to do that? Hack the /etc/daily script?