Running FreeBSD from a flash device

I wanted to get some opinions on best practices to follow when running a FreeBSD system from flash-based storage devices, with respect to minimising frequent writing and avoiding wearing the devices out rapidly.

I've built a couple of NAS systems using ZFS for my main storage pool, but to keep things simple I've always opted to create the pool from whole disks, meaning the systems can't be booted from any of the disks in the pool. Instead I've configured the systems to boot from a flash device, an internally connected USB stick in one case, and a compact flash card in another.

The flash device has bootcode installed and has a single UFS filesystem containing only the /boot directory, so the kernel and ZFS modules are loaded from there, then the root filesystem can be mounted from the ZFS pool.

What I want to do is move the entire FreeBSD installation to the flash device to maintain a cleaner separation between the OS and my data. To do this, what steps should I take to reduce the frequency of writes to the device? A few things I've already considered are:

  • Don't put swap on the device
  • Use tmpmfs or tmpfs(5) for /tmp
  • Use varmfs for /var

Another thing that springs to mind is kernel/world/port building. I assume this results in a lot of temporary files being written during the build process. Does this usually happen in the /tmp directory? If not, where else?

What other routine system activities that involve a lot of disk writing may I have missed?

Thanks for any suggestions.
 
The way I've done it is to put a single UFS filesystem onto the flash device for /, and then use ZFS for the following:
  • /usr/local
  • /usr/ports
  • /usr/src
  • /usr/obj
  • /var
Whether or not you split /home off to a ZFS filesystem depends on how much stuff you store there.

Definitely don't put swap on the flash device, unless it's an SSD.

On our SSD-using systems, I put everything onto the SSD, and just use the ZFS pool for bulk storage. On our USB/CF-using systems, I split off the above filesystems to minimise the writes/accesses to the device.
 
  • Thanks
Reactions: jem
Back
Top