https://wiki.archlinux.org/api.php?action=feedcontributions&user=Incognito&feedformat=atomArchWiki - User contributions [en]2024-03-28T18:01:12ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Securely_wipe_disk&diff=253109Securely wipe disk2013-04-06T12:09:50Z<p>Incognito: /* shred */</p>
<hr />
<div>[[Category:Security]]<br />
[[Category:File systems]]<br />
{{Article summary start}}<br />
{{Article summary text|Wipe all traces left from (un-)encrypted data and/or prepare for block device encryption}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|File Recovery}}<br />
{{Article summary wiki|Benchmarking disk wipes}}<br />
{{Article summary wiki|Frandom}}<br />
{{Article summary wiki|Disk Encryption#Preparing the disk}}<br />
{{Article summary wiki|dm-crypt with LUKS}}<br />
{{Article summary end}}<br />
<br />
Wiping a disk is done by writing new data over every single bit.<br />
<br />
{{Note|References to "disks" in this article also apply to loopback devices.}}<br />
<br />
== Common use cases ==<br />
=== Wipe all data left on the device ===<br />
The most common usecase for completely and irrevocably wiping a device will be when the device it going to be given away or also maybe sold. There may be (unencrypted) data left on the device and you want to protect against simple forensic investigation that is mere child's play with for example [[File Recovery]] software.<br />
<br />
If you want to quickly wipe everything from the disk /dev/zero or simple patterns allow maximum performance while adequate randomness can be advantageous in some cases that should be covered up in [[#Data remanence]].<br />
<br />
Every overwritten bit means to provide a level of data erasure not allowing recovery with normal system functions (like standard ATA/SCSI commands) and hardware interfaces. Any file recovery software mentioned above then would need to be specialized on proprietary storage-hardware features.<br />
<br />
In case of a HDD data recreation will not be possible without at least undocumented drive commands or fiddling about the device’s controller or firmware to make them read out for example reallocated sectors (bad blocks that [[S.M.A.R.T.]] retired from use).<br />
<br />
There are different wiping issues with different physical storage technologys, most notably all Flash memory based devices and older magnetic storage (old HDD's, floppy disks, tape).<br />
<br />
=== Preparations for block device encryption ===<br />
If you want to prepare your drive to securely set up [[Disk Encryption#Block device encryption]] inside the wiped area afterwards you really should use [[#Random data]] generated by a trusted cryptographically strong random number generator (referred to as RNG in this article from now on).<br />
<br />
{{Wikipedia|Random number generation}}<br />
<br />
{{Warning|If Block device encryption is mapped on a partition that contains anything else than random/encrypted data, disclosure of usage patterns on the encrypted drive is possible and weakens the encryption being comparable with filesystem-level-encryption. Do never use /dev/zero, simple patterns (badblocks, eg.) or other unrandom data before setting up Block device encryption if you are serious about it!}}<br />
<br />
== Select a data source for overwriting ==<br />
<br />
As just said If you want to wipe sensitive data you can use anything matching your needs. <br />
<br />
If you want to setup block device encryption afterwards you should always wipe at least with Pseudorandom data.<br />
<br />
For data that is not truly random your disk's writing speed should be the only limiting factor. If you need random data, the required system performance to generate it may extremely depend on what you choose as source of entropy.<br />
<br />
{{Note|Everything regarding [[Benchmarking disk wipes]] should get merged there.}}<br />
<br />
=== Unrandom data ===<br />
Overwriting with {{ic|/dev/zero}} or simple patterns is considered secure in most resources. In the case of current HDD's it should be sufficient for fast disk wipes.<br />
<br />
{{Warning|A drive that is abnormally fast in writing patterns or zeroing could be doing transparent compression. It is obviously presumable not all blocks get wiped this way. Some [[#Flash memory]] devices do "feature" that.}}<br />
<br />
==== Pattern write test ====<br />
[[#Badblocks]] can write simple patterns to every block of a device and then read and check them searching for damaged areas (just like memtest86* does with memory).<br />
<br />
As the pattern is written to every accesible block this effectively wipes the device.<br />
<br />
=== Random data ===<br />
{{Note|Data that is hard to compress (random data) will get written slower, if the drive logic mentioned in the [[#Unrandom data]] warning tries compressing it. This should not lead to [[#Data remanence]] though. As maximum write-speed is not the performance-bottleneck it can get completely neglected while wiping disks with random data.}}<br />
<br />
==== Kernel built-in RNG ====<br />
The kernel build in RNG's /dev/(u)[[random]] are highly recommended for producing reliable random data providing the same security level that is used for the creation of cryptographic keys.<br />
<br />
; /dev/random: uses an entropy pool of 4096 bits (512 Bytes) to generate random data and stops when the pool is exhausted until it get's (slowly) refilled. /dev/random is absolutely not designed for wiping entire HDD's.<br />
; /dev/urandom: reuses entropy and although not suited for the most crucial cryptographic purposes, for example the generation of longterm keys, its quality should be sufficient for a paranoid disk wipe, [[#Preparations for block device encryption|preparing for block device encryption]], wiping LUKS keyslots, wiping single files and many other purposes.<br />
<br />
For much better performance consider using a true [[random#Pseudorandom_number_generator|pseudorandom number generator]].<br />
<br />
== Select a program ==<br />
{{ic|/dev/<drive>}} is the drive to be encrypted.<br />
<br />
=== Coreutils ===<br />
{{Merge|Core_Utilities|Basic file operations are '''not specific to disk wiping!''' Unrelated stuff in this section should get merged and then deleted and replaced with a link to [[Core Utilities]]. Did you ever want to write an article about dd and Co? Then just go ahead.}}<br />
<br />
Official documentation for dd and shred is linked to under [[#See also]].<br />
<br />
==== Dd ====<br />
{{Wikipedia|Dd_(Unix)}}<br />
{{Note|cp does the same as dd without any operands but is not designed for more versatile disk wiping procedures.}}<br />
<br />
===== Checking progress of dd while running =====<br />
By default, there is no output of dd until the task has finished. With kill and the "USR1"-Signal you can force status output without actually killing the program. Open up a 2nd root terminal and issue the following command:<br />
# killall -USR1 dd<br />
{{Note|This will affect all other running dd-processes as well.}}<br />
Or:<br />
# kill -USR1 <PID_OF_dd_COMMAND><br />
<br />
For example:<br />
# kill -USR1 $(pidof dd)<br />
<br />
This causes the terminal in which dd is running to output the progress at the time the command was run. For example:<br />
605+0 records in<br />
605+0 records out<br />
634388480 bytes (634 MB) copied, 8.17097 s, 77.6 MB/s<br />
<br />
===== Dd spin-offs =====<br />
Other dd alike programs feature periodical status output like i.e. a simple progress bar.<br />
<br />
'''dcfldd'''<br />
<br />
{{Pkg|dcfldd}} is an enhanced version of dd with features useful for forensics and security. It accepts most of dd's parameters and includes status output. The last stable version of dcfldd was released on December 19, 2006.<sup>[http://dcfldd.sourceforge.net/]</sup><br />
<br />
'''ddrescue'''<br />
<br />
GNU {{Pkg|ddrescue}} is a data recovery tool. It's capable of ignoring read errors what is a useless feature for disk wiping in almost any case.<br />
[http://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html GNU ddrescue Manual]<br />
<br />
==== shred ====<br />
{{Box BLUE|From [http://en.wikipedia.org/wiki/Shred_%28Unix%29 Wikipedia]:|Shred is a Unix command that can be used to securely delete files and devices so that they can be recovered only with great difficulty with specialised hardware, if at all.}}<br />
<br />
Shred uses three passes, writing pseudo-random data to the harddrive each pass. This can be reduced or increased.<br />
<br />
# shred -v /dev/<drive><br />
<br />
This invokes shred with default settings, displaying the progress to stdout.<br />
<br />
# shred --verbose --random-source=/dev/urandom -n1 /dev/<drive><br />
<br />
Invokes shred telling it to only do one pass, with entropy from /dev/urandom.<br />
<br />
{{Box RED|/dev/random will block when the entropy pool is depleted. /dev/urandom will still deplete the pool but re-uses it to prevent blocking. The random number generator gathers environmental noise from device drivers and other sources into an entropy pool.}}<br />
<br />
=== Badblocks ===<br />
For letting [[Badblocks#read-write_Test|badblocks perform a disk wipe]] a destructive read-write test has to be done.<br />
<br />
# badblocks -c 10240 -wsv /dev/<drive><br />
<br />
== Select a target ==<br />
{{Note|Fdisk will not work on [[GUID Partition Table|GPT]] formatted devices. Use {{Pkg|gdisk}} instead.}}<br />
Use fdisk to locate all read/write devices the user has read acess to.<br />
<br />
Check the output for lines that start with devices such as {{ic|/dev/sdX}}.<br />
<br />
This is an example for a HDD formatted to boot a linux system:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sda: 250.1 GB, 250059350016 bytes, 488397168 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x00ff784a<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sda1 * 2048 206847 102400 83 Linux<br />
/dev/sda2 206848 488397167 244095160 83 Linux</nowiki>}}<br />
<br />
Or the Arch Install Medium written to a 4GB USB thumb drive:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sdb: 4075 MB, 4075290624 bytes, 7959552 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x526e236e<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 * 0 802815 401408 17 Hidden HPFS/NTFS</nowiki>}}<br />
<br />
=== Block size ===<br />
{{Wikipedia|Dd (Unix)#Block size}}<br />
If you have a [[Wikipedia:Advanced Format|Advanced Format]] hard drive it is recommended that you specify a block size larger than the default 512 bytes. To speed up the overwriting process choose a block size matching your drive's physical geometry by appending the block size option to the dd command (i.e. {{ic|<nowiki>bs=4096</nowiki>}} for 4KB).<br />
<br />
Fdisk prints physical and logical sector size for every disk.<br />
<br />
Alternatively sysfs does expose information:<br />
/sys/block/sdX/queue/physical_block_size<br />
/sys/block/sdX/queue/logical_block_size<br />
/sys/block/sdX/alignment_offset<br />
<br />
== Overwrite the disk ==<br />
{{warning|There is no confirmation regarding the sanity of this command so '''repeatedly check''' that the correct drive or partition has been targeted. Make certain that the {{ic|<nowiki>of=...</nowiki>}} option points to the target drive and not to a system disk.}}<br />
<br />
Zero-fill the disk by writing a zero byte to every addressable location on the disk using the [[Wikipedia:/dev/zero|/dev/zero]] stream.<br />
<br />
# dd if=/dev/zero of=/dev/sdX bs=4096<br />
<br />
or the [[Wikipedia:/dev/random|/dev/random]] stream:<br />
# dd if=/dev/urandom of=/dev/sdX bs=4096<br />
<br />
The process is finished when dd reports, {{ic|No space left on device}}:<br />
dd: writing to ‘/dev/sdb’: No space left on device<br />
7959553+0 records in<br />
7959552+0 records out<br />
4075290624 bytes (4.1 GB) copied, 1247.7 s, 3.3 MB/s<br />
<br />
== Data remanence ==<br />
{{Expansion|This section is too dependent on links to Wikipedia. Links to diverse and high quality resources should be added.}}<br />
<br />
{{Wikipedia|Data remanence}}<br />
The residual representation of data may remain even after attempts have been made to remove or erase the data.<br />
<br />
Residual data may get wiped by writing (random) data to the disk with a single or even more than one iteration. However, more than one iteration may not significantly decrease the possibility to reconstruct the data of hard disk drives. For more information see [http://www.h-online.com/news/Secure-deletion-a-single-overwrite-will-do-it--/112432 Secure deletion: a single overwrite will do it - The H Security].<br />
<br />
=== Random data ===<br />
If the data can get exactly located on the disk and was never copied anywhere else, wiping with random data can be thoroughgoing and impressively quick as long there is enough entropy in the pool.<br />
<br />
A good example is cryptsetup using /dev/urandom for [[Dm-crypt_with_LUKS#Wipe_LUKS_keyslots|wiping the LUKS keyslots]].<br />
<br />
=== Hardware specific issues ===<br />
==== Flash memory ====<br />
[[Wikipedia:Write amplification]] and other characteristics make Flash memory a stubborn target for reliable wiping.<br />
As there is a lot of transparent abstraction in between data as seen by a device's controller chip and the operating system sight data is never overwritten in place and wiping particular blocks or files is not reliable.<br />
<br />
Other "features" like transparent compression (all SandForce SSD's) can compress your /dev/zero or pattern stream so if wiping is fast beyond belief this might be the case.<br />
<br />
Disassembling Flash memory devices, unsoldering the chips and analyzing data content without the controller in between is feasible without difficulty using [http://www.flash-extractor.com/manual/reader_models/ simple hardware]. Data recovery companys do it for cheap money.<br />
<br />
For more information see: [http://www.usenix.org/events/fast11/tech/full_papers/Wei.pdf Reliably Erasing Data From Flash-Based Solid State Drives].<br />
<br />
==== Residual magnetism ====<br />
Wiped hard disk drives and other magnetic storage can get disassembled in a cleanroom and then analyzed with equipment like a [[Wikipedia:Magnetic force microscope|magnetic force microscope]]. This may allow the overwritten data to be reconstructed by analyzing the measured [[Wikipedia:Remanence|residual magnetics]].<br />
<br />
This method of data recovery for current HDD's is largely theoretical and would require substantial financial resources. Nevertheless [[Wikipedia:Degaussing#Degaussing magnetic data storage media|degaussing]] is still a practiced countermeasure.<br />
<br />
==== Old magnetic storage ====<br />
Securely wiping old magnetic storage (e.g. floppy disks, magnetic tape) is much harder due to much lower [[Wikipedia:Memory storage density|memory storage density]]. Many iterations with random data might be needed to wipe any sensitive data. To ensure that data has been completely erased most resources advise physical destruction.<br />
<br />
==== Operating system, programs and filesystem ====<br />
{{Note|This is not specific to any hardware obviously.}}<br />
The operating system, executed programs or [[Wikipedia:Journaling file system|journaling file system]]s may copy your unencrypted data throughout the block device. When writing to plain disks this should only be relevant in conjunction with one of the above.<br />
<br />
== See also ==<br />
* [http://www.gnu.org/software/coreutils/manual/coreutils.html#Basic-operations GNU Coreutils Manpage on Basic operations]. Official documentation for dd and shred.<br />
<br />
* [http://www.linuxquestions.org/questions/linux-newbie-8/learn-the-dd-command-362506/ Learn the DD command]. - linuxquestions.org</div>Incognitohttps://wiki.archlinux.org/index.php?title=Securely_wipe_disk&diff=253108Securely wipe disk2013-04-06T12:09:00Z<p>Incognito: /* shred */</p>
<hr />
<div>[[Category:Security]]<br />
[[Category:File systems]]<br />
{{Article summary start}}<br />
{{Article summary text|Wipe all traces left from (un-)encrypted data and/or prepare for block device encryption}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|File Recovery}}<br />
{{Article summary wiki|Benchmarking disk wipes}}<br />
{{Article summary wiki|Frandom}}<br />
{{Article summary wiki|Disk Encryption#Preparing the disk}}<br />
{{Article summary wiki|dm-crypt with LUKS}}<br />
{{Article summary end}}<br />
<br />
Wiping a disk is done by writing new data over every single bit.<br />
<br />
{{Note|References to "disks" in this article also apply to loopback devices.}}<br />
<br />
== Common use cases ==<br />
=== Wipe all data left on the device ===<br />
The most common usecase for completely and irrevocably wiping a device will be when the device it going to be given away or also maybe sold. There may be (unencrypted) data left on the device and you want to protect against simple forensic investigation that is mere child's play with for example [[File Recovery]] software.<br />
<br />
If you want to quickly wipe everything from the disk /dev/zero or simple patterns allow maximum performance while adequate randomness can be advantageous in some cases that should be covered up in [[#Data remanence]].<br />
<br />
Every overwritten bit means to provide a level of data erasure not allowing recovery with normal system functions (like standard ATA/SCSI commands) and hardware interfaces. Any file recovery software mentioned above then would need to be specialized on proprietary storage-hardware features.<br />
<br />
In case of a HDD data recreation will not be possible without at least undocumented drive commands or fiddling about the device’s controller or firmware to make them read out for example reallocated sectors (bad blocks that [[S.M.A.R.T.]] retired from use).<br />
<br />
There are different wiping issues with different physical storage technologys, most notably all Flash memory based devices and older magnetic storage (old HDD's, floppy disks, tape).<br />
<br />
=== Preparations for block device encryption ===<br />
If you want to prepare your drive to securely set up [[Disk Encryption#Block device encryption]] inside the wiped area afterwards you really should use [[#Random data]] generated by a trusted cryptographically strong random number generator (referred to as RNG in this article from now on).<br />
<br />
{{Wikipedia|Random number generation}}<br />
<br />
{{Warning|If Block device encryption is mapped on a partition that contains anything else than random/encrypted data, disclosure of usage patterns on the encrypted drive is possible and weakens the encryption being comparable with filesystem-level-encryption. Do never use /dev/zero, simple patterns (badblocks, eg.) or other unrandom data before setting up Block device encryption if you are serious about it!}}<br />
<br />
== Select a data source for overwriting ==<br />
<br />
As just said If you want to wipe sensitive data you can use anything matching your needs. <br />
<br />
If you want to setup block device encryption afterwards you should always wipe at least with Pseudorandom data.<br />
<br />
For data that is not truly random your disk's writing speed should be the only limiting factor. If you need random data, the required system performance to generate it may extremely depend on what you choose as source of entropy.<br />
<br />
{{Note|Everything regarding [[Benchmarking disk wipes]] should get merged there.}}<br />
<br />
=== Unrandom data ===<br />
Overwriting with {{ic|/dev/zero}} or simple patterns is considered secure in most resources. In the case of current HDD's it should be sufficient for fast disk wipes.<br />
<br />
{{Warning|A drive that is abnormally fast in writing patterns or zeroing could be doing transparent compression. It is obviously presumable not all blocks get wiped this way. Some [[#Flash memory]] devices do "feature" that.}}<br />
<br />
==== Pattern write test ====<br />
[[#Badblocks]] can write simple patterns to every block of a device and then read and check them searching for damaged areas (just like memtest86* does with memory).<br />
<br />
As the pattern is written to every accesible block this effectively wipes the device.<br />
<br />
=== Random data ===<br />
{{Note|Data that is hard to compress (random data) will get written slower, if the drive logic mentioned in the [[#Unrandom data]] warning tries compressing it. This should not lead to [[#Data remanence]] though. As maximum write-speed is not the performance-bottleneck it can get completely neglected while wiping disks with random data.}}<br />
<br />
==== Kernel built-in RNG ====<br />
The kernel build in RNG's /dev/(u)[[random]] are highly recommended for producing reliable random data providing the same security level that is used for the creation of cryptographic keys.<br />
<br />
; /dev/random: uses an entropy pool of 4096 bits (512 Bytes) to generate random data and stops when the pool is exhausted until it get's (slowly) refilled. /dev/random is absolutely not designed for wiping entire HDD's.<br />
; /dev/urandom: reuses entropy and although not suited for the most crucial cryptographic purposes, for example the generation of longterm keys, its quality should be sufficient for a paranoid disk wipe, [[#Preparations for block device encryption|preparing for block device encryption]], wiping LUKS keyslots, wiping single files and many other purposes.<br />
<br />
For much better performance consider using a true [[random#Pseudorandom_number_generator|pseudorandom number generator]].<br />
<br />
== Select a program ==<br />
{{ic|/dev/<drive>}} is the drive to be encrypted.<br />
<br />
=== Coreutils ===<br />
{{Merge|Core_Utilities|Basic file operations are '''not specific to disk wiping!''' Unrelated stuff in this section should get merged and then deleted and replaced with a link to [[Core Utilities]]. Did you ever want to write an article about dd and Co? Then just go ahead.}}<br />
<br />
Official documentation for dd and shred is linked to under [[#See also]].<br />
<br />
==== Dd ====<br />
{{Wikipedia|Dd_(Unix)}}<br />
{{Note|cp does the same as dd without any operands but is not designed for more versatile disk wiping procedures.}}<br />
<br />
===== Checking progress of dd while running =====<br />
By default, there is no output of dd until the task has finished. With kill and the "USR1"-Signal you can force status output without actually killing the program. Open up a 2nd root terminal and issue the following command:<br />
# killall -USR1 dd<br />
{{Note|This will affect all other running dd-processes as well.}}<br />
Or:<br />
# kill -USR1 <PID_OF_dd_COMMAND><br />
<br />
For example:<br />
# kill -USR1 $(pidof dd)<br />
<br />
This causes the terminal in which dd is running to output the progress at the time the command was run. For example:<br />
605+0 records in<br />
605+0 records out<br />
634388480 bytes (634 MB) copied, 8.17097 s, 77.6 MB/s<br />
<br />
===== Dd spin-offs =====<br />
Other dd alike programs feature periodical status output like i.e. a simple progress bar.<br />
<br />
'''dcfldd'''<br />
<br />
{{Pkg|dcfldd}} is an enhanced version of dd with features useful for forensics and security. It accepts most of dd's parameters and includes status output. The last stable version of dcfldd was released on December 19, 2006.<sup>[http://dcfldd.sourceforge.net/]</sup><br />
<br />
'''ddrescue'''<br />
<br />
GNU {{Pkg|ddrescue}} is a data recovery tool. It's capable of ignoring read errors what is a useless feature for disk wiping in almost any case.<br />
[http://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html GNU ddrescue Manual]<br />
<br />
==== shred ====<br />
{{Box BLUE|From [http://en.wikipedia.org/wiki/Shred_%28Unix%29 Wikipedia]:|Shred is a Unix command that can be used to securely delete files and devices so that they can be recovered only with great difficulty with specialised hardware, if at all.}}<br />
<br />
Shred uses three passes, writing pseudo-random data to the harddrive each pass. This can be reduced or increased.<br />
<br />
# shred -v /dev/<drive><br />
<br />
This invokes shred with default settings, displaying the progress to stdout.<br />
<br />
# shred --verbose --random-source=/dev/urandom -n1 /dev/<drive><br />
<br />
Invokes shred telling it to only do one pass, with entropy from /dev/urandom.<br />
<br />
{{Box RED|/dev/random will block when the entropy pool is depleted. /dev/urandom will still deplete the pool but re-uses it to prevent blocking. The random number generator gathers environmental noise from device drivers and other sources into an entropy pool. }}<br />
<br />
=== Badblocks ===<br />
For letting [[Badblocks#read-write_Test|badblocks perform a disk wipe]] a destructive read-write test has to be done.<br />
<br />
# badblocks -c 10240 -wsv /dev/<drive><br />
<br />
== Select a target ==<br />
{{Note|Fdisk will not work on [[GUID Partition Table|GPT]] formatted devices. Use {{Pkg|gdisk}} instead.}}<br />
Use fdisk to locate all read/write devices the user has read acess to.<br />
<br />
Check the output for lines that start with devices such as {{ic|/dev/sdX}}.<br />
<br />
This is an example for a HDD formatted to boot a linux system:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sda: 250.1 GB, 250059350016 bytes, 488397168 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x00ff784a<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sda1 * 2048 206847 102400 83 Linux<br />
/dev/sda2 206848 488397167 244095160 83 Linux</nowiki>}}<br />
<br />
Or the Arch Install Medium written to a 4GB USB thumb drive:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sdb: 4075 MB, 4075290624 bytes, 7959552 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x526e236e<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 * 0 802815 401408 17 Hidden HPFS/NTFS</nowiki>}}<br />
<br />
=== Block size ===<br />
{{Wikipedia|Dd (Unix)#Block size}}<br />
If you have a [[Wikipedia:Advanced Format|Advanced Format]] hard drive it is recommended that you specify a block size larger than the default 512 bytes. To speed up the overwriting process choose a block size matching your drive's physical geometry by appending the block size option to the dd command (i.e. {{ic|<nowiki>bs=4096</nowiki>}} for 4KB).<br />
<br />
Fdisk prints physical and logical sector size for every disk.<br />
<br />
Alternatively sysfs does expose information:<br />
/sys/block/sdX/queue/physical_block_size<br />
/sys/block/sdX/queue/logical_block_size<br />
/sys/block/sdX/alignment_offset<br />
<br />
== Overwrite the disk ==<br />
{{warning|There is no confirmation regarding the sanity of this command so '''repeatedly check''' that the correct drive or partition has been targeted. Make certain that the {{ic|<nowiki>of=...</nowiki>}} option points to the target drive and not to a system disk.}}<br />
<br />
Zero-fill the disk by writing a zero byte to every addressable location on the disk using the [[Wikipedia:/dev/zero|/dev/zero]] stream.<br />
<br />
# dd if=/dev/zero of=/dev/sdX bs=4096<br />
<br />
or the [[Wikipedia:/dev/random|/dev/random]] stream:<br />
# dd if=/dev/urandom of=/dev/sdX bs=4096<br />
<br />
The process is finished when dd reports, {{ic|No space left on device}}:<br />
dd: writing to ‘/dev/sdb’: No space left on device<br />
7959553+0 records in<br />
7959552+0 records out<br />
4075290624 bytes (4.1 GB) copied, 1247.7 s, 3.3 MB/s<br />
<br />
== Data remanence ==<br />
{{Expansion|This section is too dependent on links to Wikipedia. Links to diverse and high quality resources should be added.}}<br />
<br />
{{Wikipedia|Data remanence}}<br />
The residual representation of data may remain even after attempts have been made to remove or erase the data.<br />
<br />
Residual data may get wiped by writing (random) data to the disk with a single or even more than one iteration. However, more than one iteration may not significantly decrease the possibility to reconstruct the data of hard disk drives. For more information see [http://www.h-online.com/news/Secure-deletion-a-single-overwrite-will-do-it--/112432 Secure deletion: a single overwrite will do it - The H Security].<br />
<br />
=== Random data ===<br />
If the data can get exactly located on the disk and was never copied anywhere else, wiping with random data can be thoroughgoing and impressively quick as long there is enough entropy in the pool.<br />
<br />
A good example is cryptsetup using /dev/urandom for [[Dm-crypt_with_LUKS#Wipe_LUKS_keyslots|wiping the LUKS keyslots]].<br />
<br />
=== Hardware specific issues ===<br />
==== Flash memory ====<br />
[[Wikipedia:Write amplification]] and other characteristics make Flash memory a stubborn target for reliable wiping.<br />
As there is a lot of transparent abstraction in between data as seen by a device's controller chip and the operating system sight data is never overwritten in place and wiping particular blocks or files is not reliable.<br />
<br />
Other "features" like transparent compression (all SandForce SSD's) can compress your /dev/zero or pattern stream so if wiping is fast beyond belief this might be the case.<br />
<br />
Disassembling Flash memory devices, unsoldering the chips and analyzing data content without the controller in between is feasible without difficulty using [http://www.flash-extractor.com/manual/reader_models/ simple hardware]. Data recovery companys do it for cheap money.<br />
<br />
For more information see: [http://www.usenix.org/events/fast11/tech/full_papers/Wei.pdf Reliably Erasing Data From Flash-Based Solid State Drives].<br />
<br />
==== Residual magnetism ====<br />
Wiped hard disk drives and other magnetic storage can get disassembled in a cleanroom and then analyzed with equipment like a [[Wikipedia:Magnetic force microscope|magnetic force microscope]]. This may allow the overwritten data to be reconstructed by analyzing the measured [[Wikipedia:Remanence|residual magnetics]].<br />
<br />
This method of data recovery for current HDD's is largely theoretical and would require substantial financial resources. Nevertheless [[Wikipedia:Degaussing#Degaussing magnetic data storage media|degaussing]] is still a practiced countermeasure.<br />
<br />
==== Old magnetic storage ====<br />
Securely wiping old magnetic storage (e.g. floppy disks, magnetic tape) is much harder due to much lower [[Wikipedia:Memory storage density|memory storage density]]. Many iterations with random data might be needed to wipe any sensitive data. To ensure that data has been completely erased most resources advise physical destruction.<br />
<br />
==== Operating system, programs and filesystem ====<br />
{{Note|This is not specific to any hardware obviously.}}<br />
The operating system, executed programs or [[Wikipedia:Journaling file system|journaling file system]]s may copy your unencrypted data throughout the block device. When writing to plain disks this should only be relevant in conjunction with one of the above.<br />
<br />
== See also ==<br />
* [http://www.gnu.org/software/coreutils/manual/coreutils.html#Basic-operations GNU Coreutils Manpage on Basic operations]. Official documentation for dd and shred.<br />
<br />
* [http://www.linuxquestions.org/questions/linux-newbie-8/learn-the-dd-command-362506/ Learn the DD command]. - linuxquestions.org</div>Incognito