LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-05-2011, 11:03 PM   #1
anctop
Member
 
Registered: Feb 2010
Posts: 99

Rep: Reputation: Disabled
wiping a partition


I'd like to ask : is there a command for wiping a partition, not the whole disk ?

In DOS/Win, the "format /u <drive>" command wipes off data while creating the fs.

In Linux, "mke2fs -v -c <partition>" does not seem to do a similar job.
 
Old 07-06-2011, 12:22 AM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
From the command line try executing
Code:
man shred
 
1 members found this post helpful.
Old 07-06-2011, 12:44 AM   #3
anctop
Member
 
Registered: Feb 2010
Posts: 99

Original Poster
Rep: Reputation: Disabled
But "shred" is for a single file.
 
Old 07-06-2011, 12:47 AM   #4
kasl33
Member
 
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Rep: Reputation: 48
Quote:
Originally Posted by anctop View Post
I'd like to ask : is there a command for wiping a partition, not the whole disk ?

In DOS/Win, the "format /u <drive>" command wipes off data while creating the fs.

In Linux, "mke2fs -v -c <partition>" does not seem to do a similar job.
I'm not familiar with the shred command, but if you are using the Gnome desktop environment, install Gparted - it is a very simple gui that makes partitioning very easy. If you are somewhat brave, you can use cfdisk. If you are really brave, you can use fdisk;

Try these commands and learn:

blkid (as root)

fdisk -l

cfdisk /dev/sda
fdisk /dev/sda
 
Old 07-06-2011, 12:50 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
DBAN http://www.dban.org/, scrub http://linux.die.net/man/1/scrub
 
Old 07-06-2011, 01:23 AM   #6
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
When all is a file in Linux, shred should also accept /dev/sda7 or whatever. Another way could be to fill it with zeros by dd beforehand:
Code:
$ dd if=/dev/zero of=/dev/sda7
and then create the file system in it as usual.
 
1 members found this post helpful.
Old 07-06-2011, 01:27 AM   #7
anctop
Member
 
Registered: Feb 2010
Posts: 99

Original Poster
Rep: Reputation: Disabled
...

Last edited by anctop; 07-06-2011 at 01:53 AM.
 
Old 07-06-2011, 04:25 AM   #8
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
???
[Solved]?
 
Old 07-06-2011, 05:53 AM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by anctop View Post
But "shred" is for a single file.
In Linux, everything is a file. Even drive partitions.
 
Old 07-06-2011, 06:02 AM   #10
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quote:
Originally Posted by anctop View Post
I'd like to ask : is there a command for wiping a partition, not the whole disk ?
You should be more specific about what you mean with "wiping". If you only wish to create an empty partition, possibly with a new/different-than-before filesystem in place of an existing partition, you can use pretty much any partitioning tool (that can work with the partition types you want) such as fdisk or gparted. Just choose to delete the old partition and create a new one--should not take much time. If you instead mean you want to securely thrash all the data on that partition, so that it is not recoverable any more, the problem is more difficult. Tools like shred (mentioned in earlier posts) would be what you want, and they can work on partitions as well. However they don't typically work with today's journalled filesystems, so in case you use one, you'll need to take care that you work outside of the filesystem--thrash the whole thing, not just single files. Here "thrashing" means that you overwrite all of the data so many times that recovering it becomes extremely difficult. The only permanent solution I know of, that is not recoverable by any means, is to melt the whole disk into a pile of goo and then get rid of it in an appropriate way--slightly easier, but still effective method is to take a drill and make holes to the disk (tossing it into a fireplace is not going to help much). Every software solution has its limits up to the point where the disk is physically "damaged" such that there are no tracks of the original data anywhere, and that's difficult.

Actually, if you just want to turn a partition into another partition (e.g. re-format it; Windows/DOS formatting tool does just that, it doesn't actually remove any data, just like the other such tools), you can do it using any tool on any operating system, as far as they understand the format(s) you want. Windows, OS X, Linux, you name it.
 
Old 07-06-2011, 06:17 AM   #11
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Quote:
Originally Posted by b0uncer View Post
...slightly easier, but still effective method is to take a drill and make holes to the disk ...
In view of the nature of the problem I'd have thought a file (sic!) to "smooth" the surface of the disk would be appropriate .
 
Old 07-06-2011, 04:07 PM   #12
NyteOwl
Member
 
Registered: Aug 2008
Location: Nova Scotia, Canada
Distribution: Slackware, OpenBSD, others periodically
Posts: 512

Rep: Reputation: 139Reputation: 139
also look at dd with if=/dev/urandom
 
Old 07-06-2011, 04:23 PM   #13
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Quote:
Originally Posted by NyteOwl View Post
also look at dd with if=/dev/urandom
There was a recent discussion about it.
 
Old 07-06-2011, 07:50 PM   #14
anctop
Member
 
Registered: Feb 2010
Posts: 99

Original Poster
Rep: Reputation: Disabled
Thank you very much for all the replies.

I've done several experiments yesterday, and found that both "shred" and "dd" could do the job.

As I've stated in my original question, I just want to wipe a partition, not the whole disk, because I have other data partitions on the same disk.

Before asking for help in this forum, I've also played with "cfdisk". I used it to delete the target partition (say /dev/sdb3), then "Write", replied "yes", "Quit", and then reboot the system.
After the reboot, I invoked "cfdisk" again. It correctly reported that the original /dev/sdb3 was gone, leaving a "Free Space". Then I proceeded to re-create the partition, but it automaticaly recognized that the fs was "ext3".
I saved the partition table and quit "cfdisk". When I tried "mount /dev/sdb3 /mnt", I found that all my old files came back in /mnt !!
The "mkfs.ext3 -v /dev/sdb3" command does not really wipe the old data off either.

Thanks again for your answers.
 
Old 07-07-2011, 01:24 AM   #15
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Quote:
Originally Posted by anctop View Post
... I invoked "cfdisk" again. It correctly reported that the original /dev/sdb3 was gone, leaving a "Free Space". Then I proceeded to re-create the partition, but it automaticaly recognized that the fs was "ext3"...When I tried "mount /dev/sdb3 /mnt", I found that all my old files came back in /mnt !!...
That is as it should be . All those *fdisk programs write to the partition table, not to the partition. (As an aside, I once wiped "accidentally" my partition table -- and rebuilt it from an old printout without the loss of a single datum in the file systems of the hard disk).

Quote:
Originally Posted by anctop View Post
... The "mkfs.ext3 -v /dev/sdb3" command does not really wipe the old data off either...
Formatting, i.e. creating a file system prepares the structures in the file system (look for inode e.g. on Wikipedia), again not touching the data.

If you want those mangled / shredded / thrashed you have to write data (as dd or shred do).

Last edited by JZL240I-U; 07-07-2011 at 01:27 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] securely wiping disk/partition dimm0k Linux - Security 8 06-19-2011 08:35 AM
Best way to simulate data loss, corruption, partition wiping, etc & then "rescue" it? linus72 Linux - General 8 06-28-2009 06:26 PM
Wiping the HD NEVICA Linux - Newbie 7 02-20-2008 03:35 PM
Wiping windows out and expanding linux partition geomatt Linux - General 14 02-13-2005 08:49 AM
Wiping my Win2K partition? Ice9 Linux - General 5 04-17-2003 04:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration