Can I make do-release-upgrade only download packages for a later upgrade?

13,544

Solution 1

There is a way to get the update manager to do steps 1-3 for you.

  1. Run sudo update-manager from a terminal window in the GUI (this is important)

    • Start the update manager, tell it you want to upgrade to the next version of Ubuntu, and let it start running. It will disable 3rd party repositories, change the main repositories to the latest version, and then run sudo apt-get update for you.
    • It will then pop up a screen telling you that in order run the update, it will have to remove, install, and upgrade packages.
    • At this stage, go to the terminal window and force-quit the program using CTRL-C. [If you don't do this, and cancel the update via the cancel button of the update manager, it will revert the changes ].
  2. run sudo apt-get -d dist-upgrade from the command line as many times as necessary, until all the packages are downloaded and ready to install

  3. run sudo do-release-upgrade and let it complete the upgrade with the already downloaded packages.

  4. Re-enable 3rd party repositories, and run sudo apt-get update && sudo apt-get upgrade again to update 3rd party repositories to the latest version (make sure the repositories are updated to the latest release of ubuntu)

Solution 2

Your first four steps are correct, but step 5 should be sudo do-release-upgrade (instead of sudo apt-get dist-upgrade). It should notice that all (or most) of the packages it was going to download are already present in /var/cache/apt/archives.

In some earlier versions of do-release-upgrade there was a bug where it would clean /var/cache/apt/archives before downloading the packages anew, but IIRC that bug's been fixed.

Solution 3

I wrote a script to do this, for my own upgrade of multiple machines to Ubuntu 14.04 "trusty". It is called 'apt-get-other-release'. Simple use:

$ sudo apt-get-other-release -t trusty
  [ a long time passes as it downloads stuff ]
$ sudo apt-get-other-release -U
  [ it prepares the system for upgrade -- this is quick ]
$ sudo do-release-upgrade   # or update-manager, whatever you're comfortable with
  [ upgrading also takes a long time and may still download some additional stuff ]

The script is at:

ftp://www.lubkin.com/pub/user/filbo/apt-get-other-release

and version 1.0 has sha1sum: 87a466b2bb2d1ac5b0a08509246a450b8d1c7617

Behind the scenes it's basically running apt-get update; apt-get -d dist-upgrade with its own private set of sources.list files. Results are stored in /var/cache/apt-$to_rel/archives, and the '-U' flag copies those into system-wide /var/cache/apt/archives so that they will be present during your upgrade.

You could also copy the upgrade archive from one local host to another, saving bandwidth. I did this for an amd64 and an i386 upgrade, copying only those *.deb which didn't have "amd64" in their names; then ran another apt-get-other-release -t trusty on the i386 machine, which downloaded another large pile of packages since the two machines had different stuff installed on them.

Feedback appreciated; email cc appreciated, as I don't know when I will next look at askubuntu. Search engines are well aware of me.

NOTE: I have not actually done an upgrade of a system so-treated! Some time in the next week. Getting this script out while it might be of some use to people.

>Bela<

Solution 4

I also wrote a script for this, which you can find at

https://github.com/neldredge/fetch-release-upgrade

Usage: in a scratch directory, run

 ./fetch-release-upgrade.sh trusty

or whatever new release you want to upgrade to. The necessary packages will be downloaded to a subdirectory called debs. You can then move them to /var/cache/apt/archives before running do-release-upgrade.

I have not yet looked at user270294's script but it sounds like it works along similar lines and may have a few more features.

Solution 5

The following slightly shorter version of Menachem's answer worked for me:

  1. Run sudo do-release-upgrade in one terminal window, wait until the prompt:

    Do you want to start the upgrade? 
    
    ...
    
    Fetching and installing the upgrade can take several hours. Once the 
    download has finished, the process cannot be canceled. 
    
    Continue [yN]  Details [d]
    

    Do not confirm, leave it open

  2. In a second terminal window, run sudo apt-get dist-upgrade --download-only

  3. When done, continue or abort at your leisure in the first terminal window

Pro tip: install a terminal multiplexer like screen and run the do-release-upgrade inside it. Then, you can reconnect with screen -D -RR should anything happen to the terminal that shows the upgrade process. (Luckily, my upgrade today was almost complete...)

Share:
13,544

Related videos on Youtube

Menachem
Author by

Menachem

Updated on September 18, 2022

Comments

  • Menachem
    Menachem almost 2 years

    I'm running lubuntu 10.10, and would like to upgrade to 11.04. I have a very temperamental internet connection, so I would like to download all the packages before running the install.

    According to this, there is no easy way to do this. The bug report mentioned in that thread is still open.

    My question: Is there a way to hack do-release-upgrade to only download the packages, kind of like adding a "-d" to apt-get dist-upgrade?

    Or is doing it manually the only way to get the result I desire?

    If I have to do it manually, are these the steps needed to do it, or am I missing something?

    1. Disable 3rd party repositories in /etc/apt/sources.list and /etc/apt/sources.list.d
    2. Change repositories in /etc/apt/sources.list from maverick to natty
    3. run sudo apt-get update
    4. run sudo apt-get -d dist-upgrade to only download the packages. Do this as many times as necessary until all the packages are downloaded.
    5. run sudo apt-get dist-upgrade to complete the upgrade process
    • Jo-Erlend Schinstad
      Jo-Erlend Schinstad almost 13 years
      That seems close to what I would have done.
    • Jack Wasey
      Jack Wasey over 3 years
      Oct 2020 answer: apt-get --download-only --target-release groovy dist-upgrade
  • Menachem
    Menachem almost 13 years
    I did this and it worked.
  • Matt Joiner
    Matt Joiner about 12 years
    What if the south of Spain is closer?
  • Menachem
    Menachem almost 8 years
    see how to do this using the GUI here: askubuntu.com/a/418789/21794
  • dgw
    dgw about 7 years
    Is the process described in the question usable for upgrading from one LTS to the next? I have a server running 12.04 that I would like to bump to 14.04, but might not have a chance to fully prepare for the upgrade before the 12.04 repos are removed later this month.
  • Menachem
    Menachem about 6 years
    this is a good way of doing it, but it may fail if you have to turn off the computer in the middle.
  • krlmlr
    krlmlr about 6 years
    @Menachem: Thanks. What do you mean by "fail", can you please elaborate? Yes, the APT sources will likely be in an inconsistent state, but other than that?
  • Menachem
    Menachem about 6 years
    I haven't tried it, so I don't know exactly what would happen. I was just thinking that because when you cancel the do-release-upgrade it reverts the changes, but you've been using the latest apt-sources to download updates, you might end up with an unstable system when you try to rerun the update later.
  • krlmlr
    krlmlr about 6 years
    I'm not sure if merely downloading installation files changes anything, isn't this just caching files from the internet? Anyway, this process worked well for me, and I aborted then restarted do-release-upgrade after downloading.
  • Menachem
    Menachem about 6 years
    yeah. as long as you don't try to run a regular update until you're done, you should be fine.
  • SO_fix_the_vote_sorting_bug
    SO_fix_the_vote_sorting_bug about 5 years
    How do you get around the unable to acquire dpkg lock issue?