HOWTO: FreeBSD Binary Upgrade (base system + packages)

vermaden

Son of Beastie

Reaction score: 1,144
Messages: 2,748

There are many ways to upgrade FreeBSD along with installed packages to the newest version(s), most of them include compilation (buildworld/portmaster), this HOWTO will provide simple and fast way to upgrade FreeBSD system without needless compilation.

Upgrade if the base system is relatively easy, its about to type 4 commands, read and UNDERSTAND on screen comunicates, if it goes to packages, we will use the fact, that all packages are build to newest version along with newest *-RELEASE version.

0. CONFIGURATION BACKUP (rather not needed, but ...)
[font="Courier New"]root # tar -czf /root/ETC.tar.gz /etc /usr/local/etc[/font]

1. BASE SYSTEM UPGRADE (I assume that 8.1-RELEASE is the current latest version)
[font="Courier New"]root # freebsd-update upgrade -r 8.1-RELEASE[/font]
[font="Courier New"]root # freebsd-update install[/font]
[font="Courier New"]root # shutdown -r now[/font]
[font="Courier New"]root # freebsd-update install[/font]

While doing the base system procedure we will be asked for installed 'datasets' and about modifications in config files, we only need to read and UNDERSTAND the on screen comunicats.


2. PACKAGES UPGRADE
[font="Courier New"]root # pkg_info -qoa | sort > /root/packagelist[/font]
[font="Courier New"]root # pkg_delete -a -f[/font]
[font="Courier New"]root # rm -r -f /boot/modules /usr/local /var/db/pkg[/font]
[font="Courier New"]root # while read PKG; do pkg_add -r $( basename ${PKG} ); done < /root/packagelist[/font]

At this point all old packages have been removed, and latest pacakges have been installed on their place, it works automatically, unless port nam has changed, like with VirtualBox, when its port name changed from emulators/virtualbox into emulators/virtualbox-ose, so the only 'risk' here, is that some packages will not be added automatically.


2.1. SEARCHING FOR MISSED PACKAGES
[font="Courier New"]root # pkg_info -qoa | sort > /root/packagelist.NEW[/font]
[font="Courier New"]root # diff -u /root/packagelist*[/font]

This way is probably the fastest and easiest to find missed packages.


3. CLEANUP
[font="Courier New"]root # rm -r -f /root/packagelist*[/font]
[font="Courier New"]root # rm -r -f /root/ETC.tar.gz[/font]

If we had made some bigger changes in the configuration, we may keep the old configuration (/root/ETC.tar.gz).

;)
 

surgeon

New Member


Messages: 3

FBSD 7.3 is not supported?

Code:
# freebsd-update upgrade -r 8.1-RELEASE
Looking up update.FreeBSD.org mirrors... 4 mirrors found.
Fetching public key from update4.FreeBSD.org... failed.
Fetching public key from update5.FreeBSD.org... failed.
Fetching public key from update2.FreeBSD.org... failed.
Fetching public key from update3.FreeBSD.org... failed.
No mirrors remaining, giving up.
 
OP
OP
vermaden

vermaden

Son of Beastie

Reaction score: 1,144
Messages: 2,748

surgeon said:
FBSD 7.3 is not supported?
Even 7.2-RELEASE have info about upgrade using freebsd-update, so its definitely supported, the question is why You could not found any mirrors, any network issues?

http://freebsd.org/releases/7.2R/announce.html
 

surgeon

New Member


Messages: 3

Maybe this is the problem?

Code:
# freebsd-update upgrade -v debug -r 8.1-RELEASE
Looking up update.FreeBSD.org mirrors... 4 mirrors found.
Fetching public key from update4.FreeBSD.org... fetch: http://update4.FreeBSD.org/7.3-STABLE/amd64/pub.ssl: Not Found
failed.                         
Fetching public key from update5.FreeBSD.org... fetch: http://update5.FreeBSD.org/7.3-STABLE/amd64/pub.ssl: Not Found
failed.                         
Fetching public key from update2.FreeBSD.org... fetch: http://update2.FreeBSD.org/7.3-STABLE/amd64/pub.ssl: Not Found
failed.                         
Fetching public key from update3.FreeBSD.org... fetch: http://update3.FreeBSD.org/7.3-STABLE/amd64/pub.ssl: Not Found
failed.                         
No mirrors remaining, giving up.
There is no 7.3-STABLE dir. Only 7.3-RELEASE. So, where to repair that? :)
 

oliverh

Aspiring Daemon

Reaction score: 38
Messages: 557

@surgeon

Stable is development, there are no binary updates for it.
 
OP
OP
vermaden

vermaden

Son of Beastie

Reaction score: 1,144
Messages: 2,748

surgeon said:
There is no 7.3-STABLE dir. Only 7.3-RELEASE. So, where to repair that? :)
As You built *-STABLE by hand, You must now rebuilt it by hand into *-RELEASE.

You may of course stay 'STABLE' and update packages only, as step 2. and later will work as advertised (if I recall correctly packages for *-STABLE are rebuild wvery week).
 

hansivers

Member

Reaction score: 5
Messages: 35

vermaden said:
2. PACKAGES UPGRADE
[font="Courier New"]root # pkg_info -qoa > /root/packagelist[/font]
[font="Courier New"]root # pkg_delete -a -f[/font]
[font="Courier New"]root # rm -r -f /boot/modules /usr/local /var/db/pkg[/font]
[font="Courier New"]root # while read PKG; do pkg_add -r $( basename ${PKG} ); done < /root/packagelist[/font]
@Vermaden :

Many thanks again for your very informative post.

If my understanding of your script is correct, the removal of /usr/local directory (3rd line) will destroy all modifications to packages config files in /usr/local/etc. So, the admin will have to retype again all these modifications AFTER installation of newest packages. Would have been more efficient just to keep /usr/local/etc directory untouched, to provide the newest packages with the personalized version of config files?
 
OP
OP
vermaden

vermaden

Son of Beastie

Reaction score: 1,144
Messages: 2,748

hansivers said:
@Vermaden :

Many thanks again for your very informative post.

If my understanding of your script is correct, the removal of /usr/local directory (3rd line) will destroy all modifications to packages config files in /usr/local/etc.
... but the 0. step BACKUPS the /usr/local/etc directory.
 

hansivers

Member

Reaction score: 5
Messages: 35

vermaden said:
... but the 0. step BACKUPS the /usr/local/etc directory.
Yes, I have noticed. My question was more about what to do after installation of newer packages. If I follow your script step by step, the older config files are not lost (because of the initial backup) but they are no longer installed in the /usr/local/etc directory.

So I understand that the admin have two possible courses of action:

a) untar the older config files in /usr/local/etc (but it will replace the newer config files, a risky operation)

b) manually merge older and newer config files (with diff or something like that?)

That why I asked previously whether it would have been more simple to just keep /usr/local/etc untouched (to avoid the manual merging).

Many thanks again for your feedback. It is much appreciated!
 
OP
OP
vermaden

vermaden

Son of Beastie

Reaction score: 1,144
Messages: 2,748

hansivers said:
That why I asked previously whether it would have been more simple to just keep /usr/local/etc untouched (to avoid the manual merging).
I have done that in 8.0 --> 8.1 step, everything worked, that that was not a critical/important machine so I would fix it without any pressure.

As for NOT deleting /usr/local/etc, something like that my be usefull:
Code:
# cd /usr/local
# ls | grep -v etc | while read I; do rm -r -f "${I}"; done
 

hbokh

New Member


Messages: 11

Be very careful! WHY do a "rm -rf" on the complete /usr/local but backup ONLY etc in that directory?
A lot of users have a whole lot of stuff in /usr/local (web-root / installers / certificates / etc.).
 
OP
OP
vermaden

vermaden

Son of Beastie

Reaction score: 1,144
Messages: 2,748

@hbokh

HOWTO creator assumes that You KNOW what You are doing ...
 

freeck

New Member


Messages: 1

I get a "variable not defined" error at this step:

Code:
root # while read PKG; do pkg_add -r $( basename ${PKG} ); done < /root/packagelist
 
OP
OP
vermaden

vermaden

Son of Beastie

Reaction score: 1,144
Messages: 2,748

@freeck

You need to use POSIX sh(1) compatible for these commands.
 

sinbad

New Member


Messages: 9

oppps.
I'm getting "Illegal variable name" when tryiing step 4
Code:
#while read PKG ; do pkg_add -r $( basename ${PKG} ) ; done < /root/packagelist
Illegal variable name.
At first I thought its because I had csh as my shell. so I changed it back to chsh -s /bin/tcsh

but the same Illegal variable name is shown.

can someone please help me? my server is down now.
 
OP
OP
vermaden

vermaden

Son of Beastie

Reaction score: 1,144
Messages: 2,748

Both csh/tcsh are C-shells, use sh/zsh/fish/ksh/bash which are Bourne Shells.
 

sinbad

New Member


Messages: 9

Thanks so much for the reply. I was able to change to sh and run the command.
problem now is that I'm getting
Code:
unable to fetch 'ftp://ftp.package' protocol error
for all the packages.

my google turn that I need to add the http:// to the url but not sure how to apply to the command
Code:
while read PKG ; do pkg_add -r $( basename ${PKG} ) ; done < /root/packagelist
Any ideas what I can try?
thanks again.
 

sinbad

New Member


Messages: 9

Forget the upgrade. I was stupid enough to delete my www dir which was inside /usr/local. Damn me so stupid.
Please add to your initial post a warning so other stupid user like myself, who don't fall in the 'know what they doing' won't *beep**beep**beep**beep* up their sites so easily.
Feels like jumping from the roof now.
 

wblock@

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 3,639
Messages: 13,850

Look at it this way:

A) It shows how valuable backups are.
B) When you recreate it, it will be better than before because of your experience.
 
Top