Securely erasing files, by filling your disk
Posted by Steve on Sat 2 Jan 2010 at 14:34
With modern filesystems securely deleting files isn't always easy, but one approach which stands a good chance of working is to write random patterns over all unused areas of a disk - thus erasing the contents of files you've previously deleted.
The Debian secure-delete package contains a number of tools, but the one that I get the most use out of and the one which I'm most confident of is sfill.
The sfill command allows you to write data to all unused areas of a mounted partition. This should ensure that the contents of any deleted files have been overwritten, thereby giving you confidence that their contents are well and truely gone.
To get started install the package:
gold:~# aptitude update gold:~# aptitude install secure-delete
Once installed you can overwrite the unused content of any mounted partition like so:
gold:~# sfill /home
Note: This assumed /home is mounted as a partition. In my case it is, as we can see from this output:
gold:~# mount | grep /dev /dev/mapper/gold--vol-root on / type ext3 (rw,noatime,nodiratime,errors=remount-ro) udev on /dev type tmpfs (rw,mode=0755) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) /dev/md1 on /boot type ext3 (rw) /dev/mapper/gold--vol-home on /home type ext3 (rw) /dev/mapper/gold--vol-music on /home/music type ext3 (ro) /dev/mapper/gold--vol-kvm on /kvm type ext3 (rw)
When you run sfill the program eats up all free space by creating a huge file. Then the contents of this file are written in a number of steps - ensuring that all areas of the disk which were previously free have had their contents erased. Once completed the huge file is removed, meaning you have free disk space again.
For more details please consult the files installed beneath /usr/share/doc/secure-delete, or read the manpage via "man sfill".
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Yes it can take a long time - and agreed that if you're on a multi-user system that others will be inconvienced when the drive is full.
Still I'd hope that if you're the admin of a multi-user system you'd choose a time when others aren't using the system, and that you'd take care to disable email deliveries, etc. (So that delivering to ~/Maildir doesn't fail).
Debian is huge with new packages being added all the time!
[ Parent | Reply to this comment ]
Concerning the journal, wouldn't it be enough to just use the disk a little, the journal will be overwritten then, won't it?
[ Parent | Reply to this comment ]
For instance, you should know that EXT3 reserves a certain percentage of blocks (5% by default) to prevent non-root users from filling up the disk. So you might need to run this as root to work properly.
Also, if you use anything quota-related, you're in bad luck as well.
And this method is not really practical if you have large amounts of unfilled storage. The process might take too long because, and services/jobs will start to crash and complain since they're out of disk space.
My advice, if you're going to do this, is to switch to single-user mode and have the system do it's things while the rest is completely inactive.
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Good points about the use of quota-related tools, but you run the sfill tool as root anyway so the 5% reservation doesn't apply.
However you're right to say that it can take a long time to run, in practise I found the time wasn't too horrific, and that starting with a small partition such as /boot would give you a good idea of how long it would take to cleanup the rest.
[ Parent | Reply to this comment ]
yes, there's overhead with encrypting everything, but that's what multicore processors are for. ;-) i really only notice it during high i/o scenarios, like synchronizing two systems (ie unison) or moving large files between systems (eg copying iso from my bittorrent server to my desktop for burning). i don't notice it (ie see kcryptd at the top of top) when web browsing, emailing, or even compiling largish packages.
for a multiuser system, maybe it's more reasonable to encrypt /home and insure no user data gets written elsewhere (eg /tmp; also useful for quota reasons).
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
I have a mixture of both on my systems - but definitely love using LUKS to encrypt partitions.
But either way if I ever gave a disk drive away I'd run it through dban first, its just the sanest thing to do.
[ Parent | Reply to this comment ]
smartctl -a -d ata /dev/sda >smart.0baseline.log
smartctl -t offline -d ata /dev/sda
<wait length of offline test>
smartctl -a -d ata /dev/sda >smart.1offline.log
diff -u smart.[01]*.log
badblocks -v -s -p 1 -w /dev/sda
smartctl -a -d ata /dev/sda >smart.2badblocks.log
diff -u smart.[12]*.log
and it's interesting that i read dban.org trying to figure out what exactly dban did (besides the nebulous "securely wipes the hard disks"), but couldn't find anything, except the assumption that it writes "random" data based on the Gutmann FAQ entry. for badblocks, in write-mode (-w) without manually specifying a test pattern (-t), it writes 0xAA, 0x55, 0xFF, and 0x00, which effectively deletes all data, but also verifies the disk by following each write cycle with a read cycle to insure what's written is also read and can trigger SMART errors by touching a previously unused bad sector.
[ Parent | Reply to this comment ]
i translate your article to Chinese in my blog
you can see it
http://kadok0520.pixnet.net/blog/post/25604532
thank you!
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Thanks!
[ Parent | Reply to this comment ]
I bought many second hand servers which were used by companies and they didn't even bother deleting any files from them or zer0ing the boot records at least...
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
1. Filesystems allocate storage in multiples of some minimum amount, and if you store a file containing one byte of data there will be a possibly substantial quantity of storage allocated for the file but unused. It is not likely that simple tools will have any effect on this unused space, but it _is_ likely (a) that the space will have been used previously to store data, possibly sensitive data, and (b) that the data will still be there unless for example the filesystem honours some attribute such as 'chattr +s' on the file (or you've been filling the disc using this technique on a fairly regular basis for quite some time... :)
2. File metadata such as name and timestamps can be an issue.
3. It is probably not necessary to fill a partition to ensure that all erased data has been overwritten, because most sane filesystems will use a least recently used algorithm when writing data. So at worst you can just write two files which are slightly bigger than half the available free space.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Because you never know how files will be remapped to inodes/sectors - so aliasing rm isn't necessarily any more secure than the utility described here.
[ Parent | Reply to this comment ]
:-)
[ Parent | Reply to this comment ]
# /dev/zero > /zero.fill or similar?
This creates an emty file using all the drives/partition's remaining space, then delete it.
#rm /zero.fill
You can zip the dir or partition contents then also, and have maximum
compression eh?
cheers
[ Parent | Reply to this comment ]
# cat /dev/zero > /zero.fill
[ Parent | Reply to this comment ]
Kendilerini "Komünist" olarak niteleyen konturgerilla emperyalizmin sadık uşağı MLKP hırsızlıkla ele geçirilen düşüncelerimi kendi düşünceleri gibi lanse ettiler..Sanki kendileri düşünerek üretmiş gibi gösterdikleri, düşüncelerimi revize ederek ifşa ettiler.İşçi, emekçileri, gençliği ve köylüleri kandırarak, sanki kendileri düşünebilen ve üretebilen bir çeteymiş gibi göstermeye çalışıyorlar.Bu konturgerilla emperyalist cetenin yaptığı hırsızlık sayesinde, bana ayit olan Marxist düşünceyi, konturgerilla emperyalizm çetesinin revize ederek idealislestirdiği yaklaşımla bütün dünyaya yalan rüzgarıylan kendi düşüncesi gibi sunan pervasızlar kendileri tek başlarına düşünce geliştirmekten yoksun olduklarını pespaye çaresiz biçimde, bir başkasının düşüncelerini, sahtekar konturgerilla emperyalizmin kendi beceriksiz "felsefeci" olduğunu söyleyen düzenbazlara hazırlatıp kamoyuna sundular.Bana ayit olan Komünistlerin İki enternasyonal anlayışı olmalıdır.Revize ederek kıtasal komiteler oluşturmalıyıza revize ettiler.Sahtekar konturgerilla emperyalizmi ve uşakları bir care durumda didine durdukları için başkalarına ayit olan düşünceleri kendi düşünceleriymiş gibi gösteriyorlar.
KOMÜNİSLERİN İKİ ENTERNASYONAL ANLAYIŞI OLMALIDIR!
Kendimize sorular sorarak başlayabiliriz.Neden Komünislerin iki enternasyonal anlayışı olmalıdır.Burda hemen şu soru akla gelecektir.Marxın ortaya koyduğu anlayış komünistler için yeterli bir yaklaşımdır.Bizler var olan enerjimizi bunun için sarfetmeliyiz.Ayretten bir antifasist, antiemperyalist enternasyonal anlayışına ihtiyacımız yok.Bunun yerine enerjimizi Marxın ortaya koydugu anlayışı güçlendirmeliyiz, diyenler çıkacaktır.
Şunu görmek gerekiyor.AB ilk kurulduğunda, Almanya, Fransa, İngiltere eksenli bir örgütlenme biçimiydi.Gün geçtikçe genişleyip, büyüdü.Bu gün ise 25 ülkeden oluşan bir yapılanmadır.ABD emperyalizmi dünya ekonomisine egemen olmak isterken, ortaya Irak, Venezuela, İran ve Sudi Arabistan arasında petrol anlaşması, OPEC gerçekleşmesiyle, ABD’nin dünya ekonomisine egemen olma isteği, böyle giderse suya düşecek duruma geldi.ABD emperyalizmi buna izin vermeyeceğini, Venezuelada ABD yanlılarının darbe girişimiylen ifade etti.Aynı zamanda Irak işkaliylen, OPEC anlaşmasına müsade etmeyeceğini somut bir biçimde ortaya koydu.Bu işkal esnasında, avrupanın her ülkesinde yarım milyon işçi ve emekçinin yürümesi avrupa emperyalizminin, yatağa girer girmez kabus görmeye başlıyor.Bu kabus, avrupa emperyalizmine, bu konuda önlem seferberliğine soktu.Bundan kaynaklı yeni bir örgütlenmeye giderek, avrupa çati örgütü kurdu.Avrupa çatı örgütünün aldığı kararları 25 avrupa ülkeside uygulamak zorunlu kıldılar.Oluşturulan avrupa çatı örgütü hemen kendisine pilan oluşturmaya girişti.Avrupa işçi ve emekçilerinin yaşam sınırlarını düşürerek, avrupa işçi ve emekçilerini kendisine döndürerek politik gelişmelerden uzak tutmayı hedefliyordu.Bundan kaynaklı Almanyada, agenda 10 ve harz yasalarını oluşturdu.Fransada sarkozi yasasını hayata geçirdi.İsviçrede, bıloşur ve emeklilik yasalarını devreye koydu.İngiltere ve Hollanda'da faşistleşmiş yasalar işleyişe koydu.Bu biçimle işçi ve emekçileri gelecek korkusuna sokarak, gelecek peşine koşturan bir yığın haline getirmeye yöneldi.Emperyalizmin bu beklentisi, montag demo (pazartei eylemi), Bochum OPEL işçilerinin işyeri işkaliylen gelişen ve 9 ülkeye yayılan eylemler, Mersedes işçilerinin otoyolu işkali, Pariste geliştirilen bir uyarı gırevine 100 binlerce işçinin katılması sağlandı. İtalyada 500 bin işçi ve emekçinin katıldığı gırevin avrupada yükselmesi, emperyalizmi uykusundan çığlık çığlığa uyanmasına neden oluyor.Emperyalizmin gördüğü kabuslar gün geçtikçe çoğalmaya ve hız kazanmaya devam ediyor.Emperyalizim yatağından uzak duruyorki kabusları ona kap kırizi yaşatmasın, yaşama uykusuz devam ediyor.
Ama emperyalizm ne yaparsa yapsın kabusları gündüz vakti bilen emperyalizmi rahat bırakmıyor.Neoliberal saldırıların göçmen ve yerli işçi, emekçilerin bir balon gibi şişmesine neden oluyor.Şişen bu balon Pariste patladı.Emperyalizmin ırkçı saldırısıylan, neoliberal saldırısı birleşince, paris banyolleri savaş alanına döndü.Paris fabrikalarının savaşa dahil olmayışı ve derimci önderlikten yoksun oluşu, gelişen hareketin hedefsiz olarak görmek ve değerlendimek gerekiyor.Gelişen hareketin olumluluğu ise lokal olmayışıdır.Belçikaya ve Almanyanın, Berlin, Köln kentlerine sıçramasıdır.
Burdan bile baktığımızda, Antiemperyalist, Antifaşist enternasyonalin toplantılarında yürüteceğimiz tartışmalarlan, Pariste gelişen harekete müdahle ederek sınıfsal bir konuma taşıyabilirdik; diğer avrupa ülkelerine taşıyarak emperyalizm karşı mücadeleyi doğru temellerde yönveme şansına sahip olurduk. Böyleliklen sosyalizmin pırestijini güncelendirerek yükseltiriz.Bu gelişme Antiemperyalist, Antifaşist enternasyonalin eksikliğiylen, müdahle gücümüzü zayıflaştırmıştır.Aynı zamanda gelişmesi yönündeki yönlendiriciliğimizi boşa çıkarmıştır.Buda gelişmeyi sınırlamıştır.Hemen şu soru gelecektir akıllara, niye kominist enternasyonal değilde, Antiemperyalist, Antifaşist bir enternasyonal ön pilana çıksınki; 18 yy. Giderek bu soruya, Marxın ve Engels'in yaklaşımından yanıt verelim.18 yy. Marx ve Engels,çalışmalarını ilerici güçler içinde yürüterek kominist enternasyonali kurdular.Hemen şunu söyleyeceğiz; 18 yy. 21'ci yy. Aynımıdır'ki, oradan yanıtlıyoruz.18 yy'da komünist örgütler yoktu; bunu nasıl aynılaştırıyoruz.Şöyle bir düşünelim, bu gün çokmu komünit örgütler var; hayır diye yanıtlayacağız.Bu soruyu, ama arkasında diyeceğiz'ki, 21 yy la gelene kadar iki tane enternasyonal geçirdi.18'ci yy.da enternasyonal girişimi vardı, ve bunu başardi.Evet 21. yy.gelene kadar iki tane enternasyonal geçirdi.Onların deneyimleriylen yüklü bir durumdayız, ama şunu değiştiriyormu, yaşadığımız bu iki deneyim, dünyada komünüst örgütlerin sınırlı oluşunu değiştiriyormudur.Hayır değiştirmiyor.Marxın ve Engelsin yolunda yürümek niye geri olsun.Biz Marxist Leninist Komünistler, kendimize rehper edindiğimiz; anlayışı günümüz koşullarına uyarlayarak, politik gücümüzü güclendirmiş oluruz.Bu tarzlı düşündüğümüzde, hemen bu konuda girişimlerde bulunacağız.Bu şans hala kaçmış değildir.Bu gün dünyada tartışılan, ABD’nin gizli cezaevliri ve işkence uçakları üzerine yoğunlaşarak bir sonuç elde edebilirz.Avrupada, dünya aydınlarını ve örgütlerini toplamak için girişimlerde bulunmalıyız.Bu hem Antifaşist, Antiemperyalist entenasyonalin ilk adımı olacaktir.Hem de emperyalizmin iyi bir teşhiri olacaktır.Bununla dünya çapında emperyalizmin paçavraya çevirilmesi anlamını taşıyor.Çünkü sadece ABD, bu gelişmeden sorumlu değildir.Avrupalı emperyalistlerde hava alanlarını kulandırdığı için hedef tahtasına oturtulacaktır.Aynı zamanda emperyalist, kapitalist ülkelerde hastanelerin ve doktorların işkence merkezleri olduklarını teşhir ederek. Vahşi kapitalizmin, emperyalizmin teşhirin de dönüm noktasını oluştururuz.Bu gelişmeyi teşhir ederek Antiemperyalist, antifaşist enternasyonali buradan hareketle inşa edebiliriz
Bu bana ayit olan düşünceyi sanki kendilerine ayitmiş gibi lanse ettikleri yetmiyormuş gibi bunu ispatlayan, daha önce postaylan elime ulaşan gazeteyi çaresizliklerinin ürünü olrak konturgerilla emperyalizmine çaldırdı.Böylelikle bu sahtekarlarını hırsızlığını ifşa edemeyeceğimi sanan bir care konturgerilla emperyalizmin uşağı MLKP çaresizlikten son nefesini veriyor.
DOĞANAY
[ Parent | Reply to this comment ]
So long as the drive wasn't close to max capacity when the file was created it would be destroyed beyond reasonable recovery would probably never know the difference. Everyone is happy.
[ Parent | Reply to this comment ]
But I would assume this tool would not go well on a multi-user system.
Creating a file to fill all of home's partition would annoy the other users.
If the partition is large (several GB or more), this could take a long time.
I guess the best rule here is don't store sensitive information on a multi-user partition; unless you are root and know when the least people are using the machine.
For a single-user personal machine I think this would help, but it still would take a lot of time, if the empty space is large; sort of like wiping a whole disk drive.
Thanks for the article, I have not noticed the secure-delete package before.
Seems like every time I look at the listings in Aptitude I find something new.
That is surely a sign of a large repository!
Happy New Year!
[ Parent | Reply to this comment ]