How to change machine architecture by compile kernel?

Suppose that I have a machine and ran the wrong machine architecture type such as now my machine running i386, and I want to run amd64 by building new world and kernel, how?

I know buildworld can specify architecture by TARGET=amd64, but how to install the amd64 kernel?
 
There is a brute-force dangerous way: overwriting the i386 versions with 64-bit binaries and libraries from another system. I did this recently; it took some iterating to get going. And then I only trusted it long enough to do a buildworld/installworld. This is not something to try unless you are fairly familiar with FreeBSD, and only after a backup. For most users, it will be quicker, less painful, and safer to follow SirDice's advice.
 
I've done this once, with FreeBSD, using the CDROM and doing a binary upgrade, and after that recompiling all ports. But the binary upgrade procedure dissapeared from the bsdinstaller. Only the sysinstall can do this.
 
I suspect it would work to add a second hard disk, partition it with boot code, etc. Then build world and kernel for the new target architecture and install 'em on the 2nd disk. Recable if needed to boot, then do it again to put the world and kernel binaries on the original disk.

But if you're going to go to all that trouble it would probably be quicker to do it SirDice's way.
 
Back
Top