{"id":20,"date":"2008-08-14T15:50:19","date_gmt":"2008-08-14T19:50:19","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=20"},"modified":"2008-08-14T15:50:19","modified_gmt":"2008-08-14T19:50:19","slug":"how-to-use-dd-to-copy-move-and-erase-disks","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2008\/08\/14\/how-to-use-dd-to-copy-move-and-erase-disks\/","title":{"rendered":"How to use dd to copy, move and erase disks"},"content":{"rendered":"<p>Often, you may encounter the need to move a partition, copy a partition or copy a CD\/DVD. The easiest and most user-friendly way to do this is with <a rel=\"nofollow\" href=\"http:\/\/en.wikipedia.org\/wiki\/Gparted\">GParted<\/a>. However, in a server environment or a command line environment where the GUI is not available, GNU dd is an good way to perform these simple tasks. Here are  easy tips on how to use dd for disk manipulation. Most of these commands require you to be part of the &#8220;disk&#8221; group.<\/p>\n<p>If you are on the Windows platform, you will need a copy of <a href=\"\/labs\/files\/dd.exe\">rawwrite dd<\/a> for Windows in your %PATH%. To list the disks with rawwrite dd, use <strong>dd &#8211;list<\/strong> and use the devices listed there; for example, use &#8220;\\\\?\\Device\\HarddiskVolume1&#8221; instead of &#8220;\/dev\/sda1&#8221;. For CD drives, replace \/dev\/cdrom with &#8220;\\\\?\\Device\\CdRom0&#8221;.<\/p>\n<ol>\n<li><strong>dd if=\/dev\/<em>partition<\/em> of=\/dev\/<em>destination<\/em><\/strong> &#8211; Copy the partition <em>partition<\/em> to the partition <em>destination<\/em>.<\/li>\n<li><strong>dd if=\/dev\/cdrom of=<em>filename.iso<\/em><\/strong> &#8211; Make an <a rel=\"nofollow\" href=\"http:\/\/en.wikipedia.org\/wiki\/ISO_image\">ISO image<\/a> of the disc in your CD drive as <em>filename.iso<\/em>. Then you can use in Virtual Machines such as VMWare, mount it in Windows with DaemonTools or mount it as an file system in Linux.<\/li>\n<li><strong>dd <em>something<\/em> bs=<em>speed<\/em><\/strong> &#8211; Performs the action <em>something<\/em> at the speed of <em>speed <\/em>bytes per second. Can be used to copy CDs and disks faster.<\/li>\n<li><strong>dd if=\/dev\/zero of=\/dev\/<em>pdest<\/em><\/strong> &#8211; Wipes the filesystem from the partition <em>pdest<\/em>, which can you can then make a new filesystem with <strong>mkfs.ext3 \/dev\/<em>pdest<\/em><\/strong>.<\/li>\n<li><strong>dd if=\/dev\/<em>part<\/em> of=<em>filename.disk<\/em><\/strong> &#8211; Makes a intact backup of everything on the partition <em>part<\/em> into the file <em>filename.disk<\/em>.<\/li>\n<li><strong>dd if=<em>filename.disk<\/em> of=\/dev\/<em>part<\/em><\/strong> &#8211; Copies from intact backup <em>filename.disk<\/em> into the partition <em>part<\/em>. Make sure that the partition <em>part<\/em> is big enough to hold <em>filename.disk<\/em>.<\/li>\n<li><strong>dd if=\/dev\/cdrom of=\/dev\/<em>part<\/em> bs=10M <\/strong>&#8211; Copies the CD filesystem on your CD to the partition <em>part<\/em>.<\/li>\n<li><strong>dd if=\/dev\/fd0 of=<em>filename.img<\/em><\/strong> &#8211; Copies the floppy in your floppy drive to <em>filename.img<\/em>. Then the image can be used in Virtual Machines.<\/li>\n<li><strong>dd if=<em>filename.img<\/em> of=\/dev\/fd0<\/strong> &#8211; Copies the image <em>filename.img<\/em> to the floppy in your floppy drive.<\/li>\n<li><strong>dd if=\/dev\/<em>disk<\/em> of=<em>bootsect.bin<\/em> bs=512 count=1<\/strong> &#8211; Copies the boot sector of disk <em>disk<\/em> to the file <em>bootsect.bin<\/em>.<\/li>\n<li><strong>dd if=\/dev\/<em>disk<\/em> of=\/dev\/null <\/strong>&#8211; The best way to waste your CPU power; copies <em>disk<\/em> to NULL.<\/li>\n<\/ol>\n<p>So as you can see, dd is a very useful tool to manipulate partitions and images. If you found this article interesting or helpful, please help us spread the word or please leave a comment!<\/p>","protected":false},"excerpt":{"rendered":"<p>Often, you may encounter the need to move a partition, copy a partition or copy a CD\/DVD. The easiest and most user-friendly way to do this is with GParted. However, in a server environment or a command line environment where the GUI is not available, GNU dd is an good way to perform these simple [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4],"tags":[64,61,63,66,62,862,68,67,863,60,65],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/20"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}