{"id":66,"date":"2009-06-15T11:51:32","date_gmt":"2009-06-15T18:51:32","guid":{"rendered":"http:\/\/www.analogrithems.com\/rant\/?p=66"},"modified":"2011-08-25T19:53:05","modified_gmt":"2011-08-26T02:53:05","slug":"66","status":"publish","type":"post","link":"https:\/\/www.analogrithems.com\/rant\/66\/","title":{"rendered":"Unix Drive Cloning"},"content":{"rendered":"<p>There are two schools of thought for how to clone drives under unix. The quick and dirty method is via the unix command dd. This is a bit for bit copy tool So it can even copy master boot records and partition tables. But it also copys empty space and kinda requires the drives be identical. Since it&#8217;s rare to actually have identical drives I&#8217;m going to show you how to use other system tools available under IRIX and Solaris to accomplish this task ask well as even make the new cloned drives better.<\/p>\n<p><strong>We start with Solaris.<\/strong> Not much has changed in this OS over the years. Most of the following was stolen from http:\/\/timesync.gmu.edu\/wordpress\/?p=30 It was customized to account for increasing the partition sizes.<\/p>\n<p>Note that in order to garuntee the best results use the<\/p>\n<p>Say the original drive is c1t0d0 and the new drive is c1t4d0<\/p>\n<p>Note that in order to guarantee the best results use the prtvtoc &amp; df commands to look at what the old partition table is. This Will let you know what partitions you need to create and the minimum sizes for each one. When formatting the partitions can be bigger but must be at least the same size.<\/p>\n<pre lang=\"bash\">   prtvtoc \/dev\/rdsk\/c1t0d0s2 &gt; \/root\/OldPartitionTable\r\n   df -k &gt;&gt; \/root\/OldPartitionTable<\/pre>\n<p>Once you know the current partition sizes use the format command to setup your new drive.<\/p>\n<p>Now, this script will build new file systems on the partitions of the new disk\u00e2\u20ac\u00a6matching those on the original. Then it will run ufsdump, copying data from the original to the new drive\u00e2\u20ac\u00a6then unmount the new \u00e2\u20ac\u0153clone\u00e2\u20ac\u009d drive. Finally it makes the new clone bootable. Note that this jazzy blog format wraps lines on the installboot line of the script\u00e2\u20ac\u00a6a \u00e2\u20ac\u0153man installboot\u00e2\u20ac\u009d will give you a clean copy of the syntax.<\/p>\n<pre lang=\"bash\">   #! \/bin\/ksh\r\n   # script assumes:\r\n   # c1t0d0 is original\r\n   # c1t4d0 is drive we\u00e2\u20ac\u2122ll turn into a clone\r\n\r\n   partlist=$(prtvtoc \/dev\/rdsk\/c1t4d0s2 | awk \u00e2\u20ac\u02dc!\/\\*\/ {print $1}\u00e2\u20ac\u2122)\r\n\r\n   for p in $partlist\r\n   do\r\n   if [ \"$p\" != \"1\" -a \"$p\" != \"2\" ]\r\n   then\r\n   newfs \/dev\/rdsk\/c1t4d0s$p &lt; \/dev\/null\r\n   mount \/dev\/dsk\/c1t4d0s$p \/mnt\r\n   cd \/mnt\r\n   ufsdump 0uf - \/dev\/dsk\/c1t0d0s$p | ufsrestore rf -\r\n   cd \/\r\n   umount \/mnt\r\n   fi\r\n   done\r\n\r\n   mount \/dev\/dsk\/c1t4d0s0 \/mnt\r\n   installboot \/usr\/platform\/`uname -i`\/lib\/fs\/ufs\/bootblk \\\r\n   \/dev\/rdsk\/c1t4d0s0\r\n   umount \/mnt\r\n\r\n   exit 0<\/pre>\n<p><strong>How to CLONE AN IRIX SYSTEM DISK. <\/strong>I use IRIX-disk cloning as a backup strategy. It is a bit expensive perhaps because I have to keep 2 SCSI disks (cloned copies of my combined user\/root disk) in the closet as backups. In the list below I assume you are running your IRIX system on (i.e. booted from) disk #1 and you want to clone it to spare disk #3. The first time (with an uninitialised disk) cloning takes about 10 steps. A second time (when the disk is already prepared), one may start at step 7 to make a backup-clone.<\/p>\n<p>1) BECOME SUPERUSER:<\/p>\n<pre lang=\"bash\">   su<\/pre>\n<p>2) FIRST THOROUGHLY TEST THE DRIVE THAT HAS TO BECOME THE CLONE:<\/p>\n<pre lang=\"bash\">   fx -x\r\n    fx: \"device-name\" = (dksc)                       \r\n    fx: ctlr# = (0)                                  \r\n    fx: drive# = (1)                                 3\r\n    fx: lun# = (0)                                   \r\n     fx&gt;                                             exercise\r\n     fx\/exercise&gt;                                    butterfly\r\n  \tmodifier = (rd-only)                           wr-cmp\r\n  \tstarting block# = (0)                          \r\n  \tnblocks = (143374744)                          \r\n  \tnscans = (1)                                   \r\n  \tabout to destroy data on disk dksc(0,3,0)! ok? yes\r\n     ..\r\n    ..\r\n    label info has changed for disk dksc(0,3,0).\r\n    write out changes?                               yes\r\n   exit<\/pre>\n<p>3) ADD SGI LABEL:<\/p>\n<pre lang=\"bash\">   fx -x\r\n   fx: \"device-name\" = (dksc)\r\n    fx: ctlr# = (0)\r\n    fx: drive# = (1) 3\r\n    fx: lun# = (0)\r\n     auto\r\n     about to destroy data on disk dksc(0,3,0)! ok? yes\r\n     (Several tests... may take a long long time, you can\r\n      abort them.)\r\n   exit<\/pre>\n<p>It is perhaps easier to do this via the Disk Manager desktop-interface: just initialise the disk. This only takes a few seconds and also puts a SGI label on the disk.<\/p>\n<p>4) MAKE ROOTDRIVE PARTITIONING: List the disk partitioning of the system (root) disk:<\/p>\n<pre lang=\"bash\">   prtvtoc<\/pre>\n<p>List the disk partitioning of the option disk that is to be the clone:<\/p>\n<pre lang=\"bash\">   prtvtoc \/dev\/rdsk\/dks0d3vh<\/pre>\n<p>Compare the disk partitioning of the two disks. They must have the same layout for the root and (if used) the usr partition. If they are not the same, repartition the option disk to match the system disk. In the easiest case:<\/p>\n<pre lang=\"bash\">   fx \"dksc(0,3)\"\r\n    repartition\r\n    rootdrive\r\n    type of data partition = (xfs)\r\n    ..\r\n    exit<\/pre>\n<p>Then compare the prtvtoc outputs again. 5) ADD STAND-ALONE SHELL (AND OTHER PROGRAMS) TO VOLUME HEADER: If necessary, first copy the appropriate sash (on your systemdisk, SCSI ID=1) to the \/stand directory:<\/p>\n<pre lang=\"bash\">   dvhtool \/dev\/rdsk\/dks0d1vh                          (CAREFUL!)\r\n   vd                                                  (volume directory)\r\n   l                                                   (list)\r\n   g sash \/stand\/sash_Octane\r\n   g ide \/stand\/ide_Octane\r\n   g IP30prom \/stand\/IP30prom_Octane\r\n   quit<\/pre>\n<p>Then add the required programs to a volume header:<\/p>\n<pre lang=\"bash\">   dvhtool \/dev\/rdsk\/dks0d3vh                      (SCSI ID=3)\r\n   vd                                              (volume directory)\r\n   l                                               (list)\r\n   a \/stand\/sash_Octane sash                       (add to volume header)\r\n   a \/stand\/ide_Octane ide\r\n   a \/stand\/IP30prom_Octane IP30prom\r\n   l\r\n   quit\r\n   write\r\n   quit<\/pre>\n<p>6) MAKE FILESYSTEM: To make an XFS root filesystem with a 4 KB block size and a 1000 block internal log (the default values), give this command:<\/p>\n<pre lang=\"bash\">   mkfs \/dev\/dsk\/dks0d3s0<\/pre>\n<p>7) SWITCH TO SINGLE USER MODE AND MOUNT:<\/p>\n<pre lang=\"bash\">   single\r\n\r\n   mkdir \/clone\r\n   mount \/dev\/dsk\/dks0d3s0 \/clone\r\n   cd \/clone<\/pre>\n<p>8) XFSDUMP:<\/p>\n<pre lang=\"bash\">   xfsdump -l 0 - \/ | xfsrestore - .<\/pre>\n<p>Notice the 0, it is a NULL character, not an O!<\/p>\n<p>9) UNMOUNT AND SHUTDOWN:<\/p>\n<pre lang=\"bash\">   cd ..\r\n   umount \/clone\r\n   rmdir \/clone\r\n   shutdown<\/pre>\n<p>10) TEST Swap drives (in an Octane) and try if your clone is really bootable.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two schools of thought for how to clone drives under unix. The quick and dirty method is via the unix command dd. This is a bit for bit copy tool So it can even copy master boot records and partition tables. But it also copys empty space and kinda requires the drives be [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44],"tags":[],"class_list":["post-66","post","type-post","status-publish","format-standard","hentry","category-featured"],"_links":{"self":[{"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/comments?post=66"}],"version-history":[{"count":9,"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/posts\/66\/revisions"}],"predecessor-version":[{"id":488,"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/posts\/66\/revisions\/488"}],"wp:attachment":[{"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/media?parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/categories?post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.analogrithems.com\/rant\/wp-json\/wp\/v2\/tags?post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}