It is possible to upgrade to Debian 9 from Debian 8 using ssh. This tutorial shows how to upgrade from Debian 8 Jessie Linux to Debian 9 Stretch using command line. Please note that Debian 9 made significant changes and upgrade might fail including data corruption is possible due to change in data formats. See “Issues to be aware of for stretch” for more info. Make sure you read the page before typing any one of the following commands.
Step 1: Back up any important data on the server
Make a backup (I am using Rsnapshot) it cannot be stressed enough how important it is to make a backup of your system before you do this. Most of the actions listed in this tutorial are written with the assumption that they will be executed by the root user running the bash or any other modern shell. Type the following commands to see current version:
$ uname -mrs
Sample outputs:
Linux 3.16.0-4-amd64 x86_64
OR
$ lsb_release -a
Sample outputs:
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 8.8 (jessie) Release: 8.8 Codename: jessie
Step 2: Patch your existing system
Type the following apt-get command/apt command:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
OR
$ sudo apt update
$ sudo apt upgrade
$ sudo apt dist-upgrade
Reboot the system if kernel or other libs are updates, run:
$ sudo reboot
Step 3: Update /etc/apt/sources.list file
Again, read this page before typing any one of the following command. Here is my default /etc/apt/sources.list
$ cat /etc/apt/sources.list
Sample outputs:
deb http://httpredir.debian.org/debian jessie main contrib deb http://security.debian.org/ jessie/updates main
Update file as follows using the text editor such as joe command/vi command (replace jessie with stretch):
$ sudo vi /etc/apt/sources.list
Sample outputs:
deb http://httpredir.debian.org/debian stretch main contrib deb http://security.debian.org/ stretch/updates main
Save and close the file. To update list of available packages for stretch, run:
$ sudo apt-get update
Sample outputs:
Get:1 http://mirrors.kernel.org stretch InRelease [195 kB] Get:2 http://security.debian.org stretch/updates InRelease [62.9 kB] Get:3 http://security.debian.org stretch/updates/main amd64 Packages [1,404 B] Get:4 http://security.debian.org stretch/updates/main Translation-en [1,767 B] Get:5 http://mirrors.kernel.org stretch/contrib Translation-en [45.9 kB] Get:6 http://mirrors.kernel.org stretch/main Translation-en [5,392 kB] Get:7 http://mirrors.kernel.org stretch/main amd64 Packages [7,095 kB] Get:8 http://mirrors.kernel.org stretch/contrib amd64 Packages [50.9 kB] Fetched 12.8 MB in 6s (2,129 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done
See how much disk space needed for upgrade:
$ sudo apt-get -o APT::Get::Trivial-Only=true dist-upgrade
Sample outputs:
.... sysv-rc sysvinit-utils tar task-english task-ssh-server tasksel tasksel-data tcpd telnet texinfo time traceroute tzdata ucf udev util-linux util-linux-locales vim vim-common vim-runtime vim-tiny w3m wget whiptail whois xauth xdg-user-dirs xkb-data xml-core xz-utils zlib1g 398 upgraded, 139 newly installed, 3 to remove and 0 not upgraded. Need to get 213 MB of archives. After this operation, 335 MB of additional disk space will be used. E: Trivial Only specified but this is not a trivial operation.
See your free disk space with the NA command:
$ df -H
Sample outputs:
Filesystem Size Used Avail Use% Mounted on /dev/sda 21G 1.1G 19G 6% / udev 11M 0 11M 0% /dev tmpfs 210M 4.5M 206M 3% /run tmpfs 525M 0 525M 0% /dev/shm tmpfs 5.3M 0 5.3M 0% /run/lock tmpfs 525M 0 525M 0% /sys/fs/cgroup
To upgrade the system by installing/upgrading packages:
$ sudo apt-get upgrade
Sample outputs:
Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... The following packages were automatically installed and are no longer required: docutils-common docutils-doc libasprintf0c2 liblcms2-2 libpaper-utils libpaper1 libperl4-corelibs-perl libuuid-perl libwebp5 libwebpdemux1 libwebpmux1 python-docutils python-pil python-pygments python-roman Use 'apt-get autoremove' to remove them. Done The following packages have been kept back: apt apt-listchanges apt-utils aptitude aptitude-common bc bind9-host curl dbus dmsetup dnsutils eject exim4 exim4-base exim4-config exim4-daemon-light file ftp gnupg gnupg-agent gnupg2 ifupdown init init-system-helpers initramfs-tools initscripts iotop iproute2 iptables iputils-ping isc-dhcp-client isc-dhcp-common libarchive-extract-perl libavahi-client3 libc-bin libc6 libcairo2 libclass-c3-xs-perl libcpan-meta-perl libcryptsetup4 libcups2 libcurl3 libcurl3-gnutls libdbus-1-3 libdevmapper1.02.1 libfcgi-perl libfreetype6 libgcc1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgnutls-openssl27 libgtk2.0-0 libgtk2.0-bin libhtml-parser-perl .... .. The following packages will be upgraded: acl acpi acpi-support-base acpid adduser aptitude-doc-en at base-files base-passwd bash bash-completion bsd-mailx bsdmainutils bsdutils busybox bzip2 ca-certificates console-setup console-setup-linux coreutils cpio cron dash dc debconf debconf-i18n debian-archive-keyring debian-faq debianutils dictionaries-common diffutils discover dmidecode doc-debian docutils-common docutils-doc dpkg e2fslibs e2fsprogs findutils fontconfig fontconfig-config fonts-dejavu-core geoip-database gettext-base gpgv grep groff-base grub-common grub-pc grub-pc-bin grub2-common gzip hicolor-icon-theme host hostname iamerican ibritish ienglish-common info insserv install-info .... .. 283 upgraded, 0 newly installed, 0 to remove and 115 not upgraded. Need to get 69.9 MB of archives. After this operation, 14.8 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.kernel.org/debian/ stretch/main base-files amd64 9.9 [67.2 kB] Get:2 http://mirrors.kernel.org/debian/ stretch/main libtinfo5 amd64 6.0+20161126-1 [299 kB] Get:3 http://mirrors.kernel.org/debian/ stretch/main libncurses5 amd64 6.0+20161126-1 [93.4 kB] Get:4 http://mirrors.kernel.org/debian/ stretch/main libncursesw5 amd64 6.0+20161126-1 [115 kB] .... .... .. Get:281 http://mirrors.kernel.org/debian/ stretch/main xdg-user-dirs amd64 0.15-2+b1 [52.2 kB] Get:282 http://mirrors.kernel.org/debian/ stretch/main host all 1:9.10.3.dfsg.P4-12.3 [185 kB] Get:283 http://mirrors.kernel.org/debian/ stretch/main os-prober amd64 1.75 [29.8 kB] Fetched 69.9 MB in 1min 3s (1,104 kB/s) ... ... .. update-alternatives: using /usr/share/docutils/scripts/python2/rst2html4 to provide /usr/bin/rst2html4 (rst2html4) in auto mode update-alternatives: using /usr/share/docutils/scripts/python2/rst2html5 to provide /usr/bin/rst2html5 (rst2html5) in auto mode Setting up tasksel (3.39) ... Setting up task-english (3.39) ... Setting up task-ssh-server (3.39) ... Setting up tasksel-data (3.39) ... Processing triggers for libc-bin (2.19-18+deb8u9) ... Processing triggers for systemd (215-17+deb8u7) ... Processing triggers for ca-certificates (20161130+nmu1) ... Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. Processing triggers for dictionaries-common (1.27.2) ... ispell-autobuildhash: Processing 'american' dict. ispell-autobuildhash: Processing 'british' dict.
Finally upgrade everything intelligently:
$ sudo apt-get dist-upgrade
Sample outputs:
Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... The following packages were automatically installed and are no longer required: docutils-common docutils-doc libasprintf0c2 libbind9-90 libdns100 libintl-perl libintl-xs-perl libisc95 libisccc90 libisccfg90 libjasper1 liblcms2-2 liblwres90 .... .. Done The following packages will be REMOVED: libcwidget3 libsigc++-2.0-0c2a perl-modules The following NEW packages will be installed: dh-python dirmngr distro-info-data firmware-linux-free gcc-6-base gnome-icon-theme gnupg-l10n gtk-update-icon-cache initramfs-tools-core irqbalance keyutils libapparmor1 libapt-inst2.0 libapt-pkg5.0 libb-hooks-endofscope-perl libbind9-140 libboost-filesystem1.62.0 libboost-iostreams1.62.0 libboost-system1.62.0 libc-l10n libclass-method-modifiers-perl libclass-xsaccessor-perl libcpan-changes-perl libcroco3 libcwidget3v5 libdata-perl-perl libdevel-caller-perl .... .. The following packages will be upgraded: apt apt-listchanges apt-utils aptitude aptitude-common bc bind9-host curl dbus dmsetup dnsutils eject exim4 exim4-base exim4-config exim4-daemon-light file ftp gnupg gnupg-agent gnupg2 ifupdown init init-system-helpers initramfs-tools initscripts iotop iproute2 iptables iputils-ping isc-dhcp-client isc-dhcp-common libarchive-extract-perl libavahi-client3 libc-bin libc6 libcairo2 libclass-c3-xs-perl libcpan-meta-perl libcryptsetup4 libcups2 libcurl3 libcurl3-gnutls libdbus-1-3 libdevmapper1.02.1 libfcgi-perl libfreetype6 libgcc1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgnutls-openssl27 libgtk2.0-0 libgtk2.0-bin libhtml-parser-perl libintl-perl libldap-2.4-2 liblocale-gettext-perl libmagic1 libmodule-pluggable-perl libnet-ssleay-perl libparams-util-perl libpod-readme-perl libpython-stdlib libpython2.7-minimal libpython2.7-stdlib librtmp1 libsasl2-2 libsasl2-modules libstdc++6 libsub-name-perl libsystemd0 libtext-charwidth-perl libtext-iconv-perl libtext-soundex-perl libudev1 libuuid-perl libxml-libxml-perl libxml-parser-perl libxml2 linux-image-amd64 locales lsb-release mutt nfs-common openssh-client openssh-server openssh-sftp-server openssl perl perl-base pinentry-gtk2 procps python python-apt python-debianbts python-minimal python-pil python2.7 python2.7-minimal reportbug rsyslog systemd sysv-rc sysvinit-utils telnet texinfo udev util-linux util-linux-locales vim vim-common vim-runtime vim-tiny w3m wget 115 upgraded, 139 newly installed, 3 to remove and 0 not upgraded. Need to get 143 MB of archives. After this operation, 320 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.kernel.org/debian/ stretch/main locales all 2.24-11 [3,290 kB] Get:2 http://mirrors.kernel.org/debian/ stretch/main libc-l10n all 2.24-11 [819 kB] Get:3 http://mirrors.kernel.org/debian/ stretch/main libc6 amd64 2.24-11 [2,691 kB] Get:4 http://mirrors.kernel.org/debian/ stretch/main libc-bin amd64 2.24-11 [779 kB] Get:5 http://mirrors.kernel.org/debian/ stretch/main gcc-6-base amd64 6.3.0-18 [180 kB] .... .. ... Get:250 http://mirrors.kernel.org/debian/ stretch/main w3m amd64 0.5.3-34 [1,030 kB] Get:251 http://mirrors.kernel.org/debian/ stretch/main gnupg-l10n all 2.1.18-6 [892 kB] Get:252 http://mirrors.kernel.org/debian/ stretch/main irqbalance amd64 1.1.0-2.3 [40.4 kB] Get:253 http://mirrors.kernel.org/debian/ stretch/main publicsuffix all 20170424.0717-1 [98.2 kB] Get:254 http://mirrors.kernel.org/debian/ stretch/main python-debianbts all 2.6.1 [11.5 kB] Fetched 143 MB in 1min 11s (2,000 kB/s) Reading changelogs... Done apt-listchanges: Mailing root: apt-listchanges: news for localhost Extracting templates from packages: 100% Preconfiguring packages ... Deferring configuration of apt-listchanges until python3 is available (Reading database ... 32357 files and directories currently installed.) Preparing to unpack .../locales_2.24-11_all.deb ... Unpacking locales (2.24-11) over (2.19-18+deb8u9) ... Selecting previously unselected package libc-l10n. Preparing to unpack .../libc-l10n_2.24-11_all.deb ... Unpacking libc-l10n (2.24-11) ... Preparing to unpack .../libc6_2.24-11_amd64.deb ... Checking for services that may need to be restarted... Checking init scripts... Unpacking libc6:amd64 (2.24-11) over (2.19-18+deb8u9) ... Setting up libc6:amd64 (2.24-11) ... Checking for services that may need to be restarted... Checking init scripts...
Next reboot the server/desktop/laptop, run:
$ sudo reboot
Verify new upgrade
Type the following commands:
$ uname -mrs
Sample outputs:
Linux 4.9.0-3-amd64 x86_64
$ lsb_release -a
Sample outputs:
:No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 9.0 (stretch) Release: 9.0 Codename: stretch
And there you have it, Debian 8 upgrade to Debian 9. I tested this on a live system running at Linode VPS. For more info see this page.
ð§ 4 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hi Vivek,
There is a typing error that prevents source repo update.
deb http://httpredir.debian.org/debian strech main
deb http://security.debian.org/ strech/updates main
Thanks for the heads up. The tutorial has been updated :)
I would highly recommend doing “apt-get dist-upgrade -d” before doing any actual upgrades. Having all of the packages downloaded before beginning helps avoid troubles in case of network issues.
just for my unerstanding: why not directly doing a “dist-upgrade” without an “upgrade” before?