It is possible to use FreeBSD’s MFS Memory Disk to speed up access times of cached web objects.
From md(4)
:
The md driver provides support for four kinds of memory backed virtual disks:
…
swap:
Backing store is allocated from buffer memory. Pages get pushed out to the swap when the system is under memory pressure, otherwise they stay in the operating memory. Using swap backing is generally preferable over malloc backing.
Chromium’s cache is at $HOME/.cache/chromium
, and so, my /etc/fstab
contains:
1 |
|
From mount_mfs(8)
:
-s256m
specifies a memory reservation of 256 M;
-wootput:ootput
hands ownership of the mountpoint from root to the user; and
noauto
prevents the system from failing to boot properly if the mountpoint does not (yet) exist.
The following additions to /etc/rc.conf
were also made:
1 |
|
which lists arguments to mdconfig(8)
for device md0
.
At mininum the -t type
must be specified and either a -s size
for malloc or swap backed md(4)
devices or a -f file
for vnode backed md(4)
devices.
The redundancies found in fstab
and rc.conf
allows automatic mounting at boot, or manual mounting after boot.
To test the changes made, as root:
# /etc/rc.d/mdconfig restart
On to the $USER/bin/pack_chrome
executable script that will both mount the md
device, and/or sync contents from the cache at RAM to a backup cache on the HDD:
1 |
|
The script requires that the $USER
is in sudoers(5)
, and is able to use the /sbin/mount
command.
Finally, after $ crontab -e
:
1 |
|
.. and the script gets called every half-hour by cron
to automate the syncing process. This also requires that $USER
is specifically allowed in /var/cron/allow
.