Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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;
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.
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.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
Quote:
Originally Posted by anctop
... 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
... 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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.