Howto Upgrade Debian 4 Etch to Debian 5.0 Lenny

Debian version 5.0 has been released. It is recommended that you upgrade the system to latest version. Upgrading remote Debian server is a piece of cake. In this tutorial, you will learn about upgrading Debian Linux server from Etch to Lenny over ssh session.

Step # 1: Make a Backup

Upgrading system is a complex procedure. I strongly recommend backing up all data and configuration files. The upgrade process is quite reliable, but a hardware failure in the middle of an upgrade could result in a severely damaged system, so make a full system backup.

Step # 2: Apply all etch updates

Make sure etch is up to date and all security patches including kernel installed:
# apt-get update
# apt-get upgrade

Reboot the system if new kernel installed:
# reboot

Step # 3: Update /etc/apt/sources.list

Make a backup copy of /etc/apt/sources.list, enter:
# cp /etc/apt/sources.list /etc/apt/sources.list.etch
Open /etc/apt/sources.list, enter:
# vi /etc/apt/sources.list
Update it as follows (use mirror closest to your location):

# Main
deb lenny main contrib non-free
deb-src lenny main contrib non-free

# Security
deb lenny/updates main contrib non-free
deb-src lenny/updates main contrib non-free

Save and close the file.

A note about stable /etc/apt/sources.list file

For server you should always use the following file. This file ensures that you always run stable released software. With following config, you do not need to update /etc/apt/sources.list file and you can simply run below mentioned command to upgrade system to stable release:

# Main
deb stable main non-free contrib
# Source
deb-src stable main non-free contrib
# Security
deb stable/updates main contrib non-free

Step # 4: Upgrade Debian to from 4.0 to 5.0

The recommended way to upgrade from previous Debian GNU/Linux releases is to use the package management tool aptitude. This program makes safer decisions about package installations than running apt-get directly. First, upgrade the core tools aptitude and apt, enter:
# aptitude update
Now update both apt and aptitude
# apt-get install apt aptitude
# aptitude update apt aptitude
Above two commands will automatically upgrade libc6 and other support libraries. Some running services will be restarted, including ssh, rsyncd xdm, gdm and kdm etc. Now, we have updated apt and aptitude. It is time to apply system update, enter:
# aptitude upgrade
# aptitude install

Above will install required updates to the system. Finally, update entire distribution:
# aptitude dist-upgrade
Above will update the rest of the system i.e. install the newest available versions of all packages, and resolve all possible dependency changes between packages in different releases.

Step # 5: Verify your system

Type the following commands to verify kernel:
# uname -a
Sample output:
Linux 2.6.26-1-amd64 #1 SMP Sat Jan 10 17:57:00 UTC 2009 x86_64 GNU/Linux
Verify Debian version, enter:
# cat /etc/debian_version
Sample output:


Verify log files, enter:
# egrep -i 'err|warn' /var/log/dmesg
# egrep -i 'err|warn' /var/log/messages
# tail -f /var/log/dmesg
# tail -f /path/to/other/apps/log

Verify running service and open ports, enter:
# netstat -tulpn
# rcconf

Verify firewall settings, enter:
# iptables -L -n
# ip6tables -L -n


  1. man page aptitude, apt and other commands.
  2. Above instructions are tested on 64bit and 32bit server system only. I strongly recommend official release note for further information.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 24 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
24 comments… add one
  • cx42net Feb 17, 2009 @ 11:24

    It maybe would important to mention that for those are on NFS, they have to install nfs-common before executing aptitude upgrade & aptitude install :

    “Above two commands will automatically upgrade libc6 and other support libraries. Some running services will be restarted, including ssh, rsyncd xdm, gdm and kdm etc. Now, we have updated apt and aptitude. It is time to apply system update, enter:
    # aptitude install nfs-common <– add this
    # aptitude upgrade
    # aptitude install”

    I was stuck with this problem until I find this solution that worked for me.

  • Valqk Feb 17, 2009 @ 15:11

    Thanks for the article but aptitude update; aptitude dist-upgrade done the job for me 🙂

  • 🐧 nixCraft Feb 17, 2009 @ 16:55


    Yes, usaully those two command works but I’ve updated over 10 boxes with various configuration and above procedure took care of all issues.


  • valqk Feb 18, 2009 @ 17:21

    Spoke too early.
    For those using xen kernels – WATCH OUT!
    Run dist-upgrade twice so you can get xen loaded upgraded and check carefully the menu.lst!!!
    I got one dead machine last night, thanks god it wasn’t a production.
    Also, be aware – upgrade of passwd can delete some groups or users – check that too.
    everything else was fine after upgrade.

  • ekram Feb 19, 2009 @ 16:00

    2.6.24-etchnhalf.1-686 this kernel may not be updated this way.. so far i have tried and stick with that. But cat /etc/debian_version shows lenny 5.0. So far it will also work for me…..

  • Simon Mar 5, 2009 @ 20:47

    And read the release-notes !
    They document the issues regarding the upgrade the Debian project is aware of :

  • boubakri hichem Mar 11, 2009 @ 2:21

    thank u for this tuto;
    i have one suggestion :
    you can run the following line :
    # aptitude upgrade
    # aptitude install
    # aptitude dist-upgrade
    in one line :
    #aptitude upgrade && install && dist-upgrade

  • Andreas Kaiser Mar 11, 2009 @ 11:57

    Hi valqk,

    What do you mean with “dist-upgrade twice”.

    We have a production server with Debian 4 Xen Dom0 and 3 DomU (also Debian 4), could you specify where and in which order execute “dist-upgrade”?


  • Dog Man Mar 11, 2009 @ 23:32

    Will this upgrade work on ARM devices such as Buffalo Linkstations that are currently running Debian Etch? I dont want to find out the hard way (ie. bricking my system), so if anyone can clarify that would be great.

  • muchliz Mar 12, 2009 @ 11:31

    how to install wi-fi labtop from debian versi 5

  • R Sep 22, 2009 @ 10:15

    It works! But don’t do the upgrade from a X11 based terminal!

    I have tried and failed many times before figuring out that X also gets an upgrade and needs to be restarted. Bij restarting X the upgrade procedure is interrrupted. The system will not come online again.

  • len Oct 21, 2009 @ 16:26

    i tried that and it reset my network and i lost my connection!

  • Olivier Nov 27, 2009 @ 20:32

    @Dog Man : my answer is probably very late, but anyway : yes, it’ll probably work on your Buffalo. I upgraded successfully my NSLU2 from Etch to Lenny and then later to Squeeze.

  • esiminch Feb 27, 2010 @ 0:04

    nice post:) thanks a lot. just upgraded a working server with this guide.

  • Claudio Mar 5, 2010 @ 13:09

    Just wanted to know about how long the whole procedure (dist-upgrade) takes?

  • 🐧 nixCraft Mar 5, 2010 @ 16:15

    It depends upon your Internet connection speed and installed software.

  • eric May 3, 2010 @ 19:31

    one minor correction, where you say:

    Now update both apt and aptitude
    # apt-get install apt aptitude
    # aptitude update apt aptitude

    the second part of that should say
    # aptitude install apt aptitude


  • Shimon Doodkin May 7, 2010 @ 22:20

    i have did this successfully i have directadmin with exim on debian
    after this walkthought
    exim did some problems with gconv .co files from glibc pakage.
    it seemed to me like it was badly installed, apt-get reinstall did not helped.

    i have rebuilt exim and proftpd and it did not helped but might was importent.

    i did:
    aptitude purge libc6
    (accepted the solution)
    aptitude install libc6-dev
    reboot and all problems have gone.

    also i had issues with proftpd 32bit copetibility mode
    aptitude install libcap2-dev
    i did in hope it helps…

    after then i saw that php-cgi did not work because of postgresql update
    i did:
    cd /usr/lib/
    ln -s
    i hope that is all

  • Carsten Jul 20, 2010 @ 16:30

    Thanks for this How-To, worked very well on a production server. Customer and me happy again. 🙂

    Regards from Malta

  • david Oct 5, 2010 @ 21:23

    thanks for this, helped me a updating my server with less fear of doing things wrong. one thing i did just to be sure: after the full install i rebooted and checked if everything was still working. rather break it right now than at some random time when the server has to reboot and then i do not have time to fix issues.

  • Mayur Oct 10, 2010 @ 16:09

    This was just what I was looking for – thank you!

  • CableCat Dec 1, 2010 @ 11:25

    It is really bad advice you give about using “stable” instead of “lenny” in /etc/apt/sources.list
    If one does that. The system will suddenly be upgraded, and might stop working. There is a very good reason that this is no longer the default.

  • premiso Jun 16, 2011 @ 16:34

    A tidbit that the Debian Release notes recommend. Start a recording session, this way if something goes wrong, you will have a log of it:

    script -t 2>~/upgrade-lenny.time -a ~/upgrade-lenny.script

    Should aid you or whoever else with what could have gone wrong.

  • Mira Meier Jun 29, 2016 @ 8:02

    Thanks for this How-To, worked very well on a production server. Helped a lot!
    Regards from Munich

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum