Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

EC2 Ubuntu servers erase all disk contents when being shut down. Following an unfortunate accident, I have decided to prevent the command-live halt, poweroff and shutdown.

  1. What's the best way to do it? I thought about renaming these commands (at /sbin) to something like HALT_RENAMED___ERASES_ALL_DISK_CONTENTS.

  2. Are there any files, other than the three listed above, that needs to be handled?

  3. I've noticed that halt and poweroff are merely links to reboot. Should reboot be renamed, too?


share|improve this question
up vote 1 down vote accepted

I strongly recommend using EBS based instances and periodically creating snapshots of your EBS volume. In the case of a potential hardware issue, EBS based instances can be stopped/started (which causes them to start up on different hardware, unless you are very unlucky)

I recommend snapshots because EBS volumes don't have the same redundancy as S3. They're more reliable than a regular hard drive, but I've had EBS volumes fail and my snapshots have saved the day.

ec2-modify-instance-attribute --instance-initiated-shutdown-behavior stop does not work to non EBS instances.

share|improve this answer

If you're using EC2 instances and you have data that needs to persist, you should be using EBS volumes to hold the data. Otherwise you're responsible for putting together a process to periodically upload to S3 or other backup strategy to have restored upon reboot. I have close to a dozen EC2 instances running and use a combination of both strategies.

The drive mounted for / on EC2 instances is meant to clear when it is shutdown completely which is what halt, shutdown and poweroff do. The drive will remain during a reboot but when the instance is shutdown completely it is destroyed which is exactly as Amazon tells you in the terms of use for EC2 and why they recommend EBS if it needs to persist.

The only other option is to use EBS-backed instances which would then persist but you'll be paying for the storage of the EBS volume. This would but the entire instance on an EBS volume rather than just the data necessary to be persisted.

share|improve this answer

You can change the shutdown behavior:

ec2-run-instances                           \
  --instance-initiated-shutdown-behavior stop \

Read more in deap about this here:

share|improve this answer
Is this relevant to non-EBS volumes? – Adam Matan Mar 16 '10 at 14:52

There is no way.

SERIOUSLY - you should not rely on an EC2 server to keep state. This is well documented.

You CAN NOT stop a virtual machine from being shut down. What if the server fails? Wont happen - happened already at Amazon. Systems just crash.

Basically you are hunting ghsots here. You can not stop a VM from being shut down.

share|improve this answer
Of course I can not completely prevent this from ever happening; I want to eliminate the sudo halt scenerio. – Adam Matan Mar 16 '10 at 14:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.