Ubuntu – Move /var directories to to /mnt on an EC2 instance

amazon ec2mountUbuntu

I am trying to work on a standard configuration for a set of EC2 instances running ubuntu 12.04. These servers are going to be primarily web servers for a Ruby on Rails application. When you configure a new large instance, you are given a primary of 8GB and then ephemeral storage of 400 GB that is mounted to /mnt.

It seems logical to me to move some directories that have a potential for growth off to the /mnt directory, I was specifically thinking of /var/www and /var/log.

My question is two-fold:

  1. Is this a good idea or are there pitfalls that I cannot see?

  2. If this is a good idea, how should I go about configuring this. I do have the ability to configure new instances and down our old instances. My concern is over long term configuration, I am not necessarily concerned about downtime.

I am a developer with some experience in devops, but mounting drives is something I have not faced before, so explicit directions would be greatly appreciated.

Best Answer

I don't know what you keep in /var/www, but the contents on my servers definitely can't be described as "ephemeral", which I understand to mean "could go away any time, and I don't much mind". If that's not what amazon means by "ephemeral", I apologise.

As for /var/log, if you don't care about the log data at all, don't collect it in the first place.

If you do care about it, but can't afford to hold it in primary storage very long, then this isn't a mounting issue so much as a log management problem. I'd be inclined to use logrotate, if it's available to you, and configure it to move old logs out to /mnt every week or so. That way, the old logs are there (until the ephemeral storage goes away), but the current log is safe on primary storage.

A logrotate recipe like

/var/log/foo {
    olddir /mnt
    compress
    weekly
    rotate 1000
    postrotate
    /etc/rc.d/init.d/fooservice restart
    endscript
}

might be of use, at least as a template.