Transferring files over the net with OpenBSD's bsd.rd

OpenBSD's installation ramdisk does not contain useful tools to quickly transfer files from a remote machine. Specially the absence of netcat is painfully felt. The typical routine to transfer a set of files from Host A to the Host-to-be-installed B would normally be

A% tar cf - dir1 dir2 | nc -l 1234
B% nc hostA 1234 | tar xpf -

To transfer whole partitions, it would be

A% dump -a0f - /dev/sd0a | nc -l 1234
B% newfs /dev/rsd0a && mount /dev/sd0a /mnt && \
    nc hostA 1234 | (cd /mnt; restore -r -f -)

What is included in the ramdisk, is OpenBSD's FTP client, ftp, which implements a subset of HTTP. So the above procedure becomes:

A% (echo -e "HTTP/1.1 200 OK\n"; sudo dump -0af - /dev/wd0g) | nc -l 1234
B% ftp -o /dev/stdout http://hostA:1234/ | restore -r -f -

(Of course one could also set up a whole ftp or http server and put the dumpfiles there, but oneliners are the essence of doability in *NIX)

Tue, 04 Oct 2011
[/projects] permanent link

Deutsch für extrem weit Fortgetretene

Bewurstlosigkeit :
Like unconsciousness, but without the sausages.

Tue, 04 Oct 2011
[/unsorted] permanent link