Fedora upgrading

This commit is contained in:
Quentin Dufour 2017-11-25 17:21:08 +01:00
parent f35f40e58c
commit 78b5baf71c

View file

@ -0,0 +1,120 @@
---
layout: post
slug: upgrade-fedora-online
status: published
sitemap: true
title: Upgrade your Fedora online with dnf-system-upgrade
description: How to efficiently destroy your distribution
disqus: false
categories:
tags:
- linux
- fedora
---
I have installed Fedora on my computer 3 or 4 years ago. Since this installation, I have installed many packages and upgraded it every 6 months. Unfortunately, Gnome Software has never worked for me, and I never took the time to debug it. Like many people, I am using the old method with `dnf-system-upgrade`, which worked pretty well. But this time, I had a segfault on dnf during the offline upgrade. The only information I got was the following lines:
```
kernel: show_signal_msg: 7 callbacks suppressed
kernel: dnf[846]: segfault at 8 ip 00007f39b860f724 sp 00007ffd00588520 error 4 in libc-2.25.so[7f39b8586000+1cb000]
kernel: audit: type=1701 audit(1511598827.366:96): auid=4294967295 uid=0 gid=0 ses=4294967295 subj=system_u:system_r:rpm_t:s0 pid=846 comm="dnf" exe="/usr/libexec/s
systemd-coredump[869]: Failed to connect to coredump service: No such file or directory
systemd[1]: dnf-system-upgrade.service: Main process exited, code=dumped, status=11/SEGV
systemd[1]: Failed to start System Upgrade using DNF.
```
Just after the segfault, my computer rebooted on Fedora 26.
## How dnf-system-upgrade works
*Some information presented here could not be totally accurate. If you have a doubt, please follow the links.*
`dnf-system-upgrade` use a feature of systemd described here: [Implementing Offline System Updates](https://www.freedesktop.org/software/systemd/man/systemd.offline-updates.html).
By creating a symlink named `/system-update`, at the next reboot systemd will boot to a specific target named `system-update.target`
But when will this symlink created ? When you run the following command:
```
# dnf system-upgrade reboot
```
We can see [in the source of the plugin](https://github.com/rpm-software-management/dnf-plugins-extras/blob/master/plugins/system_upgrade.py) that a symlink pointing to a dnf folder is created:
```python
DEFAULT_DATADIR = '/var/lib/dnf/system-upgrade'
MAGIC_SYMLINK = '/system-update'
# ...
os.symlink(DEFAULT_DATADIR, MAGIC_SYMLINK)
# ...
reboot()
```
We can now investigate which services are triggered by this target:
```raw
$ ls /usr/lib/systemd/system/system-update.target.wants/
dnf-system-upgrade.service fwupd-offline-update.service packagekit-offline-update.service
```
We are specifically interested by `dnf-system-upgrade.service` which basically run the following command:
```raw
# dnf --releasever=27 system-upgrade upgrade
```
At the end of this script, the symlink `/system-update` is destroyed and the computer rebooted.
## Upgrading online to bypass the bug
I didn't have any idea to debug this segfault in the offline mode.
So I searched a way to run this command in an online system.
If the command segfaults, I'll have some tools to investigate it.
If the command works, I'll have an upgraded system.
Before typing any command, you must know that this tool is not intended to be run this way.
It may break your Fedora installation or kill your family.
You really should run all your commands in a virtual terminal, as if Gnome crashes during the install, it will not kill dnf.
First, you must have downloaded the update:
```
# dnf upgrade --refresh
# dnf system-upgrade download --releasever=27
```
*For more information, you can refer to the article [Upgrading Fedora 26 to Fedora 27](https://fedoramagazine.org/upgrading-fedora-26-fedora-27/)*
Then, you will need to update dnf-system-upgrade configuration stored in `/var/lib/dnf/system-upgrade.json` and set "upgrade\_status" to "ready":
```json
{
"download_status": null,
"upgrade_status": "ready", <--- this line
"exclude": [],
"allow_erasing": true,
"datadir": "/var/lib/dnf/system-upgrade",
"distro_sync": true,
"best": false,
"target_releasever": "27",
"system_releasever": "26",
"releasever": "23",
"install_packages": {},
"enable_disable_repos": []
}
```
You must create the `/system-update` symlink, otherwise the upgrade command will fail:
```raw
# ln -s /var/lib/dnf/system-upgrade /system-update
```
And finally, you can run the upgrade command:
```raw
# dnf --releasever=27 system-upgrade upgrade
```
Your computer will automatically reboot at the end. Now you'll have either a working Fedora 27 or a borken Linux distribution. Good luck and have fun !