- unlocked root acount,
- about 4 GB of disk space,
- pen and paper to take notes about things that failed and need to be repaired later,
- ability to ignore warnings and error messages, some of them pretty serious
- about 6 hours, excluding download time (I have a Debian mirror next room, so dowloads are almost instantenous)
1. Logout from your desktop environment
Switch to console (Alt-Ctrl-F1). Login as root.
The idea is to run as few apps as possible, but don't switch to single user mode - you might need virtual terminals.
2. Remove some software
This kind of migration is tough on your package manager. Some packages are newer in Debian, some are older. Some apps are divided between several packages in a different way. Files belong to another package. There's no way Apt will get everything right. To make its life easier I removed several apps. The point is to remove only a few apps (you'll have to reinstall them later) with lots of dependencies.
My choice was:
- KDE apps - I use Gnome and only a handful of KDE apps - by removing them I got rid of dozens of KDE libs
- build-essential and dkms - this removed all compilers and development libraries
- texmaker - it removed all the LaTeX stuff that I rarely use anyway
- chromium, firefox, openoffice.org, gimp
- gdm - depends on Ubuntu-specific packages
- Ubuntu-specific software: apport, software-center, indicator, usb-creator-gtk, plymouth, everything with ubuntu in its name.
Note that I couldn't remove all these at one point - some of the apps would remove too much. If that's your case, skip it and try again later.
3. Remove dependencies
Get rid of unnecesary libraries with:
apt-get autoremoveIf the latter gives "command not found", apt-get install deborphan.
4. Change /etc/apt/sources.list
Add Debian Squeeze repositories (choose a mirror close to you) and whatever you may need, I added unnoficial Multimedia repo:
deb http://www.debian-multimedia.org/ squeeze main non-free5. Install Debian package signing keys
Apt will complain about untrusted packages. Start by:
apt-get updateFor some reasons it wasn't enough on my box, I had to install the key manually:
apt-get install debian-archive-keyring debian-multimedia-keyring
gpg --recv-keys 9AA38DCD55BE302B --keyserver subkeys.pgp.net6. First Big Cycle - upgrade packages that are newer in Debian
gpg --export 9AA38DCD55BE302B | apt-key add -
There's no way you'll get all the packages reinstalled in one try. My way was to reinstall some packages, fix errors, remove unneeded dependencies, try again. The cycle looks like this:
- [upgrade command]
- apt-get -f install
- [manual fix]
- apt-get autoremove
What's an upgrade command? There's a subtle difference in the way apt-get and aptitude resolve dependencies. I did apt-get upgrade first. It only deals with easy cases, so it'll upgrade a few packages in one cycle. When it can't find anything to upgrade, switch to apt-get dist-upgrade. Try it for a few cycles, than do aptitude dist-upgrade.
After installing a few packages, upgrade command will fail. First try automatic repair with apt-get -f install. If it still doesn't work, see what the problem is. Usually a package tries to overwrite a file that's also present in another package. Install it manually, using dpkg and full path to the package file:
dpkg -i --force-all /var/cache/apt/archives/package-name.debYou can also remove Ubuntu version and install the Debian package next. Again, use dpkg instead of apt-get, --remove packagename will remove the software, but leave the config files intact, --purge will also remove configuration and often works better. See also fixes for specific packages at the end of this howto. Write down any problems, maybe the best way is to remove the package and reinstall later.
If there are no partially installed packages, remove crud with apt and orhpaner and upgrade some more. You might run apt-get clean at the end of the cycle if you're low on disk space.
7. Prepare for downgrade
Edit /etc/apt/preferences, create the file if it doesn't exist.
Package: *Exact numbers don't matter, just keep Debian priority higher than 1000, it means that matching packages will be installed even if it means downgrading.
Pin: release o=Debian
Pin: release o=Ubuntu
Pin: release o=Unknown
7. Second Big Cycle - downgrade packages
This works the same as the first cycle, only now the upgrade command will do a downgrade. Don't forget apt-get autoremove and orphaner.
8. Check if all packages have been replaced
apt-get install apt-show versionsThis will show all packages that don't come from Debian Squeeze. There might be some claiming to belong to Lenny, that's OK.
apt-show-versions | grep -v squeeze
9. Make sure your system will boot.
See if grub and init scripts upgraded correctly. Only then reboot to Debian.
10. Fix your system.
Check config files, install back packages that you removed. Remember that Firefox was renamed to Iceweasel in Debian.
Appendix - problems with specific packages
Got loads of messages about unsupported locale. Solution:
locale-genmysql-client, sane-utils, python-gnomecanvas, grub-pc
Remove and install back.
apt-get remove cups ghostscriptInstall back later.
dpkg --purge cups-pdf
At first X wouldn't start at all, than I got locked keyboard. I purged and installed back many packages before I got it to work. Only some of them were needed, also I attempted to remove some multiple times (won't hurt to remove a package that's not installed), that's the essence I got from my .bash_history:
dpkg --purge --force-all hal dbus udev xserver-xorgSyslog
aptitude --purge remove x11-apps x11-session-utils x11-server-utils xauth xbase-clients xinit xorg
dpkg --purge --force-all dbus dbus-x11 hal udev desktop-base hardinfo libx11-data x11-common x11-utils x11-xfs-utils x11-xkb-utils x11-xserver-utils xfonts-utils xinput xkb
-data xscreensaver-data xserver-common xserver-xorg xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-evdev xserver-xorg-input-synaptics xserver-xorg-video-all xs
erver-xorg-video-intel xserver-xorg-video-nouveau xserver-xorg-video-nv gconf2 gconf2-common libice6 libx11-6 libxklavier16 libxrandr2 libxrender1 libxres1 libxt6 libxv1
aptitude install hal dbus udev xserver-xorg xorg xserver-xorg-video-intel xserver-xorg-input-all
dpkg --purge rsyslogInit scripts and networking system
aptitude install rsyslog
Get rid of upstart first. I had problems with sysv-rc and needed to force reconfiguration. Some init scripts were installed with "dpkg-new" in the name, I had to rename them. As with X, I tried few solutions, this is distilled but stil redundant version:
dpkg-reconfigure sysv-rcAt one point, dpkg started complaining about missing '/sbin/update-rc.d'. I couldn't install anything until I did:
mv acpid.dpkg-new acpid
mv anacron.dpkg-new anacron
mv atd.dpkg-new atd
mv cron.dpkg-new cron
mv dbus.dpkg-new dbus
mv module-init-tools.dpkg-new module-init-tools
mv procps.dpkg-new procps
mv rsyslog.dpkg-new rsyslog
mv udev-mtab udev
dpkg --purge --force-all base-files ifupdown initscripts netbase sysv-rc sysvinit sysvinit-utils
apt-get --reinstall install base-files ifupdown initscripts netbase sysv-rc sysvinit sysvinit-utils
chmod +x /sbin/update-rc.d