1

I have a Ubuntu 14.04 server which has one drive where rootfs is mounted.

I just added an SSD disk which I have mounted at /ssd

Now I want my /tmp & /var/tmp to use this fast drive to speed up my server. First I wish to tackle just /tmp (and I know repeated writes may shorten the life of ssd).

In my crontab, I wish to add an entry like this:

@reboot /bin/sleep 5; install -d -m 1777 /ssd/tmp 
&& install -d -m 1777 /tmp && rm -r /tmp && ln -s /ssd/tmp1 /tmp

the potentially superfluous install -d -m 1777 /tmpis only there to make sure that rm -r /tmp does not fail (and rm -r /tmp exists to ensure that ln -s does not open another tmp under /tmp which will make this set ineffective.

ComBin
  • 576
  • 4
  • 7
Anil Garg
  • 11
  • 2
  • I tried unionfs but wasn't able to make it work. – Anil Garg Jun 07 '16 at 05:30
  • 1
    SSD disks get better and better, so I would not worry about the amount of writes. I would recommend some basic tuning (noatime, etc). Other than that every SSD should cope with it. Take a look here: http://unix.stackexchange.com/questions/80864/what-not-to-put-on-an-ssd/80868 – nobody Jun 07 '16 at 06:13
  • 1
    I would put "root" (including /tmp and /var/tmp/ onto the ssd but not use crontab. Use `/etc/fstab` for it. – Rinzwind Jun 07 '16 at 07:51
  • @Rinzwind May I suggest you post that as an answer? – Jos Jun 07 '16 at 07:59
  • The fastest `/tmp` would be on a tmpfs and then a swap partition on you SSD. Let a caching algorithm handle where to store your transient data because they're usually better at it. – David Foerster Jun 07 '16 at 08:49

1 Answers1

0

You can simply mount your ssd as /tmp partition. To mount on loading you can write this to /etc/fstab/.

For example:

$ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdb2 during installation

...

/dev/sdb1 /tmp           ext4    discard,defaults        0       2
/dev/sdb2 /var/tmp       ext4    discard,defaults        0       2

See https://en.wikipedia.org/wiki/Fstab for more information.

ComBin
  • 576
  • 4
  • 7
  • Tks @david and tks rinzwind. What if I added the ssd as a swap and then add following to the /etc/fstab `tmpfs /tmp tmpfs defaults 0 0` 'tmpfs /var/tmp tmpfs defaults 0 0` `tmpfs /run/shm tmpfs defaults 0 0` – Anil Garg Jun 15 '16 at 13:58