Transfer OpenBSD through the network

       531 words, 3 minutes

Last time, I transferred OpenBSD from one local disk to another .
This time, I want to replicate OpenBSD from a remote working system to another, through the network.

First of all, you have to install a basic system on the “destination” server. In my case, I just installed the kernel, the “base” and the “etc” packages. I didn’t create any users and allowed SSH remote root access as I knew this would not last.

When the basic “destination” server is ready, install the SSH keys that will allow you to connect to the “source” server. If you don’t use SSH key authentication, you don’t have to install those keys.

Then, connect to the “source” server and stop as much services as possible ; to avoid creating new data during the system copy. When done, use the `sync` command to be sure every data is written on the disk.

When the “source” server is in “idle” mode, connect to the “destination” server and stop as much services as possible ; as things are going to be overwritten during transfer. Test the remote SSH connection between “source” and “destination” servers and be sure that the “sudo” token is effective:

  # ssh user@source "sudo ls /"
  (...)
  # cd /
  # ssh user@source "sudo tar cpf - /" | tar xpf - -C / 
  Enter passphrase for key '/root/.ssh/id_rsa': 
  tar: Removing leading / from absolute path names in the archive
  (...)
  # sync

I had a bunch of “tar: Ustar cannot archive a socket” errors raising up during the transfer. The sockets will be created on next reboot so there’s no need to fear about those.

Be sure to configure the proper “hostname.if” files if you “destination” and “source” servers don’t have the same NICs. You can then shutdown the “source” server, reboot the “destination” server and enjoy the migrated system!

I tried to use dump/restore to issue the transfer but it didn’t work. What I did was:

  # ssh user@source "sudo ls /"
  (...)
  # cd /
  # ssh user@source "sudo dump -0a -f - /" | restore -rf -
  Enter passphrase for key '/root/.ssh/id_rsa': 
    DUMP: Date of this level 0 dump: Tue Feb 28 18:44:17 2012
    DUMP: Date of last level 0 dump: the epoch
    DUMP: Dumping /dev/rsd0a (/) to standard output
    DUMP: mapping (Pass I) [regular files]
    DUMP: mapping (Pass II) [directories]
    DUMP: estimated 6552323 tape blocks.
    DUMP: Volume 1 started at: Tue Feb 28 18:44:33 2012
    DUMP: dumping (Pass III) [directories]
    DUMP: dumping (Pass IV) [regular files]
  restore: ./usr: File exists
  restore: ./usr/lib: File exists
  (...)
  restore: ./var/yp: File exists
    DUMP: 34.97% done, finished in 0:09
  restore: ./bin/ksh: cannot create file: Text file busy
  (...)
  restore: ./sbin/restore: cannot create file: Text file busy
    DUMP: 70.39% done, finished in 0:04
  Connection to destination closed by remote host.

Using a remote SSH connection (from the “destination” server), the session died during the restore part. When issuing the transfer from the console, the restore process also died before the end. I couldn’t find the proper way to do the transfer. I thought of booting from an OpenBSD CD to run the dump/restore but there is no `ssh` (nor `rsh`) in such shell.