LinkedIn Sourceforge

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

Migrate from Legacy boot to UEFI

Posted on 2019-11-14 21:14:00 from Vincent in OpenBSD

Last week my NAS stopped working. The mother board has not resist to an unplanned power outage. So, I bought a new board J5005. After having placed the new board in the case, I was surprised to see that the board does not see the boot sector. Looking in the documentation of the board, we can ONLY use EUFI. Legacy boot is not supported!!!. Here bellow I will explain how to migrate my disk to UEFI.


It's now several years that UEFI is present. But since I'm using quite old material I was never confronted to such new stuff.

For sure, if the board is willing to look for a UEFI boot table, my disk build on the old motherboard will not work.

Instead of looking for solutions to remap my disk into UEFI compatible; I've decided to install my NAS from scratch on a new disk.

Installation

On the machine with the new motherboard, I've performed a standard installation as documented on the OpenBSD website. I'll not detail it further since I've used the simple standard installation steps.

Take a copy of my NAS operating system

Instead of installing and configuring all different components one by one, I've opted by the dump/restore mechanism. To do that I've first re-installed the disk into a motherboard supporting the good old Legacy boot.

Since my NAS is quite a very simple setup with few filesystems, the manipulations are quite limited.

Let me describe my setup:

obsd-nas # df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/sd0a     11.8G    2.6G    8.6G    23%    /
mfs:1281      61.9M   13.0K   58.8M     0%    /tmp
mfs:78834      775M    140M    596M    19%    /var
mfs:68496     30.9M   32.0K   29.3M     0%    /dev

As you can see sd0 is the disk where the Operating system resides.
All the rest are memory filesystems. You can have details from my old blog

Because this is not the purpose, I do not show the filesystems where data (since this is a NAS) are located.

So, my objective was to copy all elements inside "/" and not the other filesystems. To do that, I've selected the tar command.

Form the machine with the new motherboard, I take a copy of my NAS's operating system by doing

new-nas # ssh root@nas tar -czvXf - / > nas.tgz

(please note that temporarily I've authorized root remote connection first, check /etc/ssh/sshd_config)

You can place this big nas.tgz file where you want, but not in the "/" path. For example, it can be on a NFS or usb drive.

Installation

The objective is now to just uncompress the big nas.tgz. In this case, the following command will perform it:

new-nas # tar -C / -xzphf nas.tgz.

Before rebooting, we have to perform 2 adaptations:

Adapt /etc/fstab

Since disks between old an new machines are not the same, we have to adapt the /etc/fstab file accordingly.

Just grab the new DUID of your new disk:

new-nas # disklabel sd0 | grep duid 
duid: 9b7b565b6f342fc7

And put it in your /etc/fstab

9b7b565b6f342fc7.a / ffs rw,wxallowed 1 1
swap        /tmp mfs rw,-s=64m  0 0
swap        /var mfs rw,-P=/cfg/var,-s=800m 0 0
swap        /dev mfs rw,-P=/cfg/dev,-s=32m  0 0

(Don't look at memory filesystem)

Rebuid your password DB

On the new systems, I had some troubles with the passwd command saying that the user I want to change the password was not defined, ...
All my problems were solved once I've recreated the pwd.db file thanks to the following command.

new-nas # pwd_mkdb /etc/master.passwd

It's not 100% clear to me why I had issues with pwd.db, but anyhow, rebuilding it solved my issues.

Conclusions

It's amazing how simple it was to copy my whole setup from one machine to an another one.
OpenBSD is so flexible.



0, 0
displayed: 11809



What is the first vowel of the word Moon?