OpenBSD 5.5 and later | cloning a disk the easy way

ATTENTION! Your default kernel always uses the root device per default from which he origins. This is hardcoded. You can change this at boot time using the boot -a (man boot) command at the boot prompt. It is NOT possible to script this (even using the /etc/boot.conf). This is not really a problem, if your master disk fails, the kernel switches to the next available root device. But if you switch the master/clone disks after cloning in their machine slots, it will boot from the cloned (the 'new' master), but will use the still existing old master disk (the 'new' clone) as root device. That's a little bit confusing. Hint: If your master disk crashes, reclone it from the slave and put it into the first slot and let them run as the master.


DISKLABEL=$(which disklabel)
FDISK=$(which fdisk)
DUMP=$(which dump)
RESTORE=$(which restore)
NEWFS=$(which newfs)
MOUNT=$(which mount)
UMOUNT=$(which umount)
DUMP=$(which dump)
RESTORE=$(which restore)


if [ $# -lt 2 ]; then
echo “usage: FROM TO”
echo “example: wd0 wd1”

$DISKLABEL $SRC > /dev/null || exit

$DISKLABEL $TAR > /dev/null || exit





cat $LABEL | grep ‘ # /’ | (
while read LINE; do
#echo “$LINE”
echo “$SLICE is $PATH”
($DUMP -0f – $PATH )|(cd $MNT; $RESTORE -rf -)
done $MNT/etc/fstab

cp /usr/mdec/boot $MNT/boot


$(which installboot) -v /dev/${TAR}a /usr/mdec/biosboot


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.