12

This doubt is hitting me since 2-3 days, so I decided to test it myself. What I did is I installed Ubuntu 16.04.4 in VMWare and edited /etc/apt/sources.list and replaced xenial with bionic using:

sudo sed -i 's/xenial/bionic/g' /etc/apt/sources.list

Then I ran

sudo apt-get update && sudo apt-get upgrade 

I was able to upgrade to 18.04, confirmed by using lsb_release -a. However, I encountered some problems like:

  • apt does not have a stable CLI interface. Use with caution in scripts.

  • unmet dependency of python3-aptdaemon.pkcompat

  • Release 'bionic-backports' for 'appstream' not found

  • Broken Unity

I solved all the errors and installed gnome and gdm3.

So, I just want to know is it a good idea to edit sources.list? I know that my system might broke but is there any other specific reason not to use this.

Note: I tested this on Ubuntu 16.04 in VMWare to clear my doubts only.

muru
  • 197,895
  • 55
  • 485
  • 740
Kulfy
  • 17,696
  • 1
    You should run sudo apt-get dist-upgrade (or better sudo aptitude dist-upgrade) to involve new dependencies into upgrade process. Warning message about apt in scripts is normal, it exists in both 16.04 an 18.04. – N0rbert Aug 01 '18 at 13:59
  • @N0rbert I know that dist-upgrade would be a better option but again, will sudo apt-get install -f install dependencies? – Kulfy Aug 01 '18 at 14:02
  • Normally, yes. But for sure I recommend to use both commands. – N0rbert Aug 01 '18 at 14:02
  • If I consider dependencies, will it make any difference? – Kulfy Aug 01 '18 at 14:06
  • 3
    So long as you know what you're doing and use proper format in the file, that's perfectly OK – Sergiy Kolodyazhnyy Aug 01 '18 at 14:18
  • This question doesn't need version tags, as it's not version specific. – muru Aug 01 '18 at 22:41
  • @muru Yeah. But I added that because I tested on that versions. – Kulfy Aug 02 '18 at 14:59
  • No its not good , and it will effect multiple errors on your Ubuntu OS , there are other ways to upgrade the distribution or you keep your release is up to date. –  Aug 04 '18 at 01:15
  • "WARNING: apt does not have a stable CLI interface. Use with caution in scripts." is not a problem. The reasoning is provided in man apt in the section titled "SCRIPT USAGE AND DIFFERENCES FROM OTHER APT TOOLS" – DK Bose Dec 28 '18 at 16:39
  • @DKBose Actually before posting this question I never observed such thing. At that time I thought this may be a problem. – Kulfy Dec 28 '18 at 17:10

2 Answers2

13

Editing /etc/sources.list is one step to migrate to a subsequent release in Debian...but not in Ubuntu. You can still use it, but it's not recommended because most users shouldn't need to deal with precisely the problems you encountered.

Instead, Ubuntu provides a tool (the do-release-upgrade command) that will properly change the sources, download and install the upgrade, and remove orphans, all in a predictable and reproducible way to prevent corner-case problems. This tool is the recommended way to upgrade to a newer release of Ubuntu.

user535733
  • 62,253
  • 3
    But sometimes do-release-upgrade don't work. So, in that scenario should it be considered as an option if user just wants to test his/her programs? – Kulfy Aug 01 '18 at 14:05
  • 2
    It's usually better to learn why do-release-upgrade did not work. Many of the same reasons will also cause dist-upgrade to fail. – user535733 Aug 01 '18 at 14:47
  • 1
    If do-release-upgrade does not work, upgrading the debian way is fully acceptable. the ubuntu update manager does some preparation and cleanup afterwards, which the typical ubuntu user would not know about. But in the end the main step is still "apt-get upgrade && apt-get dist-upgrade". Feel free to use apt, it is only not recommended in scripts. – allo Aug 01 '18 at 14:47
  • 1
    @Kulfy Are you talking about do-release-upgrade not working right now? If that is the case, Canonical has not released the upgrade for it yet. On the release notes it does state that it will be available within a few days of the 18.04.1 release in late July. Just keep checking. – Terrance Aug 01 '18 at 16:00
  • @user535733 agreed. – Kulfy Aug 01 '18 at 16:21
  • @Terrance Yeah you got it right. By the way July has officially ended(in most time zones atleast) and still some are facing issue in upgrading to 18.04 from 16.04. As I have mentioned in the question it was just meant for clearing the doubt. So I just tested it myself before asking here. :-) – Kulfy Aug 01 '18 at 16:26
  • @Kulfy Yeah, there might be a good reason why they are hanging on to releasing it since they try to have the releases as stable as possible. I couldn't find any more information other than the few days after the release. – Terrance Aug 02 '18 at 03:30
4

I will use term "source version" for the version that you have used before upgrading and the "destination version" for the version that you have used after upgrading.

Ways of upgrading Ubuntu versions:

First way: Editing sources.list

Commonly called Debian way of upgrading or sometimes, The Brute Force Method.

This way:

  • Makes your system supplied by packages of destination version.
  • Some third-party repositories might not have the channel for destination version, so you occasionally encounter unmet dependencies problem and in all cases you cannot upgrade the packages to newer version. (For example, wine-hq repository only recently added support for Bionic).
    • You will not be able to complete updating your repository without removing third-party repositories, as you will experience 404 Not found error.

Some notes: Disable third-party repository.

Works: It either works or not.

Recommendation level: too low.

Second way: Doing do-release-upgrade:

Commonly called Ubuntu way of upgrading:

This way:

  • For repositories:
  • Switches to sources.list new repository entries
  • Automatically removes obsolete entries
  • For packages:
    • Removes possible broken packages
    • Updates packages index (equivalent to sudo apt full-upgrade)
    • Upgrades system (equivalent to sudo apt full-upgrade)
    • Removes old packages:
      • Old kernels
      • Packages existed in the source version of Ubuntu, but not existed in the destination version.
    • Deals with Nvidia Drivers.
  • Release specific jobs:
  • Plays with some configurations
  • Runs release specific scripts:
    • For example, replaces Unity Desktop with Gnome Desktop.

However, a lot of people are experiencing problems with do-release-upgrade:

Works: It works... with bugs.

Recommendation level: between low and middle.

Third way: Clean Install

This is the most recommended way of upgrading your system.

Note #1: Do not forget to Backup.

Note #2: You will most likely spend equal time to fix errors called by above-mentioned methods. If so, why hesitating to do a clean installation?

Works: Always works.

Recommendation level: very high.

Olimjon
  • 7,292
  • I came across a situation on my servers where some offer release upgrades and others don't. I was looking to upgrade from 16.04.6 to 18.04. Obviously something is blocking the upgrade on some of the servers, but it's not clear what. As for a clean install, unless you have meticulous records of everthing you installed and copied into place, it will be difficult to replicate the existing system. And it takes a long time, during which your server is off-line. At least editing the source list and a dist upgrade keeps the service running... – Peter Ford Jun 03 '20 at 12:21