Table of Contents
I wrote the way to erase data in hard disk with Linux commands.
To completely erase hard disk data, we can use not only DESTROY or わいぷたん, but also Live CD Linux.
Using Live CD Linux, erase data with command. In advance, I tried erasing data with Lubuntu of 1 CD. It is really convenience that we can erase data with only 1 CD Lunux.
Wipe out with dd
With dd
, we can erase data of a device.
Fill the Disk with Zero Data
1 |
dd if=/dev/zero of=/dev/sdX status=progress |
if
, of
is required.
status
is recommended. It can indicates to show the progress. If you don’t added status
, you should wait on silent screen until the command execution is finished.
The output will be like the following.
1 2 3 4 |
dd: error writing '/dev/sda': No space left on device 0+233 records in 0+232 records out 500107862016 bytes (500 GB, 466 GiB) copied, 5582.54 s, 89.6 MB/s |
And, iflag
, oflag
may make the command fast.
1 |
dd if=/dev/zero of=/dev/sdX iflag=nocache oflag=direct status=progress |
Fill the Disk with Random Data
1 |
dd if=/dev/urandom of=/dev/sdX status=progress |
Assign if
/dev/urandom
.
The output will be like below.
1 2 3 4 |
dd: error writing '/dev/sda': No space left on device 0+14905 records in 0+14904 records out 500107862016 bytes (500 GB, 466 GiB) copied, 35100.8 s, 14.2 MB/s |
Wipe out with shred
I don’t strongly recommend, but we can erase data with shred
.
1 |
shred -v /dev/sdX |
The above command writes random values into the hard disk. -v
indicates to show the progress.
次のような出力になります。 一部省略していますが、 -v
をつけると進捗状況が順次新しい行として表示されていきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
shred: /dev/sda: pass 1/3 (random)... shred: /dev/sda: pass 1/3 (random)...496MiB/466GiB 0% shred: /dev/sda: pass 1/3 (random)...497MiB/466GiB 0% ... shred: /dev/sda: pass 1/3 (random)...465GiB/466GiB 99% shred: /dev/sda: pass 1/3 (random)...466GiB/466GiB 100% shred: /dev/sda: pass 2/3 (random)... shred: /dev/sda: pass 2/3 (random)...449MiB/466GiB 0% ... shred: /dev/sda: pass 2/3 (random)...465GiB/466GiB 99% shred: /dev/sda: pass 2/3 (random)...466GiB/466GiB 100% shred: /dev/sda: pass 3/3 (random)... shred: /dev/sda: pass 3/3 (random)...543MiB/466GiB 0% ... shred: /dev/sda: pass 3/3 (random)...465GiB/466GiB 99% shred: /dev/sda: pass 3/3 (random)...466GiB/466GiB 100% |
The Reason Why I Don’t Recommend
However, even shredding devices is not always completely reliable. For example, most disks map out bad sectors invisibly to the application; if the bad sectors contain sensitive data, shred won’t be able to destroy it.
Yes, if sensitive data exists in bad sector, shred
don’t erase it.