GeekSocket Plug in and be Geekified

Recovering from aborted Fedora update

When Fedora 27 was released I was updating my office laptop and suddenly laptop turned off while installing the update after reboot. Probably it was dead because of battery. It was not even starting. Situation w​as- both the old and new versions of same package were present. After searching a bit, I found this forum thread which solved my problem. And laptop came back to life. In this post I will explain the steps I used to recover my laptop.


1. Creating live USB drive

As laptop was not booting up at all, the only solution was to boot in to the USB. Generally I use livecd-tools which can be installed through dnf but for some reasons it was not working so I used dd to create bootable USB.

$ umount /dev/sdx
$ sudo dd if=Fedora-Workstation-Live-x86_64-27-1.6.iso of=/dev/sdx
3186688+0 records in
3186688+0 records out
1631584256 bytes (1.6 GB, 1.5 GiB) copied, 519.202 s, 3.1 MB/s

where sdx is USB device’s name. Once you boot into the USB, we will use that OS to perform further tasks.


2. Mounting the / partition inside live boot

The easiest way to do it through nautilus (Files), from ‘Other Locations’ mount the slash partition of machine.

Other Locations Update

If the drive is LUKS encrypted it will ask you password, just provide it and note down the mount point.

Mounted partitions

[liveuser@localhost-live ~]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
...
/dev/mapper/live-rw      6.4G  4.4G  2.0G  70% /
tmpfs                    7.8G  456K  7.8G   1% /tmp
/dev/mapper/fedora-home  217G  8.7G  197G   5% /run/media/liveuser/e853c0ce-7807-45cc-b77f-af6b4420ec5a
/dev/mapper/fedora-root   69G   14G   52G  21% /run/media/liveuser/3921e678-5de5-41d8-8537-c6733d2455dc

Our / partition is now mounted at the following location

/run/media/liveuser/3921e678-5de5-41d8-8537-c6733d2455dc. We will refer this as /path/to/root/ for rest of the post.


3. Using dnf from live OS to update

dnf has one option which is --installroot, we can specify the location where root partition is mounted. All the operations are performed on that partition. More about options

$ sudo dnf --installroot=/path/to/root/ --releasever=27 distrosync

This will synchronize all the existing packages to match the release version 27, more on distrosync

Even after doing this, my laptop was not booting up. The reason behind this was some of packages were duplicated, means both versions were present i.e. the fc26 and fc27. This was causing all the trouble.

Solution for this is to delete one of the version of package which has duplicate. Needs to be done for all duplicated packages.

$ sudo dnf repoquery --duplicated --installroot=/path/to/root/ | grep fc27 > removelist

This will give us list of all packages which has duplicate. Using grep will give us names of packages having  version fc27. About repoquery

$ cat removelist | xargs sudo dnf --installroot=/path/to/root/ -y remove %

This will traverse over the list and remove the packages. Notice the -y flag, otherwise we will have to press y every time.

And now we have to do distrosync again. It will update the remaining packages properly.

$ sudo dnf --installroot=/path/to/root/ --releasever=27 distrosync
$ reboot

Finally the laptop booted up \o/


4. Updating the kernel

It was booting up using old kernel of fc26. The kernel of fc27 was already installed.

$ sudo dnf list kernel
Installed Packages
kernel.x86_64             4.13.9-200.fc26               @updates
kernel.x86_64             4.13.16-202.fc26              @updates
kernel.x86_64             4.13.16-302.fc27              @updates

Reinstalling kernel, kernel-headers, kernel-modules of fc27 solved the issue.

$ sudo dnf reinstall kernel kernel-core kernel-modules

If doing this doesn’t solve problem you may need to generate grub2 configuration. One of the following command will do that trick.

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
or
$ sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

One of the reason I like Fedora is, ‘seamless updates’. No matter what happens, you will be able to update your installation smoothly. This incident proved that again 🙂

Started writing: 8th Jan

Finished: 31st Jan


Comments

comments powered by Disqus