{"id":302,"date":"2017-10-24T13:56:39","date_gmt":"2017-10-24T11:56:39","guid":{"rendered":"http:\/\/owncloud.gonscak.sk\/?p=302"},"modified":"2020-02-12T07:00:32","modified_gmt":"2020-02-12T06:00:32","slug":"disk-cloning-with-dd","status":"publish","type":"post","link":"https:\/\/www.gonscak.sk\/?p=302","title":{"rendered":"disk cloning with dd"},"content":{"rendered":"<p>How to create a disk or usb image, and compress it on the fly? And how to restore it?<br \/>\nI have own operating system on USB key. To create a full-backup and then possible restore to another device, I use linux command dd (dd &#8211; convert and copy a file).<br \/>\nNow, we must determine, on which patch we have s source disk. I my case, it is<\/p>\n<pre>sudo fdisk -l \/dev\/sdb\nDisk \/dev\/sdb: 29,5 GiB<\/pre>\n<p>First, I install additional\u00a0 software for monitoring and best compressing on more cores<\/p>\n<pre>sudo apt-get install pigz pv<\/pre>\n<p>Then, I create a full copy of the usb key. Without compression it takes 30GB, with compression, it take only 3GB. With command &#8220;pv&#8221; we can watch progress. Pigz compress the source image with multiple threads and cores. With parameter -c it writes all processed output to stdout. So\u00a0 with operand &#8220;&gt;&#8221; we write this pigz output to a file:<\/p>\n<pre>sudo dd if=\/dev\/sdb | pv | pigz -c &gt; \/home\/vasil\/Documents\/corsair-work.dd.gz<\/pre>\n<p>If we had som bad blocks on source disk, and we want to clone it anyway, we can use another <em>conv <\/em>options. Like:<\/p>\n<pre><code>conv=sync,noerror<\/code><\/pre>\n<p>This means:<\/p>\n<ul>\n<li>noerror &#8211; This makes use dd continue even after a read error is encountered;<\/li>\n<li>sync &#8211; This option has sense especially when used together with noerror.<\/li>\n<\/ul>\n<p>In such a case the <em><code>noerror<\/code><\/em> option will make dd continue running even if it a sector cannot be read successfully, and the <em><code>sync<\/code><\/em> option will make so that the amount of data failed to be read its replaced by <code>NULs<\/code>, so that the length of the data is preserved even if the actual data is lost (since it&#8217;s not possible to read it).<\/p>\n<p>Then, I remove the source usb key and insert new one. It also has a path \/dev\/sdb. Now, I restore it with this command:<\/p>\n<pre>pigz -cdk Documents\/corsair-work.dd.gz |pv| sudo dd of=\/dev\/sdb bs=4M<\/pre>\n<p>Parameter -c also write output to stdout and program dd writes it to disk. Parameter -k menas, that keep original file after decompress. And parameter -d means decompress.<br \/>\nNow, we can boot system with new usb key. And this image is identical as the source.<br \/>\nI hope, that this help someone. Have a nice day.<\/p>\n ","protected":false},"excerpt":{"rendered":"<p>How to create a disk or usb image, and compress it on the fly? And how to restore it? I have own operating system on USB key. To create a full-backup and then possible restore to another device, I use linux command dd (dd &#8211; convert and copy a file). Now, we must determine, on &hellip; <a href=\"https:\/\/www.gonscak.sk\/?p=302\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">disk cloning with dd<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,39,59],"tags":[72,73,74,75,76],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-centos","category-debian-jessie","category-ubuntu","tag-backup","tag-compress","tag-dd","tag-image","tag-pigz"],"_links":{"self":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=302"}],"version-history":[{"count":1,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":519,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions\/519"}],"wp:attachment":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}