14

I am on Ubuntu 18.04 LTS. Updated the system to the latest. Recently I noticed something unusual on Ubuntu with my Internet connection. My limited Internet quota was used up quickly by something invisible. As a user came from Windows this was something odd as Ubuntu never did such a thing to me. I installed nethogs and found out that the devil who vanished my data was /usr/lib/snapd/snapd

I found a somewhat similar question, but it does not answer what I am going to ask. Removing snapd from start up did not help either.

  • Why does snapd use this much data?
  • Is there a way to stop those connections without disabling snap apps?

    nethogs interface showing culprit

Zanna
  • 70,465
  • How much is "this much data"? What is "My limited Internet quota"? Why do you assume snapd is "the devil who vanished my data"? What you've posted is a screenshot of a terminal window, that shows snapd downloading something at 1.4MBps at that moment. Does it prove anything? – mikewhatever Apr 06 '19 at 08:49
  • 1
    @mikewhatever I have 500MB of data that is why it is called limited, in several minutes it is over without opening any apps, just booting up the system. It is a screenshot just to show what I found out. If you think this is not the reason, can you help me to figure out why my data quota is over within several minutes with no visible apps opened. – Nuwan Thisara Apr 06 '19 at 09:12
  • Ubuntu updates itself in the background by default same as pretty much any OS. A newly installed system usually have hundreds of MB of updates. There is no apparent reason to believe that snapd is "the devil" or Ubuntu did something to you from what you've posted. 500MB is really limited, especially if the Ubuntu machine is not the only device using it. – mikewhatever Apr 06 '19 at 09:24
  • @mikewhatever BTW this is not a newly installed system. I installed this version soon after it released. – Nuwan Thisara Apr 06 '19 at 09:51

1 Answers1

20

By default, snaps are set to refresh themselves 4 times per day. If you are using many snaps, this could be a data intensive process for you.

Perhaps limiting the number of times per day that the snaps refresh would help. You can adjust this on your system with

sudo snap set system refresh.timer=fri,15:00

to set the update of snaps to occur on Friday at 15:00, or tell snapd that you are using a metered connection:

sudo snap set system refresh.metered=hold

I suspect (but cannot prove) that snapd looks at the "Restrict Background Data" flag of the network connection (as shown in the image below), to determine that the connection is metered. If you choose to set your connections to "metered" then to update your snaps, you will need to

sudo snap refresh

on occastion, just as you would occasionally sudo apt update and sudo apt upgrade

=====

For more information on this, please see https://docs.snapcraft.io/system-options/87

enter image description here

Charles Green
  • 21,339
  • Thank you very much for your answer. I will try this and tell you if my problem is fixed. – Nuwan Thisara Apr 06 '19 at 15:03
  • @NuwanThisara I hope that it does what you need! You may also want to consider disabling the auto update services for apt. – Charles Green Apr 06 '19 at 15:13
  • I set the refresh time to fri.15:00 but when I tested nethogs just after system boot, snapd was running and downloading something consuming data. I stopped it. What is the problem? – Nuwan Thisara Apr 07 '19 at 01:04
  • 2
    Try sudo snap set system refresh.timer to see if the setting holds over reboot. I would hope so, but I don't use snaps. This is actually part of the reason why. – Charles Green Apr 07 '19 at 01:29
  • It says.............error: invalid configuration: "refresh.timer" (want key=value) – Nuwan Thisara Apr 07 '19 at 12:28
  • @NuwanThisara I'm sorry, I made a typo - I meant to ask to to read the value, which should be sudo snap get system refresh.timer – Charles Green Apr 07 '19 at 22:59
  • The result is fri,15:00 – Nuwan Thisara Apr 08 '19 at 02:52
  • 1
    But snapd was running to day also when the system booted up – Nuwan Thisara Apr 08 '19 at 02:58
  • 1
    @NuwanThisara Because snapd is a service and needs to be running to load your snaps, it has to start at boot time to manage the applications that you have loaded using it. I do hope that setting the refresh interval to once per week will help with the data consumption, as the only alternative that I know of, is setting the internet connection to a 'metered' connection, which may be good for your situation anyhow. – Charles Green Apr 08 '19 at 13:38
  • Thank you. I will try and inform you. – Nuwan Thisara Apr 08 '19 at 13:43
  • snapd dev here. This is the right answer; the only thing it doesn't cover is setting your connection to metered without gnome (using nmcli), which is covered in the snapcraft forum. – Chipaca Apr 14 '19 at 11:53
  • The correct command to check the refresh timer is sudo snap get system refresh.timer – Carlos Saltos Jan 24 '21 at 13:36
  • In my case snapd is WRITING a lot of data ... around 3 Mb/s ... that is something my harddisk can handle easily BUT -> snapd is doing it all the time for hours the whole day, every day ... WHY ? ... how can I fix that ? ... what happened if I deinstall snapd ? ... it's required ? – Carlos Saltos Jan 24 '21 at 13:44
  • @CarlosSaltos I have not paid much (any) attention to snaps since April 2019 - I would question the data use, and would encourage you to submit that as a new question. – Charles Green Jan 24 '21 at 22:11