{"id":1845,"date":"2013-07-16T09:38:14","date_gmt":"2013-07-16T08:38:14","guid":{"rendered":"http:\/\/kudzia.eu\/b\/?p=1845"},"modified":"2013-07-16T09:38:14","modified_gmt":"2013-07-16T08:38:14","slug":"cloning-gpt-disk-to-a-smaller-drive","status":"publish","type":"post","link":"https:\/\/kudzia.eu\/b\/2013\/07\/cloning-gpt-disk-to-a-smaller-drive\/","title":{"rendered":"cloning GPT disk to a smaller drive"},"content":{"rendered":"<p>while rescuing data from server having problems with either disk or raid controller i had to clone data from 2x 1TB RAID1 to 4x 500GB RAID10. as it turned out the space available on the destination server was 1GB less than on the source machine. shrinking the source drive with gparted-live and dd&#8217;ing over the network was not enough. full list of necessary steps &#8211; below.<br \/>\n<!--more--><\/p>\n<ul>\n<li>first resize the partitions on the source machines so the total size of them fits on the destination machine. i use <a href=\"http:\/\/gparted.sourceforge.net\/livecd.php\">gparted-live<\/a>.<br \/>\n<a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/07\/gparted-resize.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/07\/gparted-resize.png\" alt=\"gparted-resize\" width=\"771\" height=\"718\" class=\"alignnone size-full wp-image-1851\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/07\/gparted-resize.png 771w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/07\/gparted-resize-300x279.png 300w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><\/a><\/p>\n<\/li>\n<li>run linux on both machines and do sector-by-sector clone over the network. i was lazy so instead of booting the source machine from a live-cd i have just re-mounted all partitions as read only to avoid any writes to the disk during cloning [this might be risky, dont do it with important data].:\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# all of this on the source machine\r\n# stop all processes that might keep files opened for writing\r\n\/etc\/init.d\/cron stop; \/etc\/init.d\/mysql stop ; \/etc\/init.d\/apache2 stop; \/etc\/init.d\/rsyslog stop \r\n# re-mount all partitions as read only\r\nmount -no remount,ro \/ \r\n# and clone\r\ndd if=\/dev\/sda bs=10M | ssh -c arcfour -o Compression=no root@destination &quot;dd of=\/dev\/sda bs=10M&quot;\r\n<\/pre>\n<\/li>\n<li>after dd&#8217;ing the disk image boot the destination machine from gparted-live cd, go to the terminal and run gdisk and press v,x,e,w,y:\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@debian:\/home\/user# gdisk \/dev\/sda\r\nGPT fdisk (gdisk) version 0.8.5\r\n\r\nWarning! Disk size is smaller than the main header indicates! Loading\r\nsecondary header from the last sector of the disk! You should use 'v' to\r\nverify disk integrity, and perhaps options on the experts' menu to repair\r\nthe disk.\r\nCaution: invalid backup GPT header, but valid main header; regenerating\r\nbackup header from main header.\r\n\r\nWarning! One or more CRCs don't match. You should repair the disk!\r\n\r\nPartition table scan:\r\n  MBR: protective\r\n  BSD: not present\r\n  APM: not present\r\n  GPT: damaged\r\n\r\n****************************************************************************\r\nCaution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk\r\nverification and recovery are STRONGLY recommended.\r\n****************************************************************************\r\n\r\nCommand (? for help): v\r\n\r\nCaution: The CRC for the backup partition table is invalid. This table may\r\nbe corrupt. This program will automatically create a new backup partition\r\ntable when you save your partitions.\r\n\r\nProblem: The secondary header's self-pointer indicates that it doesn't reside\r\nat the end of the disk. If you've added a disk to a RAID array, use the 'e'\r\noption on the experts' menu to adjust the secondary header's and partition\r\ntable's locations.\r\n\r\nProblem: Disk is too small to hold all the data!\r\n(Disk size is 7340032 sectors, needs to be 8388608 sectors.)\r\nThe 'e' option on the experts' menu may fix this problem.\r\n\r\nIdentified 3 problems!\r\n\r\nCommand (? for help): x\r\n\r\nExpert command (? for help): e\r\nRelocating backup data structures to the end of the disk\r\n\r\nExpert command (? for help): w\r\n\r\nFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING\r\nPARTITIONS!!\r\n\r\nDo you want to proceed? (Y\/N): Y\r\nOK; writing new GUID partition table (GPT) to \/dev\/sda.\r\nThe operation has completed successfully.\r\n<\/pre>\n<\/li>\n<li>reboot &#8211; this time the system should boot from the smaller destination disk<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>while rescuing data from server having problems with either disk or raid controller i had to clone data from 2x 1TB RAID1 to 4x 500GB RAID10. as it turned out the space available on the destination server was 1GB less than on the source machine. shrinking the source drive with gparted-live and dd&#8217;ing over the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-1845","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/comments?post=1845"}],"version-history":[{"count":10,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1845\/revisions"}],"predecessor-version":[{"id":1857,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1845\/revisions\/1857"}],"wp:attachment":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/media?parent=1845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/categories?post=1845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/tags?post=1845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}