Ensuring SSD alignment with parted tool

I’ll show how to partition your SSD Vertex disk keeping the desired alignment to SSD erase block size. The following links were useful to point me that align partitions increase the SSD performance and how to complete the first part of the Journey to set up my Ubuntu+MacBook Pro+Vertex SSD.

http://thunk.org/tytso/blog/2009/02/20/aligning-filesystems-to-an-ssds-erase-block-size/
http://www.ocztechnologyforum.com/forum/showthread.php?t=48309

You would ask me why don’t follow Ted’s post to make my partition table. Basically because I don’t want to use LVM. There is another important difference between our scenes: he has a Intel SSD with 128KB erase block size and I have a OCZ Vetex SSD with 512KB erase block size and of course it makes difference in the calculations.

Let’s start

$ sudo parted
(parted) unit b

The ‘unit’ command is very important because it makes the ‘print’ command show the start/end partition boundaries in bytes (and not in MB, GB or whatever).

This is my current partition table:


(parted) p
Model: ATA OCZ-VERTEX (scsi)
Disk /dev/sda: 128035676160B
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start         End            Size          File system  Name                  Flags
1      20480B        209735679B     209715200B    fat32        EFI System Partition  boot
2      209735680B    37656481791B   37446746112B  hfs+         Untitled
3      37656985600B  48393879551B   10736893952B  ext4         primary               boot
4      48393879552B  128035323903B  79641444352B  ext4         primary

Now, the very first question: How can I see that the partitions are aligned?

Good one. You just need to ensure that the boundaries can be divided by “erase block size” (EBS). In my case, the Vertex EBS is 512KB (= 512 * 1024B). Getting the 3rd partition as instance: 37656985600 / (512 * 1024) = 71825 (and no rest), so the begining of this partition is aligned.

How did I get this value?

  1. Get the end boundary of the second partition (37656481791)
  2. 37656481791 / (512 *1024) = 71824.04
  3. Get the non-decimal part +1 (71825)
  4. 71825 *512 * 1024 = 37656985600

So you have the aligned start address of your 3rd partition.

Note that to have a aligned end address, you need to choose a partition size that can be divided by 512KB as well, I’ve chosen 10736893952 (~10GB).

The end address in this case is  37656985600 + 10736893952 – 1 = 48393879551

Below you have the parted command to create the partition:

(parted) mkpart primary 37656985600 48393879551

In the same way I calculated the 4th partition boundaries (/home)

(parted) mkpart primary 48393879552 128035323903

Note that I lost some KB between the 2nd and 3rd partition and at the end of the disk. It’s normal as the second partition is not aligned (maybe MacOS is not prepared to SSD yet?).

I also marked the 3rd partition as bootable:

(parted) toogle 3 boot

And it’s done. The next post will show how to install Ubuntu Jaunty using a customised mkfs.ext4 command.

6 Comments »

  1. Gino Badouri Said,

    August 31, 2009 @ 6:51 am

    Thanks for this post! :)

    I would like to try this procedure using an Intel X25-M Postville G2 80GB.
    This drive has a erase block size of 128KB (I believe)

    I need the following setup.
    GPT label with 5 primary partitions (I believe gpt does not have the limit of 4 primary partitions).

    1. HFS+ EFI partition around 200MB (for storing the Chameleon2 bootloader and /Extra modules required for launching my hackintosh)
    This will include the bootsector (boot1h from chameleon2 see: http://forum.voodooprojects.org/index.php/topic,649.0.html)
    2. HFS+ partition around 15GB for Mac OS X SL
    3. NTFS Partition around 30GB for Windows 7
    4. ext3 partition around 200MB for my linux grub loader
    5. ext4 partition 30GB for my linux distro (fedora 11)

    Some questions:

    1. The first partition has to start at 20480 bytes to be aligned?

    2. So because my ebs is 128kb I would do “End boundary” / (128*1024) = outcome.
    (“outcome” minus the decimal part + 1) * 128 * 1024 = aligned start of the next partition, am I right?

    3. If I want to specify the size of a partition (in bytes), does it have to be dividable by 512 or 128 (ie it’s related to the ebs also) ?

    4. I’m planning on doing the partitioning with parted using the gaprted live disc. Also the formatting of the fourth and fifth partition for linux will also be done using the live disc.
    The first and second partition will be formatted as hfs+ using leopard (which I have installed on an external usb drive) by doing: “diskutil eraseVolume “HFS+” “EFI” /dev/disk0s1″
    The same goes for the second partition.
    The third partition will be formatted as NTFS using the Windows7 install disc.
    Any thoughts on this?

    Regards,

    Gino

  2. Aloisio Said,

    August 31, 2009 @ 10:30 am

    Hey I’ll try to answer your questions…

    1. Actually I just created the 2 linux partitions. I installed leopard, resized the second partition using bootcamp and then I went to linux to create my 2 partitons. So, the boundaries of first and second partitions were created by leopard itself.

    2. yes, you’re right.

    3. It must be divided always by ebd, in your case 128KB

    4. As I said in first item, I suggest you to install leopard normally and then resize your user partition using bootcamp. This method will ensure that the MacOS will work flawlessly. The rest of the process is OK, probably you won’t have problems on it.

    regards and good luck :)

  3. Dallin Said,

    November 17, 2009 @ 2:20 am

    Ok how about aling for Windows 7 on a single 128GB Vertex SSD drive?

  4. Dallin Said,

    November 17, 2009 @ 2:21 am

    Windows 7 Pro does make two partitions right. I think the first partition is alinged, Just I don’t think the main is aling correctly can you confrim for me?

  5. Aloisio Said,

    November 20, 2009 @ 5:02 pm

    Hey Dallin, since my last windows (ealier XP) I just use Linux. I have no clues for you in this case.

  6. Panos Said,

    February 17, 2010 @ 8:17 pm

    Hello. I issue this command using parted: mkpart primary 1048576 52614397952… and parted creates a partition like : Number Start End Size Type File system Flags
    1 1048576B 52614398463B 52613349888B primary ntfs
    .. so it is obvious that it does not do what i asked it to… the “end” is different. Why is that? Please note, that i am running parted from within Ubuntu 9.10 live cd.

RSS feed for comments on this post · TrackBack URI

Leave a Comment