SMF vs EFI disk labels

Re-labeling a disk drive for Solaris install after a non-solaris OS was put on the disk or the disk was used for ZFS file system

It appears to be that some OSes use a different label, the same one that is used for zfs file systems, called EFI. UFS file system requires though traditional SMF label. Therefore, to install Solaris on such disk, it must be relabeled. For more info on EFI and SMF labels see http://docsun.cites.uiuc.edu/sun_docs/C/solaris_9/SUNWaadm/SYSADV1/p117.html

If you attempt to install Solaris without relabeling the disk, you will get the following error:

 awk: division by zero record number 21
 /sbin/install-solaris: test: unknown operator 25000

In debugging the above script, one can find:

 # sh -x /sbin/install-solaris

 + prtvtoc /dev/rdsk/c1t0d0s0
 + [ 0 -eq 0 ]
 + break
 + [ 0 -eq 8 ]
 + awk BEGIN { tot = 1 }
                $3 == "bytes/sector"    { bytes_p_sec = $2 }
                $3 == "sectors/track"   { sec_p_track = $2 }
                $3 == "tracks/cylinder" { track_p_cyl = $2 }
                $3 == "sectors/cylinder" { sec_p_cyl  = $2 }
                $4 == "cylinders"       { cyls        = $2 }
                # round down, just to be sure we do not over estimate
        END {
                mbytes_p_disk= ((bytes_p_sec * sec_p_track) / 1048576) *       track_p_cyl * cyls;

                # be accurate in the mbytes_p_cyl, but integerize
                # mbytes_p_disk after this
                printf("mbytes_p_cyl=%f;export  mbytes_p_cyl;",                mbytes_p_disk/cyls);
                mbytes_p_disk=int(mbytes_p_disk);
                printf("mbytes_p_disk=%d;export mbytes_p_disk;", mbytes_p_disk);
                printf("bytes_p_sec=%d;  export bytes_p_sec;",  bytes_p_sec);
                printf("track_p_cyl=%d;  export track_p_cyl;",  track_p_cyl);
                printf("sec_p_cyl=%d;    export sec_p_cyl;",    sec_p_cyl);
                printf("sec_p_track=%d;  export sec_p_track;",  sec_p_track);
                printf("cyls=%d;         export cyls",          cyls);

        } /tmp/vtoc.838
 awk: division by zero
 record number 21
 + eval
 + rm -f /tmp/vtoc.838
 SI_DISKSIZES=
 SI_TOTALDISK=
 + export SI_DISKLIST
 + export SI_DISKSIZES
 + export SI_NUMDISKS
 + export SI_TOTALDISK
 dsk_name=c1t0d0
 + echo c1t0d0
 + grep c1t0d0
 + [ 0 -ne 0 ]
 n=0
 + sed s/,/ /g
 + echo c1t0d0
 + expr 0 + 1
 n=1
 + basename c1t0d0
 + basename c1t0d0
 + [ c1t0d0 = c1t0d0 ]
 + break
 i=0
 + sed s/,/ /g
 + echo
 disk_range=25000-40000
 + expr 25000-40000 : \([0-9]*\)-[0-9]*
 t_lower=25000
 + expr 25000-40000 : [0-9]*-\([0-9]*\) 
 t_upper=40000
 + [ -ge 25000 -a -le 40000 ]
 /sbin/install-solaris: test: unknown operator 25000

Below is the procedure for relabeling the disk. Boot from a CDROM in a signle user mode, for example:

 ok boot cdrom -s

Verify that the disk indeed uses EFI label. The visual difference between two labels is that EFI do not have slice 2 that describes the entire disk and absence of cylinders.

 # prtvtoc /dev/rdsk/c1t0d0s0
 * /dev/rdsk/c1t0d0s0 partition map
 *
 * Dimensions:
 *     512 bytes/sector
 * 71132959 sectors
 * 71132892 accessible sectors
 *
 * Flags:
 *   1: unmountable
 *  10: read-only
 *
 *                          First     Sector    Last
 * Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       0      2    00         34   4096000   4096033
       1      3    01    4096034   8192000  12288033
       3      4    00   12288034   8192000  20480033
       4      4    00   20480034   8192000  28672033
       5      4    00   28672034   8192000  36864033
       6      4    00   36864034   8192000  45056033
       7      4    00   45056034  26060507  71116540
       8     11    00   71116541     16384  71132924

Run the format command, select the disk and type label:

 # format -e c1t0d0
 format> label
 [0] SMI Label
 [1] EFI Label
 Specify Label type[1]: 0
 Warning: This disk has an EFI label. Changing to SMI label will erase all
 current partitions.
 Continue? y
 Auto configuration via format.dat[no]?
 Auto configuration via generic SCSI-2[no]?
 format> verify
 Warning: Primary label on disk appears to be different from
 current label.

 Warning: Check the current partitioning and 'label' the disk or use the
         'backup' command.

 Primary label contents:

 Volume name = <        >
 ascii name  = <SUN36G  cyl 24620 alt 2 hd 27 sec 107>
 pcyl        = 24622
 ncyl        = 24620
 acyl        =    2
 nhead       =   27
 nsect       =  107
 Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm       0 -    90      128.37MB    (91/0/0)      262899
  1       swap    wu      91 -   181      128.37MB    (91/0/0)      262899
  2     backup    wu       0 - 24619       33.92GB    (24620/0/0) 71127180
  3 unassigned    wm       0                0         (0/0/0)            0
  4 unassigned    wm       0                0         (0/0/0)            0
  5 unassigned    wm       0                0         (0/0/0)            0
  6        usr    wm     182 - 24619       33.67GB    (24438/0/0) 70601382
  7 unassigned    wm       0                0         (0/0/0)            0

 format> quit