I m looking for best and fastest way to remove all my data From hard drive. I M on linux Of you know something with doing this operation on a USB stick share with me. Other ways are also acceptable Anything quick Best regards
-
Upvoted since you usually find the cryptic DD response and you almost never find the cat command response, which is wonderful in its simplicity. – Markus Bawidamann Aug 18 '22 at 02:40
-
Are you planning to re-use the disk or is this about removal of data before the destruction of the disk? – Kusalananda Nov 28 '22 at 15:32
-
If your drive supports SMART, it may have a fast secure-erase that works simply by wiping its encryption key. Consider a tool that can do this before resorting to overwriting the data. – Toby Speight Jul 20 '23 at 13:25
5 Answers
cat /dev/zero > /dev/device is the fastest way bar none for the spinning rust.
If you have an SSD drive, blkdiscard /dev/device is even faster. It will not physically write zeros but it will effectively wipe the data (so you'll get zeros if you try to read it).
- 26,392
- 4
- 33
- 64
-
Very good solution, make sure you redirect into a file (not directly into the device, but a mount point, such as cat /dev/zero > /media/device-mount/this_file_grows_huge_till_it_fills_whole_device.fill ------- use--- watch df -h ----- to see the drive fill. This command is also a lot more safe and easier to remember than the cryptic dd command. DD has by the way no safety locks, you can do terrible things with it and one little typo and your SSD or HDD is destroyed forever, it is a truely ancient UNIX tool, from the days where userfriendlyness was a new rare concept. – Markus Bawidamann Aug 18 '22 at 02:29
-
@MarkusBawidamann that doesn't necessarily fill the disk with zeros, and it certainly doesn't overwrite existing files. Notice that the specifically answer to which you've responded does not include "_the cryptic `dd` command_" that you're worried about – roaima Jul 18 '23 at 08:59
dd if=/dev/zero of=/dev/sdX bs=1M
dd copies bits from "if" to "of". Blocksize 1M is usually a good value for performance. Repace sdX with your actual drive.
If you need to track progress, install "pv" (pipeviewer)
pv /dev/zero > /dev/sdX
or, in newer versions of dd, specify status=progress (which will actually be faster as there is a slight overhead using pv).
- 411,918
- 54
- 1,065
- 1,164
- 401
- 3
- 8
To list disk details use fdisk or GNOME Disk.
fdisk:
$ fdisk -l
dd is powerful tool for clobbering (overwriting). date is also often a good idea. Use ; instead of &&, because ; doesn't care if dd succeeds/fails and – no matter what happens – you get the date printed. If you don't like the shell, you can also do this step with GNOME Disk.
dd:
$ date; dd if=/dev/zero of=/dev/drive_or_partition bs=1M; date
Cheers
- 51
- 3
-
Can list drives with `lsblk -o name,size,mountpoint,type,uuid` too for a (I think) easier to read output. – Mint Feb 23 '23 at 01:07
Old thread I know, but I've found the following to be much faster than cat. cat on my drive started to slow down after 30GB of data was written, whereas dd just kept ploughing on.
dd if=/dev/zero of=/fillup.zero bs=8388608
presuming you want the root partition filled up, if not set a different mount point, I also find out the PID of the dd command and then run
watch kill -USR1 {pid}
to give a running total of Gigabytes written on stdout, I used a bash script to find out the fastest blocksize for the drive.
There is method to my madness I have need to relocate a sector on my root partition which is at the end of the drive so I'm forcing a write on the sector to let the drive electronics re-map it, I'm also testing the rest of the drive (just in case), my Veeam backups were failing on snapshot backup until I found out why, it fixed it.
7155482624 bytes (7.2 GB, 6.7 GiB) copied, 31.2744 s, 229 MB/s
decent throughput as well.
- 21,637
- 21
- 47
- 71
- 11
- 2
-
The question didn't mention `cat`. Perhaps this was intended as a comment to one of the answers? – Toby Speight Jul 20 '23 at 13:26
looking for best and fastest way to remove all my data from hard drive
Asked 1 year, 9 months ago
it is important to distinguish between hard drive and solid state drive (SSD)
with SSD you can take advantage of TRIM, For example (in windows) if you have win10 running and the SSD in question mounted as a secondary drive such as D: then it's as easy as re-GPT'ing the disk and making one large partition on the entire SSD and then using Tools on D: to cause TRIM to happen, which will zero out the SSD. How to manually cause TRIM to happen in linux on mounted file systems is with fstrim which is provided by the util-linux rpm.
In the case of a hard drive where you can't make use of TRIM, three software utilities I know of in linux are shred, nwipe, and scrub (which would also work on an SSD).
And there is always the tried and true dban which is dariks boot and nuke which is a bootable linux that you put on cd or usb, and it boots a stripped down linux OS giving only the menu option of which disk to choose and various wipe methods. On an 8+ terabyte hard drive of today, choosing a 7-pass wipe method, would not be fast, but it does offer a quick zero out menu option. DBAN is often the easiest when you have one pc, one disk which is your operating system, and you can't entirely nuke a running operating system disk while it's in operation.
In the enterprise space, if you are using a self-encrypting disk (SED) which I believe are always an SSD, all you have to do is in the BIOS/EFI under the RAID card menu is change the encryption key of the disk which is one mouse click... while it does not zero out data the existing data is lost because it can no longer be self-decrypted. There's a fancy term for this... basically amounts to a "secure delete" where the AES encryption algorithm in affect no longer has the key on the existing data.
One other utility in linux I recently came across is provided by sg3_utils-1.37-19.el7.x86_64 and is sg_sanitize; how fast it may be I do not know, it works at the SCSI level.... sg_sanitize [--quick] --overwrite --zero /dev/sdX and check progress via sg_requests /dev/sdX. This might do better than cat /dev/zero > /dev/device but I don't know.
- 5,749
- 7
- 48
- 84