5

When installing packages with apt-get install, it first starts to download all needed packages and then installs them one by one.

But, If you use apt-get download, and interrupt the process during the first phase, and start over again, it downloads all packages again from scratch (erasing any partially-downloaded .deb files).

How can I continue the aborted download process without re-downloading the already received partial data?

3
  • 1
    @A.B. I think he wants to keep the partial downloads and just continue with downloading the rest. So that no data is downloaded twice. This might be useful for huge packages and people with slow connections. - I edited the question to sound like that. If I understood it falsely, please feel free to roll the edit back, rubo77!
    – Byte Commander
    Oct 27, 2015 at 9:17
  • @ByteCommander It is exactly what apt-get does always! It never re-downloads partially downloaded data
    – Anwar
    Aug 14, 2016 at 14:50
  • Now, as I read this again, I think so too, but I am sure, that, last year, when I asked this, I asked, because I was so unhappy, that it didn't keep the already downloaded parts in my case. Can you think of a setup, where id doesn't keep the partial downloads?
    – rubo77
    Aug 14, 2016 at 15:30

2 Answers 2

3

Your claim that

If you interrupt the process during the first phase, and start over again, it downloads all packages again.

is completely wrong! Apt is a smart package management system and it never re-downloads packages required to satisfy an installation request twice, not even for a single package or .deb file.

Those .deb files which are half-downloaded reside in /var/cache/apt/archives/partial directory and with ls command (in 16.04, you need to use sudo ls) you can check those files there.

You can verify this by looking at the apt-get manpage, where it says about /var/cache/apt/archives/partial/

  /var/cache/apt/archives/partial/
  Storage area for package files in transit. Configuration Item:
  Dir::Cache::Archives (partial will be implicitly appended)

You can even pick of one of those files and manually resume download using wget -c.

In the background, Apt uses wget program with -c switch, which from man-page means

-c,  --continue                  resume getting a partially-downloaded file
2
wget -v -d -nc -c -S --random-wait --keep-badhash\
https://mirror.math.princeton.edu/pub/ubuntu/ubuntu/pool/universe/c/chromium-browser/chromium-browser_105.0.5195.102-0ubuntu0.18.04.1_i386.deb

REBUTTAL & REAL WORKING SOLUTION

Counter-point: If using apt-get download, and restarting, then yes it DOES RESTART OVER FROM SCRATCH.

Platform: I'm using Ubuntu Bionic - 18.04 LTS - x86 (32bit) (...as the engine under Bodhi_Linux_5.1.0's bootable ISO - LiveCD).

again... The answer to this is if using the --download-only option, or apt-get download some-package as opposed to apt-get install some-package ...

if using apt-get download somepackage then YES it WILL RESTART the download FROM SCRATCH.

SOLUTION

My solution to this:

  1. backup the existing PARTIALLY-DOWNLOADED .deb file to .deb.BAK

  2. use apt-get's --print-uris option to show me the URL of the .deb file to download

  3. resume partial-download using wget -c instead of apt-get.... like so: wget -v -d -S -c [--random-wait] [--keep-badhash] https://url-to-file/path/some0package.deb

Code Template for the above steps:

  1. $ cp some0package.deb some0package.deb.BAK

  2. $ apt-get --print-uris download some0package

  3. $ wget -v -d -c -S --random-wait --keep-badhash [copy & paste here the full https://URL you got from the previous command, but NOT the other rest of that output]

Code EXAMPLE using chromium-browser:

$ cp\
chromium-browser_105.0.5195.102-0ubuntu0.18.04.1_i386.deb\
chromium-browser_105.0.5195.102-0ubuntu0.18.04.1_i386.deb.BAK

$ apt-get download --print-uris chromium-browser

[RESULTING OUTPUT:]

https://mirror.math.princeton.edu/pub/ubuntu/ubuntu/pool/universe/c/chromium-browser/chromium-browser_105.0.5195.102-0ubuntu0.18.04.1_i386.deb' chromium-browser_105.0.5195.102-0ubuntu0.18.04.1_i386.deb 79183996 SHA512:bc34c6241b4200bf9c4c8a7dccba5415daec9623741328146bf4d8edb91d3db7489d5c467162075caf9266644369ac2af0c41cd6b4e320e9c110a6e71411b4ce

In the above output, the --print-uris option gives us several pieces of info; more than we need.

  • the URL path to the package-file on the server-side ((THIS FULL URL IS WHAT WE NEED TO COPY!))
  • the filename as it expects will be locally on your PC
  • the total complete filesize on the SERVERside;
  • an SHA512 hash (to do a comparison after it's been downloaded)

Of these, I only need to copy

  • the first part, the URL
  • optional: the SHA512 hash (if i wish to compare after-download that it matches the server's copy) :

$ wget -v -d -c -S --random-wait --keep-badhas https://mirror.math.princeton.edu/pub/ubuntu/ubuntu/pool/universe/c/chromium-browser/chromium-browser_105.0.5195.102-0ubuntu0.18.04.1_i386.deb

This worked for me! In summary:

  1. I started with the command: $ apt-get download chromium-browser

  2. It got interrupted / I canceled (ctrl-c).

  3. I backed up the existing file: $ cp [local-filename.deb] [local-filename.deb.BAK]

  4. I grabbed the web URL to use via: $ apt-get download --print-uris chromium-browser

  5. I highlighted & COPIED TO CLIPBOARD the first part of the OUTPUT from that command, which (for ME) ended up being (don't use this; use the one you get in your terminal ) https://mirror.math.princeton.edu/pub/ubuntu/ubuntu/pool/universe/c/chromium-browser/chromium-browser_105.0.5195.102-0ubuntu0.18.04.1_i386.deb

  6. I then used wget -c (the '-c' means 'continue an existing download')... (with added verbose, so i could see if anything went wrong what the problem is) .... and PASTED the URL i'd gotten from the previous command, like so:

$ wget -v -d -c -S --random-wait --keep-badhash\

https://[URL-you-got-and-copied-from-output-of-the-previous-command] somepackage.deb

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .