tier1.jp

Fast APT with tmpfs (with plenty DRAM) and Apt-Cacher NG

APT, the package manager on Debian GNU/Linux, can be much faster with,

  1. tmpfs utilization
  2. APT-Cacher NG

Note

This is a spin-off article from our Debian base install guide's - Debian minimum security settings.

APT with ephemeral tmpfs /tmp

APT behavior can be tweaked by files in /etc/apt/apt.conf.d/.

In this case, we set up ephemeral tmpfs for APT .deb package tmpfs extractions.

  1. It will be fast to install and/or upgrade, provided you have plenty DRAM.
  2. It also reduces write operations on your NVMe/SSDs.

Note

This is necessary if you use /tmp with noexec.

This also requires enough DRAM and/or swap area.

FYI: 4GB DRAM can handle GNOME install (gnome-core) without swapping.

What we have to do is writing small configuration file with mkdir some mount point directory.

root# mkdir -p /srv/apt/temp # this mountpoint is an example.
root# nano /etc/apt/apt.conf.d/01-tempdir
APT::ExtractTemplates::TempDir "/srv/apt/temp";
DPkg {
  Pre-Invoke  { "mount -t tmpfs tmpfs /srv/apt/temp" };
  Post-Invoke { "umount /srv/apt/temp" };
};

Then, APT uses DRAM to extract various files, which provide us ultra fast APT operations.

Using Apt-Cacher NG for many Debian machines

If you have multiple Debian machine, the you should use Apt-Cacher NG.

It caches APT database and deb files.

  1. Once cached, updating other machines become very quick.
  2. It does saves Debian mirror's precious bandwidth, too.

Server side

root# apt install apt-cacher-ng

Server & Clients

DIRECT is a fallback when the proxy is down.

root# nano /etc/apt/apt.conf.d/02-proxy
Acquire::http::Proxy "http://RAW_SERVER_IP_ADDRESS:3142";
Acquire::http::Proxy DIRECT;

Avoid using hostname.

Apt-Cacher NG Web UI

Bookmark http://{server-ip}:3142/acng-report.html.

Thank you for reading. Have a nice day.

published: MODIFIED: