Partition Alignment Confusion

17,404

Assuming the figure of 1536kB (1.5MiB) is correct, you'll need to either use some manual alignment options in your partitioning software (GParted, parted, gdisk, etc.) or align on a multiple of both 1MiB (the default with most modern software) and 1.5MiB. Since 3MiB is the minimum value that satisfies both constraints, that's what you should use.

You're right that 1.5MiB is a bizarre value. It's such an odd value, in fact, that I'm a bit suspicious of it, and I'd err on the size of caution by aligning on a 3MiB boundary, or maybe even 6MiB (just in case the true value is 2MiB).

To do this, you need to understand your partitioning software's options. In GParted, you can't set alignment to an arbitrary value, just to none, cylinder, or MiB. Unfortunately, the user interface, although GUI, is a bit unclear:

GParted's partition-creation dialog box

You'd need to set the space via the "Free Space Preceding" box; but that's the free space between the new partition and the one before it, and where that one ends is unknown -- at least, not from the Create New Partition dialog box. The text-mode parted utility has similar problems.

If your disk should use GPT, I recommend that you use gdisk instead. (If you're booting in BIOS mode and want to use MBR, fdisk gives you more flexibility, but it still can't be set to use arbitrary alignment values, so you'll need to specify you partition start values manually.) You'll have a hard time installing gdisk in the Ubuntu installer, so it's easier to use System Rescue CD or Parted Magic to do the work. You can change the alignment by typing x to enter the experts' menu, using the l (or L) option to set the alignment (which you specify in sectors), and then using 'm' to return to the main menu, from which you can create partitions. It looks something like this:

$ sudo gdisk /dev/sdd
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): x

Expert command (? for help): L
Enter the sector alignment value (1-65536, default = 2048): 6144

Expert command (? for help): m

Command (? for help): n
Partition number (2-128, default 2): 
First sector (34-30297182, default = 6144) or {+-}size{KMGTP}: 
Last sector (6144-30297182, default = 30297182) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/sdd: 30297216 sectors, 14.4 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2E980CFA-8BD4-4D53-BABC-CCEFEFB6B2EF
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 30297182
Partitions will be aligned on 6144-sector boundaries
Total free space is 1566 sectors (783.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1             264            4807   2.2 MiB     EF00  EFI System
   2            6144        30297182   14.4 GiB    8300  Linux filesystem

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.

See the gdisk documentation, and particularly its walkthrough page, for more information on using this program.

Note that gdisk creates or modifies partitions, but it does not create filesystems. Thus, you'll need to either use mkfs on your partitions or let the installer create filesystems on the partitions that you create.

Share:
17,404

Related videos on Youtube

JayW
Author by

JayW

Updated on September 18, 2022

Comments

  • JayW
    JayW over 1 year

    I have a new Samsung 840 250GB SSD on the way, and I want to make sure that everything is running optimally after install.

    I've spent many frustrating hours on the internet trying to understand how I should align the partitions of the SSD when it arrives (and even how to partition everything; my other drive is a 1TB HDD with files already on it). I'd like to know a foolproof way of setting everything up.

    Now, the only place I could find the erase block size of the 840 is here:

    http://thessdreview.com/Forums/ssd-beginners-guide-discussion/3630.htm

    I simply can't understand why such information isn't made freely accessible by manufacturers! But, anyway, this would suggest the EBS is 1536kb, which seems odd to me.

    It is to my understanding that you should now align by MiB (usually set at 1MiB). I assume that the figure above should actually be 1536k B=1.5MiB? This seems to suggest the partition alignment will be somewhat non-standard.

    So my question is: How do I align my partitions given this information? Please bear in mind that I have never used linux before; I'm doing my best to get everything set up so that I can begin to learn but am finding this process incredibly opaque and time consuming. If possible, a step by step guide through GParted would be great; at the moment I'm considering an NTFS partition ~20GB for Windows (playing games), an EXT4 ~20GB for ubuntu (for doing everything else) and a shared documents+games partition for everything else in NTFS file format. I'm not going to have any swap partition and use swap files instead.

    • RoboJ1M
      RoboJ1M over 10 years
      It is 1536KB because the Samsung 840 (mainstream line) uses 3 bits per cell NAND (called TLC). It's entirely correct. @rod-smith
  • JayW
    JayW almost 11 years
    Thanks Rod, I don't think my question is a total duplicate since the EBS is such a strange value (for such a popular drive!). I'm suspicious too - given that general guides for partition alignment suggest that you should take a multiple of MiB's, Samsung would be shooting themselves in the foot if they didn't stick to this, or at least make it well known that they aren't. Then again, I can't find any other sources for the correct figure. I think I will try dropping them an email to confirm. If they do, I will try using 1.5 MiB (or 3, if you have to pick an integer) in GParted.
  • JayW
    JayW almost 11 years
    On another note, many thanks for trying to explain these issues. I find it extremely frustrating that in a question where I explicitly expressed the fact that I have as of yet no experience of linux to have my question directed to a question where I would seemingly need rather in-depth knowledge to understand the solution. And still people scratch their heads as to why many more don't join the linux community...
  • RoboJ1M
    RoboJ1M over 10 years
    It most certainly is 1536, as the 840's (non-pro) use 3 bits per cell NAND (reduce costs at the cost of lifespan, don't worry it's still >=11 years) @jayw What would also be useful is how to shunt your partition about if you only find out this information after the event! ¬.¬ I assume all you really have to do is set the partition start in gparted to 3MiB and you're done (as long as its the first partition that is). What about the 2nd/nth partitions though? If the partition length isn't a multiple of 3MiB for instance.
  • Programster
    Programster over 10 years
    Just to keep things short and simple, can someone confirm this rule of thumb I 'pulled' from here: If you're on an SSD, place a 3 in the field labeled "Free space preceding (MiB)" for each and every partition (including swap) and keep your partition sizes as multiples of 3 MiB. This includes LVG and the LVMs within.