5

I am afraid of upgrading my Ubuntu because half of the time when I upgrade, I get a broken system that I must reinstall. So I always do it on weekends and very rarely.

I have a Dell XPS 13 9310 and the last two times I tried to upgrade I got a black screen while doing it, and had to reinstall Ubuntu, because it wouldn't boot anymore.

Are there tips so I can try to prevent this from happening again?

Guerlando OCs
  • 863
  • 10
  • 51
  • 88
  • Upgrading, especially on a supported path, shouldn't have big issues like that. I would suggest reporting a bug. Generally, take a backup of anything important. Also, even if it won't boot, you can probobly recover a lot, if not all, of your files by using a live CD. See this question and this question for backing up your data. – cocomac Dec 14 '21 at 16:51
  • 1
    Such failure is very unusual, so there likely are not many useful "tips" beyond preparation for failure (backups). Were it my system, I would review the logs around the time of such a failure -- software developers like to log the causes of as many failures as they can think of. Possible solutions depend upon the cause. – user535733 Dec 14 '21 at 17:03
  • @cocoma losing stuff is not a problem, I'm actually used to it so I have backups of everything, but this always happens, even on a XPS 13 which is officially supported. – Guerlando OCs Dec 14 '21 at 17:06
  • But if you have backups, then why are you concerned about having to reinstall. It isn't ideal, but it shouldn't be that hard if you took backups. One additional thing... make the /home a separate partition if you reinstall, as that will help later – cocomac Dec 14 '21 at 17:08
  • If you have an Nvidia card, make sure your drivers are current BEFORE attempting the upgrade. Use the Software & Updates, Additional Drivers tab, app to do so. – heynnema Dec 14 '21 at 17:33
  • If your method constantly fails, change (fix) your method. Also, make use of AskUbuntu's search feature. Maybe someone else has already solved a similar problem. – waltinator Dec 14 '21 at 17:56
  • @GuerlandoOCs Have you read this, maybe helpful. – lemrm Dec 14 '21 at 19:20
  • 1
    @Nmath That's a logical misuse of the XY Problem link. The purpose of a fire hydrant is to provide water to fire trucks so they can put out fires, because it's too late to solve the problem if the house has already burned down. Reviewing a question like this as too broad is wrong, otherwise the reader can't be warned about a possible mistake before he makes that mistake. – karel Dec 15 '21 at 11:30
  • There may be some other better way to go about this, but the next time you are preparing to run an upgrade, post all of your hardware and everything and what you are planning to do. It possibly will get closed as duplicate, but that's fine if the duplicate has the answer you need. Also, if things go bad, then you can post why the solutions did not work. In an ideal world, this is great for everybody. – Paul Dec 15 '21 at 19:37
  • 1
    @Nmath Your preceding comment was constructive. The question was ambiguously worded before I edited it, but I'm not sure that my edit fully resolves the original close vote reason. Please read it and see what you think. – karel Dec 16 '21 at 00:39
  • 1
    @karel I think it's sufficiently resolved and voted to reopen – Nmath Dec 16 '21 at 01:23

1 Answers1

7

Before upgrading to a newer release disable third-party repositories (PPAs) with the following command:

sudo sed -i 's/^/#/' /etc/apt/sources.list.d/*.list
sudo apt update
sudo apt upgrade

Sometimes the upgraded system will contain many unnecessary files, config files which aren't working with the new system, etc. Config files which aren't working are identified by the Ubuntu installer when upgrading. When I upgraded from Ubuntu 18.04 to Ubuntu 20.04 it took about an hour and I received one notification about a config file that needed to be edited. I copy/pasted the suggested edit into a text file and edited the config file after the upgrade was completed. It should be noted that if I hadn't watched the terminal output for the entire hour that it took to upgrade to 20.04 I would have missed the suggested edit which worked perfectly.

After the upgrading process is completed run the following commands:

sudo apt update
sudo apt autoremove  
sudo apt clean
deborphan # Install this package management tool with sudo apt install deborphan
sudo reboot

Re-enable third-party repositories with the following command, which will remove the # character from the lines that begin with deb.

sudo sed -i '/deb/s/^#//g' /etc/apt/sources.list.d/*.list

Change all instances of the old release codenames of the third-party repositories to the new release codenames. For example for an upgrade from Ubuntu 18.04 to Ubuntu 20.04 the old release codename is bionic and the codename of the upgraded release is focal. To change all instances of bionic to focal in third-party repositories run the following commands:

sudo sed -i 's/bionic/focal/g' /etc/apt/sources.list.d/*.list  
sudo apt update

If you get an error message like:

E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu focal Release' does not have a Release file.   
N: Updating from such a repository can't be done securely, and is therefore disabled by default.

you will need to remove these repositories from your software sources with command(s) of the form:

sudo add-apt-repository --remove ppa:ubuntu-wine/ppa  
sudo apt update 

For removing unnecessary files from the upgraded system I use the following commands:

  • sudo apt autoremove
  • sudo apt clean
  • deborphan - Install this package management tool with sudo apt install deborphan.

Running these commands after upgrading takes me about 5 minutes. My workstation has a lot of installed software. If I had done a fresh install instead of an upgrade configuring all the installed applications on my workstation would have taken me 2-3 days.

A successful upgrade is almost entirely dependent of your level of understanding of the Ubuntu operating system. Problems caused by an upgrade can almost always be solved if you have the level of skill necessary to solve them. When I am upgrading Ubuntu I keep a second laptop running alongside the computer being upgraded, so that I can immediately search Ask Ubuntu for the solution as soon as something goes wrong.

karel
  • 114,770