System Administration Guide: Devices and File Systems

Copying File Systems Between Disks

Two commands are used to copy file systems between disks:

For more information about volcopy, see the volcopy(1M).

The next section describes how to use the dd command to copy file systems between disks.

Making a Literal File System Copy

The dd command makes a literal (block-level) copy of a complete UFS file system to another file system or to a tape. By default, the dd command copies standard input to standard output.


Note –

Do not use the dd command with variable-length tape drives without first specifying an appropriate block size.


You can specify a device name in place of standard input or standard output, or both. In this example, the contents of the diskette are copied to a file in the /tmp directory:


$ dd < /floppy/floppy0 > /tmp/output.file
2400+0 records in
2400+0 records out

The dd command reports on the number of blocks it reads and writes. The number after the + is a count of the partial blocks that were copied. The default block size is 512 bytes.

The dd command syntax is different from most other commands. Options are specified as keyword=value pairs, where keyword is the option you want to set and value is the argument for that option. For example, you can replace standard input and standard output with this syntax:


$ dd if=input-file of=output-file

To use the keyword=value pairs instead of the redirect symbols in the previous example, you would type the following:


$ dd if=/floppy/floppy0 of=/tmp/output.file

ProcedureHow to Copy a Disk (dd)

Steps
  1. Make sure that the source disk and destination disk have the same disk geometry.

  2. Become superuser or assume an equivalent role.

  3. Create the /reconfigure file so the system will recognize the destination disk to be added when it reboots.


    # touch /reconfigure
    
  4. Shut down the system.


    # init 0
    
  5. Attach the destination disk to the system.

  6. Boot the system.


    ok boot
    
  7. Copy the source disk to the destination disk.


    # dd if=/dev/rdsk/device-name of=/dev/rdsk/device-name bs=block-size
    
    if=/dev/rdsk/device-name

    Represents the overlap slice of the master disk device, usually slice 2.

    of=/dev/rdsk/device-name

    Represents the overlap slice of the destination disk device, usually slice 2.

    bs=blocksize

    Identifies block size, such as 128 Kbytes or 256 Kbytes. A large block size value decreases the time it takes to copy the disk.

    For more information, see the dd(1M)

  8. Check the new file system.


    # fsck /dev/rdsk/device-name
    
  9. Mount the destination disk's root (/) file system.


    # mount /dev/dsk/device-name /mnt
    
  10. Change to the directory where the /etc/vfstab file is located.


    # cd /mnt/etc
    
  11. Using a text editor, edit the destination disk's /etc/vfstab file to reference the correct device names.

    For example, change all instances of c0t3d0 to c0t1d0.

  12. Change to the destination disk's root (/) directory.


    # cd /
    
  13. Unmount the destination disk's root (/) file system.


    # umount /mnt
    
  14. Shut down the system.


    # init 0
    
  15. Boot from the destination disk to single-user mode.


    # boot diskn -s
    

    Note –

    The installboot command is not needed for the destination disk because the boot blocks are copied as part of the overlap slice.


  16. Unconfigure the destination disk.


    # sys-unconfig
    

    The system is shut down after it is unconfigured.

  17. Boot from the destination disk again and provide its system information, such as host name, time zone, and so forth.


    # boot diskn
    
  18. After the system is booted, log in as superuser to verify the system information.


    hostname console login:

Example 27–1 Copying a Disk (dd)

This example shows how to copy the master disk /dev/rdsk/c0t0d0s2 to the destination disk /dev/rdsk/c0t2d0s2.


# touch /reconfigure
# init 0
ok boot
# dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t2d0s2 bs=128k
# fsck /dev/rdsk/c0t2d0s2
# mount /dev/dsk/c0t2d0s2 /mnt 
# cd /mnt/etc
# vi vfstab
(Modify entries for the new disk)
# cd /
# umount /mnt
# init 0
# boot disk2 -s
# sys-unconfig
# boot disk2