How to 4k Align Flash on Solaris x86

How to 4k Align Flash on Solaris x86

Solaris Procedure

This article will give a step by step example of how to use the fdisk system utility to ensure your flash devices have partitions that start on 4k byte boundaries.

A few notes before starting:

  • For optimal performance, the partitions on flash devices need to be aligned to start on 4k boundaries.
  • If you are running on a SPARC Solaris platform, you can skip this.
  • If you intend to run ZFS on your entire device, you can skip this procedure (assuming you have no intention of testing out the raw device capability before installing the zpool). ZFS will put its own partitioning scheme in place, and replace the default fdisk label with an EFI label that is aligned by default.
  • In the future, this will be handled automatically by Solaris (work in progress).

A bit of background: if you fdisk a new device on Solaris, it gives you a message about no Solaris partition existing, and politely asks you if you would like to use 100% of the device for the Solaris partition. In general, this is a great idea. Unfortunately, it's still keyed to the 512k sector disk drives, and if you do this on a flash device, you can end up with the partition starting on a cylinder that is not 4k aligned:

# fdisk /dev/rdsk/c0t13d0p0
             Total disk size is 2987 cylinders
             Cylinder size is 16065 (512 byte) blocks 

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1                 Solaris2          1  2986    2986    100

In the above example, we start on cylinder 1. If we do the math, we can see this is not a number that is evenly divisible by 4k:

(1 cylinder * 16065 blocks/cylinder * 512 bytes/block) / 4096 = 2008.125

The next 4k aligned value in this case would be cylinder 8; again, doing the math, we can see if we use cylinder 8, we end up with a number that is evenly divisible by 4k:

(8 cylinders * 16065 blocks/cylinder * 512 bytes/block) / 4096 = 16065

It is typically easy to locate the flash devices by using the solaris format command. The example system has a flash device with a MARVELL vendor id, and is typical of the entry you'd expect to see on an F5100 or F20 device. Here is a line excerpted from the format output:

      13. c1t115d0 <MARVELL cyl 2985 alt 2 hd 255 sec 63>
          /pci@0,0/pci10de,5d@e/pci1000,3150@0/sd@73,0
       ...

In order to run fdisk, you need to add the "p0" suffix to the
raw device:

   # fdisk /dev/rdsk/c1t115d0p0

Depending on the state of the fdisk partition, you may see that a partition is
already in place. Or, you may get a message like the following:

  # fdisk /dev/rdsk/c1t115d0p0
  No fdisk table exists. The default partition for the disk is:

  a 100% "SOLARIS System" partition

  Type "y" to accept the default partition,  otherwise type "n" to edit the
  partition table.

Most typically, we see systems come with the 100% solaris system partition in
place. This looks like the following:

  # fdisk /dev/rdsk/c1t115d0p0
             Total disk size is 2987 cylinders
             Cylinder size is 16065 (512 byte) blocks

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1       Active    Solaris2          1  2986    2986    100


  SELECT ONE OF THE FOLLOWING:
   1. Create a partition
   2. Specify the active partition
   3. Delete a partition
   4. Change between Solaris and Solaris2 Partition IDs
   5. Exit (update disk configuration and exit)
   6. Cancel (exit without updating disk configuration)
  Enter Selection: 3

Note that we start on cylinder 1, which is unaligned. We need to delete
this partition, and start on cylinder 8:

  Specify the partition number to delete (or enter 0 to exit): 1
  Are you sure you want to delete partition 1? This will make all files and
  programs in this partition inaccessible (type "y" or "n"). y

  Partition 1 has been deleted. This was the active partition.

Now it's time to create our new, aligned, partition.

   SELECT ONE OF THE FOLLOWING:
   1. Create a partition
   2. Specify the active partition
   3. Delete a partition
   4. Change between Solaris and Solaris2 Partition IDs
   5. Exit (update disk configuration and exit)
   6. Cancel (exit without updating disk configuration)
  Enter Selection: 1
  Select the partition type to create:
   1=SOLARIS2  2=UNIX        3=PCIXOS     4=Other
   5=DOS12     6=DOS16       7=DOSEXT     8=DOSBIG
   9=DOS16LBA  A=x86 Boot    B=Diagnostic C=FAT32
   D=FAT32LBA  E=DOSEXTLBA   F=EFI        0=Exit? 1
  Specify the percentage of disk to use for this partition
  (or type "c" to specify the size in cylinders). c
  Enter starting cylinder number: 8
  Enter partition size in cylinders: 2979
  Should this become the active partition? If yes, it  will be activated
  each time the computer is reset or turned on.
  Please type "y" or "n". y

Now just need to save and exit:

  SELECT ONE OF THE FOLLOWING:
   1. Create a partition
   2. Specify the active partition
   3. Delete a partition
   4. Change between Solaris and Solaris2 Partition IDs
   5. Exit (update disk configuration and exit)
   6. Cancel (exit without updating disk configuration)
  Enter Selection: 5
  #

If we rerun fdisk now, we can verify that are changes have worked:

  # fdisk /dev/rdsk/c1t115d0p0
             Total disk size is 2987 cylinders
             Total disk size is 2987 cylinders
             Total disk size is 2987 cylinders
             Cylinder size is 16065 (512 byte) blocks

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1       Active    Solaris2          8  2986    2979    100

Generally, it is easiest to do only 1 dimm manually like this, and use
the fdisk -F and fdisk -W options to script the remaining disks.

fdisk -W <filename> <devicename> creates a fdisk file from the disk table.
Use this option with the devicename that you configured manually above.

fdisk -F <filename> <devicename> uses the fdisk file <filename> to
initialize the disk table on <devicename>.

Additional Information
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact