📜 ⬆️ ⬇️

FreeBSD 7.1 - i386 -> amd64 migration via SSH only :)

There is a server that is located in a data center in Moscow. There is me who is in the county town of N ™ :-) The only access to the server is SSH and Remote PDU for rebooting.

There is a need to upgrade to FreeBSD amd64, updating the software and rebuilding the kernel in one.

What happened to:
FreeBSD hostname FreeBSD 7.1-RELEASE i386.
')
What happened after:
FreeBSD hostname FreeBSD 7.1-RELEASE amd64.



Short disclamer:


We take as a basis:

FreeBSD 7.x i386.
The presence of two HDD (or partitions).

First, we need complete system and kernel sources (/ usr / src / directory). You can install them via CVSup (src-all directive), or via sysinstall (sysinstall -> Distribution -> src).

In principle, the source code does not weigh a lot and swing quickly.

After that, we need to create a new kernel configuration for our system.

cp /usr/src/sys/amd64/conf/GENERIC ~/<_>
ee <_>


Kernel options depend on your tasks and hardware, I will not give mine here. The only thing I advise you to add from myself -

options IPFIREWALL_DEFAULT_TO_ACCEPT


This is useful because in the new system at the time of the first start there will be no ipfw configurations (and by default it blocks everything, including our SSH). I got so :) I had to send the server to reboot and transfer the configuration.

After we finish configuring the kernel, we “install” our config back by copying. The main thing is not to forget that we take and set the config not in sys / i386, as usual, but sys / amd64.

I personally removed all the “extra” options from /etc/make.conf that could interfere with the compilation - optimization, etc., which I advise you.

After that, you need to collect the world:

cd /usr/src/
make -s buildworld TARGET_ARCH=amd64


And the core:

make -s buildkernel TARGET_ARCH=amd64 KERNCONF=<_>


With the -s switch, we say make that we don’t need to output every file, only the naming of the directories it collects.
The whole procedure (C2D E7200) took about two to two and a half hours.

Next, we assume that our second HDD is mounted on / backup /, which is clean.

Install the world:
make -s installworld TARGET_ARCH=amd64 DESTDIR=/backup/

Install the kernel:
make -s installkernel TARGET_ARCH=amd64 DESTDIR=/backup/ KERNCONF=<_>

Install configuration files, etc. trifle:
cd etc/
make -s distribution DESTDIR=/backup/


At this step, there may be problems with the lack of any conf. files (personally I swore sendmail and sshd). They can be simply copied from the working system.

Drag the core:

cp -pr / backup / boot / kernel /boot/kernel.test

And edit \ transfer the config. files in / backup / etc. We are interested in rc.conf (hostname, network settings), sshd_conf and passwd-shadow. If you have not set default_to_accept, do not forget to open SSH in rc.firewall for yourself.

It's time to try.

For a one-time download, we will use nextboot. This is a very good program that allows you to boot with another kernel \ world ONCE. If the server is restarted, our old system will reboot.

nextboot -D
nextboot -o vfs.root.mountfrom = ufs: / dev / ad2s1d -k kernel.test

The -D switch resets the nextboot configuration if it already exists. -o vfs.root.mountfrom specifies where the root partition is located. Naturally, instead of ad2s1d, your second disk \ partition should be specified, not mine, and -k is the path to the kernel relative to / boot /.

Last checklist:





If all clauses are satisfied - sudo shutdown -r now

If you did everything right, and you are also a little lucky and the system did not throw out the feint with your ears - we will see a working amd64 FreeBSD :)
If you didn’t see it on the network in a few minutes - we reboot the server through remote power management and look for where we made a mistake :)

It remains only to rebuild all the necessary software.

Source: https://habr.com/ru/post/50828/


All Articles