How To Wiki
m (clean up, typos fixed: comand → command, usb → USB)
Tag: Visual edit
(13 intermediate revisions by 8 users not shown)
Line 5: Line 5:
 
==Wiping the entire disk==
 
==Wiping the entire disk==
 
This will overwrite all partitions, [[master boot record]]s, and data. Use the sudo command as well (sudo dd...)
 
This will overwrite all partitions, [[master boot record]]s, and data. Use the sudo command as well (sudo dd...)
* Filling the disk with all zeros ''(This may take a while, as it is making every bit of data '''0''')'' :<pre>dd if=/dev/zero of=/dev/sda bs=1M</pre>
+
* Filling the disk with all zeros ''(This may take a while, as it is making every bit of data '''0''')'' :<pre>dd if=/dev/zero of=/dev/sdX bs=1M *replace X with the target drive letter.</pre>
   
* If you are wiping your hard drive for security, you should populate it with random data rather than zeros ''(This is going to take even longer than the first example.)'' :<pre>dd if=/dev/urandom of=/dev/sda bs=1M</pre>
+
* If you are wiping your hard drive for security, you should populate it with random data rather than zeros ''(This is going to take even longer than the first example.)'' :<pre>dd if=/dev/urandom of=/dev/sdX bs=1M *replace X with the target drive letter.</pre>
 
The reason one should fill with urandom in case of required security is explained here: [http://www.marksanborn.net/howto/wiping-a-hard-drive-with-dd/]
 
The reason one should fill with urandom in case of required security is explained here: [http://www.marksanborn.net/howto/wiping-a-hard-drive-with-dd/]
   
'''Important Note:''' You need to replace ''sda'' with the device name you want to overwrite. ''sda'' is usually the first hard drive, the second drive would be ''sdb'' and so on. Use for example gparted to find the correct drive. If you replace the device name, you can also wipe USB sticks and other peripherals.
+
'''Important Note:''' You need to replace ''sdX'' with the device name you want to overwrite. ''sda'' is usually the first hard drive, the second drive would be ''sdb'' and so on. Use for example gparted to find the correct drive. If you replace the device name, you can also wipe USB sticks and other peripherals.
   
 
==Wiping the Master boot record (MBR)==
 
==Wiping the Master boot record (MBR)==
 
If you messed up your [[master boot record]] (MBR) you can wipe it using this command :
 
If you messed up your [[master boot record]] (MBR) you can wipe it using this command :
<pre>dd if=/dev/zero of=/dev/hda bs=446 count=1</pre>
+
<pre>dd if=/dev/zero of=/dev/hdX bs=446 count=1 *replace X with the target drive letter.</pre>
   
 
==Wiping partitions==
 
==Wiping partitions==
 
You can wipe a partition using the same method than for the whole disk. Just replace the device identifier. If /dev/sda is the whole disk, then (on Linux, because the naming scheme vary from one Linux to another) /dev/sda3 is the third partition on the disk.
 
You can wipe a partition using the same method than for the whole disk. Just replace the device identifier. If /dev/sda is the whole disk, then (on Linux, because the naming scheme vary from one Linux to another) /dev/sda3 is the third partition on the disk.
* Filling the second partition on the /dev/sda disk with all zeros :<pre>dd if=/dev/zero of=/dev/sda2 bs=1M</pre>
+
* Filling the second partition on the /dev/sda disk with all zeros :<pre>dd if=/dev/zero of=/dev/sdX2 bs=1M *replace X with the target drive letter.</pre>
* Filling the third partition with random data :<pre>dd if=/dev/urandom of=/dev/sda3 bs=1M</pre>
+
* Filling the third partition with random data :<pre>dd if=/dev/urandom of=/dev/sdX3 bs=1M *replace X with the target drive letter.</pre>
   
 
==Wiping specific files==
 
==Wiping specific files==
Line 29: Line 29:
 
==References==
 
==References==
 
*[http://www.linuxquestions.org/linux/answers/Hardware/Clean_Hard_Drive_zero_fill Clean Hard Drive (zero fill)]
 
*[http://www.linuxquestions.org/linux/answers/Hardware/Clean_Hard_Drive_zero_fill Clean Hard Drive (zero fill)]
*[http://gentoo-wiki.com/MBR MBR]<div id="wikia-credits">
+
*[http://gentoo-wiki.com/MBR MBR]<div id="wikia-credits"> </div>
   
<small>From [http://howto.wikia.com HowTo Wiki], a [http://www.wikia.com Wikia] wiki.</small></div>
+
<small>From [http://howto.wikia.com HowTo Wiki], a [http://www.wikia.com Wikia] wiki.</small>
 
[[Category:Howto]]
 
[[Category:Howto]]
 
[[Category:Linux]]
 
[[Category:Linux]]

Revision as of 18:28, 14 February 2020

You may need to wipe you hard drive to clean up partition errors, bad installations, or for privacy. This will show you howto do this

These methods use a command called dd

Wiping the entire disk

This will overwrite all partitions, master boot records, and data. Use the sudo command as well (sudo dd...)

  • Filling the disk with all zeros (This may take a while, as it is making every bit of data 0) :
    dd if=/dev/zero of=/dev/sdX bs=1M *replace X with the target drive letter.
  • If you are wiping your hard drive for security, you should populate it with random data rather than zeros (This is going to take even longer than the first example.) :
    dd if=/dev/urandom of=/dev/sdX bs=1M *replace X with the target drive letter.

The reason one should fill with urandom in case of required security is explained here: [1]

Important Note: You need to replace sdX with the device name you want to overwrite. sda is usually the first hard drive, the second drive would be sdb and so on. Use for example gparted to find the correct drive. If you replace the device name, you can also wipe USB sticks and other peripherals.

Wiping the Master boot record (MBR)

If you messed up your master boot record (MBR) you can wipe it using this command :

dd if=/dev/zero of=/dev/hdX bs=446 count=1 *replace X with the target drive letter.

Wiping partitions

You can wipe a partition using the same method than for the whole disk. Just replace the device identifier. If /dev/sda is the whole disk, then (on Linux, because the naming scheme vary from one Linux to another) /dev/sda3 is the third partition on the disk.

  • Filling the second partition on the /dev/sda disk with all zeros :
    dd if=/dev/zero of=/dev/sdX2 bs=1M *replace X with the target drive letter.
  • Filling the third partition with random data :
    dd if=/dev/urandom of=/dev/sdX3 bs=1M *replace X with the target drive letter.

Wiping specific files

  • try the command "wipe filename" (cf more detail man wipe or wipe -h)
  • Can also try the command "shred" ex: # shred -n 6 -z -v personalinfo.tar.gz (cf man shred)

References

From HowTo Wiki, a Wikia wiki.