HOWTO: FreeBSD Binary Upgrade (base system + packages)

Would you like to share some of your solutions for certain problems? Tips or tricks? Post here. All new topics are automatically moderated.

HOWTO: FreeBSD Binary Upgrade (base system + packages)

Postby vermaden » 13 Sep 2010, 09:49

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

;)
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
[FILE][color="DarkSlateBlue"]http://vermaden.blogspot.com[/color][/FILE]
User avatar
vermaden
Giant Locked
 
Posts: 2316
Joined: 16 Nov 2008, 19:37
Location: pl_PL.lodz

Postby psycho » 13 Sep 2010, 12:52

great how-to, like usual...
Hiroshima '45 - Tschernobyl '86 - Windows '95 - Psycho '10
psycho
Member
 
Posts: 128
Joined: 03 Oct 2009, 06:08
Location: universe

Postby graudeejs » 13 Sep 2010, 15:20

fix: s/probable/probably/ at the end of post

Nice howto
User avatar
graudeejs
Style(9) Addict
 
Posts: 4591
Joined: 16 Nov 2008, 23:23
Location: Riga, Latvia

Postby surgeon » 15 Sep 2010, 13:10

FBSD 7.3 is not supported?

Code: Select all
# 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.
surgeon
Junior Member
 
Posts: 3
Joined: 15 Sep 2010, 12:49
Location: Lubin

Postby vermaden » 16 Sep 2010, 09:27

surgeon wrote:FBSD 7.3 is not supported?


Even 7.2-RELEASE have info about upgrade using [FILE]freebsd-update[/FILE], so its definitely supported, the question is why You could not found any mirrors, any network issues?

[FILE]http://freebsd.org/releases/7.2R/announce.html[/FILE]
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
[FILE][color="DarkSlateBlue"]http://vermaden.blogspot.com[/color][/FILE]
User avatar
vermaden
Giant Locked
 
Posts: 2316
Joined: 16 Nov 2008, 19:37
Location: pl_PL.lodz

Postby surgeon » 16 Sep 2010, 11:02

vermaden wrote:the question is why You could not found any mirrors, any network issues?

Nope.

I can easily browse http://update5.freebsd.org/ and http://update4.freebsd.org/.
But not http://update.freebsd.org/.
surgeon
Junior Member
 
Posts: 3
Joined: 15 Sep 2010, 12:49
Location: Lubin

Postby Sora_ » 19 Sep 2010, 18:56

surgeon wrote:Nope.

I can easily browse http://update5.freebsd.org/ and http://update4.freebsd.org/.
But not http://update.freebsd.org/.


You just have to wait... I had the same problem and after 10 minutes i tried it again and it worked.
Sora_
Junior Member
 
Posts: 3
Joined: 18 Sep 2010, 12:23

Postby MrHien » 21 Sep 2010, 17:23

Nice tut! It working for me..
MrHien
Junior Member
 
Posts: 1
Joined: 04 Jul 2010, 09:25

Postby surgeon » 23 Sep 2010, 11:09

Maybe this is the problem?

Code: Select all
# 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? :)
surgeon
Junior Member
 
Posts: 3
Joined: 15 Sep 2010, 12:49
Location: Lubin

Postby oliverh » 23 Sep 2010, 20:53

@surgeon

Stable is development, there are no binary updates for it.
What was the goal of the Linux community--to replace Windows? One can imagine higher aspirations., Bill Joy
User avatar
oliverh
Member
 
Posts: 557
Joined: 16 Nov 2008, 19:21
Location: 127.0.0.1

Postby vermaden » 23 Sep 2010, 21:02

surgeon wrote: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).
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
[FILE][color="DarkSlateBlue"]http://vermaden.blogspot.com[/color][/FILE]
User avatar
vermaden
Giant Locked
 
Posts: 2316
Joined: 16 Nov 2008, 19:37
Location: pl_PL.lodz

Postby hansivers » 26 Sep 2010, 08:11

vermaden wrote: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?
hansivers
Junior Member
 
Posts: 34
Joined: 18 Nov 2008, 22:03
Location: Quebec, Canada

Postby vermaden » 26 Sep 2010, 17:48

hansivers wrote:@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 [FILE]/usr/local/etc[/FILE] directory.
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
[FILE][color="DarkSlateBlue"]http://vermaden.blogspot.com[/color][/FILE]
User avatar
vermaden
Giant Locked
 
Posts: 2316
Joined: 16 Nov 2008, 19:37
Location: pl_PL.lodz

Postby hansivers » 27 Sep 2010, 14:34

vermaden wrote:... but the 0. step BACKUPS the [FILE]/usr/local/etc[/FILE] 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!
hansivers
Junior Member
 
Posts: 34
Joined: 18 Nov 2008, 22:03
Location: Quebec, Canada

Postby vermaden » 27 Sep 2010, 15:00

hansivers wrote: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: Select all
# cd /usr/local
# ls | grep -v etc | while read I; do rm -r -f "${I}"; done
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
[FILE][color="DarkSlateBlue"]http://vermaden.blogspot.com[/color][/FILE]
User avatar
vermaden
Giant Locked
 
Posts: 2316
Joined: 16 Nov 2008, 19:37
Location: pl_PL.lodz

Postby hbokh » 07 Nov 2010, 18:52

[color="Red"]Be very careful![/color] 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.).
User avatar
hbokh
Junior Member
 
Posts: 10
Joined: 17 Nov 2008, 19:55
Location: GRN, NL

Postby vermaden » 08 Nov 2010, 05:57

@hbokh

HOWTO creator assumes that You KNOW what You are doing ...
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
[FILE][color="DarkSlateBlue"]http://vermaden.blogspot.com[/color][/FILE]
User avatar
vermaden
Giant Locked
 
Posts: 2316
Joined: 16 Nov 2008, 19:37
Location: pl_PL.lodz

Postby freeck » 04 Jan 2011, 17:21

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

Code: Select all
root # while read PKG; do pkg_add -r $( basename ${PKG} ); done < /root/packagelist
freeck
Junior Member
 
Posts: 1
Joined: 28 Dec 2010, 19:16

Postby vermaden » 05 Jan 2011, 09:30

@freeck

You need to use POSIX [FILE]sh(1)[/FILE] compatible for these commands.
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
[FILE][color="DarkSlateBlue"]http://vermaden.blogspot.com[/color][/FILE]
User avatar
vermaden
Giant Locked
 
Posts: 2316
Joined: 16 Nov 2008, 19:37
Location: pl_PL.lodz

Postby sinbad » 28 Jul 2012, 15:33

oppps.
I'm getting "Illegal variable name" when tryiing step 4
Code: Select all
#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.
sinbad
Junior Member
 
Posts: 9
Joined: 28 Jul 2012, 15:23

Postby vermaden » 28 Jul 2012, 19:18

Both csh/tcsh are C-shells, use sh/zsh/fish/ksh/bash which are Bourne Shells.
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
[FILE][color="DarkSlateBlue"]http://vermaden.blogspot.com[/color][/FILE]
User avatar
vermaden
Giant Locked
 
Posts: 2316
Joined: 16 Nov 2008, 19:37
Location: pl_PL.lodz

Postby sinbad » 28 Jul 2012, 20:39

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: Select all
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: Select all
while read PKG ; do pkg_add -r $( basename ${PKG} ) ; done < /root/packagelist


Any ideas what I can try?
thanks again.
sinbad
Junior Member
 
Posts: 9
Joined: 28 Jul 2012, 15:23

Postby sinbad » 28 Jul 2012, 21:53

Forget the upgrade. I was stupid enough to delete my [file]www[/file] dir which was inside [file]/usr/local[/file]. 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.
sinbad
Junior Member
 
Posts: 9
Joined: 28 Jul 2012, 15:23

Postby wblock@ » 29 Jul 2012, 03:39

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.
User avatar
wblock@
Old Fart
 
Posts: 10167
Joined: 07 Sep 2009, 23:23
Location: Milky Way galaxy


Return to Howtos & FAQs (Moderated)

Who is online

Users browsing this forum: No registered users and 1 guest