štvrtok 1. marca 2012

FreeBSD system upgrade/kernel upgrade 1

Previously I showed how to upgrade ports tree and update ports.
It's very important to have ports up to date although time to time it's also important to have system up to date or you lack functionality or performance as reason for upgrade.

I've noticed one utility made by BSD individual named freebsd-update. I have really no experience with it, and now I'm going to show how to upgrade manually so you can see whole "background" process of it.
Mentioned utility provides way of upgrade OS or install security patches via fetched binaries. Binaries are compiled source codes, so the process is much quicker I assume.
Anyway I'll show you older way and this utility is nice idea for next topic, why to not make process easier if it's possible but I think it's still important to know background even there are useful utilities like "freebsd-update".

As first step, backup all config files, data, .... you never know what can happen.

1. Download source code
First,we have to download source code of considering version of system we are going to upgrade to.
Etc. I use 8.2 and I want to upgrade whole system to 9.0.
I'm upgrading without preparation so everything can happen.
Source code location is in "/usr/src/". If there is something, just delete it or backup.
As you can recall, we have used "cvsup" to download ports tree. We will use the same utility for downloading source code.
cp /usr/share/examples/cvsup/stable-supfile /root/cvsup/
chmod 600 /root/cvsup/stable-supfile
Edit lines in above file:
*default host=cvsup.sk.FreeBSD.org # use your favorite server
*default release=cvs tag=RELENG_9_0 # 9.0 will be fetched
Run cvsup:
cvsup -L 2 /root/cvsup/stable-supfile


2. Customize make.conf
There is file named "make.conf" in "/etc/". I don't know real performance results of doing this but it's like a habit to specify CPU type and characteristics for compiler to make the compilation more effective. I'll write about this in further article as there is no room now.

3. Kernel hardening
This really needs individual article. Kernel is the brain or core of our OS system(FBSD). In some cases like high performance network server, database server or any focused use of FreeBSD there is best practice to remove all unnecessary balast from kernel and on other hand, add some features and functionality which are not included in standard kernel.
Basically, all you need, you can do within running live kernel but difference is, that you adjust source and this source will be compiled to binary data. Result of doing this aims to faster processing of data, queries....and security as well.  

We will skip this step and we are going to use "GENERIC" standard kernel configuration. The same as we would get from CD installation etc.

Anyway we are going to use default configuration, make a copy of GENERIC to your own file. Just copy, rename and edit will be part of next article.
cd /usr/src/sys/amd64/conf - use i386 dir instead of amd64 when you use i386 architecture
cp GENERIC /root/kernel/MY_OWN_KERNEL
ln -s /root/kernel/MY_OWN_KERNEL - nice tip from handbook, cause your kernel conf should be placed in "conf" directory I think. So this way, your kernel is stored in special directory and you create a symbolic link towards to "conf" directory.

4. Compilation
You can make a dinner during the compilation. The process takes a lot of time even with consideration everything will go with no problems.
We can make it shorter with hardening so at the end, the system will compile just what you need. Now, we have chosen standard compilation without hardening so everything must be compiled. We'll get "universal" system for general use.
In case your compilation fails, clean "/usr/obj" directory and start over.

*
If it's not your purpose to upgrade to higher version of OS, if it's just matter of rebuilding kernel in order of whatever, you don't need to make buildworld. So the process is much easier and quicker. All you need is make buildkernel and make installkernel.
*

make buildworld -this is the most time consuming process. It builds surrounding components for kernel. At least what I know...
make buildkernel KERNCONF=MY_OWN_KERNEL
make installkernel KERNCONF=MY_OWN_KERNEL
reboot to single user mode -check the menu at the boot seq. We do this because in singe user mode, there is just base system running so we can update files from "world" for services which would normally run.
mount -a -if mount doesnt work, try full path to mount
cd /usr/src
mergemaster -p -I suggest leave the new files so they will be written to some temp dir and then manually compare a adjust with existing ones. Follow the wizard.
make installworld
mergemaster
reboot


Now check "uname -a" and check if everything works as it should. 


5.Hints
1. Make sure your kernel comes from right architecture
2. Make sure you have at least 300M free space in "/" because your old kernel will be backed up in "/boot" directory so you can roll back.
3. If you have problem within compilation, try to uncomment CPU tunnings in "make.conf" and try again.
4. In my case I did upgrade from 8.2 to 9.0. It's a quite huge step and it ended with problems.
My system is booting right but many ports and kernel modules are not working properly. System is freezing frequently due to mismatch of installed ports and new libraries from "world".
My situation is more complicated because I have FreeBSD as desktop so I have more ports, more libraries running so more problems can show up.
I've noticed as I reinstalled some ports that some problems has disappeared but some still exist.
Maybe the solution would be to reinstall everything you have. Another way is to install new version of OS from media and then install everything you need and restore config files from backup. Or, as I mentioned at the beginning of this article, there is a original update tool from FreeBSD, I assume less problems using this utility as the process of upgrade I showed is quite knowledge demanding because a lot of problem might occurred after this "raw" upgrade. Anyway, at least it's the best way how to learn about system.

Summarized, this way of upgrade is not bad, but at first, have a great knowledge of your system before upgrade. Do some documentary what you have installed, what modules are loaded, what is more important to run and what is not, do a backup scenario and so on...
Seems complicated and this is just because FreeBSD is so powerful and you need to subdue it. After the system is running OK, will be running right this for ever so its worth.

In next article I'll show something about make.conf adjustment and kernel hardening so you can have a system focused just to your needs which leads to better performance and security.

Žiadne komentáre:

Zverejnenie komentára