Sunday·01·November·2009
/var/cache/apt/ on tmpfs //at 16:44 //by abe
My ASUS EeePC 701 (4G) “nemo” running Debian Sid has a 4 GB SSD as main disk, which is on the one hand quite full (mostly with software I use, but also local working copies of software I work on) and on the other hand an SSD, so I always try to reduce the amount of write to disk without losing convenience. Similar issues have systems which run off a CF or SD card or maybe even an USB stick.
Since I ordered a 2 GB RAM bar together with the EeePC, I not bound to the 512 MB which it had originally. But on the other hand I seldom needed more than 1 GB of RAM. Usually I needed between 400 MB and 1 GB of RAM. So it’s quite obvious to use tmpfs on as many places as possible.
Making /tmp
, /var/run
and /var/lock
tmpfs
were the most obvious directories to mount as tmpfs. Especially /var/run
on tmpfs brought up a few bugs a
while ago (mostly init.d scripts relying on /var/run/$PACKAGENAME/
’s existence), but it’s no hassles to
use nowadays. Even in Debian Stable such bugs got fixed.
Next target to explore for was /var/cache
. According to the FHS, /var/cache is intended for cached data from applications. […] The application
must be able to regenerate or restore the data.
So it
should be safe to put anything under /var/cache
on tmpfs.
One directory in there which gets written quite often and with a lot
of data on Debian Unstable is /var/cache/apt
and its subdirectories, especially /var/cache/apt/archives
. If you update your
Sid installation daily, all new or updated .deb
s will be downloaded to /var/cache/apt
first.
So I put /var/cache/apt
on tmpfs by
putting the following line into /etc/fstab
:
tmpfs /var/cache/apt tmpfs defaults,noexec,nosuid,nodev,mode=0755 0 0
But despite FHS stating that anything under /var/cache
must be reproducible by the application, apt is
puking and refusing to work:
!447 Z31 ?0 L1 root@nemo:pts/0 (-zsh) 16:13:10 [~] # apt-get update E: Archive directory /var/cache/apt/archives/partial is missing. !448 Z32 ?100 L1 root@nemo:pts/0 (-zsh) 16:13:17 [~] #
If you create /var/cache/apt/archives/partial
, it will also argue about
/var/cache/apt/partial
.
Of course the workaround is simple: Just put mkdir -p /var/cache/apt/partial
/var/cache/apt/archives/partial
in /etc/rc.local
.
But nevertheless, this is a bug in apt – which already has been reported by madduck earlier this year (#523920). Unfortunately the APT maintainers have not yet even commented on this FHS violation and therefore also a Debian Policy (Section 9.1.1) violation.
One more thought about /var/cache/apt
vs only /var/cache/apt/archives
: apt-file
also caches its data under /var/cache/apt
. So if you want to use
apt-file after a reboot and have /var/cache/apt
mounted as tmpfs, you have to run apt-file update
first and it will download all
Contents
files (can be dozens of
megabytes) and not only the differences to previously downloaded Contents
files.
So if you use apt-file
a lot, you
probably go better with making only /var/cache/apt/archives
tmpfs and not whole /var/cache/apt
.
Tagged as: apt, apt-file, caching, Debian, EeePC, nemo, Sid, tmpfs, var
2 comments // show without comments // write a comment