Comment empêcher Snapd de se mettre à jour automatiquement?


31

Je viens d'installer Ubuntu 18.04.Au bout de quelques minutes, j'ai remarqué que ma bande passante était remarquablement faible.J'ai installé nethogs et réalisé que /usr/lib/snapd/snapd consomme mon Internet.

Questions:

  1. Comment puis-je le désactiver?Cela m'empêche vraiment d'utiliser Internet.
  2. Puis-je désactiver le système de package snap lors de l'installation d'Ubuntu?

Merci beaucoup,

25

Snap packages are a good way to get access to much more software than before. You can now get as snap packages Skype, LibreOffice latest, GIMP latest, all JetBrains IDEs or even games.

All these are installed using the Ubuntu Software application and it's not necessary to use the command line.

The important question for you is this, do you really need to disable snap packages?

To temporarily disable snap packages (until reboot or if you run with start):

sudo systemctl stop snapd.service

To permanently disable snap packages:

sudo systemctl stop snapd.service
sudo systemctl disable snapd.service

To reenable snap packages:

sudo systemctl reenable snapd.service
sudo systemctl start snapd.service

21
  1. You can disable autostart for the service by clicking on the start button then search for "Startup Applications" and change the setting like this.


  1. If these answers did't help out you may do next:

    sudo systemctl mask snapd.service - Completely disable the service by linking it to /dev/null; you cannot start the service manually or enable the service.

    sudo systemctl unmask snapd.service - Removes the link to /dev/null and restores the ability to enable and or manually start the service


If you will need update a snap program you can unmask and start the service, then use command snap refresh


4

I tried determining the pid for /usr/lib/snapd/snapd, using sudo nethogs wlp4s0.
Then killed this process using sudo kill -9 pid_of_the process.
Then disabled this process using sudo systemctl disable snapd.service.
Since then, i'm living a peaceful life. My data usage remains under control as well.


3

You can mask your snap service with:

systemctl mask snapd

And then use this script, which will give you the possibility to update your snaps easily ever still:

#!/bin/bash

# this script unmasts and starts the snapd service, do a refresh and disable it again

set -x
systemctl unmask snapd.service
systemctl start snapd.service
systemctl status --no-pager snapd.service
snap refresh
systemctl mask snapd.service
systemctl stop snapd.service
kill -9 $(pgrep snapd)

Put it in /usr/local/sbin/snap-update and give it executable rights with chmod +x.

Then you can just run:

sudo snap-update

I created a gist for it here that also deletes the old snaps, after new ones are installed.


1

You can change update time of snap to, say, Monday 12 a.m. like this:

sudo snap set system refresh.timer=mon,12:00

Then you have to refresh it

sudo snap refresh

As mentioned you can also temporarily disable updates:

sudo systemctl stop snapd.service

0

snaps updates are controlled by the app developers if you don't want a particular snap to update you could ask the developer to create a "static" channel which they simply don't update, updates would then be a simple matter of switching channels with `sudo snap refesh --channel=

i see that nextcloud approaches it this way; they appear to have a channel for version 12, among others, which hasn't seen an update since 2018


0

That is a pretty complex question, but though, we all need a simple, one-push solution. All I need here - is to make my system silent. The script below - is Kubuntu-20.04 specific. Though, you can omit the firefox, thunderbird, ufw and kdegames removal.

sudo apt purge mlocate -y
sudo apt purge ufw -y
sudo apt purge firefox -y
sudo apt purge thunderbird -y
sudo apt purge unattended-upgrades -y
sudo apt purge geoip-database -y
sudo apt purge libgeoip1 -y
sudo apt purge libgeoclue-2-0 -y
sudo apt purge geoclue-2.0 -y
sudo apt purge ubuntu-report -y
sudo apt purge apport -y
sudo apt purge whoopsie -y
sudo apt purge popularity-contest -y
sudo apt purge kdegames-mahjongg-data-kf5 kmahjongg libkf5kmahjongglib-data libkf5kmahjongglib5 kdegames-card-data-kf5 libkf5kdegames-data libkf5kdegames7 libkf5kdegamesprivate1 -y

sudo rm /etc/update-motd.d/50-motd-news || true
sudo rm /etc/cron.daily/popularity-contest || true
sudo rm /etc/cron.d/popularity-contest || true
sudo rm /etc/cron.daily/ubuntu-advantage-tools || true
sudo rm /etc/cron.daily/apt-compat || true
sudo rm /etc/cron.weekly/apt-xapian-index || true
sudo rm /etc/cron.daily/slack || true

sudo systemctl stop packagekit-offline-update
sudo systemctl disable packagekit-offline-update
sudo systemctl stop packagekit
sudo systemctl disable packagekit

sudo snap refresh
sudo snap set system refresh.metered=hold
sudo systemctl stop snapd.service
sudo systemctl disable snapd.service

Looks pretty silent, so far. As a traffic sniffer - I'm using tcptracer-bpfcc(my favourite), wireshark, nethogs and tcpdump.