12

I am running an Ubuntu server on EC2 ebs, and my application needs a lot of temporary disk space, allocated in /tmp. However, on ec2 the root drive which also contains /tmp is pretty small, around 10GB. All of the remaining disk space is mounted under /mnt. As a result, my application returns 'out of disk space' errors, because /tmp seems to be full.

What is the best way to solve this problem? One thing I can think of is create /mnt/tmp and make a symbolic link

/tmp --> /mnt/tmp

However I am a bit reluctant to mess around with something that is used by so many linux programs and tools. I am not sure if every program will correctly resolve the symbolic link, and not sure what it would to to performance.

Jeroen Ooms
  • 2,239
  • 8
  • 34
  • 51

3 Answers3

5

With EBS-backed images, the ephemeral storage is still available, it just isn't mapped as a block device by default (as it is on instance-store images)

The amazon doc is here, and there's a useful blog post, here

In summary: you can specify this mapping on the command line when you launch the image, and then mount it as a normal volume on /dev/sd[x]. Or you if you roll your own AMI, then you can bake the mapping into that AMI so that all images launched from it have access to it from the outset.

Symlinking /tmp will work, but I wouldn't recommend it in this case, where you have a large amount of temporary storage in use. Once you have the device mapping available, you can have the device mounted as /tmp in /etc/fstab.

With a small instance, you should have 150GB of instance store available for free. It hoepfully goes without saying that this storage dies when the instance reboots. If your usage isn't that temporary, then you need to create your own, new EBS volume and mount it that way.

SmallClanger
  • 9,127
  • 1
  • 32
  • 47
  • 1
    Why is symlinking not recommended? For example if I want to put both /var/tmp and /var/log onto my ephemeral storage, I can mount the storage as /mnt and symlink both directories there. – j0nes Mar 11 '12 at 13:45
  • Good point. I was thinking about this specific case, based on the assumption that the OP was considering symlinking back to the main partition. I'll clarify my answer. – SmallClanger Mar 11 '12 at 14:15
1

You can bind the /tmp mount point to /mnt/tmp:

sudo mount -B /tmp /mnt/tmp

hithwen
  • 111
  • 2
0

Symbolic linking as suggested in the question is not that bad a solution. But there is some extra care to be taken while doing so. Just to consolidate the precise steps involved in mounting the volume are:

1) Create new volume in AWS console. Attach it to instance.

2) Format it and mount it under say /mnt/vol1

3) Clean up /tmp to whatever extent possible.

4) mkdir /mnt/vol1/tmp && mv /tmp/* /mnt/ && rmdir /tmp && ln -s /mnt/vol1/tmp /tmp

chicks
  • 3,793
  • 10
  • 27
  • 36
Murphy
  • 101
  • 1
  • 1
    Moving the files to the new directory is not going to achieve the desired result for any file which is currently open. I would reboot instead, since programs cannot expect files in `/tmp` to survive a reboot. – kasperd Apr 04 '16 at 22:03