Differences between revisions 19 and 20
Revision 19 as of 2017-08-15 11:19:48
Size: 7512
Editor: MichaelPaoli
Comment: Caveats and Known Problems, e.g.: iamerican /var/lib/ispell/american.hash issue
Revision 20 as of 2017-08-30 02:51:23
Size: 8385
Editor: PaulWise
Comment: more recent cross-grading articles
Deletions are marked like this. Additions are marked like this.
Line 105: Line 105:
 * Articles by Jose M. Calhariz:
   * [[http://blog.calhariz.com/post/2017/07/12/Crossgrading-the-kernel-in-Debian-9|Crossgrading the kernel in Debian 9]]
   * [[http://blog.calhariz.com/post/2017/07/12/Crossgrading-a-minimal-install-of-Debian-9|Crossgrading a minimal install of Debian 9]]
   * [[http://blog.calhariz.com/post/2017/07/13/Crossgrading-a-more-typical-server-in-Debian9|Crossgrading a more typical server in Debian 9]]
   * [[http://blog.calhariz.com/post/2017/07/16/Crossgrading-a-complex-Desktop-and-Debian-Developer-machine-running-Debian-9|Crossgrading a complex Desktop and Debian Developer Machine running Debian 9]]
   * [[http://blog.calhariz.com/post/2017/07/30/Crossgrading-a-complex-Desktop-and-Debian-Developer-machine-running-Debian-9%2C-another-try|Crossgrading a complex Desktop and Debian Developer Machine running Debian 9, for real]]

Translation(s): none

Cross-grading a Debian System

This page is meant to document the procedure for cross-grading a Debian install using Multiarch.


The first Debian release to feature Multiarch is Wheezy, so you will need to upgrade before attempting the procedure described here.

A full backup is also strongly recommended as this procedure is still very much work in progress. Reinstalling is still the safer option. You have been warned!


These are the steps for converting an i386 install to amd64, but they should be applicable for any other architecture pairs if your machine can run both (e.g. armel and armhf). You can use arch-test to determine which Debian architectures your system can run. You can install qemu-user-static add support for more Debian architectures.

Add the new architecture

# dpkg --print-architecture
# dpkg --add-architecture amd64
# dpkg --print-foreign-architectures
# apt-get update

Install a kernel that supports both architectures in userland

# apt-get install linux-image-amd64:amd64
# reboot

Make sure you are actually running the new kernel before proceeding with the next steps (uname -a).

Crossgrade `dpkg` `tar` and `apt`

Get all the packages needed to replace dpkg, tar and apt, then install them for the new architecture. It is changing dpkg that actually 'counts' for changing the default arch. Tar has to be replaced with dpkg, not apt otherwise it gets removed then there is no tar to put the new one back with. You need to upgrade first (or otherwise check all the versions of packages to be crossgraded in this step) to make sure all amd64/i386 packages are in version-sync otherwise the cross-grade will break.

# apt-get clean
# apt-get upgrade
# apt-get --download-only install dpkg:amd64 tar:amd64 apt:amd64
# dpkg --install /var/cache/apt/archives/*_amd64.deb
# dpkg --print-architecture
# dpkg --print-foreign-architectures

If you got this far you are now effectively running amd64, but with mostly i386 packages. You can try to replace them with the corresponding amd64 packages. If that doesn't work (not all libraries will necessarily have been converted to Multiarch yet) it should be possible to remove the i386 package and install the amd64 version instead.

One rather brutal way to do the swap is

dpkg --get-selections | grep :i386 | sed -e s/:i386/:amd64/ | dpkg --set-selections
apt-get -f install

You will have to type in 'Yes, do as I say' to get apt to do this.

Caveats and Known Problems

Apt dependency resolver generates broken solutions

It might happen that apt's resolver emits an unworkable solution:

E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

In this case you can inspect what packages are marked as Broken and decide what to do:

apt -o Debug::pkgProblemResolver=1 -f install


The KDE desktop environment creates the file ~/.config/Trolltech.conf which contains locations of shared libararies and, more problematic, their architecture. This causes panel widgets to crash. The file can apparently be safely removed or renamed to fix these problems.

iamerican (and possibly others/similar)

Similar to KDE, some package(s) (e.g. iamerican on at least Debian 7.5) may have saved caches/hashes that need updating. E.g. encountered:

$ echo foo | spell
/usr/bin/ispell: Illegal format hash table

corrected with:

# (cd / && umask 022 && dpkg-reconfigure iamerican)

which then caused updating of: /var/lib/ispell/american.hash


Sample cross-grade script

Here is a script to essentially do the above for you. It could do with some work to put in a lot more error checking, but it works OK on a build-essential basic chroot - you may have problems on a more fully-configured real system. Use at your own risk!

# scary script to crossgrade your debian machine between arches.
# usage crossgrade <final-architecture>
set -e

if [ -z "$1" ]; then
  echo "Usage: crossgrade <architecture>  (debian architecture to convert to)"
  exit 1

#validate arch
if ! TO=$(dpkg-architecture -qDEB_HOST_ARCH -a$1); then
    echo "$1 is not a recognised architecture name"
    exit 1
FROM=$(dpkg --print-architecture)
echo "Crossgrading from $FROM to $TO"

#check for a compatible kernel
# should check $FROM and $TO harder
# allow for switching kernel over too to minimal one if requested?
case $TO in
dpkg --add-architecture $TO
# check that dpkg --print-foreign-architectures is $TO
apt-get update
apt-get upgrade

# Install a kernel capable to run the new architecture with the old
# architecture in userspace

KERNEL=$(uname -m)
echo "Current kernel arch is $KERNEL"
if [ "$KERNEL" != "$TO_KERN" ]; then
    if apt-get install linux-image-$TO:$TO; then
        echo "There should be a reboot here"
        echo "kernel updating to linux-image-$TO:$TO failed"

#Crossgrade dpkg and apt
apt-get clean
apt-get --download-only install dpkg:$TO apt:$TO

#check ever package to be installed is available in same version for amd64 if installed (multiarch sync is needed)
#for pkg in /var/cache/apt/archives/*_$TO.deb
#    file=$(basename $pkg)
#    pkgname= ${file%%_.*}
#    version= ${file##*._} 
#    if dpkg -l $($pkgname)
#in practice this needs to run twice (do it more? is there a better way?)
if ! dpkg --install /var/cache/apt/archives/*_$TO.deb; then
    dpkg --install /var/cache/apt/archives/*_$TO.deb

test $(dpkg --print-architecture) = $TO

test $(dpkg --print-foreign-architectures | grep $FROM) = $FROM

echo "Yay! dpkg and apt crossgrade completed successfully"
echo "Updating core packages"
apt-get -f install