[Semibug] backup files over serial console

Nick Holland nick at holland-consulting.net
Sat Mar 16 23:39:18 EDT 2019

On 3/16/19 9:50 PM, Mark Moellering wrote:
> I am trying to put OpenBSD on an ubiquiti edgerouter - 4.  I was able
> to install it on a EdgeRouter-Lite but that was easier, as I could open
> the case and everything was installed on a USB stick.
> the EdgeRouter-4 cannot be opened (or I haven't figure out how).  I am
> pretty sure I can install OpenBSD but I would like to try and make a
> backup of the software first. 
> As near as I can tell, this needs to be done over the serial cable.  I
> really can't figure out how to do this.  I read the cu man page and it
> says:
> Copy file from remote to local.  The *cu* utility prompts first for
> 	     the name of the file to be	sent, then for a command to be exe-
> 	     cuted on the remote machine.
> I have no idea what this means... I am more of a programmer who uses
> FreeBSD / openBSD
> than a sysadmin, so I am pretty lost at this point. Can someone explain
> what this means or how to
> backup directories, etc over the console? Or is there another / better
> way to do this?

cu can be used to transfer text files -- capturing the output of 'cat' or
sending text files as if you are typing rapidly.  Not so good for binary
stuff.  You would have to add something like xmodem to actually move
binary stuff over the serial port.

You probably don't want to send gigabytes of data over a serial port
anyway.  Serial ports are slow.

I see there's a USB port on it.  Assuming that's supported by OpenBSD
(hm. looks like it might be imperfect), I'd boot from the OpenBSD bsd.rd
kernel (the install kernel) and dd the on-board storage to a file on the
USB drive, or even image it directly to the USB drive.

For example, assuming the on-board storage is sd0 and the USB drive is sd1:
   # cd /dev
   # sh MAKEDEV sd1    # because this isn't in RAMDISK kernels)
   # dd if=/dev/rsd0c of=/dev/rsd1c bs=1m

Note: this creates an IMAGE on sd1, you probably can't jam it in another
machine and see files.  IF you "mount" the USB stick first, you could
change the of to "of=/mnt/er4.img", however, if you use FAT, you might
have issues with big files.  If you use FFS, you will probably find that
FFS is not platform neutral; you can't be sure you can read the files on
another machine other than another Octeon system.

Looks like the OpenBSD support of the USB port might require a little
pre-boot magic before working, so I'd recommend making two copies and
comparing them elsewhere before overwriting what you want.


More information about the Semibug mailing list