0

I need to measure the exact size of some installation.

For example, I need to know the disk usage of apt install vim.

My idea is to install a clean Ubuntu first, then I measure the size of its filesystem (x KB); After that, I do apt install pkgname and measure the size of its filesystem (y KB) again.

So the disk usage of apt install pkgname = y - xKB.

However, there are some virtual directories, such as /proc, so I don't know how to measure the exact size of the filesystem. Also, when we do apt install pkgname, a deb file will be downloaded in /var/cache/apt/archives/, so I don't know how to measure exactly the disk usage for pkgname.

5
  • This exercise doesn't make very much sense, because, while you can get the package and installation sizes, what are you going to do with disk caches many programs use? Mar 2 '18 at 6:42
  • @mikewhatever exactly, that's why I pose this question.
    – Yves
    Mar 2 '18 at 6:47
  • @mikewhatever the command apt-cache --no-all-versions show $package | grep '^Size: ' will show the size of deb package or the disk usage of installation of package? I don't think they are the same.
    – Yves
    Mar 2 '18 at 6:48
  • You did not ask this explicitly, but the question seems to imply that you want to mesure the disk space taken by every file package or program, in fact, anything that writes to disk, before it is done. Why you want something like this is unclear, and the task is probably too broad for a single question/anser. Mar 2 '18 at 7:08
  • Don't forget the logfiles! Mar 2 '18 at 9:31
3

To measure the disk usage of a filesystem, there's df (with -k for output in kB):

$ df --output=used -k /
    Used
15761016

Also, when we do apt install pkgname, a deb file will be downloaded in /var/cache/apt/archives/...

Not with apt. See Where are packages stored installed with APT in Ubuntu 16.04? apt-get and others will still save the deb file, but for that you have apt-get clean:

clean
   clean clears out the local repository of retrieved package files.
   It removes everything but the lock file from
   /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
1

Use apt show <packagename> and look at the line Installed-Size:.

apt show also prints a line Download-Size: and this is what apt-show reports in the line Size:. This tells you the size of the .deb package which needs to be downloaded in order to install the software.

The information is also displayed for packages that aren't installed at the moment.

3
  • Can this command tell me the information of packages which have not been installed?
    – Yves
    Mar 2 '18 at 7:02
  • sorry I'm totally a newbie, if Installed-Size is the disk usage of the installation of some package, what is Download-size?
    – Yves
    Mar 2 '18 at 7:08
  • @Yves I added the information you asked for.
    – Sethos II
    Mar 2 '18 at 9:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.