{"id":11452,"date":"2019-03-14T07:58:28","date_gmt":"2019-03-14T07:58:28","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11452"},"modified":"2019-03-14T07:58:28","modified_gmt":"2019-03-14T07:58:28","slug":"how-to-clone-a-partition-or-hard-drive-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/how-to-clone-a-partition-or-hard-drive-in-linux\/","title":{"rendered":"How to Clone a Partition or Hard drive in Linux"},"content":{"rendered":"<p>There are many reasons why you may want to clone a Linux partition or even hard drive, most of which are related to\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-system-backup-tools\/\" target=\"_blank\" rel=\"noopener\">creating backups of your data<\/a>. There are multiple ways you can achieve this in Linux by using some external tools such as\u00a0<strong>partimage<\/strong>\u00a0or\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-centos-ubuntu-disk-cloning-backup-using-clonezilla\/\" target=\"_blank\" rel=\"noopener\">Clonezilla<\/a>.<\/p>\n<p>However in this tutorial we are going to review Linux disk cloning with tool called\u00a0<strong>dd<\/strong>, which is most commonly used to convert or copy files and it comes pre-installed in most Linux distributions.<\/p>\n<h3>How to Clone Linux Partition<\/h3>\n<p>With\u00a0<strong>dd command<\/strong>\u00a0you can copy entire hard drive or just a Linux partition. Lets start with cloning one of our partitions. In my case I have the following drives:\u00a0<strong>\/dev\/sdb<\/strong>,\u00a0<strong>\/dev\/sdc<\/strong>.. I will clone\u00a0<strong>\/dev\/sdb1\/<\/strong>\u00a0to\u00a0<strong>\/dev\/sdc1<\/strong>.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/backup-or-clone-linux-partitions-using-cat-command\/\" target=\"_blank\" rel=\"noopener\">How to Clone Linux Partitions Using \u2018cat\u2019 Command<\/a><\/p>\n<p>First list the these partitions using the\u00a0<a href=\"https:\/\/www.tecmint.com\/fdisk-commands-to-manage-linux-disk-partitions\/\" target=\"_blank\" rel=\"noopener\">fdisk command<\/a>\u00a0as shown.<\/p>\n<pre># fdisk -l \/dev\/sdb1\/ \/dev\/sdc1\r\n<\/pre>\n<div id=\"attachment_31375\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/List-Linux-Partitions.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31375\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/List-Linux-Partitions.png\" sizes=\"auto, (max-width: 838px) 100vw, 838px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/List-Linux-Partitions.png 838w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/List-Linux-Partitions-768x257.png 768w\" alt=\"List Linux Partitions\" width=\"838\" height=\"280\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">List Linux Partitions<\/p>\n<\/div>\n<p>Now clone a partition\u00a0<strong>\/dev\/sdb1\/<\/strong>\u00a0to\u00a0<strong>\/dev\/sdc1<\/strong>\u00a0using the following\u00a0<strong>dd command<\/strong>.<\/p>\n<pre># dd if=\/dev\/sdb1  of=\/dev\/sdc1 \r\n<\/pre>\n<p>The above command tells\u00a0<strong>dd<\/strong>\u00a0to use\u00a0<strong>\/dev\/sdb1<\/strong>\u00a0as input file and write it to output file\u00a0<strong>\/dev\/sdc1<\/strong>.<\/p>\n<div id=\"attachment_31376\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Clone-Linux-Partition-with-dd-Command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31376\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Clone-Linux-Partition-with-dd-Command.png\" sizes=\"auto, (max-width: 837px) 100vw, 837px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Clone-Linux-Partition-with-dd-Command.png 837w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Clone-Linux-Partition-with-dd-Command-768x146.png 768w\" alt=\"Clone Linux Partition with dd Command\" width=\"837\" height=\"159\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Clone Linux Partition with dd Command<\/p>\n<\/div>\n<p>After cloning Linux partition, you can then check both partitions with:<\/p>\n<pre># fdisk -l \/dev\/sdb1 \/dev\/sdc1\r\n<\/pre>\n<div id=\"attachment_31377\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Verify-Linux-Partition-Cloning.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31377\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Verify-Linux-Partition-Cloning.png\" sizes=\"auto, (max-width: 845px) 100vw, 845px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Verify-Linux-Partition-Cloning.png 845w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Verify-Linux-Partition-Cloning-768x250.png 768w\" alt=\"Verify Linux Partition Cloning\" width=\"845\" height=\"275\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Verify Linux Partition Cloning<\/p>\n<\/div>\n<h3>How to Clone Linux Hard Drive<\/h3>\n<p>Cloning a Linux hard drive is similar to cloning a partition. However, instead of specifying the partition, you just use the entire drive. Note that in this case it is recommended that the hard drive is same in size (or bigger) than the source drive.<\/p>\n<pre># dd if=\/dev\/sdb of=\/dev\/sdc\r\n<\/pre>\n<div id=\"attachment_31378\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Clone-Hard-Drive-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31378\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Clone-Hard-Drive-in-Linux.png\" sizes=\"auto, (max-width: 842px) 100vw, 842px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Clone-Hard-Drive-in-Linux.png 842w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Clone-Hard-Drive-in-Linux-768x138.png 768w\" alt=\"Clone Hard Drive in Linux\" width=\"842\" height=\"151\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Clone Hard Drive in Linux<\/p>\n<\/div>\n<p>This should have copied the drive\u00a0<strong>\/dev\/sdb<\/strong>\u00a0with its partitions on the target hard drive\u00a0<strong>\/dev\/sdc<\/strong>. You can verify the changes by listing both drives with\u00a0<a href=\"https:\/\/www.tecmint.com\/fdisk-commands-to-manage-linux-disk-partitions\/\" target=\"_blank\" rel=\"noopener\">fdisk command<\/a>.<\/p>\n<pre># fdisk -l \/dev\/sdb \/dev\/sdc\r\n<\/pre>\n<div id=\"attachment_31379\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Verify-Linux-Hard-Drive-Cloning.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31379\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Verify-Linux-Hard-Drive-Cloning.png\" sizes=\"auto, (max-width: 842px) 100vw, 842px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Verify-Linux-Hard-Drive-Cloning.png 842w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Verify-Linux-Hard-Drive-Cloning-768x423.png 768w\" alt=\"Verify Linux Hard Drive Cloning\" width=\"842\" height=\"464\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Verify Linux Hard Drive Cloning<\/p>\n<\/div>\n<h3>How to Backup MBR in Linux<\/h3>\n<p><strong>dd command<\/strong>\u00a0can also be used to backup your\u00a0<strong>MBR<\/strong>, which is located at the first sector of the device, before the first partition. So if you want to create backup of your MBR, simply run:<\/p>\n<pre># dd if=\/dev\/sda of=\/backup\/mbr.img bs=512 count=1. \r\n<\/pre>\n<p>The above command tells\u00a0<strong>dd<\/strong>\u00a0to copy\u00a0<strong>\/dev\/sda<\/strong>\u00a0to\u00a0<strong>\/backup\/mbr.img<\/strong>\u00a0with step of\u00a0<strong>512<\/strong>\u00a0bytes and the count option tells to copy only\u00a0<strong>1<\/strong>\u00a0block. In other words you tell\u00a0<strong>dd<\/strong>\u00a0to copy the first\u00a0<strong>512<\/strong>\u00a0bytes from\u00a0<strong>\/dev\/sda<\/strong>\u00a0to the file you have provided.<\/p>\n<div id=\"attachment_31380\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Backup-MBR-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31380\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Backup-MBR-in-Linux.png\" sizes=\"auto, (max-width: 838px) 100vw, 838px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Backup-MBR-in-Linux.png 838w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Backup-MBR-in-Linux-768x133.png 768w\" alt=\"Backup MBR in Linux\" width=\"838\" height=\"145\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Backup MBR in Linux<\/p>\n<\/div>\n<p>That\u2019s all!\u00a0<strong>dd command<\/strong>\u00a0is a powerful Linux tool that should be used with caution when copying or cloning Linux partitions or drives.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/clone-linux-partitions\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many reasons why you may want to clone a Linux partition or even hard drive, most of which are related to\u00a0creating backups of your data. There are multiple ways you can achieve this in Linux by using some external tools such as\u00a0partimage\u00a0or\u00a0Clonezilla. However in this tutorial we are going to review Linux disk &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/how-to-clone-a-partition-or-hard-drive-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Clone a Partition or Hard drive in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11452","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11452"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11452\/revisions"}],"predecessor-version":[{"id":11453,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11452\/revisions\/11453"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}