Sometimes for peace of mind it is safer to go though an upgrade in a chroot environment first. This enables one to work out any potential issues which may arise while performing the upgrade.
For this scenario I have the following configuration:
* Main system is running Debian Wheezy (7.0)
* System to be upgraded is running Debian Squeeze (6.0) the obsolete Stable release
* Steps performed here are as the ‘root’ user
First do a df to see how much space you have:
df -m
Filesystem 1M-blocks Used Available Use% Mounted on
rootfs 4290 262 3809 7% /
udev 10 0 10 0% /dev
tmpfs 330 1 329 1% /run
/dev/mapper/myvg-root 4290 262 3809 7% /
tmpfs 5 0 5 0% /run/lock
tmpfs 660 1 659 1% /run/shm
/dev/sda1 228 19 197 9% /boot
/dev/mapper/myvg-home 161270 104626 48452 69% /home
/dev/mapper/myvg-tmp 5328 12 5044 1% /tmp
/dev/mapper/myvg-usr 8446 4784 3234 60% /usr
/dev/mapper/myvg-var 2816 2066 607 78% /var
/dev/mapper/myvg-opt 8064 1086 6569 15% /opt
As you can see above, there is just under 50GB free in the /home mounted file system. This would be a good place to place the chroot and do a test upgrade.
* Create the directory for the chroot environment
mkdir /home/chroot/squeeze
* Ensure you have debootstrap installed
dpkg --get-selections |grep debootstrap
If debootstrap isn’t installed, then install it with apt-get install debootstrap
* Create environment variable for the chroot directory
CHROOT=/home/chroot/squeeze/
* Install squeeze 32-bit using the appropriate mirror
debootstrap --arch i386 squeeze $CHROOT http://debian.mirror.rafal.ca/debian/
* Modify your ssh configuration to allow ROOT login access (temporarily) in order to transfer the squeeze system into your chroot (or use another viable method) and then HUP the process for sshd
sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
ps -ef |grep [s]shd | awk '{print "kill -HUP " $2}' | sh
* Next login to your server which is running squeeze and change to the root directory
ssh testserver01
cd /
* Now transfer all of the appropriate directories into your newly created change root environment (you may have additional ones)
( tar -cf - ./bin ./boot ./cdrom ./dev ./etc ./home ./initrd.img ./lib ./media ./mnt ./opt ./sbin ./selinux ./srv ./sys ./usr ./var ./vmlinuz ) | ( ssh root@targetmachine 'cd /home/chroot/squueze && tar -xvf - ' )
* Next create some bind mounts for some key file systems
mount --bind /proc $CHROOT/proc
mount --bind /sys $CHROOT/sys
mount --bind /dev $CHROOT/dev
mount --bind /dev/pts $CHROOT/dev/pts
* Switch to your chroot environment
chroot $CHROOT
* Update your sources.list
sed -i 's/squeeze/wheezy/g' /etc/apt/sources.list
* start script so it keeps a log of the upgrade process, in particular the errors
script -t 2>/test.timing -a /test.log
* Perform an update and then upgrade it
apt-get update
apt-get dist-upgrade
* If all was successful, leave the chroot environment exit
* Don't forget to disable root logins on your local machine (if you followed the ssh steps above)