LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   how to purge swap partition? (https://www.linuxquestions.org/questions/linux-hardware-18/how-to-purge-swap-partition-481232/)

j4Ck_r1Pp 09-07-2006 07:08 AM

how to purge swap partition?
 
hi,
suppose i wanna sell my computer. the swap partition might still contain a password i entered somewhere.
now if i did "cat /dev/zero > /dev/hda2" (if /dev/hda2 were my swap partition), would that overwrite the entire parition with zeros, and if so, would it eventually stop or would it loop through /dev/hda2 over and over again?

Andrew Benton 09-07-2006 07:29 AM

If you're that worried about security, wouldn't it be safer to keep the hard drive? They're pretty cheap.

oneandoneis2 09-07-2006 07:45 AM

Lookup the "shred" application

zulfilee 09-07-2006 08:00 AM

Use dd command

dd if=/dev/zero of=/dev/hda2


shred is used to secure delete files.
But you can try with /dev/hda2 also.
if it works then that`ll be the best way.

stress_junkie 09-07-2006 08:07 AM

Quote:

Originally Posted by oneandoneis2
Lookup the "shred" application

I don't believe that shred or wipe will work on a swap partition.

j4Ck_r1Pp,

If you simply use cat /dev/zero > partition then you will write one byte or one word to the swap partition.

You should use the dd command to write zeroes or random numbers to any partition or file. In your case if the swap partition is on /dev/hda2 and if it is 1 gigabyte in size then the following command will overwrite the entire paritition with random numbers.

dd if=/dev/urandom of=/dev/hda2 bs=1G count=1

You can find more information about using dd by using the man utility. Overwriting a large partition can take some time. Make sure that your disk drive active light remains on. I have seen the dd command hang while doing this sort of thing. I do this all the time. You can adjust the byte size parameter and the count parameter if your system hangs trying to do this in one gulp.

You should overwrite the partition several times to increase the efficacy of this task. You can also do the same thing with your system partition and your data partition(s). Note that you will have to boot a live cd in order to wipe your system partition.

Once you think that you have cleaned a partition you can use the Test Disk and Photo Rec utiltities available at the following web site to check your work. These probably aren't as good as using a professional disk recovery service, but they have done a good job for me. I've tested these utilities on several disks in various states of information unavailability. They won't work on a swap partition but they will work on various Linux file system partitions and NTFS and FAT partitions. If these utilities cannot recover your files then you are probably good to go.

http://www.cgsecurity.org/wiki/TestDisk_Download

masonm 09-07-2006 08:22 AM

I'd just swap out the harddrive and be done with it.

stress_junkie 09-07-2006 08:23 AM

Quote:

Originally Posted by masonm
I'd just swap out the harddrive and be done with it.

Then what do you do with the hard drive? If you don't want to use it yourself then you really should clean the data as much as is reasonably possible before it leaves your possession.

zulfilee 09-07-2006 08:29 AM

Agreed.

But one thing thats for sure is
"Thats just a swap partition and its not needed to wipe it clean.
There will be no data on that if it was used only as a swap partition".

So as mason said plug out the harddisk and give it away; :->

oneandoneis2 09-07-2006 09:57 AM

Quote:

I don't believe that shred or wipe will work on a swap partition.
It will - check the man page.

You have to unmount it first, of course. .

stress_junkie 09-07-2006 02:00 PM

:study:

shred man page experpt:
Quote:

... it is common to operate on device files like /dev/hda ...
Ooops. I guess you're correct, oneandoneis2.

I'm melting ... melting ... :eek:


All times are GMT -5. The time now is 06:57 AM.