I exhausted my tmpfs due to runaway nginx logs in /tmp/log. I would like to move all the logs, and possibly the whole /tmp tree to my SSD to prevent future problems. It was fairly easy to move /tmp/log by using mount --bind.
Questions:
how can I get my mount --bind to survive a reboot? Normally I'd do this in fstab. (When I searched, unfortunately I get a bunch of unrelated info on the Bind package...)
is there a way to cleanly disable the whole tmpfs system and use the ssd instead?
I'm OK with using mount --bind to redirect /tmp/log to an SSD, if disabling the tmpfs is going to be messy and complicated.
no really... ssd is likely module related... so "post pre-init"
cat /lib/functions/preinit.sh | grep -C20 tmpfs
then you've got some init.d action @ /etc/init.d/boot... with ssd traditionally being kicked in at /etc/init.d/fstab... you could add the commands there after block mount for a more "precise" hook ... but any earlier introduces complexities in the os-init and recovery routines... in the event the ssd is ever to become unavailable...
on that... you should probably have something like;
if [ ! -b /dev/ssdpart ]; then exit 0; fi
if ! mount | grep -q '/ssdmountpoint'; then exit 0; fi
etc. etc.
startup is also ok... for whole of /tmp, you could try -o move...
I'm a little confused about the --move (or -o move) option. Didn't actually know it existed. From the docs:
mount --bind olddir newdir
mount --move olddir newdir
This will cause the contents which previously appeared under olddir to be accessed
under newdir. The physical location of the files is not changed.
The bind option I understand. I use mount --bind /opt/log /tmp/log.
The move option seems backwards to me. --bind will already make olddir available at newdir. What i want is the original contents of newdir merged into olddir.
Add a swap partition to your SSD. After plugin:
swapon -a
mount -o remount,size=2G /dev/shm /tmp/
Tmpfs should claim 2G using swap if needed. You can check this with "df -h /dev/shm"
Last step: add the tmpfs remount command and swapon command into rc.local.