Differences between revisions 21 and 38 (spanning 17 versions)
Revision 21 as of 2018-01-21 11:03:05
Size: 8533
Editor: ?Joy
Comment: sectioning
Revision 38 as of 2020-12-20 15:02:02
Size: 12871
Editor: ?KevinWu
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: none-~ ~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: [[fr/CrossGrading|Français]] -~
Line 8: Line 8:

ToDo: the DebianPackage:crossgrader package entered Debian in 2020, using it should be documented on this page.
Line 27: Line 29:
# apt-get update # apt update
Line 33: Line 35:
# apt-get install linux-image-amd64:amd64 # apt install linux-image-amd64:amd64
Line 44: Line 46:
# apt-get clean
# apt-get upgrade
# apt clean
# apt upgrade
Line 53: Line 55:
# apt-get --download-only install dpkg:amd64 tar:amd64 apt:amd64 # apt --download-only install dpkg:amd64 tar:amd64 apt:amd64
## 2020-10 Debian sid: apt --download-only install dpkg:amd64 tar:amd64 apt:amd64 libsystemd0:amd64
Line 59: Line 62:
}}} # apt update
# apt upgrade
# apt full-upgrade
}}}

Notes 2020-10 Debian sid: --download-only line would need at minimum also ''libsystemd0''. If you didn't and get errors about missing libsystemd0 and can no longer run apt, you can still download and place [[https://packages.debian.org/sid/amd64/libsystemd0/download|libsystemd0]] deb in /var/cache/apt/archives/ and run the dpkg --install again to fix the system. The writer of this also needed to do the same for ''apt-utils'' and ''perl-base''. After that apt upgrade did not still work but apt install -f worked without needing to type the 'Yes, do as I say' (at this point) - but do run apt install -f from a tty, not under X/Wayland, my X crashed in the middle.
Line 65: Line 73:
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
Before a mass replacement from old to new architectures, if you have packages without installation candidates (from old releases), you may want to first try removing those with
{{{
# apt install aptitude:amd64
# aptitude purge '?obsolete'
}}}

A possible brute-force way to do the swap is
{{{
# apt install $(dpkg -l | grep '^.i.*:i386' | grep :i386 | sed -e s/:i386/:amd64/ | awk '{print $2}')
}}}
You will have to type in 'Yes, do as I say' to get apt to do this, so make sure each package in the warning is actually going to get installed with the new architecture.

Notes 2020-10: I needed to edit the list to remove the pae kernel references and then use that edited list from a file for apt install. You will experience various errors regardless. I needed to for example manually dpkg -i bash and dash, symlink /bin/sh to the existing one a couple of times, and try again and again. Do not expect not needing to do a lot of apt install -f, dpkg --configure -a, manual dpkg -i from /var/cache/apt/archives/ and apt autoremove --purge (to remove replaced :i386 binaries). However using above and these notes I ended up with a functional system and there were big portions that just ran without interruptions.

Another more brutal way to do the swap is
{{{
# dpkg --get-selections | grep '\binstall$' | grep :i386 | sed -e s/:i386/:amd64/ | dpkg --set-selections
# apt -f install
Line 72: Line 94:
Once the swap is done, you can remove all the redundant libraries and drop the old architecture with
{{{
# apt purge $(dpkg -l | grep '^.i.*:i386' | awk '{print $2}')
# dpkg --remove-architecture i386
# apt update
}}}
Line 73: Line 102:

=== Caution with systemd ===

systemd may not like being cross-graded, possibly it is safer to cross-grade it from a liveCD. Make sure to cross-grade udev at the same time, otherwise various units will fail.

=== APT dependency resolver wants to revert apt itself ===

If the system had packages that depend on apt like apt-utils, it's possible run into a situation where {{{apt -f install}}} wants to revert apt itself to i386. Aborting and doing another operation {{{apt autoremove}}} will illustrate the reason better:

{{{
The following packages have unmet dependencies:
 apt-utils:i386 : Depends: apt:i386 (= 1.4.8) but it is not installed
}}}

In such a case, the solution is to temporarily remove {{{apt-utils:i386}}} from the system, and install {{{apt-utils}}} afterwards. Note: this new apt-utils will be amd64, but once you switch apt to amd64, using the :amd64 suffix will not work.
Line 86: Line 130:
apt -o Debug::pkgProblemResolver=1 -f install # apt -o Debug::pkgProblemResolver=1 -f install
Line 107: Line 151:
== Articles == == Links ==
Line 120: Line 164:
 * [[http://dubiel.pl/Programy/debian%20cross%20grade%20from%20i386%20to%20amd64.txt|Crossgrade production system with apache, samba, fetchmail, dovecot, ftpd, hylafax, dhcpd, bind9, squid in three steps]]
 * [[https://stbuehler.de/blog/article/2017/06/28/debian_stretch__upgrade_32-bit_to_64-bit.html|Another procedure from Germany]]
 * [[https://github.com/kilobyte/crossgrade|crossgrade script by kilobyte]]
 * [[SummerOfCode2020/ApprovedProjects/ArchitectureCrossGrade|GSoC 2020 crossgrading project]]
Line 184: Line 232:
apt-get update
apt-get upgrade
apt update
apt upgrade
Line 193: Line 241:
    if apt-get install linux-image-$TO:$TO; then     if apt install linux-image-$TO:$TO; then
Line 195: Line 243:
        exit 1
Line 201: Line 250:
#Crossgrade dpkg and apt
apt-get clean
apt-get --download-only install dpkg:$TO apt:$TO
echo Crossgrading dpkg and apt
apt clean
apt --download-only install dpkg:$TO apt:$TO tar:$TO
Line 219: Line 268:
Line 223: Line 271:
Line 224: Line 273:
apt-get -f install


}}}
apt upgrade
apt full-upgrade

echo "Removing obsolete packages"
apt install aptitude:$TO
aptitude purge '?obsolete'

echo "Mass reinstalling $TO packages -- double check installed packages match warned-about packages"
apt install $(dpkg -l | grep '^.i.*:'"$FROM" | grep ":$FROM" | sed -e "s/:$FROM/:$TO/" | awk '{print $2}')

echo "Removing redundant libraries"
apt purge $(dpkg -l | grep '^.i.*:'"$FROM" | awk '{print $2}')

echo "Removing $FROM"
dpkg --remove-architecture "$FROM"
apt update

}}}

Translation(s): Français


Cross-grading a Debian System

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

ToDo: the crossgrader package entered Debian in 2020, using it should be documented on this page.

Pre-requisites

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!

Steps

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
i386
# dpkg --add-architecture amd64
# dpkg --print-foreign-architectures
amd64
# apt update

Install a kernel that supports both architectures in userland

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

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

Make sure all packages are in sync between architectures

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 clean
# apt upgrade

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.

# apt --download-only install dpkg:amd64 tar:amd64 apt:amd64
## 2020-10 Debian sid: apt --download-only install dpkg:amd64 tar:amd64 apt:amd64 libsystemd0:amd64
# dpkg --install /var/cache/apt/archives/*_amd64.deb
# dpkg --print-architecture
amd64
# dpkg --print-foreign-architectures
i386
# apt update
# apt upgrade
# apt full-upgrade

Notes 2020-10 Debian sid: --download-only line would need at minimum also libsystemd0. If you didn't and get errors about missing libsystemd0 and can no longer run apt, you can still download and place libsystemd0 deb in /var/cache/apt/archives/ and run the dpkg --install again to fix the system. The writer of this also needed to do the same for apt-utils and perl-base. After that apt upgrade did not still work but apt install -f worked without needing to type the 'Yes, do as I say' (at this point) - but do run apt install -f from a tty, not under X/Wayland, my X crashed in the middle.

Crossgrade all other architecture-dependent packages

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.

Before a mass replacement from old to new architectures, if you have packages without installation candidates (from old releases), you may want to first try removing those with

# apt install aptitude:amd64
# aptitude purge '?obsolete'

A possible brute-force way to do the swap is

# apt install $(dpkg -l | grep '^.i.*:i386' | grep :i386 | sed -e s/:i386/:amd64/ | awk '{print $2}')

You will have to type in 'Yes, do as I say' to get apt to do this, so make sure each package in the warning is actually going to get installed with the new architecture.

Notes 2020-10: I needed to edit the list to remove the pae kernel references and then use that edited list from a file for apt install. You will experience various errors regardless. I needed to for example manually dpkg -i bash and dash, symlink /bin/sh to the existing one a couple of times, and try again and again. Do not expect not needing to do a lot of apt install -f, dpkg --configure -a, manual dpkg -i from /var/cache/apt/archives/ and apt autoremove --purge (to remove replaced :i386 binaries). However using above and these notes I ended up with a functional system and there were big portions that just ran without interruptions.

Another more brutal way to do the swap is

# dpkg --get-selections | grep '\binstall$' | grep :i386 | sed -e s/:i386/:amd64/ | dpkg --set-selections
# apt -f install

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

Once the swap is done, you can remove all the redundant libraries and drop the old architecture with

# apt purge $(dpkg -l | grep '^.i.*:i386' | awk '{print $2}')
# dpkg --remove-architecture i386
# apt update

Caveats and Known Problems

Caution with systemd

systemd may not like being cross-graded, possibly it is safer to cross-grade it from a liveCD. Make sure to cross-grade udev at the same time, otherwise various units will fail.

APT dependency resolver wants to revert apt itself

If the system had packages that depend on apt like apt-utils, it's possible run into a situation where apt -f install wants to revert apt itself to i386. Aborting and doing another operation apt autoremove will illustrate the reason better:

The following packages have unmet dependencies:
 apt-utils:i386 : Depends: apt:i386 (= 1.4.8) but it is not installed

In such a case, the solution is to temporarily remove apt-utils:i386 from the system, and install apt-utils afterwards. Note: this new apt-utils will be amd64, but once you switch apt to amd64, using the :amd64 suffix will not work.

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

KDE

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
fi

#validate arch
if ! TO=$(dpkg-architecture -qDEB_HOST_ARCH -a$1); then
    echo "$1 is not a recognised architecture name"
    exit 1
fi
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
   amd64)
       TO_KERN=amd64
       ;;
   i386)
       TO_KERN=amd64
       ;;
   armhf)
       TO_KERN=armhf
       ;;
   armel)
       TO_KERN=armhf
       ;;
   arm64)
       TO_KERN=arm64
       ;;
   mips)
       TO_KERN=mips64le
       ;;
   mipsel)
       TO_KERN=mips64le
       ;;
   mips64le)
       TO_KERN=mips64le
       ;;
   ppc)
       TO_KERN=ppc64el
       ;;
   powerpc)
       TO_KERN=ppc64el
       ;;
   ppc64el)
       TO_KERN=ppc64el
esac
   
dpkg --add-architecture $TO
# check that dpkg --print-foreign-architectures is $TO
apt update
apt 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 install linux-image-$TO:$TO; then
        echo "There should be a reboot here"
        exit 1
        #reboot
    else
        echo "kernel updating to linux-image-$TO:$TO failed"
    fi
fi

echo Crossgrading dpkg and apt
apt clean
apt --download-only install dpkg:$TO apt:$TO tar:$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
#do
#    file=$(basename $pkg)
#    pkgname= ${file%%_.*}
#    version= ${file##*._} 
#    if dpkg -l $($pkgname)
#done
#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
fi

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 upgrade
apt full-upgrade

echo "Removing obsolete packages"
apt install aptitude:$TO
aptitude purge '?obsolete'

echo "Mass reinstalling $TO packages -- double check installed packages match warned-about packages"
apt install $(dpkg -l | grep '^.i.*:'"$FROM" | grep ":$FROM" | sed -e "s/:$FROM/:$TO/" | awk '{print $2}')

echo "Removing redundant libraries"
apt purge $(dpkg -l | grep '^.i.*:'"$FROM" | awk '{print $2}')

echo "Removing $FROM"
dpkg --remove-architecture "$FROM"
apt update