dotplan

troubleshooting & performance analysis

  • Author: gary
  • Published: Jan 7th, 2010
  • Category: sysadmin
  • Comments: 2

How to change a disk “type” in Solaris.

Tags: , , ,

Sometimes you might want to change the “type” of a disk within Solaris. The “type” of the disk is stored on the disk itself, along with the partition table (presumably in the VTOC in the first part of the disk). For the purpose of this post, I use disk “name” and “type” interchangeably.

In the past, the name of the disk would be displayed in format, something like “SUN 10G blah blah” but sometimes the disk name is just “DEFAULT” which can be annoying. It turns out that it is quite simple to change the name of the disk, IF you happen to know the correct sequence.

So, in this case, I want to change the name of disk 1, which currently has the name “DEFAULT” followed by some details of the physical layout.

Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c3d0 DEFAULT cyl 4092 alt 2 hd 128 sec 32
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c3d1 DEFAULT cyl 141 alt 2 hd 64 sec 32
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0

The first thing I am going to do is to create a file which contains the geometry of this disk. In the case of x86 accessing the disk via a BIOS, the “disk” is actually just the partition which is given over to Solaris, but in principle we think of it as “the disk”

We will use the format “save” option from within the format/disk mentu to generate the file. The file is called format.dat by default, and this will be a freshly created file, similar in syntax to /etc/format.dat, but only containing information about one disk (the one which we want to change).

Specify disk (enter its number): 1
selecting c3d1
Controller working list found
[disk formatted, defect list found]

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
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        show       - translate a disk address
        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
        volname    - set 8-character volume name
        !     - execute , then return
        quit
format> save
Saving new disk and partition definitions
Enter file name["./format.dat"]:
format> q

Next we will edit that file, and change the name to whatever it is we want to use. The original content of format.dat

gjl@vbox-sol1:/a# cat format.dat
#
# New disk/partition type  saved on Thu Jan  7 11:14:21 2010
#
disk_type = "DEFAULT" \
         : ctlr = ata : ncyl = 141 : acyl = 2 : pcyl = 143 \
         : nhead = 64 : nsect = 32 : rpm = 3600

partition = "original" \
         : disk = "DEFAULT" : ctlr = ata \
         : 2 =  0, 288768 : 8 =  0, 2048 : 9 =  1, 4096
 

and now the edited version, I have hust change the word “DEFAULT” to “SOLARIS_DATA_VDI”

gjl@vbox-sol1:/a# cat format.dat
#
# New disk/partition type  saved on Thu Jan  7 11:14:21 2010
#
disk_type = "SOLARIS_DATA_VDI" \
         : ctlr = ata : ncyl = 141 : acyl = 2 : pcyl = 143 \
         : nhead = 64 : nsect = 32 : rpm = 3600

partition = "original" \
         : disk = "SOLARIS_DATA_VDI": ctlr = ata \
         : 2 =  0, 288768 : 8 =  0, 2048 : 9 =  1, 4096

So, now I want to use this file to change the values stored on the disk, which is used by format to identify the disk. To do that I will be using the -x option to format, and point to my just edited copy of format.dat

gjl@vbox-sol1:/a# format -x ./format.dat
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c3d0 DEFAULT cyl 4092 alt 2 hd 128 sec 32
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c3d1 DEFAULT cyl 141 alt 2 hd 64 sec 32
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0

Notice that nothing has changed in the output of format…. yet. Now I will tell format that I want to change the disk type, and the disk type “SOLARIS_DATA_VDI” will now appear in the menu. It has all the same values as originally, except that I have changed the name.

First I select the disk I am going to change (disk 1)

Specify disk (enter its number): 1
selecting c3d1
Controller working list found
[disk formatted, defect list found]

Then I select “type” to change the type and my new disk type appears as a selectable option.

format> type

AVAILABLE DRIVE TYPES:
        0. SOLARIS_DATA_VDI
        1. DEFAULT
        2. DEFAULT

I select Option ’0′

Specify disk type (enter its number)[2]: 0
selecting c3d1
No current partition list
No defect list found
[disk formatted, no defect list found]

and finally I label the disk.

format> la
Ready to label disk, continue? y

format> q
gjl@vbox-sol1:/a#

Now, when I run format again, I see that the disk type/name has changed, even though I am no longer using my special “format.dat”. Which is because the name is stored on the disk itself.

gjl@vbox-sol1:/a# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c3d0 DEFAULT cyl 4092 alt 2 hd 128 sec 32
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c3d1 SOLARIS_DATA_VDI cyl 141 alt 2 hd 64 sec 32
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0

Of course, a simpler way to mark the disk would be just to add a “Volume name” to the disk. I specifically wanted to get rid of the disk type “DEFAULT” from my disk list, so changing the volume name alone was not enough. In the format output below, I create the volume name “VDISK” which appears in addition to the name “SOLARIS_DATA_VDI” which is actually the ASCII disk name/type”

format> vol
Enter 8-character volume name (remember quotes)[""]:"VDISK"
Ready to label disk, continue? y

format> di

AVAILABLE DISK SELECTIONS:
       0. c3d0 DEFAULT cyl 4092 alt 2 hd 128 sec 32
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c3d1 SOLARIS_DATA_VDI cyl 141 alt 2 hd 64 sec 32  VDISK
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0

Tags: , , ,

2 Responses to “How to change a disk “type” in Solaris.”


  1. Gagan
    on Apr 1st, 2010
    @ 1:39 am

    Thanks for this piece of information. this was great help.

    Thanks
    Gagan


  2. Darren
    on Jul 1st, 2010
    @ 7:26 am

    Very good – but how can the same be done with EFI labeled disks ?
    The ‘save’ command in format does not work when EFI labels are in force such as when the disk is used in a zpool.

    Good article though.

    Thanks,
    Darren

Leave a Reply

*

© 2009 dotplan. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.