Friday, April 20, 2007

Update FreeBSD And System

For this tutorial you should know about freebsd, howto create and edit files,howto install files from the ports and at least some basic knowledge.There are other tutorials here that will describe lots of other stuff as well.You need to run most of the commands as root user for those who don’t know it.In this tutorial i show you how to update your sources and rebuild your kerneland then i show you howto update your ports.Everything behind the # is a command in the shell.I don’t take any responsibility if there goes something wrong.I tested this tutorial more then once and use it by my day to day work.For FreeBSD 4.x and FreeBSD 5.x
sometimes there is need or sometimes you just want to keep your system up-to-date.For this you need a tool called ‘cvsup’, which you can install from the ports.Most of the time you don’t need a GUI on a server so we install ‘cvsup-without-gui’.
You can find it under
/usr/ports/net/cvsup-without-gui
1. Installation of cvsup-without-gui
# cd /usr/ports/net/cvsup-without-gui# make install clean
After the installation of that program you need to create a supfile.If you can not use or find cvsup after installation just reload your shell or logoffand log back in again then it should work.You can create this file on any place you like. Most of the time it’s create in /tmp or /root.Some admin’s empty there /tmp automaticly after every reboot.
In this example i will update a 4.9-release.
First we create the supfile.
# touch /tmp/4.9-supfile

Then edit the file with an editor of your choice like vi,nano or pico and write in the following:
*default host=CHANGE_THIS.FreeBSD.org*default base=/usr*default prefix=/usr*default release=cvs tag=CHANGE_THIS*default delete use-rel-suffix*default compresssrc-all
A list of cvsup-hosts can be found here. (example. cvsup.ie.FreeBSD.org)http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html#CVSUP-MIRRORS#
A lift of cvs-tags can be found here. (example: RELENG_4_9_0_RELEASE)http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvs-tags.html
The file looks then like the following:
*default host=cvsup.ie.FreeBSD.org*default base=/usr*default prefix=/usr*default release=cvs tag=RELENG_4_9_RELEASE*default delete use-rel-suffix*default compresssrc-all
Source Tree updateTo update your Source-Tree use the following command:
# cvsup -g -L 2 /tmp/4.9-supfile
This can take a while, especially with slow internet lines like isdn or dsl.When you got the source we can start with the update-process.
DON’T FORGETT THERE CAN ALMOST GO SOMETHING WRONG SO SAVE YOUR FILES -> BACKUP !!!
Build the world new


Change to the Folder
/usr/src
and type in the following command
# make buildworld
Go and get a coffe or like we in ireland go and get a tea. It can take some hours withold and slow machines before the “world” has been finished. When the buildworld processwas finished without any error we have to build a new kernel.
Build new Kernel


Copy the original Kernel Configuration File GENERIC:
# cp /usr/src/sys/i386/conf/GENERIC /usr/src/sys/i386/conf/MYKERNEL
If you want you can edit your kernelconfig (MYKERNEL)
Explanations for all the Options can be fond here.
English Handbook:http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
Change to the folder
/usr/src
Type in the following command:
# make buildkernel KERNCONF=MYKERNEL
and then after this is finished
# make installkernel KERNCONF=MYKERNEL
if you want you can write this all in one command:
# make buildkernel KERNCONF=MYKERNEL && make installkernel KERNCONF=MYKERNEL
Only insert your kernelconfiguration name (example. MYKERNEL).There is no need to put in any path he will find the file by himself.After the building of the kernel your computer needs to be restarted to loadthe new kernel, preferably in singleuser mode.(if you dont know how to get here read the handbook)When you update from 4.x to 5.x you must restart your computer with the singleuser mode.When you only do a make world that is only doing the Security Branch then youdon’t have to go to the singleuser mode.
Mergemaster run


# mount -a (only if you are in the singleuser mode)# cd /usr/src
then type
# make installworld
Here again after all that work we should go and get a cup of tea.When this is finished we can go on with the following commands.
# mergemaster
and after that
# mergemaster -p
To explain all the options there the tutorial would explode.You should have a look in the manpage to find out more about that.Everything is normaly explained there. We are nearly finished now.If there were new devices created by mergemaster, you would have gotinformed about that. If this was required but mergemaster hasn’t doneit properly just go to /dev and type in
# sh MAKEDEV all
If this is all done reboot your system back to normal mode and you got anup-to-date FreeBSD 4.9-Release!In the next part we go to update our ports.
2. Ports-update


First of all we create a new supfile
# touch /tmp/ports-supfile
Then edit the file with an editor of your choice like vi, nano or pico andput in the following information.
*default host=CHANGE_THIS.FreeBSD.org*default base=/usr*default prefix=/usr*default release=cvs tag=.*default delete use-rel-suffix*default compressports-all
A list of all cvsup-hosts can be found here again.http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html#CVSUP-MIRRORS
The file should look then like the following.
*default host=cvsup.ie.FreeBSD.org*default base=/usr*default prefix=/usr*default release=cvs tag=.*default delete use-rel-suffix*default compressports-all
Ports Tree Update


Now there comes the actual update. To update the ports now type the following.
# cvsup -g -L 2 /tmp/ports-supfile
This can take now a while again depending on what internet connection you got.
Now you start the update of the INDEX DB.
# portsdb -Uu
change then to the folder
/usr/ports/sysutils/portupgrade
and install the port with the following command
# make install clean
after that is done start portupgrade with the Option -a
# portupgrade -a
This can take now a while again depending on how fast your internet and yourcomputer is.Thats all then what we have todo
Original file written by Bummibaer in german and translation from marvin. I have no problem if you wanna link to that page or if you copy it to somewhere else but please leave the copyright information.

No comments: