close

Aligning Solaris x86 partitions / slices

Most physical and virtual hardware is now presenting 63 sectors per track. [eg VMware, VirtualBox].

With the advent of “Green” disks with native 4kB blocks, I am increasingly worried about alignment. For Solaris, this needs to happen at two levels – The alignment of the Solaris MBR partition, and the alignment of Solaris slices within that Solaris MBR partition.

In part one of this blog, I will demo how to get around this.

Boot Schillix, or any other Operating System installer

Log in as root, and once at the root prompt, proceed as follows.

Print out the “geometry” of the disk. Here you can see in Cylinder/Head/Sector (CHS) terms, this disk is 2088/255/63

root@unknown:~# fdisk -G c0d0p0
* Physical geometry for device /dev/rdsk/c0d0p0
* PCYL     NCYL     ACYL     BCYL     NHEAD NSECT SECSIZ
 2088     2088     0        0        255   63    512

You can show the partition table with the following command:

root@unknown:~# fdisk -W - c0d0p0 | tail -5
* Id    Act  Bhead  Bsect  Bcyl    Ehead  Esect  Ecyl    Rsect      Numsect
 0     0    0      0      0       0      0      0       0          0
 0     0    0      0      0       0      0      0       0          0
 0     0    0      0      0       0      0      0       0          0
 0     0    0      0      0       0      0      0       0          0

You can see the default “Solaris” partition (type 191 == 0xBF), and geometry that gets created. From this you can see that the first partition starts 16065 sectors in (and therefore not 4kB block aligned).

It’s interesting that this partition doesn’t start 63 sectors in (ie the first sector after the first track). By default, Solaris seems to create the first partition after the entire first cylinder.

root@unknown:~# fdisk -B c0d0p0
root@unknown:~# fdisk -W - c0d0p0 | tail -5
* Id    Act  Bhead  Bsect  Bcyl    Ehead  Esect  Ecyl    Rsect      Numsect
 191   128  0      1      1       254    63     1023    16065      33527655
 0     0    0      0      0       0      0      0       0          0
 0     0    0      0      0       0      0      0       0          0
 0     0    0      0      0       0      0      0       0          0

Ok, let’s wipe that out and start afresh:

root@unknown:~# dd if=/dev/zero count=1 of=/dev/rdsk/c0d0p0
1+0 records in
1+0 records out

Fixing it

Now let’s do things manually. Manually creating the partition 64 sectors in:
root@unknown:~# fdisk -A 191:128:0:0:0:0:0:0:64:33543720 c0d0p0

root@unknown:~# fdisk -W - c0d0p0 | tail -5
* Id    Act  Bhead  Bsect  Bcyl    Ehead  Esect  Ecyl    Rsect      Numsect
 191   128  1      2      0       254    63     1023    64         33543720
 0     0    0      0      0       0      0      0       0          0
 0     0    0      0      0       0      0      0       0          0
 0     0    0      0      0       0      0      0       0          0

So the partition is now aligned, but we also need to make sure that Solaris slices within the partition are also aligned. I think the easiest way of doing this is to lie to Solaris, and get it to change the virtual geometry from 63 sectors per track to 32 sectors per track. We will need to recalculate the number of sectors, based on the total LBA sectors of the disk. From the calculations below, you can see that the number of tracks should now be 4110, and that the new geometry will fit within the “actual” geometry. [The last thing that we want is to have Solaris try to read past the end of the disk].

root@unknown:~# echo $((2088*63/32))
4110
root@unknown:~# echo $((2088*255*63))
33543720
root@unknown:~# echo $((4110*255*32))
33537600

Ok, now we can create the Solaris VTOC table:

root@unknown:~# format c0d0p0
Failed to inquiry this logical diskselecting c0d0p0
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
 !<cmd>     - execute <cmd>, then return
 quit

format> curr
Current Disk = c0d0
< cyl 2086 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0

And here’s where we lie to Solaris, and change the sectors per track to 32:

format> type

AVAILABLE DRIVE TYPES:
 0.
 1. other
Specify disk type (enter its number)[0]: 1
Enter number of data cylinders: 4108
Enter number of alternate cylinders[2]:
Enter number of physical cylinders[4110]:
Enter number of heads: 255
Enter number of data sectors/track: 32
Enter rpm of drive[3600]:
Enter format time[default]:
Enter cylinder skew[default]:
Enter track skew[default]:
Enter tracks per zone[default]:
Enter alternate tracks[default]:
Enter alternate sectors[default]:
Enter cache control[default]:
Enter prefetch threshold[default]:
Enter minimum prefetch[default]:
Enter maximum prefetch[default]:
Enter disk type name (remember quotes): original
selecting c0d0
No current partition list
No defect list found
[disk formatted, no defect list found]
format> curr
Current Disk = c0d0
<original cyl 4108 alt 2 hd 255 sec 32> /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0

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
 !<cmd> - execute <cmd>, then return
 quit


And here’s where we create the slices. For the purposes of demonstration, we will create 3 slices : /, swap and /home:

partition> p Current partition table (original):
Total disk cylinders available: 4108 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
 0       root    wm       3 -   35      131.48MB    (33/0/0)     269280
 1       swap    wu      36 -   68      131.48MB    (33/0/0)     269280
 2     backup    wu       0 - 4109       15.99GB    (4110/0/0) 33537600
 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      69 - 4107       15.72GB    (4039/0/0) 32958240
 7 unassigned    wm       0               0         (0/0/0)           0
 8       boot    wu       0 -    0        3.98MB    (1/0/0)        8160
 9 alternates    wm       1 -    2        7.97MB    (2/0/0)       16320

partition> 0 Part      Tag    Flag     Cylinders        Size            Blocks
 0       root    wm       3 -   35      131.48MB    (33/0/0)     269280

Enter partition id tag[root]:
Enter partition permission flags[wm]:
Enter new starting cyl[3]:
Enter partition size[269280b, 33c, 35e, 131.48mb, 0.13gb]: 10g 

partition> 1
Part      Tag    Flag     Cylinders        Size            Blocks
 1       swap    wu      36 -   68      131.48MB    (33/0/0)     269280

Enter partition id tag[swap]:
Enter partition permission flags[wu]:
Enter new starting cyl[36]: 2574
Enter partition size[269280b, 33c, 2606e, 131.48mb, 0.13gb]: 2g

partition> 6
Part      Tag    Flag     Cylinders        Size            Blocks
 6        usr    wm      69 - 4107       15.72GB    (4039/0/0) 32958240

Enter partition id tag[usr]: home
Enter partition permission flags[wm]:
Enter new starting cyl[69]: 3089
Enter partition size[8315040b, 1019c, 4107e, 4060.08mb, 3.96gb]:


This is the final Solaris partition table:

partition> p Current partition table (unnamed):
Total disk cylinders available: 4108 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
 0       root    wm       3 - 2573       10.00GB    (2571/0/0) 20979360
 1       swap    wu    2574 - 3088        2.00GB    (515/0/0)   4202400
 2     backup    wu       0 - 4109       15.99GB    (4110/0/0) 33537600
 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       home    wm    3089 - 4107        3.96GB    (1019/0/0)  8315040
 7 unassigned    wm       0               0         (0/0/0)           0
 8       boot    wu       0 -    0        3.98MB    (1/0/0)        8160
 9 alternates    wm       1 -    2        7.97MB    (2/0/0)       16320 
partition> label
Ready to label disk, continue? y

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
 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
 !<cmd>     - execute <cmd>, then return
 quit
format> q

轉貼自:https://osdude.wordpress.com/2010/09/10/aligning-solaris-x86-partitions-slices/
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 小宇哥 的頭像
    小宇哥

    小宇哥的CS學習筆記

    小宇哥 發表在 痞客邦 留言(0) 人氣()