TechBuzzPro

How to Upgrade Debian 8 Jessie to Debian 9 Stretch

· 5 min read · Apps & Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide walks you through upgrading a Debian 8 (Jessie) system to Debian 9 (Stretch). It covers preparation, repository changes, the actual upgrade process, and post-upgrade steps. Before starting, ensure you have a full backup and a stable internet connection.

What You'll Need

  • A Debian 8 Jessie system with root or sudo access.
  • A complete backup of important data (ideally a full system backup).
  • A stable internet connection.
  • At least 1 GB of free disk space (more if you have many packages).
  • Time: the upgrade can take 30 minutes to a few hours depending on your system.

Step-by-Step

  1. Back up your system. Before any major upgrade, back up your important files, configuration, and ideally the entire system. Use tools like tar, rsync, or a disk imaging tool.
  2. Update your current Jessie system. Run sudo apt update and then sudo apt upgrade to ensure all packages are up to date. Reboot if a kernel update was installed.
  3. Edit the sources.list file. Open /etc/apt/sources.list (and any files in /etc/apt/sources.list.d/) with a text editor. Replace every occurrence of jessie with stretch. For example, change deb http://deb.debian.org/debian/ jessie main to deb http://deb.debian.org/debian/ stretch main. Also update any jessie-updates to stretch-updates and jessie-backports to stretch-backports if present.
  4. Update the package index. Run sudo apt update. This will fetch the package lists for Stretch. Expect warnings about packages that are no longer available; that's normal.
  5. Upgrade to Stretch (minimal). Run sudo apt upgrade. This will upgrade most packages but may leave some packages held back if they require new dependencies or configuration changes. Answer prompts about configuration files carefully – usually keeping the current version is safe unless you know otherwise.
  6. Perform a full distribution upgrade. Run sudo apt dist-upgrade. This handles dependency changes and installs/removes packages as needed. This is the core of the upgrade. It may take a while. Again, answer configuration prompts thoughtfully.
  7. Remove obsolete packages. Run sudo apt autoremove to clean up packages that are no longer needed. Also consider sudo apt purge for any packages you know you don't want.
  8. Reboot. Once the upgrade completes, reboot your system with sudo reboot. After reboot, verify that the system is running Stretch with lsb_release -a or cat /etc/debian_version (should show 9.x).
  9. Check for remaining issues. Run sudo apt update and sudo apt upgrade again to ensure everything is clean. Also check for any held packages with apt-mark showhold and decide whether to unhold them.

Common Mistakes

  • Skipping the backup. The most common and dangerous mistake. Always back up before upgrading.
  • Not updating Jessie first. Upgrading from an outdated Jessie can cause dependency conflicts. Always bring Jessie fully up to date first.
  • Forgetting to update all sources.list files. Some third-party repositories are in /etc/apt/sources.list.d/. If you only edit the main file, those repos will still point to Jessie and cause errors.
  • Using apt upgrade instead of apt dist-upgrade. The former may leave many packages held back. You need the distribution upgrade to complete the transition.
  • Ignoring configuration file prompts. Blindly accepting new config files can overwrite your customizations. Read the diff and decide.

Tips

  • Perform the upgrade in a terminal (Ctrl+Alt+F1) rather than a graphical session to avoid display issues.
  • Keep a log of the upgrade output: sudo apt dist-upgrade 2>&1 | tee upgrade.log. This helps troubleshoot later.
  • If you use a custom kernel or third-party modules, check their compatibility with Stretch before upgrading.
  • Consider using screen or tmux so the upgrade continues even if your SSH connection drops.
  • After the upgrade, test critical services (web server, database, etc.) one by one.

Troubleshooting

  • APT errors about missing packages or dependencies. Run sudo apt -f install to fix broken dependencies. If that fails, try sudo apt update again and then sudo apt dist-upgrade.
  • Held packages. If apt dist-upgrade reports held packages, check why with apt-mark showhold. You can unhold them with sudo apt-mark unhold and then retry the upgrade.
  • Boot issues after reboot. If the system fails to boot, boot into recovery mode or a live CD. Check /var/log/apt/history.log and /var/log/dpkg.log for errors. You may need to reinstall the kernel: sudo apt install --reinstall linux-image-amd64 (or your architecture).
  • Network not working after upgrade. Check network manager or systemd-networkd. Sometimes the network interface names change. Use ip addr to see available interfaces and adjust /etc/network/interfaces accordingly.
  • Configuration file conflicts. If a service fails, check its configuration. Often the new default config is incompatible with your old settings. Compare with dpkg --compare-versions or manually inspect the files.
  • If the upgrade fails halfway. Do not panic. Run sudo apt dist-upgrade again – it will resume. If it repeatedly fails, check the error message and search for it online; often it's a single problematic package that can be removed or pinned.

Frequently Asked Questions

Can I skip versions and upgrade directly from Jessie to Buster?

No, Debian only supports upgrading from one release to the next. You must go through Stretch first.

Will my custom repositories work after the upgrade?

Only if they provide packages for Stretch. You'll need to update their URLs or remove them if they don't.

How long does the upgrade take?

It depends on your internet speed and number of packages. Typically 30 minutes to 2 hours.

Do I need to reinstall my desktop environment?

No, the upgrade will handle it, but you may need to log out and back in. Some themes or extensions might break and need updating.

What if I run out of disk space during the upgrade?

Free up space by removing old packages with sudo apt clean and sudo apt autoremove. You can also move large files to an external drive temporarily.

Is it safe to upgrade a production server this way?

It's generally safe if you have a backup and test in a staging environment first. For critical servers, consider a fresh install instead.