Synopsis #
The RAID 1 discipline of softraid(4) mirrors data across two or more chunks. The assembled volume appears as a normal sd(4) disk and is partitioned and formatted at that virtual layer.
RAID1 improves availability after a component failure. It does not protect against deletion, corruption, compromise, fire, theft, or an error applied to the mirror. Maintain and test independent backups.
This procedure destroys all data on the selected component partitions. Disk names can change whenever hardware or installation media changes. Identify devices by model, size, attachment, and disklabel UID before every destructive command.
Plan the Mirror #
The example uses:
| Role | Device |
|---|---|
| First physical disk | sd1 |
| Second physical disk | sd2 |
| RAID chunks | sd1a and sd2a |
| Assembled volume | reported by bioctl, assumed sd3 |
| Data filesystem | sd3a mounted at /srv |
The component partitions must have type RAID and compatible sizes. The mirror’s usable size is limited by its smallest chunk.
Identify and Label the Component Disks #
Inspect all candidates:
# sysctl hw.disknames
# Record disk names and disklabel UIDs
# dmesg | grep '^sd'
# Match disks to size and attachment
# disklabel sd1
# Inspect the first proposed component
# disklabel sd2
# Inspect the second proposed component
Stop unless both devices are unambiguously identified and all required data has been backed up.
Prepare the required outer partitioning for each data disk, then create one equal-size disklabel partition of type RAID on each. Use disklabel(8)
interactively and inspect the proposed offset and size rather than copying sector values from another disk:
# disklabel -E sd1
Label editor (enter '?' for help at any prompt)
sd1> a a
offset: [default]
size: [default] *
FS type: [4.2BSD] RAID
sd1*> w
sd1> q
Repeat for sd2, then inspect both completed labels. This is the final destructive checkpoint.
Create the Mirror #
Create the RAID1 volume with bioctl(8) :
# bioctl -c 1 -l /dev/sd1a,/dev/sd2a softraid0
Record the virtual disk name reported by the command. This example assumes sd3. Confirm its discipline and state:
# bioctl sd3
# Confirm RAID 1 and an online state
# disklabel sd3
# Confirm the expected virtual size
Clear stale signatures only on the assembled virtual disk, never on either physical chunk:
# dd if=/dev/zero of=/dev/rsd3c bs=1m count=1
Initialize the virtual disk’s outer partition table as appropriate for the platform and intended use. For a data-only amd64 disk using an MBR OpenBSD area, one example is:
# fdisk -iy sd3
Create a normal 4.2BSD partition on the virtual disk:
# disklabel -E sd3
Label editor (enter '?' for help at any prompt)
sd3> a a
offset: [default]
size: [default] *
FS type: [4.2BSD]
sd3*> w
sd3> q
Create and mount the filesystem:
# newfs /dev/rsd3a
# Create FFS on the virtual partition
# install -d -o root -g wheel -m 755 /srv
# Create the mount point
# mount /dev/sd3a /srv
# Mount the mirrored filesystem
Use the virtual partition’s DUID in /etc/fstab rather than relying on sd3, which can change across boots.
Monitor Mirror Health #
Inspect the assembled volume regularly:
# bioctl sd3
$ sysctl hw.sensors.softraid0
Softraid exports volume status through hardware sensors, so sensorsd(8) can report state changes. Test the notification path.
A degraded mirror remains a data-loss risk until it has rebuilt and returned to an online state. Reduce writes and replace the failed component promptly, but do not rush device identification.
Replace a Failed Component #
Before removing hardware, record bioctl output, disk identity, chunk state, and the assembled volume name. Shut down when the controller or enclosure does not support safe hot replacement.
After installing the replacement disk:
- identify it from current
sysctl,dmesg, anddisklabeloutput; - create outer partitioning compatible with the surviving component;
- create an equal-size partition of type
RAID; - inspect the completed label and confirm that the surviving disk is not the target;
- start the rebuild by naming the full replacement chunk and the assembled volume.
If the replacement chunk is /dev/sd2a and the assembled volume is currently sd3:
# bioctl -R /dev/sd2a sd3
Monitor progress and state:
# bioctl sd3
$ sysctl hw.sensors.softraid0
Do not reboot, detach the volume, or treat redundancy as restored until the rebuild completes and the volume reports an online state. If the rebuild reports errors, preserve the surviving data and backup before attempting additional repair.
Bootable Mirrors #
Boot support depends on the platform and softraid discipline. Current softraid(4) documents RAID1 boot support on selected architectures. installboot(8) can install boot code so all chunks of a supported volume are bootable.
A bootable-root migration requires architecture-specific outer partitioning, boot areas, filesystem layout, /etc/fstab, boot-code installation, and a physical test of booting from each component. Do not convert this data-volume procedure into a root migration by adding installboot alone.
See Storage and File Systems for softraid concepts and Back Up and Restore an OpenBSD System for independent recovery copies.