3

I have just bought a new laptop. And I have been setting up new partitions. I generally insert a Linux liveboot OS, create partitions and then install the OS to the hard-drive.

But after the OS is installed, and I open 'Disk Utility', the warning :

The partition is misaligned by ###bytes. This may result in very poor performance. Repartitioning is suggested

appears for each selected partition in the drive. Even though I have partitioned and repartitioned the whole disk around 2-3 times, the warnings still remain.

Initially I thought it was due to some error. But the misalignment refuses to go away. The last time I partitioned, one partition ended up without any misalignment. All others are misaligned.

This is how I generally partition my drive :

    |--Part1--|--Part2--|--Part3--|----Extended Partition----|
    |---------|---------|---------|---swap---part5---part6---|

On my earlier laptop, I have used this scheme many times. But it does not work well on this new hard-drive. I have tried both Mint and Ubuntu. I am currently using Mint, whose partition is not misaligned

UPDATE 1

On running sudo fdisk -l /dev/sda this is the output :

/dev/sda1              63    80276804    40138371   83  Linux
Partition 1 does not start on physical sector boundary.
/dev/sda2        80277504   136921087    28321792   83  Linux
/dev/sda3   *   136921995   215046089    39062047+   7  HPFS/NTFS/exFAT
Partition 3 does not start on physical sector boundary.
/dev/sda4       215046151   976768064   380860957    5  Extended
Partition 4 does not start on physical sector boundary.
/dev/sda5       215046153   220909814     2931831   82  Linux swap / Solaris
Partition 5 does not start on physical sector boundary.
/dev/sda6       220909878   390829319    84959721    b  W95 FAT32
Partition 6 does not start on physical sector boundary.
/dev/sda7       390829383   976768064   292969341    b  W95 FAT32
Partition 7 does not start on physical sector boundary.

UPDATE 2

The /sys/block/sda/queue/physical_block_size says 4096.

The hard drive is a Hitachi HTS5 on my Asus X55C. So i'm guessing it is a post-2009 build.

I partitioned this drive when installing the OS using a Linux Mint Cinnamon live boot USB. On seeing the warnings, I totally partitioned the drive again with an Ubuntu 12.04 live boot USB. I had both Linux Mint and Ubuntu 12.04 for some time. Then I removed Ubuntu.

UPDATE 3 - Solution to the problem

As observed before only one partition was rightly aligned. So, I ran GParted, deleted the misaligned partitions, and created them again. Some things I noticed :

  1. If I tried creating the partition in Disk Utility, misalignment occurs. But if I created the partition in GParted, it forcefully puts in a minimum preceding 1 MiB freespace. And now there is no misalignment.
  2. I had an NTFS partition where I had installed windows. But it was misaligned by around 2000 bytes. So, I tried to move it with a 1 MiB preceding freespace. All was well, but GParted crashed when I was not watching the screen. But I was almost sure that had the process completed, the error would have been rectified.

I deleted all previous partitions, except /dev/sda2 and recreated them with GParted. This is now the output of sudo fdisk -l /dev/sda :

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    80277503    40137728   83  Linux
/dev/sda2        80277504   136921087    28321792   83  Linux
/dev/sda3       136921088   200579071    31828992   83  Linux
/dev/sda4       200579072   976773119   388097024    5  Extended
/dev/sda5       200581120   206725119     3072000   82  Linux swap / Solaris
/dev/sda6       206727168   413573119   103422976    7  HPFS/NTFS/exFAT
/dev/sda7       413575168   620421119   103422976    7  HPFS/NTFS/exFAT
/dev/sda8       620423168   976773119   178174976    7  HPFS/NTFS/exFAT

My Question

Please help me understand this problem. Since I have not yet received a complete answer, these are my questions :

  1. I have used the tools I used this time before also. Then why is the partition misaligned?
  2. Could this be due to physical problems in the hard drive?
  3. Do such problems occur with partition tools in the Ubuntu and Linux Mint live-boot installers?

It was impossible to partition the drives with Disk Utility, but worked with GParted with 1 MiB freespace preceding aligned to MiB.

  • Do you see that really for every partitions, or only for the logical ones? This difference is important. – peterh - Reinstate Monica Dec 10 '13 at 12:24
  • @PeterHorvath Yes, for both primary and logical partitions. – user21904 Dec 10 '13 at 15:52
  • Thanks. Probably your partitioning tool is buggy, or you need to set it to some disk sector alignment. Against the warning of the kernel, I don't think that it resulted really poor performance. You can test this by comparing the speed of the unpartitioned disk image to one of its partition (f.e. /dev/sda to /dev/sda2). If it is really important to you (me it were!) then I suggest to change your partitioning tool, or try to set the sector limits with sector-precision. – peterh - Reinstate Monica Dec 10 '13 at 16:03
  • @PeterHorvath I always partition with the built-in tool that you use when you are installing Ubuntu or Mint. Since I have never come across this problem before, is this some problem with the hard-drive or its controller, etc? – user21904 Dec 10 '13 at 16:11
5

Some tools produce false alarms on this issue. To verify the problem, you must use a tool that presents partition start points in sectors. For MBR disks, you can use fdisk or parted with its unit s option. For GPT disks, you can use gdisk or parted with its unit s option. For instance:

fdisk -l /dev/sda
parted /dev/sda unit s print
gdisk -l /dev/sda

You'll need to type these commands as root or use sudo. The details of the output vary a bit from one program for another, but it will look something like this:

$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 0.8.8

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): B322E151-7686-4B94-ACDF-F8F4CC2E9813
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 8-sector boundaries
Total free space is 6690 sectors (3.3 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          390625   189.7 MiB   EF00  EFI System
   2          390626          803249   201.5 MiB   8300  Gentoo /boot
   3          803256         1212850   200.0 MiB   8300  Unused
   4         1212851       976768064   465.2 GiB   8E00  Linux LVM data (nessus)
   5       976768065       976768464   200.0 KiB   EF02  BIOS boot partition

(Note that if you use fdisk and see a partition with the code ee under the Id column, you've got a GPT disk, and its output is useless. You must use parted, gdisk, or a very recent fdisk on GPT disks.)

Check the start sector values. A properly-aligned partition will have a start sector value that's a multiple of 8. In this example, partitions 1 and 3 are properly aligned, but partitions 2, 4, and 5 are not. In the case of MBR disks, ignore any "misalignment" of extended partitions; only primary and logical partitions need to be properly aligned.

Note also that 8-sector alignment is important only for Advanced Format (AF) disks. (SSDs and some types of RAID arrays have their own alignment issues. Details vary, but alignment to 2048 sectors works for most disks.) If your disk is an older non-AF disk, you needn't worry about the issue. AF was first introduced in late 2009, but even in 2010, many new disks were not AF models. Today, most new disks use AF, but I don't know offhand how many (if any) non-AF disks are being sold.

For more information, see my article on the topic.


EDIT: Most of your partitions are misaligned; only partition #2 begins on an 8-sector boundary. My hunch is that your partitions were originally laid out using an old partitioning tool -- one that used cylinder alignment rather than 1-MiB alignment.

This might or might not be important; it depends on whether the disk uses Advanced Format technology. The most reliable way to determine this is to check the technical specification sheets from the manufacturer; however, the /sys/block/sdX/queue/physical_block_size file (where sdX is the drive identifier, such as sda or sdb) may hold reliable information.

Certainly. if it reads 4096, the disk is almost certainly an Advanced Format model. If it has the value 512, you might not have an Advanced Format disk -- or the kernel might be misreporting this data. If the disk pre-dates December of 2009, it's not an Advanced Format disk.

For more on this, read my IBM developerWorks article.


EDIT 2: Please see the above-referenced article. The problem is caused by using outdated partitioning software. Recent Linux tools, including the installers for Ubuntu and Mint, should not create this problem unless you use advanced options to change the alignment policies. This problem cannot be caused by defective hardware, although you should be sure that the "Windows XP compatibility" jumper on some Western Digital drives is not set.

| improve this answer | |
  • I ran 'fdisk -l /dev/sda' and the result confirmed that all except one partition is misaligned, because of the message : Partition # does not start on a physical sector boundary. – user21904 Dec 11 '13 at 11:39
  • I installed gparted. But it gives no warnings whatsoever. It seems that the partitions are actually misaligned, but not all tools throw warnings. Like you said, @RodSmith, I will try to correct the misalignments on the primary partitions, and leave the others alone. The only thing I still don't understand is why the partitions generally tend to misalign on this hard-drive, while never before on any others I have partitioned? – user21904 Dec 11 '13 at 13:45
  • 1
    By and large, explicit warnings about misalignment are unreliable!! To verify what's going on, you must check the sector-precise alignment values manually. Be especially wary of older tools, which sometimes warn about cylinder alignment problems, which have been irrelevant for at least two decades. Using an obsolete tool that does cylinder alignment can be a reason for such problems to appear. Another can be misuse of a newer tool that doesn't enforce 2048-sector alignment. – Rod Smith Dec 11 '13 at 23:10
  • I have updated my question with the fdisk output, if it is of any help. – user21904 Dec 13 '13 at 5:50
  • Please see my edit, above. – Rod Smith Dec 13 '13 at 20:09
1

I had the same problem on Debain 7.0. Formatting with the Ubuntu 13.10 GUI tool did not help.

In the end I used fdisk, deleted the old partitions and created new ones. When selecting the starting point, I choose 2048 and the warning disappeared.

| improve this answer | |
  • The solutions are working. The only thing I haven't been able to figure out is why the problem ever occurred! – user21904 Feb 24 '14 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.