/rescue to the rescue

I need vacations, I really do.

Yesterday night, I decided to upgrade my home’s Internet gateway from NetBSD 6.0 to 6.1. As I already had some success with jmmv‘s sysupgrade, I simply ran

# sysupgrade auto ftp://ftp.fr.NetBSD.org/pub/NetBSD/NetBSD-6.1/amd64

… on an i386 machine. That obviously lead to massive failure such as:

/bin/ls cannot execute elf binary

As I still had an SSH session opened on that server, my first thought was to use /rescue‘s binaries, which are statically linked, but guess what, /rescue is also part of base.tgz, the first set installed by sysupgrade(8). Doomed? not yet. I remembered that my gateway mounts /usr/pkgsrc over NFS, from my NetBSD NAS. So I fetched i386‘s base.tgz on the NFS server, extracted /rescue/sh and /rescue/tar, copied them to /usr/pkgsrc and made sh suid root so I could call tar with the -C / flag in order to replace amd64 binaries. For some reason, rescue‘s tar would not gunzip base.tgz, I really was not brave enough to dig into this, so I gunzipped it on the NFS server.

$ /usr/pkgsrc/tmp/sh
# tar xvfp base.tar -C /

That worked, and I was able to run sysupgrade(8) again, this time with the good architecture.

Within a week, I’ll be sunbathing in Ibiza, I think I deserved it.