{"id":1164,"date":"2020-07-24T10:31:39","date_gmt":"2020-07-24T08:31:39","guid":{"rendered":"https:\/\/www.web-workers.ch\/?p=1164"},"modified":"2020-07-24T10:33:17","modified_gmt":"2020-07-24T08:33:17","slug":"how-to-remove-all-partitions-data-on-a-disk","status":"publish","type":"post","link":"https:\/\/www.web-workers.ch\/index.php\/2020\/07\/24\/how-to-remove-all-partitions-data-on-a-disk\/","title":{"rendered":"How to remove all partitions \/ data on a disk"},"content":{"rendered":"<p>To remove \/ delete all data on your disk drive, you can use one of the following methods below. Have a look a <a href=\"https:\/\/gparted.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">gparted<\/a> in case you need a live DVD to boot from to perform the steps.<\/p>\n<h2>Old good\u00a0dd command<\/h2>\n<p>Use the following dd command to remove data from \/dev\/hdX:<\/p>\n<pre class=\"wp_syntax\"># dd if=\/dev\/zero of=\/dev\/hdX bs=512 count=1<\/pre>\n<p>OR for sata disk, use the following syntax:<\/p>\n<pre class=\"wp_syntax\"># dd if=\/dev\/zero of=\/dev\/sdX bs=512 count=1<\/pre>\n<p>In this example, empty sata disk \/dev\/sdb, enter (you must be login as the root user):<\/p>\n<pre class=\"wp_syntax\"># fdisk \/dev\/sdb\r\n# dd if=\/dev\/zero of=\/dev\/sdb bs=512 count=1\r\n# fdisk -l \/dev\/sdb<\/pre>\n<h2>Securely wipe hard disk with shred<\/h2>\n<p>You can use the\u00a0<a href=\"https:\/\/linux.die.net\/man\/1\/shred\" target=\"_blank\" rel=\"noopener noreferrer\">shred command<\/a>\u00a0to securely remove everything so that no one recover any data:<\/p>\n<pre># shred -n 5 -vz \/dev\/sdb<\/pre>\n<h2>The scrub command<\/h2>\n<p>You can use a disk scrubbing program such as <a href=\"https:\/\/linux.die.net\/man\/1\/scrub\">scrub<\/a>. It overwrites hard disks, files, and other devices with repeating patterns intended to make recovering data from these devices more difficult. Type the following command to securely wipe out \/dev\/sdb:<\/p>\n<pre># scrub -p dod \/dev\/sdb<\/pre>\n<h2>Remove paritions with fdisk<\/h2>\n<p>fdisk can be used to display or manipulate a disk partition table. To remove all partitions perform the following steps.<\/p>\n<p>First, get a listing of your current partition scheme, type the following command:<\/p>\n<pre># fdisk -l.<\/pre>\n<pre>Disk \/dev\/hda: 20.0 GB, 20060651520 bytes\r\n255 heads, 63 sectors\/track, 2438 cylinders\r\nUnits = cylinders of 16065 * 512 = 8225280 bytes\r\n\r\n   Device Boot      Start         End      Blocks   Id  System\r\n\/dev\/hda1               1        1024     8225248+   b  W95 FAT32\r\n\/dev\/hda2   *        1025        2438    11357955    c  W95 FAT32 (LBA)\r\n\r\nDisk \/dev\/hdb: 80.0 GB, 80060424192 bytes\r\n255 heads, 63 sectors\/track, 9733 cylinders\r\nUnits = cylinders of 16065 * 512 = 8225280 bytes\r\n\r\n   Device Boot      Start         End      Blocks   Id  System\r\n\/dev\/hdb1   *           1        2432    19535008+  83  Linux\r\n\/dev\/hdb2            2433        2554      979965   82  Linux swap \/ Solaris\r\n<strong>\/dev\/hdb3            2555        6202    29302560   83  Linux<\/strong>\r\n\/dev\/hdb4            6203        9733    28362757+   5  Extended\r\n\/dev\/hdb5            6203        9733    28362726   83  Linux<\/pre>\n<p>From the output above, there are two disk listed:<\/p>\n<p>&#8211; \/dev\/hda \u2013 20 GB<br \/>\n&#8211; \/dev\/hdb \u2013 80 GB<\/p>\n<p>Let us assume that we want to remove a partition \/dev\/hdb3 from \/dev\/hdb disk. Type the following command:<\/p>\n<pre># fdisk \/dev\/hdb<\/pre>\n<pre>The number of cylinders for this disk is set to 9733.\r\nThere is nothing wrong with that, but this is larger than 1024,\r\nand could in certain setups cause problems with:\r\n1) software that runs at boot time (e.g., old versions of LILO)\r\n2) booting and partitioning software from other OSs\r\n   (e.g., DOS FDISK, OS\/2 FDISK)\r\n\r\nCommand (m for help):<\/pre>\n<p>Now type p command to list partition:<\/p>\n<pre>Command (m for help): p<\/pre>\n<pre>Disk \/dev\/hdb: 80.0 GB, 80060424192 bytes\r\n255 heads, 63 sectors\/track, 9733 cylinders\r\nUnits = cylinders of 16065 * 512 = 8225280 bytes\r\n\r\n   Device Boot      Start         End      Blocks   Id  System\r\n\/dev\/hdb1   *           1        2432    19535008+  83  Linux\r\n\/dev\/hdb2            2433        2554      979965   82  Linux swap \/ Solaris\r\n<strong>\/dev\/hdb3            2555        6202    29302560   83  Linux<\/strong>\r\n\/dev\/hdb4            6203        9733    28362757+   5  Extended\r\n\/dev\/hdb5            6203        9733    28362726   83  Linux<\/pre>\n<p>Now let us say you want to delete \/dev\/hdb3 (3rd partition). Type the d command to delete a partition:<\/p>\n<pre>Command (m for help): d<\/pre>\n<p>It will prompt you for the partition number. Type 3: (repeat the step for every partition)<\/p>\n<pre>Partition number (1-4):\u00a0<strong>3<\/strong><\/pre>\n<p>Verify that partition deleted:<\/p>\n<pre>Command (m for help): p<\/pre>\n<p>Now save the changes and exit to shell prompt. Type the w command:<\/p>\n<pre>Command (m for help): w<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To remove \/ delete all data on your disk drive, you can use one of the following methods below. Have a look a gparted in case you need a live [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[130,126,133,127,131,124,129,10,128,132,125],"class_list":["post-1164","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-data","tag-dd","tag-delete","tag-disk","tag-erease","tag-fdisk","tag-gparted","tag-linux","tag-partition","tag-remove","tag-scrub"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2020\/07\/wipe-disk1.jpg?fit=600%2C400&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8sxjX-iM","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/1164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/comments?post=1164"}],"version-history":[{"count":7,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/1164\/revisions"}],"predecessor-version":[{"id":1176,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/1164\/revisions\/1176"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/media\/1174"}],"wp:attachment":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/media?parent=1164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/categories?post=1164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/tags?post=1164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}