Summary: dd to copy harddisk

From: Peter Vos <peterv_at_easics.be>
Date: Thu Sep 13 2001 - 11:35:09 EDT
Hello,
First of all, thanks to all the responses from 
(hopefully I don't forget anyone):

"Neill, Mark (MBS)" <Mark.Neill@mortgagefamily.com>
"JULIAN, JOHN C. (AIT)" <jj2195@sbc.com>
Hindley Nick <nick.hindley@lbhf.gov.uk>
Russ Poffenberger <poffen@san-jose.tt.slb.com>
todd.a.fiedler@mail.sprint.com
Bertrand_Hutin@notes.amdahl.com
"Eriksson (London), Christer" <Christer.Eriksson@seb.co.uk>
Tony Tran <tonytran@contour.com>
"Ricca, Paul" <PTRicca@aztectech.com>
Edward Scown <eascown3@yahoo.com>
"Caterina Brott" <cbrott@newfie.nosc.mil>
Steve Camp <steve@camp.com>
"Wade, Wally" <Wally.Wade@GD-ES.COM>
Lars Oliver Bausch <lars.bausch@dotsch.de>
"Kruchkoff, A (Alex)" <Alex.Kruchkoff@SYD.RABOBANK.COM>
"Pankaj Anand" <pankaj.anand@wipro.com>
Tony Walsh <Tony.Walsh@Sun.COM>
Gabel Martin <Martin.Gabel@ffm3.siemens.de>
Paul Updike <updike@msai.mea.com>


-----original message:-----
The disk of one of our machines (Ultra2) has begun making 'chirping' 
noises, so we will change it with another one.
I would like to use dd to copy the existing disk - which contains the OS
-
with dd to a new disk.
Does this also work when using 2 different disks? (The noisy disk is
a 2.1G, and will probably be replaced by a bigger one)
What other things do I have to keep in mind? (apart from creating the
partitions and doing the dd)
-----summary:-----

Almost everyone advised against using dd, and use ufsdump/restore
instead, followed by installboot to make the disk bootable.
It's not possible to list everyone's answer, but I will include the most
detailed (from "Ricca, Paul" <PTRicca@aztectech.com>):



INFODOC ID: 16311 
SYNOPSIS: How to do a disk-to-disk copy via ufsdump/tar under Solaris
2.X. 
DETAIL DESCRIPTION: 
For Solaris 2.X:
________________

Follow the steps below to add a new external/internal disk:

[1.] Bring the system down to the ok prompt.

        # init 0

[2.] Find an available target setting.  This command will show
   what you currently have on your system.

        # probe-scsi
        
   If the disk is on another scsi controller (another card off of
   an sbus slot)     
        
        # probe-scsi-all
        
[3.] Attach the new disk with the correct target setting.  Run
probe-scsi 
     again to make sure the system sees it.  If it doesn't, the disk is
either
     not connected properly, has a target conflict, or is defective.
Resolve
     this issue before continuing.

     In this example, we'll say:
     T3 original internal drive
     T1 new/other internal drive where a duplicate copy of the OS will
be
placed.
   
[4.] Perform a reconfiguration boot.

     # boot -rv
        
     rv -> reconfigure in verbose mode.

[5.] Run format and partition the disk.

     (Here's our example):
        
     # format
       Searching for disks...done


     AVAILABLE DISK SELECTIONS:

     1. c0t1d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>
 
/iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@1,0
     2. c0t3d0 <SUN0535 cyl 1866 alt 2 hd 7 sec 80>
 
/iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@3,0
        Specify disk (enter its number): 1
        selecting c0t1d0
        [disk formatted]


        FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        quit
        format> part
        
        PARTITION MENU:
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        7      - change `7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        quit
        partition> print
        
        Current partition table (original):
        Total disk cylinders available: 2036 + 2 (reserved cylinders)

        Part      Tag    Flag     Cylinders        Size           
Blocks
        0       root    wm       0 -  203      100.41MB    (204/0/0)
205632
        1       swap    wu     204 -  407      100.41MB    (204/0/0)
205632
        2     backup    wm       0 - 2035     1002.09MB    (2036/0/0)
2052288
        3 unassigned    wm       0               0         (0/0/0) 0
        4        var    wm     408 -  611      100.41MB    (204/0/0)
205632
        5 unassigned    wm     612 - 1018      200.32MB    (407/0/0)
410256
        6        usr    wm    1019 - 2034      500.06MB    (1016/0/0)
1024128
        7 unassigned    wm       0               0         (0/0/0) 0


        partition> 
        
        ****** Modify partitions to suit your needs ******
        ****** Do NOT alter partition 2, backup !!! ******

       In this example we'll go with the current displayed partition
table
listed:

       partition> 0
      Part      Tag    Flag     Cylinders        Size            Blocks
       0 unassigned    wm       0 -  162       80.23MB    (163/0/0)  
164304
   
      Enter partition id tag[unassigned]: 
      Enter partition permission flags[wm]: 
      Enter new starting cyl[0]: o
      `o' is not an integer.
      Enter new starting cyl[0]: 0
      Enter partition size[164304b, 163c, 80.23mb, 0.08gb]: 100.41mb
      partition> pr
      Current partition table (unnamed):
      Total disk cylinders available: 2036 + 2 (reserved cylinders)

      Part      Tag    Flag     Cylinders        Size            Blocks
      0 unassigned    wm       0 -  203      100.41MB    (204/0/0)  
205632
      1 unassigned    wu     163 -  423      128.46MB    (261/0/0)  
263088
      2     backup    wu       0 - 2035     1002.09MB    (2036/0/0)
2052288
      3 unassigned    wm       0               0        
(0/0/0)          0
      4 unassigned    wm     424 -  749      160.45MB    (326/0/0)  
328608
      5 unassigned    wm     750 - 1109      177.19MB    (360/0/0)  
362880
      6 unassigned    wm    1110 - 2035      455.77MB    (926/0/0)  
933408
      7 unassigned    wm       0               0        
(0/0/0)          0

      partition> 1
      Part      Tag    Flag     Cylinders        Size            Blocks
      1 unassigned    wu     163 -  423      128.46MB    (261/0/0)  
263088

      Enter partition id tag[unassigned]: 
      Enter partition permission flags[wu]: 
      Enter new starting cyl[163]: 204
      Enter partition size[263088b, 261c, 128.46mb, 0.13gb]: 100.41mb
      partition> pr
      Current partition table (unnamed):
      Total disk cylinders available: 2036 + 2 (reserved cylinders)

      Part      Tag    Flag     Cylinders        Size            Blocks
      0 unassigned    wm       0 -  203      100.41MB    (204/0/0)  
205632
      1 unassigned    wu     204 -  407      100.41MB    (204/0/0)  
205632
      2     backup    wu       0 - 2035     1002.09MB    (2036/0/0)
2052288
      3 unassigned    wm       0               0        
(0/0/0)          0
      4 unassigned    wm     424 -  749      160.45MB    (326/0/0)  
328608
      5 unassigned    wm     750 - 1109      177.19MB    (360/0/0)  
362880
      6 unassigned    wm    1110 - 2035      455.77MB    (926/0/0)  
933408
      7 unassigned    wm       0               0        
(0/0/0)          0
   
      partition> 4
      Part      Tag    Flag     Cylinders        Size            Blocks
      4 unassigned    wm     424 -  749      160.45MB    (326/0/0)  
328608

      Enter partition id tag[unassigned]: 
      Enter partition permission flags[wm]: 
      Enter new starting cyl[424]: 408
      Enter partition size[328608b, 326c, 160.45mb, 0.16gb]: 100.41mb
      partition> pr
      Current partition table (unnamed):
      Total disk cylinders available: 2036 + 2 (reserved cylinders)

      Part      Tag    Flag     Cylinders        Size            Blocks
      0 unassigned    wm       0 -  203      100.41MB    (204/0/0)  
205632
      1 unassigned    wu     204 -  407      100.41MB    (204/0/0)  
205632
      2     backup    wu       0 - 2035     1002.09MB    (2036/0/0)
2052288
      3 unassigned    wm       0               0        
(0/0/0)          0
      4 unassigned    wm     408 -  611      100.41MB    (204/0/0)  
205632
      5 unassigned    wm     750 - 1109      177.19MB    (360/0/0)  
362880
      6 unassigned    wm    1110 - 2035      455.77MB    (926/0/0)  
933408
      7 unassigned    wm       0               0        
(0/0/0)          0

      partition> 5
      Part      Tag    Flag     Cylinders        Size            Blocks
      5 unassigned    wm     750 - 1109      177.19MB    (360/0/0)  
362880

      Enter partition id tag[unassigned]: 
      Enter partition permission flags[wm]: 
      Enter new starting cyl[750]: 612
      Enter partition size[362880b, 360c, 177.19mb, 0.17gb]: 177mb
      partition> pr
      Current partition table (unnamed):
      Total disk cylinders available: 2036 + 2 (reserved cylinders)

      Part      Tag    Flag     Cylinders        Size            Blocks
      0 unassigned    wm       0 -  203      100.41MB    (204/0/0)  
205632
      1 unassigned    wu     204 -  407      100.41MB    (204/0/0)  
205632
      2     backup    wu       0 - 2035     1002.09MB    (2036/0/0)
2052288
      3 unassigned    wm       0               0        
(0/0/0)          0
      4 unassigned    wm     408 -  611      100.41MB    (204/0/0)  
205632
      5 unassigned    wm     612 -  971      177.19MB    (360/0/0)  
362880
      6 unassigned    wm    1110 - 2035      455.77MB    (926/0/0)  
933408
      7 unassigned    wm       0               0        
(0/0/0)          0


      partition> 6
      Part      Tag    Flag     Cylinders        Size            Blocks
      6 unassigned    wm    1110 - 2035      455.77MB    (926/0/0)  
933408

      Enter partition id tag[unassigned]: 
      Enter partition permission flags[wm]: 
      Enter new starting cyl[1110]: 972
      Enter partition size[933408b, 926c, 455.77mb, 0.45gb]: $
      partition> pr
      Current partition table (unnamed):
      Total disk cylinders available: 2036 + 2 (reserved cylinders)

      Part      Tag    Flag     Cylinders        Size            Blocks
      0 unassigned    wm       0 -  203      100.41MB    (204/0/0)  
205632
      1 unassigned    wu     204 -  407      100.41MB    (204/0/0)  
205632
      2     backup    wu       0 - 2035     1002.09MB    (2036/0/0)
2052288
      3 unassigned    wm       0               0        
(0/0/0)          0
      4 unassigned    wm     408 -  611      100.41MB    (204/0/0)  
205632
      5 unassigned    wm     612 -  971      177.19MB    (360/0/0)  
362880
      6 unassigned    wm     972 - 2035      523.69MB    (1064/0/0)
1072512
      7 unassigned    wm       0               0        
(0/0/0)          0
   
      partition> 


      NOTE: You will know for certain that your partitioning is correct
if
            you add all the cylinder values [the values enclosed in (
)], 
            like so, 204+204+204+360+1064=2036 which is the same value
for
            slice 2 or the whole disk (Tag = backup).

      Now label the disk. This is important as this is what saves the
      partition table in your VTOC (Virtual Table Of Contents).
      It's also always recommended to do the labeling part twice to
      be certain that the VTOC gets saved.
         
      partition> label
      partition> q
      format> q

      After partitioning c0t1d0 to be exactly the same as c0t3d0,
      be sure you label the disk so that VTOC gtes updated with the
      correct partition table.

    
      To recap, our scenario is:
      c0t3d0 (running Solaris 2.6) being copied to c0t1d0 (which will
have
      the copied Solaris 2.6 slices/partitions)

      c0t3d0s0 /     ->  c0t1d0s0 /
      c0t3d0s4 /var  ->  c0t1d0s4 /var
      c0t3d0s5 /opt  ->  c0t1d0s5 /opt
      c0t3d0s6 /usr  ->  c0t1d0s6 /usr
     
     
[6.] For each of the partitions that you wish to mount, run newfs to
     contruct a unix filesystem.
            
     So, newfs each partition.

     # newfs -v /dev/rdsk/c0t1d0s0
     # newfs -v /dev/rdsk/c0t1d0s4
     # newfs -v /dev/rdsk/c0t1d0s5
     # newfs -v /dev/rdsk/c0t1d0s6


[7.] To ensure that they are clean and mounted properly,
     run fsck on these mounted partitions:

     # fsck /dev/rdsk/c0t1d0s0
     # fsck /dev/rdsk/c0t1d0s4
     # fsck /dev/rdsk/c0t1d0s5
     # fsck /dev/rdsk/c0t1d0s6
  
[8.] Make the mount points.
     # mkdir /mount_point

     Create mountpoints for each slice/partition, like so:
   
     # mkdir /root2
     # mkdir /var2
     # mkdir /opt2
     # mkdir /usr2

[9.] Mount the new partitions.
     # mount /dev/dsk/c0t1d0sX /mount_point

     Mount each partition (of the new disk), like so:
   
     # mount /dev/dsk/c0t1d0s0 /root2
     # mount /dev/dsk/c0t1d0s4 /var2
     # mount /dev/dsk/c0t1d0s5 /opt2
     # mount /dev/dsk/c0t1d0s6 /usr2

[10.] Now we ufsdump each slices/partitions:
      It is often difficult to copy from one disk to another disk.  
      If you try to use dd, and the disks are of differing sizes, then 
      you will undoubtedly run into trouble. Use this method to copy 
      from disk to disk and you should not have any problems.

      Of course you're still on the old disk (that's where you
      booted from c0t3d0):

      # cd /
      (Just ensures that you are in the root's parent/top directory).

      # ufsdump 0f - /dev/rdsk/c0t3d0s0 | (cd /root2; ufsrestore xf -)
      # ufsdump 0f - /dev/rdsk/c0t3d0s4 | (cd /var2;  ufsrestore xf -)
      # ufsdump 0f - /dev/rdsk/c0t3d0s5 | (cd /opt2;  ufsrestore xf -)
      # ufsdump 0f - /dev/rdsk/c0t3d0s6 | (cd /usr2;  ufsrestore xf -)

      The gotcha here is that you can't really specify the directory
name
      as ufsdump will interpret it as not being a block or character
device.
      To illustrate this error:

      # cd /usr
      # ufsdump 0f - /usr | (cd /usr2; ufsrestore xf - )


        DUMP: Writing 32 Kilobyte records
        DUMP: Date of this level 0 dump: Wed Dec 10 17:33:42 1997
        DUMP: Date of last level 0 dump: the epoch
        DUMP: Dumping /dev/rdsk/c0t3d0s0 (tmpdns:/usr) to standard
output.
        DUMP: Mapping (Pass I) [regular files]
        DUMP: Mapping (Pass II) [directories]
        DUMP: Estimated 317202 blocks (154.88MB).
        DUMP: Dumping (Pass III) [directories]
        DUMP: Broken pipe
        DUMP: The ENTIRE dump is aborted.

       However, using tar instead of ufsdump will work in this type of
       scenario:

       Example:
       
       # cd /usr
       # tar cvfp - . | (cd /usr2; tar xvfp - )

[11.] OPTIONAL (This may be redundant BUT ensures that
      the copied files are once again clean and consistent).
      Checking the integrity of a filesystem is always highly
      recommended even if it becomes redundant in nature.
        
      Now, check and run fsck on the new partition/slices:

      # fsck /dev/rdsk/c0t1d0s0
      # fsck /dev/rdsk/c0t1d0s4
      # fsck /dev/rdsk/c0t1d0s5
      # fsck /dev/rdsk/c0t1d0s6

[12.] Edit your /mount_point/etc/vfstab file to have this disk 
      bootup from the correct disk/devices c0t1d0 as opposed to c0t3d0.
   
      # cd /root2
      # vi /root2/etc/vfstab
      
      Change c0tXd0sX devices to reflect the new disk!

      #device         device                mount     FS      fsck  
mount
mount
      #to mount       to fsck               point     type    pass  at
boot
options
      #
      #/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2      /usr      ufs      1     
yes
-
      fd                 -                   /dev/fd   fd       -     
no
-
      /proc              -                   /proc     proc     -     
no
- 
      /dev/dsk/c0t1d0s1  -                   -         swap     -     
no
-
      /dev/dsk/c0t1d0s0  /dev/rdsk/c0t1d0s0  /         ufs      1     
no
-
      /dev/dsk/c0t1d0s6  /dev/rdsk/c0t1d0s6  /usr      ufs      1     
no
-
      /dev/dsk/c0t1d0s4  /dev/rdsk/c0t1d0s4  /var      ufs      1     
no
-
      /dev/dsk/c0t1d0s5  /dev/rdsk/c0t1d0s5  /opt      ufs      2     
yes
-
      swap               -                   /tmp      tmpfs    -     
yes
-
        
      :wq!


[13.] Now you must run installboot to load a new bootblk on
      that disk. Not loading a bootblk will leave this disk
      in an unbootable state as the boot strap program is
      contained within the bootblk, and this in turn is what 
      loads the boot file called ufsboot after interfacing with
      the OBP (Open Boot PROM).
    
      You can do this from your current booted disk or you
      may choose to boot off from cdrom via
      ok> boot cdrom -sw (single-user mode, writeable mode
      off of cdrom's mini-root).

      If you choose to get bootblk from your current disk:

      The location of the bootblk in Solaris 2.5 or higher is under:
      /usr/platform/`uname -i`/lib/fs/ufs/bootblk
      while in Solaris 2.4 or lower it's at:
      /usr/lib/fs/ufs/bootblk
    
      # /usr/sbin/installboot /usr/platform/`uname
-i`/lib/fs/ufs/bootblk
\       
        /dev/rdsk/c0t1d0s0
              
      If you choose to get bootblk from your cdrom image:
    
      ok> boot cdrom -sw

      # installboot
/cdrom/solaris_2_5_sparc/s0/export/exec/sparc.Solaris_2.5 \  
        /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0txd0s0

      ANOTHER SPARC EXAMPLE:

      To install a ufs bootblock on slice 0 of target  0  on  con-
      troller  1,  of the platform where the command is being run,
      use:

      example# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk 
\ 
               /dev/rdsk/c1t0d0s0


[14.] Now create an alias for the other disk (this may be existent if
      it's off of the onboard/first scsi controller).
    
      ok> probe-scsi
     
          T3  original boot disk
          T1  new disk with copied slices
        
      Verify via devalias command to see current aliases:
      disk1 is for sd@1,0 which is scsi id/target 1
     
      ok> devalias   
            
      ok> setenv boot-device disk1
      ok> boot -rv
     
      (You do not necessarily need to do a reconfiguration boot as
devices
      had already been created. This parameter will only be run if you
attached
      new devices to your system).
      
      By default this will always boot from the new disk. If you want to
boot from   
      the old disk you can manually tell it to boot to that alias, like
so:
  
      ok> boot disk 
      or 
      ok> boot disk3
    
      (This will boot off from any Target 3/scsi id 3 internal disk).
     
      Also see INFODOC #'s 14046, 11855, 11854 for setting different
      boot devalias'es.
     
      NOTE: If the new disk encounters a problem on booting, most likely
cause
            would be inappropriate devlinks so, the  course of action to
            take here is the /etc/path_to_inst, /dev, /devices fix:
          
      The following is a solution to solve problems with /dev, /devices,
and/or
      /etc/path-to_inst. This routine extracts the defaults (with links
intact)
      from the Solaris 2.x CD-ROM.

      ok> boot cdrom -sw

      # mount /dev/dsk/c0t1d0s0 /a    ** This step assumes your boot
disk is

                                         c0t1d0s0

      # cd /tmp/dev
      # tar cvfp - . | (cd /a/dev; tar xvfp - )
      # cd /tmp/devices
      # tar cvfp - . | (cd /a/devices; tar xvfp - )
      # cd /tmp/root/etc
      # cp path_to_inst /a/etc/path_to_inst
      # reboot -- -rv


[15.] If you plan to move this new disk you copied the OS on, you
      MUST ensure that it will be moved to a similar architecture
      and machine type as hardware address paths are usually
      different from one machine to another. 

      Each hardware platform has a hardware device tree which must 
      match the device tree information saved during installation in 
      /devices and the /dev directories.

      Another reason is that a kernel from one architecture cannot 
      boot on a machine of a different architecture.  Customers often 
      overlook these architecture differences (Sun 4/4c/4m/4d/4u). A 
      boot drive moved from a SPARCstation 2 (sun4c architecture) 
      cannot boot on a SPARCstation 5 (sun4m architecture).

      For more details on why you can't move Solaris 2.X boot disk
      between machines please see INFODOC 13911 and 13920.
    
      Also ensure that you have the correct hostname, IP address and
      vfstab entries for this new drive if you plan to move it to
      another machine.      

APPLIES TO: Hardware, Operating Systems/Solaris/Solaris 2.x 
ATTACHMENTS: 

-----end of summary-----


This afternoon, we spent about one hour switching the drives,
and all went very well.

Thanks to all, this list has been a great help!
Peter.


-- 
Peter Vos                  Easics NV - a TranSwitch Company
Design Support Engineer    System-on-Chip Design
Tel: +32-16-395627         Interleuvenlaan 86
Fax: +32-16-395619         B-3001 Leuven - Belgium
mailto:peterv_at_easics.be    http://www.easics.com

_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Thu Sep 13 10:33:29 2001

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:25 EST