Mansome
Posts: 68
Joined: Sat May 16, 2015 2:32 pm

Is there any easy way to speed up apt-get on raspbian?

Thu Dec 15, 2016 7:08 pm

Hi all,

I am noticing the apt-gets update takes forever now when it used to be faster. I have gigabit connectivity in my home so I know its not the connection. While I know the pi wont even go that fast apt-get shouldn't be downloading in kbs.

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 12:35 am

Mansome wrote:Hi all,

I am noticing the apt-gets update takes forever now when it used to be faster. I have gigabit connectivity in my home so I know its not the connection. While I know the pi wont even go that fast apt-get shouldn't be downloading in kbs.
If you've got multiple pis then it might be worth looking at setting up an apt proxy. This means all package downloads will be cached on that rather than having to be downloaded from the internet.

Other than that getting a better (faster) sd card may help depening on what the bottlenecck is

Mansome
Posts: 68
Joined: Sat May 16, 2015 2:32 pm

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 1:48 am

I have top of the line samsung cards that are beyond class 10 on speed. The thing is it didnt used to be this bad. Now it just apt-gets to a crawl. There just has to be some way. I read about something called apt-fast but does this work on the pi?

MaxK1
Posts: 1043
Joined: Sun Aug 26, 2012 11:34 pm

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 5:45 am

Define "forever" - Is it taking hours? (that would be really bad) A couple of minutes? (not very good) or what? Is it always slow? or just sometimes?
You are in a maze of twisty little passages, all alike.
When General Failure and Major Disaster get together, Private Parts usually suffers.

User avatar
simonmcc
Posts: 181
Joined: Mon Aug 19, 2013 10:07 pm

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 7:10 am

is it the download time that is long, or the installation?

If it is the download only, obviously a caching proxy would be best, as already suggested, however, what I sometimes do is simply copy the contents of the /var/cache/apt/archives/ directory to my newly built pi, and that means it doesnt have to 'get' the archives, they are already there, all it has to do is install them
simonmcc.blogspot.com/search/label/pi

fruitoftheloom
Posts: 21072
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 8:52 am

Mansome wrote:Hi all,

I am noticing the apt-gets update takes forever now when it used to be faster. I have gigabit connectivity in my home so I know its not the connection. While I know the pi wont even go that fast apt-get shouldn't be downloading in kbs.
Raspberry Pi 3B connected to a UK THREE Mobile 3G MiFi:

sudo apt-get update
Hit http://archive.raspberrypi.org jessie InRelease
Get:1 http://mirrordirector.raspbian.org jessie InRelease [14.9 kB]
Hit http://archive.raspberrypi.org jessie/main armhf Packages
Get:2 http://mirrordirector.raspbian.org jessie/main armhf Packages [8,982 kB]
Hit http://archive.raspberrypi.org jessie/ui armhf Packages
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB
Ign http://archive.raspberrypi.org jessie/main Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB
Ign http://archive.raspberrypi.org jessie/ui Translation-en
Get:3 http://mirrordirector.raspbian.org jessie/contrib armhf Packages [37.5 kB]
Get:4 http://mirrordirector.raspbian.org jessie/non-free armhf Packages [70.3 kB]
Get:5 http://mirrordirector.raspbian.org jessie/rpi armhf Packages [1,356 B]
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/main Translation-en
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
Fetched 9,106 kB in 26s (339 kB/s)
Reading package lists... Done
[email protected]:~ $
Retired disgracefully.....
This at present is my daily "computer" https://www.asus.com/us/Chrome-Devices/Chromebit-CS10/

User avatar
RaTTuS
Posts: 10499
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 8:55 am

Code: Select all

 time sudo apt-get update
Get:1 http://mirrordirector.raspbian.org jessie InRelease [14.9 kB]
Get:2 http://archive.raspberrypi.org jessie InRelease [13.2 kB]
Get:3 http://mirrordirector.raspbian.org jessie/main armhf Packages [8,982 kB]
Get:4 http://archive.raspberrypi.org jessie/main armhf Packages [130 kB]
Get:5 http://archive.raspberrypi.org jessie/ui armhf Packages [53.6 kB]
Hit http://archive.raspberrypi.org jessie/staging armhf Packages
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB
Ign http://archive.raspberrypi.org jessie/main Translation-en
Ign http://archive.raspberrypi.org jessie/staging Translation-en_GB
Ign http://archive.raspberrypi.org jessie/staging Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB
Ign http://archive.raspberrypi.org jessie/ui Translation-en
Get:6 http://mirrordirector.raspbian.org jessie/contrib armhf Packages [37.5 kB]
Get:7 http://mirrordirector.raspbian.org jessie/non-free armhf Packages [70.3 kB]
Get:8 http://mirrordirector.raspbian.org jessie/rpi armhf Packages [1,356 B]
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/main Translation-en
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
Fetched 9,303 kB in 10s (850 kB/s)
Reading package lists... Done

real    0m23.598s
user    0m16.710s
sys     0m1.210s
a 2nd time to rule out stuff

Code: Select all

time sudo apt-get update
Hit http://mirrordirector.raspbian.org jessie InRelease
Hit http://mirrordirector.raspbian.org jessie/main armhf Packages
Hit http://mirrordirector.raspbian.org jessie/contrib armhf Packages
Hit http://mirrordirector.raspbian.org jessie/non-free armhf Packages
Hit http://mirrordirector.raspbian.org jessie/rpi armhf Packages
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/main Translation-en
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
Hit http://archive.raspberrypi.org jessie InRelease
Hit http://archive.raspberrypi.org jessie/main armhf Packages
Hit http://archive.raspberrypi.org jessie/ui armhf Packages
Hit http://archive.raspberrypi.org jessie/staging armhf Packages
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB
Ign http://archive.raspberrypi.org jessie/main Translation-en
Ign http://archive.raspberrypi.org jessie/staging Translation-en_GB
Ign http://archive.raspberrypi.org jessie/staging Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB
Ign http://archive.raspberrypi.org jessie/ui Translation-en
Reading package lists... Done

real    0m27.558s
user    0m12.050s
sys     0m1.210s
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

MaxK1
Posts: 1043
Joined: Sun Aug 26, 2012 11:34 pm

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 12:45 pm

You did mean update and not upgrade or dist-upgrade,right? I can update in under 30 seconds (26 seems to be fairly normal for me - similar to what RaTTus and fruitoftheloom show) If it is taking longer, I would look for a network problem or mirror problem.
You are in a maze of twisty little passages, all alike.
When General Failure and Major Disaster get together, Private Parts usually suffers.

Mansome
Posts: 68
Joined: Sat May 16, 2015 2:32 pm

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 1:29 pm

Its both the update and the dist-upgrade but not the installation part. It usually sits on a get line for 5 minutes or more at time. I used to could setup an image with various packages via scripts in a couple of hours. Now I have to let it run all night because the download takes so long for the update and dist-upgrade. An apt proxy is not the best option for me because not all of the pi's are on the same network that are having this problem. At my house I have 2 Pi 2's and 2 Pi 3's, at my dad's house there is 1 Pi 2 and 1 Pi 3. All pi's are having the same issue. One other thing I noticed since this has been going on when doing an apt-get instead of IPv4 addresses I am seeing IPv6 addresses.

wh7qq
Posts: 1345
Joined: Thu Oct 09, 2014 2:50 am

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 8:24 pm

Getting rid of some of your unused packages might help speed the upgrade. I did

Code: Select all

apt-get remove --purge wolfram* libreoffice* scratch
and recovered a Gig of memory and sped up the upgrade process noticeably. Generally, I find that the slowest part of the upgrade process is all of the work that the Pi has to do (after the download which goes fairly quickly)...unpacking and installing the new/upgraded packages, etc. that involve a lot of memory access and cpu work.

I did see a big improvement in my upgrade speeds when I put my root directory on a SSD/USB...had an old, 32G SSD sitting around doing nothing so I used it. The SD card interface on the Pi tends to be pretty slow.

If you are using wifi, especially with the RPi 3's onboard wifi, you may find that hooking up with ethernet speeds things up. If you are any distance from the AP or router, the wifi will slow down due to a weak signal.

Another trick is to use the "at" command to schedule it when you are not using the Pi. "at" is not included in the Raspbian iso but is in the repository. You can add it with

Code: Select all

sudo apt-get update && sudo apt-get install -y at
then, when upgrading, the following as an example:

Code: Select all

sudo at 0300 tomorrow 
at>apt-get update
at>  apt-get upgrade -y
at>CTL-d
The "-y" is important when upgrading when you are not around, to answer "Yes" to all the questions you get when you upgrade...otherwise, the command does not complete. Read up on the at command...it will accept a wide variety of timing expressions such as "tomorrow", "tonight", "tea time" and such. Also be aware that it will do its work at the Pi's system time if that is different from your local time. The "CTL-d" exits the "at" command structure.

Mansome
Posts: 68
Joined: Sat May 16, 2015 2:32 pm

Re: Is there any easy way to speed up apt-get on raspbian?

Fri Dec 16, 2016 8:36 pm

I having the issue with Jessie lite, the latest version no other customizations prior to the apt-get. Its still painfully slow. Removing packages doesn't really help me if it is the first time its being run. Scheduling isnt an option because of the packages require user input. Like for instance adobe flash just needs you to press the enter key. If there was a way to script the enter key input I could get around this by scheduling.

tweak42
Posts: 503
Joined: Tue Mar 22, 2016 3:16 am
Location: Los Angeles, California

Re: Is there any easy way to speed up apt-get on raspbian?

Sat Dec 17, 2016 12:04 am

Mansome wrote:I having the issue with Jessie lite, the latest version no other customizations prior to the apt-get. Its still painfully slow. Removing packages doesn't really help me if it is the first time its being run. Scheduling isnt an option because of the packages require user input. Like for instance adobe flash just needs you to press the enter key. If there was a way to script the enter key input I could get around this by scheduling.
Does using apt instead of apt-get make any difference?
I started using just plain apt a year ago on my ubuntu systems because apt-get would sometimes hang on some 3rd party repositories whereas apt would multi-thread and continue to get updates on others while waiting on the slow one. I'm not sure if the downloads themselves are multi-threaded or just package checking. Never tried apt-fast.

Mansome
Posts: 68
Joined: Sat May 16, 2015 2:32 pm

Re: Is there any easy way to speed up apt-get on raspbian?

Sat Dec 17, 2016 3:29 am

tweak42 wrote:
Mansome wrote:I having the issue with Jessie lite, the latest version no other customizations prior to the apt-get. Its still painfully slow. Removing packages doesn't really help me if it is the first time its being run. Scheduling isnt an option because of the packages require user input. Like for instance adobe flash just needs you to press the enter key. If there was a way to script the enter key input I could get around this by scheduling.
Does using apt instead of apt-get make any difference?
I started using just plain apt a year ago on my ubuntu systems because apt-get would sometimes hang on some 3rd party repositories whereas apt would multi-thread and continue to get updates on others while waiting on the slow one. I'm not sure if the downloads themselves are multi-threaded or just package checking. Never tried apt-fast.
I never tried apt before I might have to give this one a try in the future. I did partially solve this problem. It turns out that my router has been handing out IPV6 addresses and when processing the apt-get I noticed the sites had IPV6 addresses. I turned off IPV6 and now my apt-get is back to what it was before this problem. Its still not going to the speed I would like to see but at least now I do not have to run it overnight anymore.

Martin Frezman
Posts: 1020
Joined: Mon Oct 31, 2016 10:05 am

Re: Is there any easy way to speed up apt-get on raspbian?

Sat Dec 17, 2016 8:37 am

Yes. IPV6 is evil.
If this post appears in the wrong forums category, my apologies.

Return to “Troubleshooting”