Solaris Tips

Copying a disk VTOC using format

If you have some experience with Solaris on Sun hardware, you already know that almost all machines lack hardware RAID. Instead, you use Solstice DiskSuite, renamed in Solaris 9 to Sun Volume Manager.

As Solstice Disk Suite/Sun Volume Manager mirrors slice by slice, we need to copy the VTOC (read "partition table") from one disk to another.

This method is slower than the usual prtvtoc | fmthard method, but it is also quite quick and easier to remember.

The procedure

I assume your system disk is c0t0d0 and it will be mirrored in c0t1d0.

  1. Launch format(1M):
    # format
    Searching for disks...done
    
    
    AVAILABLE DISK SELECTIONS:
           0. c0t0d0   DISK1
              /pci@1f,4000/scsi@3/sd@0,0
           1. c0t1d0   DISK2
              /pci@1f,4000/scsi@3/sd@1,0
    Specify disk (enter its number):
    
  2. Select the origin disk:
    Specify disk (enter its number): 0
    selecting c0t0d0: DISK1
    [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
            !     - execute , then return
            quit
    format>
    
  3. Select partition:
    format> p
    
    
    
    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
            ! - execute , then return
            quit
    partition> 
    
  4. Select name:
    partition> n
    Enter table name (remember quotes): 
    
  5. Enter a name for your VTOC definition, enclosing it with quotes if it contains spaces:
    Enter table name (remember quotes): source
    
  6. Select quit to go to main menu and then disk:
    partition> q
    
    
    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
            !     - execute , then return
    
            quit
    format> di
    
    
    AVAILABLE DISK SELECTIONS:
           0. c0t0d0   DISK1
              /pci@1f,4000/scsi@3/sd@0,0
           1. c0t1d0   DISK2
              /pci@1f,4000/scsi@3/sd@1,0
    Specify disk (enter its number)[0]: 
    
  7. Select the destination disk:
    selecting c0t1d0: DISK2
    [disk formatted]
    format> 
    
  8. Select partition:
    format> p
    
    
    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
            ! - execute , then return
            quit
    partition> 
    
  9. Select... select:
    partition> s
            0. source
    Specify table (enter its number)[0]: 
    
  10. Select the VTOC definition you named previously:
    Specify table (enter its number)[0]: 0
    
    partition> 
    
  11. Select label, to write the VTOC to the disk:
    partition> label
    Ready to label disk, continue? 
    
  12. Last chance to bail out before overwriting the wrong disk's VTOC...
    Ready to label disk, continue? y
    
  13. You are done! Select quit twice to go back to the command prompt.

Well, it does not look so easy to remember, but what you really need to remember is:

  1. Run format(1M)
  2. Select the source disk
  3. Give a name to its VTOC
  4. Select the target disk
  5. Select the predefined VTOC created previously
  6. Label the disk

If you are new to Solaris and come from Linux, it would be useful to read my page about the naming of disk devices.

1