Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to empty out all the data on a partition. What is the quickest way to do this? It is an Amazon EBS volume if that matters.

share|improve this question
    
The data is not that important. I just want to quickly erase it start a new process. –  shantanuo Apr 7 '12 at 3:53

3 Answers 3

up vote 6 down vote accepted

Very briefly:

umount /data
mkfs.xfs /dev/sdf1
mount /data

The basic concept here is that by formatting the partition, you get rid of everything on it really fast. I chose xfs here because it formats really fast versus ext3/4.

share|improve this answer
    
That doesn't get rid of the data, only make it marginally less accessable. –  womble Apr 7 '12 at 2:52
    
@womble He didn't scope 'remove everything' all that closely. –  sysadmin1138 Apr 7 '12 at 2:53
    
And given that he's since clarified "the data is not that important" (which I'm reading both as "I don't much care if I don't have it" and "I don't much care if you do have it"), +1 for mkfs from me. –  MadHatter Apr 7 '12 at 4:53

It all depends on how much you want the data gone. If you just want to avoid having to sit through a lengthy rm, then a reformat (as suggested by Sysadmin1138) would do the trick. If you'd prefer not to have to worry (too much) about the data still being accessable, then being an EBS volume you can just unattach it and attach a new one, and let Amazon worry about wiping it. If, on the other hand, you really want to make sure that data's gone and don't trust Amazon to do it, then you'll need to dd if=/dev/zero of=/dev/blah to obliterate it yourself.

Then we're into the world of hardware forensics, which if that's a worry for you, you really made a mistake going to the cloud.

share|improve this answer
    
+1 for another excellent criticism of the whole over-applied cloud concept. –  MadHatter Apr 7 '12 at 4:54

Here's something easy, but can take a while for lots of files, and the deleted files can be recovered from the block device until they are overwritten:

sudo rm -rf /data/* /data/.[^.]*

Here's something quick, but as above, does not necessarily make your data unrecoverable:

sudo umount    /dev/sdf1
sudo mkfs.ext4 /dev/sdf1
sudo mount     /dev/sdf1

Replace "ext4" with the file system of your choice (I prefer xfs as it is fast). Remove "sudo" if you are already root.

If you care about making sure that nobody can access the data you had on that volume, the most complete solution would be:

  1. umount the file system
  2. detach the EBS volume
  3. delete the EBS volume and all EBS snapshots
  4. create a new EBS volume
  5. attach the new EBS volume
  6. create a file system on the new EBS volume
  7. mount the file system

This process trusts Amazon to wipe your old data before letting anybody else use those disk blocks (pretty standard). If you want to take more care, you should encrypt the block device before using it.

share|improve this answer

Your Answer

 
discard

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.