Upgrading Jails after upgrading FreeBSD8?

Thorny

Developer
Hello,

i've upgraded my system from 8.0 RC2 to RC3. After completing the update, i checked my jails and after the login, every jail tolds me, that it is currently RC3. Is there no more update process for the jails needed?

Greetings,
Torsten
 
A jail has it's own base os, so yes, you will need to update those as well.

How you do that depends largely on how you've setup your jails.
 
I followed the instruction from the handbook: http://www.freebsd.org/doc/en/books/handbook/jails-build.html

I also read some articles about upgrading the jails after an freebsd-update, but there were no articles about new versions.

Also i've already upgraded the root instance and now every jail says its also RC3. Everything is running fine.

Therefor my question: Is this just an "accident". Do i need an upgrade of the jails after upgrading the root from 8.0 RC2 to RC3. If yes, is there a new description of the upgrade process?
 
How do you ascertain that the jail is RC3? Uname, perhaps? That shows the base OS's kernel version, I think.
 
DutchDaemon said:
How do you ascertain that the jail is RC3? Uname, perhaps? That shows the base OS's kernel version, I think.
It does. Uname doesn't tell you anything about the versions of the userland tools.
 
DutchDaemon said:
How do you ascertain that the jail is RC3? Uname, perhaps? That shows the base OS's kernel version, I think.

The welcome message after login told me ;)

I tried uname:
Code:
# uname -v
FreeBSD 8.0-RC3 #0: Tue Nov 10 06:35:19 UTC 2009     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
 
The welcome message (a.k.a. motd) reads the base OS's kernel, so that's the 'RC3' you see. It holds no information about the jails' OS versions.

/etc/rc.d/motd

Code:
uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,'
 
As stated: uname queries the kernel, of which there is only one, the one running the entire system (i.e. base OS and all jails in it)..
 
Upgrading jails is actually covered in the handbook. Unfortunately, as I believe has been discussed here before, there's really no easy way to identify a 'world' version and whether it matches up with your kernel. If in doubt, update the the jails anyway.

Tip: use
Code:
mergemaster -U
if you upgrade world semi-frequently. Huge time saver.

Alternatively, ezjail is supposed to handle this stuff for you at the cost of a little more disk space. I don't use it because I only run 1 jail.
 
anomie said:
@Thorny: if you haven't specifically updated your jails, they weren't updated, period. :)

Since you rebuilt world on the host system, feel free to try my script for updating jails. (Back up first.)

Thanks for the script. I have problems with it. It aborts with
Code:
Shut down all Jails and try again. Exiting...

Ok, the code says:
Code:
JCHK1=$(jls)

if [ -n "${JCHK1}" ] ; then
  echo 'Shut down all Jails and try again. Exiting...'
  exit 1
fi
if i remember correctly, a "jls" at FreeBSD 7 without running jails was empty. On FreeBSD 8 it returns:
shiva# jls
JID IP Address Hostname Path
so it's not empty. but i am not good enough in shell-scripting to work around this. so i will skip this line for the update ;)
 
Oof, sorry. I should have mentioned that I don't have a FBSD 8 system to test on. I believe DutchDaemon's change should get you going.

You are also going to need the very handy sysutils/cpdup port if you haven't already installed it.
 
Thanks for the script and the workaround.

I've running the script, but it takes too long. I have 10 Jails and there cumulated size is around 1 TB. cpdup takes just to long for this. And it makes not too much sense, if i already have backups ;)

So i wrote a script myself inspired by the one of anomie. It determine the jails automatically, stop the jails, update them and start them after updating them. User interaction is just needed for the merging of the config-files.
Also i support the "-j" parameter for "make installworld", but i'm not sure, if this is really used.

I also have extra output and questions to the user, to make the risk clear and to remeber the imported things before such an upgrade.

I would be glad, if you can have a look at it. Also have a look at the output - my english is not the best.

Link to version with color - it's really easier to read: http://www.meisterderspiele.de/upgrade-jails-thorny.html
Without color: ;)
Code:
#!/bin/sh

# Author: Torsten Zuehlsdorff
# Date  : 2009-11-13
# Contact: [email]foo@meisterderspiele.de[/email] 
# (add NOSPAM to subject, german mailfilters mistrust english language ;) )
# Tested with FreeBSD 8.0

# See copyright at bottom of script

#############################
### config section: start ###
#############################

NumOfJobsForMake=4 

###########################
### config section: end ###
###########################

echo "this script updates ALL jails!"
echo "this is dangerous and can cause REAL DAMAGE"
echo "make sure that you REALLY HAVE AN ACTUAL BACKUP!"
echo "do you HAVE AN ACTUAL BACKUP?"
echo "[yes|no]"

read BackupRequest

if [ "yes" != "$BackupRequest" ] ; then
  echo "come back if an actual backup exists ;)"
  exit 1
fi

echo ""
echo "please make sure, that you've alreay rebuild you world:"
echo "# cd /usr/src && make cleanworld && make buildworld"
echo "is the world already rebuild?"
echo "[yes|no]"
read IsWorldRebuilded

if [ "yes" != "$IsWorldRebuilded" ] ; then
  echo "rebuild the world and re-run the script"
  exit 1
fi

echo ""
echo "please make sure, that the update runs within a screen (port: sysutils/screen)"
echo "if you're session crash during a backup, the jails will be in an broken state"
echo "screen will reduce this risk"
echo "are you running the script in screen? (you're free to lie and hope)"
echo "[yes|no]"
read RunningInScreen

if [ "yes" != "$RunningInScreen" ] ; then
  echo "start again, if you're running the script within screen"
  exit 1
fi

# set pathes
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

# get a list of all pathes to the jails
echo "Get list of all jails"
JailList=$(jls -a | grep -v "^   JID" | awk '{ print $4 }')

# shutdown the jails for the update
echo "stop the jails"
/etc/rc.d/jail stop

# check if all jails are stopped
CheckJailShutdown=$(jls | grep -v "^   JID")

if [ -n "$CheckJailShutdown" ] ; then
  echo "Error: not all jails are stopped"
  exit 1
fi


echo "start updating the jails"

# iterate through jail list and update every one
for JailPath in ${JailList} ; do

  # check if the given path to the jail exists
  if [ ! -e ${JailPath} ] ; then
    echo "given path to jail do not exists: {$JailPath}"
    echo "Skipping the jail - hit any key to continue"
    read SkipMessage
    continue
  fi
  
  # upgrade the world of the jail
  echo "start install world for $JailPath"
  cd /usr/src && make -j $NumOfJobsForMake installworld DESTDIR=${JailPath}
  echo "finish install world for $JailPath"
  
  # merge the old config-files of the jails with their new versions
  echo "prepare for merging various config files for $JailPath"
  echo "hit any key to continue"
  read StartMerging
  
  mergemaster -iU -D ${JailPath}
  
  echo "finish merging the files for $JailPath"
  echo "hit any key to proceed with the next upgrade"
  read ProceedWithUpgrade
  
done

echo "finish upgrading the jails"
echo "starting the jails"

/etc/rc.d/jail start

echo "finish starting the jails"

echo "all done"

exit 0

# ---------------------------------
#  Copyright (c) 2009 Torsten Zuehlsdorff
#  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#  1. Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#  2. Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
#  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
#  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
#  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
#  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#  SUCH DAMAGE.
 
@Thorny: I didn't test your script, but it looks pretty good. :)

The English is "close enough" (i.e. it isn't going to baffle anyone).
 
In Handbook it's written that after upgrade a jail must be rebuild totally although it looks like after system upgrade it's enough to
Code:
#cd /usr/src
#make installworld DESTDIR=/path/to/jail
I also have a question but it's better to place it in new thread...
 
Back
Top