Zobrazujú sa príspevky s označením upgrade. Zobraziť všetky príspevky
Zobrazujú sa príspevky s označením upgrade. Zobraziť všetky príspevky

nedeľa 25. marca 2012

Installation/upgrade/settings/hints summary

As I needed to reinstall whole system, I wrote down some notes as summary from beginning up to last post plus some new hints.

1. Minimal install
I started with version 9.0-Release. Than you don't have problems to upgrade to latest major version. Etc. from 8.2 to 9.0.
The post about installation is in this article.

2. Post install settings
a)Post install settings include steps from articles part1, part2, part3.
If you have already your settings in your current system and you would like to transfer them, just backup configuration files and put them into new system in the same place. Don't forget to install all ports/packages as before.

b)Edit your "make.conf" for instance like this. Do it before anything else, because from this point you will compile ports so let them be compiled with customized way.

c)HINT:Edit loader.conf. First important option we need to adjust is boot delay. By default the delay is 10s. Just put this line into "/boot/loader.conf":
autoboot_delay="1"

d)Install cvsup and create ports tree/source code. Don't forget to refuse what you don't need. I added to refuse file also:
src/games

Later we will cut off unnecessary features for compilation. We won't compile games so we don't need to download them.

e)HINT:As you recall about mutli-threaded source compilation, we can do this for ports compilation as well with very simple way.
cd /usr/ports/Mk/
vi bsd.port.mk
FORCE_MAKE_JOBS=yes
MAKE_JOBS_NUMBER=5

Why 5?As I've noticed, every time you upgrade ports tree, the "bsd.port.mk" is overwritten. So be aware of this. Of course there is workaround,I have to find it.

f)Install helpful ports like mc, vim...and adjust their configuration.

3. Compilation prepare of your own kernel/world
The aim is to skip everything unnecessary in compilation.

a)Make your own kernel config. Edit GENERIC in currently downloaded source! GENERICs may be different in content among major versions.

b)HINT:Adjust "world" compilation by refusing some stuff. This is my example:
cd /etc
touch src.conf
vi src.conf and what I have there:
WITHOUT_ATM=
WITHOUT_BLUETOOTH=
WITHOUT_CALENDAR=
WITHOUT_CVS=
WITHOUT_CTM=
WITHOUT_DICT=
WITHOUT_FLOPPY=
WITHOUT_GAMES=
WITHOUT_HTML=
WITHOUT_IDEA=
WITHOUT_INFO=
WITHOUT_IPFILTER=
WITHOUT_IPFW=
WITHOUT_LEGACY_CONSOLE=
WITHOUT_NCP=
WITHOUT_PORTSNAP=
WITHOUT_PPP=
WITHOUT_ROUTED=

c)HINT:Install "screen". Screen creates virtual terminals which you can detach and reconnect without loss of content or process output...
For example you can run the compilation in virtual terminal, detach terminal so switch back to normal shell, do your work and time to time switch to virtual terminal to check the process status. You can do the same with ssh connection, open terminal, run command, log off and another day log in back to remote machine, reconnect to virtual terminal and continue with work.
cd /usr/ports/sysutils/screen
make install clean

Usage example:
I want to create virtual terminal with name "MCBSD": screen -S MCBSD
I do something in new terminal and I want to switch back to normal shell:
Ctrl+a+d - this is for detach
I want to list the running terminals: screen -ls
I want to reconnect back to MCBSD terminal: screen -r MCBSD
I'm in the MCBSD terminal and want to terminate this terminal because I don't need it anymore: Ctrl+d

d)Edit "make.conf" to not to compile modules.

4. Compilation of your own kernel/world
-do a backup of config files
cd /usr/src
make buildworld
make buildkernel KERNCONF=[your_kernel]
make installkernel KERNCONF=[your_kernel]
-reboot to single user mode. On boot screen option something like "boot prompt". Type: "boot -s"
mount -a
cd /usr/src
mergemaster -p - leave everything in tmp folder
make installworld
mergemaster - leave everything in tmp folder
-Check differences between tmp and current files.
-manually copy files from tmp folder to final destination if needed.
make delete-old
make delete-old-libs - be careful, google first about it or don't do it
reboot
-if everything works fine, done
-You can reinstall all your ports, this is what I do.

 5. Reinstall ports/packages
It's not necessary if everything goes well. But I do it.
HINT:Install "portmaster". You will need it anyway (or another port-mgmt).
cd /usr/ports/ports-mgmt/portmaster
make install clean
man portmaster

To reinstall all ports with creating packages after compilation which saves time further. Will write about.
portmaster -a -f -g
Packages are stored in "usr/ports/packages".

Now you have fresh system waiting to be backed-up.
This is perfect stage when you can do a backup of whole system.
Every time you will need to install or reinstall computer/server or create new server or even a jail, you will do a restore and in few minutes(bit longer) you have a fresh system ready to go.


š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.

nedeľa 19. februára 2012

Ports install/deinstall and upgrade

As I mentioned before, there are two ways of "installing" ports.
One way is via "pkg_add" with "-r" parameter which fetches pre-compiled package from a public server. Check previous article. Without "-r" option, package is installed from hard drive, so you have to download package manually. Benefit of doing it this way is speed.
Second way is via compilation of source code. Search for package you want, go to relevant directory in ports tree and type "make install clean". This means shorten version to include three commands: "make"+"make install"+"make clean".
Every port can have additional parameters to be compiled with.
For example original port "cvsup" can be compiled with/without X11 support. To show additional parameters type:
make showconfig


To configure parameters type: "make config". Or to reset parameters and start again type: "make rmconfig".
To find more option look into "man ports". 

To upgrade installed ports, I use "portmaster". It's very efficient and quick tool to upgrade ports. You can check in handbook, there are many ways how to do that but I prefer this one.
Do "make install clean" in ".../ports/ports-mgmt/portmaster/". 
In manbook, there is a lot of options that are useful in case of automatized update or so. 
Basically I use two options: "-L" and "-a". 
First one shows installed ports and available updates if any and second updates all ports which have update available. 


Do deinstall ports, three basic options exists. 
1. Use "make deinstall clean" in relevant port directory.
2. Use "pkg_delete". "-r" for dependencies remove and "-n" for dry run so you can see what will happen if...
3. Install "pkg_cutleaves" and check man. This one is useful to safely remove ports with dependencies. Quite interactive.