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

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