Introduction/special considerations

Raspberry Pi is a good platform for TeX: light-weight by modern standards. Typically use just a text editor (maybe IDE), TeX complier and a PDF viewer.

TeX Live choices

You may use the distribution’s TeX Live packages (available via apt-get, aptitude, …). This is an easy install, but you will be limited to the distro’s update cycle. Raspbian is a Debian which runs TeX a few years behind.

The alternative is to use the TeX Live DVD or other routes. Slightly more harder to install but you get an updated TeX installation. As a UKTUG, or similar user-group, member you most likely have a DVD as part of your membership.

Special considerations

A Raspberry Pi has some specific issues in that it has fairly small storage and it’s mostly flash. Flash wears fairly quickly if it gets written too much.

Flash

Flash will typically last of the order of 10^5 writes. The effective life is dependent on which model of SD card you have, percentage use, and the quality of its wear levelling.

In order to reduce SD wear some installations have /tmp in RAM, using tmpfs. A Raspbian installation may have /tmp on the SD card, but some sources suggest that /tmp gets moved to tmpfs. Typically 5 or 20MB.

This stops the most regularly written files from wearing the SD card unnecessarily. But the downside is that /tmp is relatively small/finite size.

/tmp in tmpfs

For most applications, including TeX, an size/inode limit isn’t normally a problem. But for build and install then some thought is needed.

I will just cover install here. Build is more complex, but most people won’t ever need to know.

The installer/tlmgr uses /tmp to untar packages, some of which can be quite big. Their distribution in the archive is effectively random. If you are lucky with your installation choices then only small packages get untarred, so you won’t hit the limit. But just one slightly large tar file and the whole install fails.

So you may need a bigger temporary directory, and some other things too.

Installation

Install needs access to the DVD contents (or other repository) and a mountable read-write volume that allows for a big temporary directory. Best that it be magnetic and not flash.

You can use a USB HDD or possibly mount your PC’s HDD over your LAN via sshfs or NFS. Net-mount could take the least additional hardware, but can be slow.

The preferred solution is to use a USB HDD.

If you have a USB DVD reader, then you can plug it directly to your Pi. Or copy the DVD to a USB stick.

Remember to set TMPDIR:

Once mounted, you must tell the installer/tlmgr to use your bigger temporary directory. Using the environmental variable “TMPDIR” you point there. Something of the form of: “export TMPDIR="/media/wibble/tmp"“.

If you are happy with a /tmp in your SD card (or wherever), then no need to set a new temporary directory/TMPDIR.

Decide on your mountable volumes

Primarily a choice of: LAN mount or USB HDD:

LAN mount

Via sshfs or NFS you need to mount the DVD and a separate temp dir. Documentation for these share methods is elsewhere.

The advantage is that it takes the least hardware and can be done remotely. It allows for parallel installs onto multiple RPis; should you desire. But the downside is that it can be slow, especially since most RPi’s ethernet is only 100T. Wifi even slower.

Typically you will do two separate shares: the DVD and the temp dir. The DVD can be mounted with export entries like: /media/cdrom and probably something like /working/tmp for the temporary.

Generally not a good idea to mount your PC’s own /tmp, so make your share’s temp dir either in your own home or in another more generally shareable directory.

Maybe you want a network swap; goes rather slowly but you can be assured that nothing’s writing to your SD card unnecessarily.

Typically your LAN mounts would look like:

/mnt/wibble/cdrom the DVD contents
/mnt/wibble/tmp temporary dir
/mnt/wibble/swapfile your new swapfile

See below the caution about interruptible swapfiles.

USB HDD

You might want a separate DVD drive, but less hardware is to copy its contents to your external HDD. If you have something like a WD PiDrive then this is nearly permanently mounted to the RPi. But you might be using a more portable one.

  1. Copy the TeX Live DVD to a reasonable directory (or  use USB DVD).
  2. Make a temporary directory
  3. Maybe make a big swapfile

So your HDD looks like:

/work/texlive/2018 the DVD contents (or whatever year)
/work/texlive/tmp temporary dir
/work/texlive/swapfile your new swapfile

If you are using your own bigger swapfile then read the documentation on swapon/swapoff to ensure it gets used. You should ensure the USB connectors can’t be disturbed, else your RPi will probably hang/crash.

Controlling your package manger/stock TeX Live

Most Linuxes have Tex Live already available as packages within the distribution. For example: whichever Raspbian you are using. This will be an older version of Tex Live than is on this year’s DVD/repository; so you want to suppress it: a) so you don’t run the wrong binary/script b) saves space.

You should ensure that the stock TeX LIve packages aren’t installed when you install the DVD. Then you suppress the package manager from installing them in the future.

The instructions for this are maintained on the TeX Live Debian pages (https://www.tug.org/texlive/debian.html).

Build

The TeX Live DVD binaries are built for an ARMv6 chip, as found in a RPi v1. They will run on any variant of Pi; whether 1, 2 or 3, … (these can have ARMv7 and later) . So good for most people.

On more advanced RPis, with later chips, then possibly a native build would run more efficiently. Should you wish to do so then another page on building might get written in the future.

Conclusion

Once setup TeX works nicely on a RPi.

Thanks

Thanks to UKTUG for funding the Raspberry Pi TeX Live build project.