Published:

Notes on upgrading to Ubuntu 18.04 Bionic Beaver on my laptop

This blog entry is a quick wrap-up of updating Ubuntu on my machine.

By the way, it was one of the many long-delayed administrative tasks I talked about in Journal 2: Farewell Plotly.js! recently.

Upgrading to Ubuntu 18.04

My machine before upgrade:

  • Lenovo Thinkpad T470
  • Dual boot with Ubuntu and Windows 10
  • A separate Ubuntu /home partition encrypted with LUKS / cryptsetup

Upgrade steps

  • File backup of /home – Though I run file backups with Déjà Dup, I ran a another file backup with rsync
    • Cleaning up /home, e.g. by
      • cleaning up Trash and
      • removing no longer needed node_modules directories in my programming projects.
      • Removed git repositories of some customer projects I'm no longer involved in and that are captured on a remote git server anyways.
      • Also removed VirtualBox VM instances that I needed for past projects. With Vagrant in use those can be recreated easily anyways.
    • Then ran rsync -aAX --exclude={"/home/<user>/VirtualBox VMs/Win10VM", "/home/<user>/.local/share/Trash", "/home/<user>/.vagrant.d/boxes"} --info=progress2 /home/<user>/ <backup-destination>
      • Unfortunately --exclude wasn't working for me, so I transferred unnecessary data.
      • Target destination formatted as ext4 (to preserve file system attributes), just like the /home partition itself.
      • It took about 25 minutes for about 90 GiB of data. To me it seems that the real bottleneck for backup these days appears to be the sheer number of files, not the overall size. A note for my future task to make my backup leaner: why even bother backing up .git directories when latest commits have been pushes to remote anyways?
  • Tested Ubuntu 18.04 with USB stick – before doing any further steps I tried the new version with an USB stick.
    • Booting from an alternative device on my Thinkpad is easy, just hit enter on the start screen and follow instructions.
    • At this stage I copied /etc/fstab and /etc/crypttab to an external location. Both files determine the automounting of the encrypted LUKS partition as /home.
  • Created image of root parition – I went a long way back and forth on this. Originally I planned to take an image of the root partition, then install Ubuntu 18.04 and then try to restore old Ubuntu with that partition image. I skipped that test due to lack of time and confidence. Anyways, here's how I created the image.
    • There exist several options, some are documented at Disk cloning - ArchWiki
      • dd the low level tool of choice. Major drawback is that you can easily screw things up because it's so low level. Another drawback is that you'd also copy unused blocks of the partition.
      • Clonezilla recommended a lot of times, but their website wasn't looking trustworthy to me.
      • e2image a tool to copy ext4 (and ext2, ext3) partitions efficiently without copying unused blocks. Is used by gparted.
    • After quite some research I figured to try out the Copy/Paste feature of gparted. Therefore booted with the Ubuntu on my USB stick and started gparted there. Then copied the root partition to an unallocated area of my backup disk.
    • To gain enough unallocated space I had to shrink (with gparted of course) another partition though, in my case the ext4 file backup partition just created before. That took quite some time.
    • The copying was relatively fast. Looking at the "details" in the respective gparted dialog, I saw that e2image -ra -p '/dev/nvme0n1p5' '/dev/sdb3' was used under the hood – just like the ArchWiki article linked above claimed.
    • As mentioned above I didn't tested restoring the partition due to lack of confidence. I don't know for sure, but I suspect that I would have to mess with GRUB and stuff to get things going again. Anyway I believe it's realistic to think that one would be able to restore from such a copied partition if one needs this. In fact I'm thinking to buy a cheap refurbished Thinkpad for a few hundred Euros to test these things out before applying them on my work machine.
  • Tried to run upgrade within old Ubuntu – Tried to run the upgrade (dist-upgrade) mechanism within the old Ubuntu installation. Unfortunately the upgrade path in my particular case wasn't supported any longer. There exist resources on the web that work around this by messing with /etc/apt/sources.list. But I decided to do a fresh install of Ubuntu.
  • Fresh install of Ubuntu 18.04 – Here are the steps. Overall I must admit that the usability of the install dialog could be more user-friendly. I've not found any good (i.e. complete) documentation for the current installation dialog. I only found outdated stuff. I felt to take risks when clicking 'next' a few times. Not a good sign. However, there is an official tutorial that may help in some situations. But the scenario in the tutorial haven't resembled my situation. Anyways, here is a rough description of my steps:
    • Booted Ubuntu 18.04 from USB and launched installation dialog.
    • On the first screen I chose Normal installation, Download updates while installing Ubuntu and Install third-party software for graphics...
    • On second screen I chose Something else. This dialog page already presented other options than the tutorial linked above shows. Why did I choose Something else? Because I knew I'd need to mount the separate encrypted home partition eventually.
    • On the third screen you are then presented with a trimmed-down gparted user interface. Here, you can manage all partitions of the disk. I was pretty unsure what to do here in the first place. But it goes like this: select the partition you want to reinstall Ubuntu on. In my case that was the existing Ubuntu partition of course. After selecting the right partition, you need to Change... it to be the location for /. As a second step I chose the existing swap partition to be the new swapping partition as well. I did that with the Change... button again. For a few minutes I asked myself what would happen to my /home partition. Because you can also select a partition and Change... it to be the place for /home for example. After all, I "guessed" that with the current setting /home will simply be on the root partition. I clicked Install finally without knowing if this click would be the point of no return. It is not, you get two warnings before installation starts. Unfortunately I can't remember them anymore.
    • Installation took a half hour or so. Luckily everything went fine and Ubuntu 18.04 started without a problem.
    • Now, I had not yet mounted the real /home partition. Before doing so, I quickly took a look at the current /home directory. It was pretty minimal and it was located on the root partition as anticipated. So I went on to edit /etc/crypttab and /etc/fstab. Here I literally copied the respective entries from the files I saved before. I rebooted the machine and was immediately presented with the prompt to supply the password that unlocks the encryption keys in the LUKS header.
    • After logging in with my user, my "old" /home partition was mounted again. Great!!

Conclusion and first impressions of Ubuntu 18.04

  • Overall the upgrade was somewhat frightening to me due to a couple of reasons. A lot of options and no official recommendation how to create partition images. Would have something gone haywire, I would have wanted to go back to the previous state of my machine. But maybe it's not Ubuntu's fault. Maybe it's my lack of understanding. Or maybe it's because upgrading a machine, you rely on for work, is frightening per se. I definitely consider buying a cheap refurbished Thinkpad to test disaster recovery strategies.
  • The new UI (Gnome) looks very polished and is somewhat similar to the Unity desktop environment I used before.
  • The settings were very clear to me. There's a bug in the order how to set the primary monitor and where the dock is shown. Eventually I figured out an order of steps that work.
  • This time I installed Intellij IDEA in my home directory. Last time I made the mistake to put it into /opt that is located in the root partition. But the new installation picked up settings nicely. I didn't need to re-enter license keys or anything like that.
  • I thought more settings and stuff would have been purged by the new install. That was far less the case. For example all my Firefox settings, the history and even my very own Markdown Link add-on was retained. Sure, it's kind of logical because my existing /home partition from before the upgrade is used. However, I don't take this smooth transition for granted and of course it's more an achievement of Firefox than that of Linux / Ubuntu. But still, upgrading a Windows machine was always followed by more work.

Published by Robert Möstl

« Back to Blog