Increasing size of /tmp on EC2 instances

amazon ec2

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.

Best Answer

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.

Related Topic