For some reason, I need to switch my main (and only) disk running OpenBSD. As it is a production machine, I want to do it fast and painless.
The system will go from the internal SSD disk to an external USB FlashVoyagerGT stick. Yeah, quite weird, but this is temporary 🙂 Anyway, here are the directions.
Connect the second disk to the machine, check its name, initialize the MBR, create the partition and the filesystem(s):
# fdisk -i sd1 Do you wish to write new MBR and partition table? [n] y Writing MBR at offset 0. # disklabel -E sd1 Label editor (enter '?' for help at any prompt) > a c (...) > a b (...) > w > q # newfs sd1a /dev/rsd1a: 15287.9MB in 31309568 sectors of 512 bytes (...) # shutdown -h now Shutdown NOW!
Now boot your system in single-user mode and clone the data from the initial disk to the second one:
boot> boot -s (...) Enter pathname of shell or RETURN for sh: /bin/ksh # mount /dev/sd1a /mnt # mount_mfs -s 4096m swap /tmp # cd /mnt # dump -0f - /dev/sd0a | restore -rf -
Another option is to use the `tar` command:
# mount /dev/sd1a /mnt # tar cpzXf - / | tar xpzf - -C /mnt
Note that, in some case, you may get an error such as “
tar: Link name too long for ustar usr/local/lib/GNUstep/SOGo/(…)“. AFAIK, this is a limitation of the OpenBSD tar implementation which limits a filename at 100 characters.
We can now check that both disk have the same content and reboot (to install the MBR) properly:
# df -h # shutdown -h now
Reboot the system and, in the OpenBSD loader, force to boot on the secondary disk:
boot> boot hd1a:/bsd -s (...) Enter pathname of shell or RETURN for sh: /bin/ksh # /usr/mdec/installboot -n -v /boot /usr/mdec/biosboot sd0 # shutdown -h now
The primary disk can now be removed and the system will boot on the previously “secondary disk” ; as soon as the bios is configured to 😉
If everything went well, you now run the system from the new system.
Source: Adding extra disks in OpenBSD