Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Tried to install Ubuntu 12.04 from USB-stick alongside the existing Win7 OS 64bit, and now I'm not sure if install was completely successful: Disk Utility tool claims that the Extended partition (which contains Ubuntu partition and Swap) is "misaligned" and recommends repartition. What should I do, and if should I do this repartition, how to do it (especially if I would like not to lose the data on Win7 partition)?

Background info: A considerably new Thinkpad laptop (UEFI BIOS, if that matters). Before install there were already a "SYSTEM_DRV" partition, the main Windows partition and a Lenovo recovery partition (all NTFS). Now the table looks like this: SYSTEM_DRV (sda1), Windows (sda2), Extended (sda4) (which contains Linux (sda5; ext4) and Swap (sda6)) and Recovery (sda3). Disk Utility Tool gives a message as follows when I select Ext: "The partition is misaligned by 1024 bytes. This may result in very poor performance. Repartitioning is suggested."

There were couple of problems during the install, which I describe below, in the case they happen to be relevant.

Installer claimed that it recognized existing OS'es fine, so I checked the corresponding option during the install. Next, when it asked me how to allocate the disk space, the first weird thing happened: the installer give me a graphical "slide" allocate disk space for pre-existing Win7 OS and new Ubuntu... but it did not inform me which partition would be for Ubuntu and which for Windows. ..well, I decided to go with the setting installer proposed. (not sure if this is relevant, but I guess I'd better mention it anyway - the previous partition tools have been more self-explanatory...)

After the install (which reported no errors), GRUB/Ubuntu refused to boot. Luckily this problem was quite straightforwardly resolved with live-Ubuntu-USB and Boot-Repair ("Recommended repair" worked just fine). After all this hassle I decided to check the partition table "just to be sure"- and the disk utility gives the warning message I described.

I checked my disk specs on Hitachi/HGST website, and yes, it's Advanced Format ("Advanced Format, 512-byte emulation").

Also, fdisk gives me the following:

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     3074047     1536000    7  HPFS/NTFS/exFAT
/dev/sda2         3074048   523241959   260083956    7  HPFS/NTFS/exFAT
/dev/sda3       939907072   976771071    18432000    7  HPFS/NTFS/exFAT
/dev/sda4       523243518   939907071   208331777    5  Extended
Partition 4 does not start on physical sector boundary.
/dev/sda5       523243520   932153343   204454912   83  Linux
/dev/sda6       932155392   939907071     3875840   82  Linux swap / Solaris

Apparently sda4 (extended) partition is off by 2 bytes (sda4 starts on 523243518, sda5 523243520), but if I understood correctly, this should not be a problem, as the logical partition sda5 seems to be OK(?). In other words, there should be no need for repartitioning?

share|improve this question
add comment

3 Answers 3

There's two issues usually involved here. I think the main problem is that the physical sector size on the disk might be (say for example) 4096 bytes whereas the logical sector size is usually 512 bytes. Where the start of the partition is not at the beginning of the physical sector a discrepancy occurs with how the disk is read. This can mainly cause a performance problem on some machines with some drives. I don't believe it will actually cause any loss of data or similar problems, however I'm not a disk drive engineer.

The second issue is that Linux disk utilities and the ext file system in general seem to assume that partitions should line up with the cylinders on the hard drive. I've seen it written that if a cylinder extends past a cylinder boundary and the next partition starts in the same cylinder, data corruption could result. Sorry I've got no firm reference on this and google seems to be finding anything but information on cylinder alignment, but it had something to do with ext2/3/4 assuming that it could write to the end of a cylinder under certain circumstance.

Usually, I set up partitions with Gparted before I start the installation (gparted is on the LiveDVD) and then select how I want to use the partitions manually by selecting "do something else" when I get to that part of the installation. It's usually later that I realise that Gparted has left a few MB of unused space either at the end of the drive, or if I've set up the whole drive with Gparted, right at the end. Here's the exact example of the drive that I'm on at the moment. Note that I have two boot partitions of about 20Gb, with a the rest of the drive being an extended partition containing the swap partition and /home. Note the 2Mb of unallocated space right at the end of the extended partition. This was Gparted's doing, not mine. I've seen other disks that (for example) might have some unallocated space beteen the primary partitions or before the extended partition because the partitions were created at different times and with different programs.

Gparted screen

Since it is only a few MB, and after reading the information about the potential problems, I usually let it be. If Gparted wants to take a belt and suspenders approach I'm quite happy to let it do so.

I suggest you boot off the LiveDVD/USB again and just resize the ext4 partition Ubuntu is on with Gparted. I think you'll find that Gparted will try to align the partition with the cylinders, and this should solve the problems for you. Don't bother re-installing unless the resize breaks the Linux boot in some way.

During my google searches I did find information about Gparted aligning to full MB figures, but this is not my experience. The amount of space left is more like a cylinder's worth, rather that something that denotes MB boundaries.

share|improve this answer
add comment

Fabricator4 is correct about the physical sectors of most modern disks being 4096 bytes in size, whereas logical sectors are 512 bytes in size. This can cause severe performance problems (but not data loss); see this article I wrote on the topic some time ago for details.

Old utilities aligned partitions on "cylinders" for reasons that were valid in the 1980s but that have no bearing today. Nonetheless, the practice continued in most Linux partitioning tools until a year or two ago. No filesystem should write outside the bounds of its containing partition, though, and AFAIK ext2/3/4 never had any sort of cylinder-alignment assumptions.

Today, some disk utilities produce false alarms about alignment problems under some circumstances, and I suspect that's what you're seeing. In particular, alignment of extended partitions is irrelevant. You need only be concerned about alignment of primary and logical partitions. To be 100% sure of what you've got, view your partition table with fdisk (or parted with sector-precise data, or gdisk for GPT disks, which yours isn't). Check that all the primary and logical partitions begin on sector values that are multiples of 8. (The partition end values are irrelevant, as are the start values for extended partitions.) For instance:

$ sudo fdisk -lu /dev/sda

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x8e0cb6b5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63    20033054    10016496   27  Unknown
/dev/sda2        20033055   103699574    41833260   17  Hidden HPFS/NTFS
/dev/sda3   *   103699575   249907139    73103782+   5  Extended
/dev/sda5       103699638   131781194    14040778+  17  Hidden HPFS/NTFS
/dev/sda6       131781258   183992444    26105593+   b  W95 FAT32
/dev/sda7       183992508   187076924     1542208+  82  Linux swap / Solaris
/dev/sda8   *   187076988   187398224      160618+  83  Linux
/dev/sda9       187398288   249907139    31254426   8e  Linux LVM

This is an older disk that was partitioned with cylinder alignment, so you can see that a number of partitions do not begin on 8-sector multiples. This isn't a problem because it's an old disk that uses 512-byte physical sectors. If you see such a result, you should check with your disk's manufacturer to determine its status. Look for mention of Advanced Format, which is the marketing name for disks with 4096-byte physical sectors.

If you don't have an Advanced Format disk or if all your primary and logical partitions are properly aligned, you shouldn't worry about any complaints from Disk Utility.

share|improve this answer
add comment

This is might be due to advanced formatting, which means that the physical sectors on the disc are larger than the traditional 512 bytes, its 4 KB, which is 8 times larger. If the disc was formatted with an old formatting tools that uses 512 B sectors, which can cause the partition not to be properly aligned, and it could cause the message to show up.

Properly aligned partitions will be very slightly more optimal, and random write performance will be slower on the non-aligned partitions. But it will work.

If the system works well, you don't need to worry about it. But if you want to have it fixed, then I would suggest that yo u have a backup of your system, just in case. I would recommend the you can have that fixed, the next time you have a good excuse for reinstalling, and repartitioning the drive.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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