1

How do I clear the contents of an Amazon AWS EBS volume. I am looking to revert it to the factory state.

I am not looking to delete the volume itself and will be reusing it with the same instance I currently use it with.

Nimesh Neema
  • 1,528
  • 2
  • 17
  • 44

1 Answers1

7

An Amazon EBS volume acts like a normal disk. So, just do whatever you would normally do to a disk to "revert it to the factory state".

However, I actually would recommend deleting the volume and adding a new one. This is because EBS tracks which blocks have been used on a disk volume. When a Snapshot is made of a volume, it copies all the used blocks to the snapshot. So, you only pay for snapshot storage of used blocks. Taking a snapshot of a brand new volume is practically free because only a few directory blocks are used.

If, however, you have a previously-used disk then many of the blocks will be marked as used. Even if you do a Quick Format of the disk, EBS still thinks that the blocks are in use (it doesn't know anything about the data, just the fact that data has been written to some blocks). Therefore, if you take a snapshot of a recently 'cleaned' disk, you'll also be including all of the old blocks in the snapshot.

Similarly, even when data is deleted from a disk, it is still possible to read the raw disk sectors so somebody might be able to read the deleted data. Deleting and recreating the volume will prevent this from happening.

If you never snapshot and you're not worried about somebody sniffing around deleted blocks, then just tell your operating system to clear the disk (eg Windows Quick Format).

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Thanks for the helpful answer. I originally though of deleting contents instead of Volume as I as unable to get rid of some of the files from a server program that I installed. I am using an instance running Ubuntu. I tried `sudo rm -rf ` as well as killed any associated processes as identified from the output of `ps -A` by running `kill -9 ` but to no avail. The process was successfully killed, but data somehow is not getting deleted. No error message is returned by `rm -rfv`. – Nimesh Neema Jun 08 '18 at 10:43