4

When I usually log in to server and do apt upgrade its usually max a few hundred mb is required for update. I just logged in to one of my vps that only has virtualmin installed and the apt upgrade is reporting it needs 16.8gb which is more space than I have available.

This doesn't seem right. How can I see what packages are requiring so much space?

Guerrilla
  • 193
  • 5
  • 18
  • 16GB is huge - I think you're right to suspect something is up. I can't see a way to get this breakdown with `apt` or `apt-get`. You could do a laborious manual search by looking at each package to be upgraded and issuing `apt install ` (or a list of packages) - that would tell you the total download size for and its dependencies. – Joe P Jun 05 '17 at 23:03

1 Answers1

1

Install apt-show-versions package on the machine:

$ sudo apt-get install apt-show-versions -y

Get a list of packages that are upgradable:

$ apt-show-versions -u

The following shall provide you with a list of upgradable packages and their correspnding size (bytes) in ascending order:

$ for i in `/usr/bin/apt-show-versions -u | tr ' ' / | cut -f1,6 -d'/' | tr / =` ; do echo -n $i ; sudo apt-cache show $i | grep '^Size:' | cut -d: -f2 ; done | sort -k2 -n

A quick break down of the above command:

  • /usr/bin/apt-show-versions -u | tr ' ' / | cut -f1,6 -d'/' | tr / = provide a list of packages with their upgradable version in packagename=version format
  • sudo apt-cache show $i | grep '^Size:' fetch the size of the package
  • sort -k2 -n display formatted output in ascending order

Find out security updates:

$ apt-show-versions -u | grep security

It is generally a good practise to configure security auto-updates:

$ sudo apt-get install unattended-upgrades -y

If unattended-upgrades is already installed, and you like to ensure it is configured to automatically apply security updates:

$ sudo dpkg-reconfigure unattended-upgrades

vagarwal
  • 845
  • 6
  • 8
  • 1
    How does this answer the question? I have tried this and I don't see any way of getting **sizes**. – Joe P Jun 07 '17 at 10:05
  • Does the Size: reported by apt-cache correspond to the size that would need to be downloaded for an update? I thought it was the size for a new install, and that these wouldn't necessarily be the same. – Joe P Jun 07 '17 at 13:43
  • One system of mine reports `Need to get 75.0 MB of archives` from `apt upgrade` but your command results in a total of 2736502 = 2672MB approx – Joe P Jun 07 '17 at 13:55
  • Edit of your command to show just total: `for i in \`/usr/bin/apt-show-versions -u | tr ' ' / | cut -f1,6 -d'/' | tr / =\` ; do apt-cache show $i | grep '^Size:' | cut -d: -f2 ; done | paste -sd+ | bc` – Joe P Jun 07 '17 at 13:56
  • 2736502 bytes = 2.736502 megabytes and even that is not close enough to 75.0 MB. I can only speculate that you have a few packages already available in /var/cache/apt. I tried this on two separate servers: `for i in $(/usr/bin/apt-show-versions -u | tr ' ' / | cut -f1,6 -d'/' | tr / =) ; do echo -n $i ; sudo apt-cache show $i | grep '^Size:' | cut -d: -f2 ; done | awk '{ total+=$2 } END { print total / 1000 / 1000 }'` and the output is *very* near to value provided by apt upgrade. The *Size* value in apt-cache show might be the size of the .deb package. – vagarwal Jun 07 '17 at 14:17