• About
  • Manuals
  • Network
Confessions of a FreeBSD hacker Various tips & tricks about computers in general and FreeBSD in particular
Confessions of a FreeBSD hacker

Diskless /var

January 28, 2013 21:53 / Leave a Comment / Magnus Strahlert

On root filesystems that’s served from flash memory it may be advisable to keep off heavy writes from them. By putting /var on a ramdrive you can greatly increase the expected lifetime of an ssd or a usb memorystick.

Initial steps

A snapshot of /var needs to be created. On true diskless systems FreeBSD ramdrive filesystems can be set up by populating /conf/base. While it won’t be supported in this case, it might prove a good idea to use the same base for this purpose.
Start off by creating an initial snapshot of /var

mkdir -p /conf/base/var
tar -cf /conf/base/var.cpio.gz -C / --format cpio --gzip var

The contents on disk of /var is now obsolete.

rm -rf /var/*

Configuration

/etc/rc.conf

mdconfig_md0="-t swap -s 64m"
mdconfig_md0_cmd="tar -xpz -C / -f /conf/base/var.cpio.gz"

/etc/fstab

/dev/md0 /var ufs rw,noauto 0 0

/etc/rc.shutdown.local

Whenever the system is shutdown, the snapshot must be updated with the current contents.

mv /conf/base/var.cpio.gz /conf/base/var.cpio.gz.old
tar -cf /conf/base/var.cpio.gz -C / --format cpio --gzip var

The above would also prove useful in crontab to safeguard for brownouts or system crashes. So add the following to root’s crontab.

0 * * * * /bin/sh /etc/rc.shutdown.local
Posted in: FreeBSD / Tagged: freebsd, ramdrive, snapshot, ssd, usb

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

Post Navigation

← Previous Post
Next Post →

Recent Posts

  • Takeaways utilising VFIO in a KVM virtual guest
  • Converting VM from ESXi to KVM with iSCSI storage
  • Deploying oVirt in self-hosted mode
  • Ansible playbook for handling perl on FreeBSD
  • iSCSI: Migrating from istgt to ctld

Tags

ansible backup carp chroot cluster cross-server esxi freebsd ftp ftpchroot gpt grub hast install iscsi kvm linux lun lvm mirror network nfs nfsroot ovirt pxe raid ramdrive raspberrypi snapshot ssd ssh terminalserver usb vfio virtio virtualbox vlan vmware volumes winxp zfs zpool zroot

Archives

  • July 2019
  • March 2018
  • February 2018
  • July 2017
  • February 2016
  • January 2015
  • August 2014
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • September 2012
  • July 2012
  • April 2012
  • March 2012
  • November 2011
  • August 2011

Recent Comments

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    © Copyright 2013-2016 - Magnus Strahlert
    Infinity Theme by DesignCoral / WordPress