[SOLVED] Install updates on next shutdown, not on the next boot

UPDATE: As @claydoh mentioned, this feature has been implemented by @tduck and will be available on Plasma 6.2. :tada: Thank you!
Plasma 6.2 is planned to be released on October 8th.


(This is a Feature Request for KDE neon)

Currently, KDE neon installs the software updates when you boot your PC. It often takes 5-10 mins even on my Rizen 9 machine.
If the updates are installed when you shutdown the PC, I think the boot performance would be dramatically improved.

Here’s current update process (Actual):

  1. The user apllies updates on Discover
  2. The user press the shutdown button (Or run command like halt and shutdown)
  3. The user boot the PC again
  4. The update installation process automatically starts
  5. After the update installation, the PC automatically reboots
  6. The Plasma login screen (SDDM) is shown

In my usecase, I usually shutdown my PC when I finish everything to do in that day. (i.e. at night in most cases.)
Then at the next morning, I boot the PC and I usually have to wait for 5-10 mins or more for the update process.

I wish the update process was like this (Expected):

  1. The user applies updates on Discover
  2. The user press the shutdown button (Or run command like halt and shutdown)
  3. OS reboots
  4. The update installation process automatically starts
  5. After the updates are installed, the PC is shutted down (not rebooted)
  6. The user boot the PC again
  7. The Plasma login screen (SDDM) is shown without waiting for update process

By changing the timing of the update processes, you don’t have to wait when you boot your PC because the update process is already finished when you shutdown your machine.

If the updates are installed on shutdown, you can just press shutdown button and then you can leave your desk. You don’t have to wait until the update process has been completed.

I’m not sure if anyone want to keep the current behavior, but I think it can be implemented as an option if necessary.

Unfortunately, I don’t have experience in OS layer and I guess I can only write a feature request and maybe help some tests, but I hope the neon developers will get interested in this.

3 Likes

The way it works now, is that Discover provides the ability to use systemd’s Offline Updates - which reboots into a low level session, applies the updates, then reboots (again).

To achieve similar goals of having an environment without many (or any) OS/system libraries loaded when shutting down seems difficult, but I am not expert, to be sure. I do think this may be out of scope for KDE itself, since it isn’t tied to any desktop or similar thing.

Perhaps reversing things, so that the system shuts down after the low level session, instead of rebooting? I’ll wager this is possible, but would need systemd devs or similar people to implement it. I think.

1 Like

Thanks for your reply.

Sorry, I wrote an idea which is different from the one I initially had by mistake.
Since the old idea may be difficult to implement, I just rewrote my suggestion.

Old idea: Press Shutdown button => package update => OS shutdown

New idea: Press Shutdown button => OS Reboot (Shutdown → Boot) => package update => OS shutdown (not reboot)

Hi phanect

As a workaround I would temporarily place a timer to shutdown script in the autostart folder and have it set to shutdown well after any updates have finished.

In the morning just remove or disable the script and store it until next time.

Hope this helps.

Vektor

Hi @vektor,

Unfortunately, it doesn’t work on my end because I encrypt the disk and I guess I cannot run the shutdown script before I’m asked for the disk decryption password :confounded:

Thanks anyway for your suggestion!

I don’t know how I forgot this:
Specifically for Ubuntu-based systems (including neon), unattended-upgrades can be set to do things during shutdown.

https://help.ubuntu.com/community/AutomaticSecurityUpdates
Which also has some other options to look at, since there are always options :smiley:

The config files seem to be well commented, and there is an option to be set to apply things during shutdown, so the only other thing to set is which sections of the repos are updated with this. I am sure some setup using this tool might be able to suit your use case.

Also note these only deal with native packaging repos, not Snaps or Flatpaks.

@claydoh Thanks for the info!

Since KDE neon is a PackageKit-based distro and does not fully support apt, I think I need to test if it really works and does not break the system, but I will try.

Also note these only deal with native packaging repos, not Snaps or Flatpaks.

AFAIK, Snaps and Flatpaks are installed immediately and not on boot time, so I think that’s fine.

No, it IS a fully apt based distro-- same as Ubuntu which also uses Packagekit, btw. So does Fedora and others.

Packagekit is just a layer used by GUI tools such as Gnome Software, Plasma Discover, Apper, Pkcon, and probably other applications to interface with all the different packaging systems out there.

Apt is being used by packagekit to do the actual work on Ubuntu, neon, etc. Packagekit does not interfere with this stuff at all.

@claydoh We might have different understanding of (apt|PackageKit) based distro, but my concern is the lack of apt upgrade support. KDE neon does not support apt upgrade command.

$ sudo apt upgrade
[sudo] password for phanect: 
On KDE neon you should use `pkcon update` to install updates.
If you absolutely must use apt you do have to use dist-upgrade or full-upgrade in place of the upgrade command.
  https://neon.kde.org/faq#command-to-update
Abort.

If unattended-upgrades internally use apt[-get] upgrade, it should not work on neon.

In addition, KDE neon switched from apt to PackageKit to avoid breaking package dependencies IIRC, so I think I also have to test if it does not break the dependencies by using unattended-upgrades which may not be fully controlled by PackageKit.

Anyway, thanks for your advice. I will continue to test if unattended-upgrades works until the KDE neon developers get interested in this feature request.

Ahh, good point. It has been quite a few years since I last used unattended-upgrades in neon, and can’t recall much about it tbh.

I wonder if cron-apt or something with aptititude might be more suitable? It should be configurable to use dist-upgrade, or probably even pkcon if one really wanted to add that extra layer

However:

This is not correct. All that they did was to redirect the apt/apt-get upgrade to something that provides this message. There is no switching at all. Packagekit is not a replacement. It needs and requires apt/dnf/whatever native packaging commands a distro has in order to do the work. It calls apt to do a job, it doesn’t do apt’s job.

neon does need apt full-upgrade/apt dist-upgrade at times due to its need to remove packages when upgrading Plasma at times. This is the reason why they redirected apt upgrade to prevent it from being used, and started promoting pkcon.

But it probably does break unattended-upgrades.
Or, unattended-upgrades would at some point break neon.

I am not sure that unattended-upgrades or apt’s configs can be set to use full-upgrade/dist-upgrade. Can’t seem to find good references for it I can understand.

In any case bit of work is needed to achieve the desired goal.

If I may pipe in here, I suggest you uninstall unattended upgrades. The behavior you are experiencing should not be happening. I suspect its due to the fact that you use disk encryption. My Neon does not do anything without my permission and direct action. If it is a normal app update that does not require a reboot, I update “online”. If its system related, I do “offline”. All of this happens only when I tell it to.

One thing I have learned using Linux for 30 years is that you never, ever, update immediately or without checking what is being updated.

Thanks for the replies.

@claydoh

KDE neon switched from apt to PackageKit

This is not correct.

I noticed I still have difficulties in writing technically precise expressions… :sweat_smile:

Maybe I had to say that:

“KDE neon disabled apt upgrade CLI and recommend us to use pkcon update command instead to avoid breaking package dependencies…”

I confirmed that apt dist-upgrade still works on neon.
Therefore, it might be worth trying unattended-upgrades if it can run dist-upgrade, but there seems no such public API/CLI/config options at least…

@shadow

Yes, hopefully, I want to execute offline updates after the shutdown. That’s why I created this thread.
However, since I failed to get the attention of neon or Discover developers, I guess this feature will not be implemented, unfortunately.

If I could implement this feature with some Shell Scripts and/or QML + JS, I would create a package to allow offline updates after the shutdown or contribute to adding such a feature, but I think I have to write C++ to implement this feature.
I’m just a web frontend engineer and not great in C++…

I could not find anything that indicates it can be set to use dist-upgrade, but I did not dig too deeply .

Probably the systemd developers, as this is where the feature actually originates from, not KDE or Discover.

A very nice rabbit hole to go down, though :smiley:
I can’t code at all, but I imagine it might hopefully be as simple as changing whatever is used to call that second reboot in the systemd service to call a shutdown instead.

1 Like

In addition, sudo apt full-upgrade also works normally on KDE neon. No warning messages at all. I use it all the time and ignore the pkcon interface on top of it all.

1 Like

As a workaround, you can disable offline updates on System Settings >> Software Update, that way, it will update while the system is still on. It might cause some instability, but it can be worth it if you value faster updates.

1 Like

:smiley: :smiley:
Lookee here…

1 Like

Sorry, I haven’t seen this thread for some days.

Wow, I’m really exited to hear that this feature is available now!
I was almost giving up.

Big thanks @tduck and other contributors involved in implementing this feature!

Oh wow, never saw this thread. You’re welcome guys :grin:. Wasn’t a very difficult thing to add all in all so it’s chill

3 Likes