# [Solved] SSD - Disk Geometry Corruption - Dual Boot Config

## jasn

I have been trying to align the partitions on my SSD for a dual boot (Gentoo/Windows 7) configuration, and I keep running into a disk geometry corruption problem. I started with Theodore Ts'o's blog post on aligning SSDs, and then I read the OCZ User Forums Linux Tweaks thread here. I figured if I simply followed Ted's suggestions to start fdisk with the -H 224 -S 56 geometry parameters, (so I can align on 128k boundaries for my Samsung based, Corsair P256 SSD), and then create all of my Linux and Windows partitions, that I would be set. I don't want to use LVM. I just want to partition the drive statically for both OSes, (like I've done in the past). So I created the following partitions;

/dev/sda1 - 32M for /boot

/dev/sda2 - 35G for my Windows 7 OS

/dev/sda3 - 55G for my Windows 7 Data

/dev/sda4 - (rest of drive for extended partition)

/dev/sda5 - 4G for my Linux swap partition

/dev/sda6 - rest of drive for my Linux root partition

Creating the partitions using fdisk works fine, and if I do a fdisk -l right after I'm done, I see the geometry reported correctly as 224 heads, and 56 sectors. I even do all of my mkfs/mkntfs/mkswap steps, from the SystemRescueCD, after partitioning, and fdisk -l still reports the geometry and partitions correctly. My problem is that when I reboot to do my directed Windows 7 install to /dev/sda2, (no partitioning and no formatting), after I reboot to the SystemRescueCD again, to begin my Gentoo install, I find that the disk geometry has been corrupted by the Windows installation. When I look at the disk again with fdisk -l, it reports that the drive geometry is now the default 255 heads and 63 sectors, and that partitions do not end on cylinder boundaries. Like this;

```
root@sysresccd /root % fdisk -l

Disk /dev/sda: 256.1 GB, 256060514304 bytes

255 heads, 63 sectors/track, 31130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0xf7c8e09a

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1               1           4       31332   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2   *           4        4574    36703744    7  HPFS/NTFS

/dev/sda3            4574       11754    57677312    7  HPFS/NTFS

Partition 3 does not end on cylinder boundary.

/dev/sda4           11754       31131   155645952    5  Extended

Partition 4 does not end on cylinder boundary.

/dev/sda5           11754       12277     4202212   82  Linux swap / Solaris

/dev/sda6           12277       31131   151443684   83  Linux
```

When I look at the drive with the original fdisk geometry parameters, it shows up as;

```
root@sysresccd /root % fdisk -H 224 -S 56 -l   

Disk /dev/sda: 256.1 GB, 256060514304 bytes

224 heads, 56 sectors/track, 39869 cylinders

Units = cylinders of 12544 * 512 = 6422528 bytes

Disk identifier: 0xf7c8e09a

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1               1           5       31332   83  Linux

/dev/sda2   *           6        5857    36703744    7  HPFS/NTFS

Partition 2 does not end on cylinder boundary.

/dev/sda3            5858       15053    57677312    7  HPFS/NTFS

/dev/sda4           15054       39869   155645952    5  Extended

/dev/sda5           15054       15723     4202212   82  Linux swap / Solaris

/dev/sda6           15724       39869   151443684   83  Linux
```

This is happening exactly the same way on two different P256 SSDs in two different laptops. So after having manually partitioned the drive under Linux with fdisk, and then simply installed Windows 7, not only is the drive not reporting the correct geometry, it now reports that one, (or several), of the partitions do not end on cylinder boundaries. This is strangely reminiscent of the 2005  bug in Fedora Core 2 that caused the hard disk geometry as reported in the partition table to be altered during Linux installation, for dual boot (Fedora/XP) systems.

I also tried doing this from Windows. I booted the Windows 7 install disc, and then created all the same partitions as above with the Windows command line disk partition tool, diskpart.exe, (which defaults to a 1024K offset for the first partition). I then installed Windows 7, and then rebooted with the SystemRescueCD to install Gentoo, and fdisk -l again showed a geometry of 255 heads, 63 sectors, (which may or may not have been correct. I don't know how to check the geometry from diskpart), but also partition 1 not ending on a cylinder boundary. I've read this Microsoft Technet forum post that suggest that some Windows 7 users having problems with formatting floppy disks, because of Windows 7 corrupting the disk geometry. I don't know if this is related to that or not. Has anyone else seen anything like this?

BTW, the only way I was able to get through an SSD partition -> installation of Windows 7 -> and then an installation of Gentoo, without fdisk reporting corrupted disk geometries, was to start all over with fdisk, and partition the SSD with the default disk geometry parameters only, fdisk /dev/sda. In other words, run fdisk without any additional drive parameters.

Thanks..Last edited by jasn on Thu Apr 22, 2010 9:12 pm; edited 1 time in total

----------

## NeddySeagoon

jasn,

Disk geometry is a myth perpertated by hard drives for the sake of backwards compatibility with operating systems like DOS and Windows before Win98. Its not actually used by modern operating systems as it cannot address drives bigger that 8G.

Having partitions ending on cylinder boundaries was never important but DOS did assume that partitions always began on head 0 so not finishing partitions on a boundary is wasted space. Fdisk still obeys that rule and gives the warning when you change the geometary.

Today, drives are accessed as a linear array of logical blocks - the drive maps the logical block number to its own idea of cylinder, head and track to write or find your data. This mapping is dynamic too - 'spinnies' relocate sectors that are getting hard to read, hopefully before they fail entirely and SSDs do something similar to implement "wear levelling".

----------

## jasn

Thank you Neddy.

I appreciate your point regarding the terminology used, both in describing the partition process, but also the terminology used by the programs themselves, and how they're not really relevant to today's technology. However, I believe what the warnings indicate, is a problem. At least in this case. I believe that the Windows 7 installer is exhibiting strange behavior. In this case causing the installer to corrupt "non-standard" partition layouts and I am curious if anyone else has seen this. The installer clearly changed my custom partition setup of 224 heads and 56 sectors back to the default 255 heads and 63 sectors, which corrupted the existing partitions.

When this happened the first time, one of the partitions that was "out of bounds" was my new Gentoo root partition, for which I was midway in the installation process. I thought to myself, I'll just ignore the fdisk warnings and proceed onward. However I quickly found out that the existing partition with my Gentoo stage 3 on it, was now corrupted. In fact I couldn't even chroot in to it, because /bin/bash had been corrupted. So I went back and tried different partition schemes, using tools under both Windows and Linux, until I realized that the only one which worked correctly, was the "regular", non-aligned, fdisk partitioning.

The only way I could set up my dual boot system correctly was to use SystemRescueCD and fdisk, to setup the partitions, and then install Windows 7 on its partition, followed by installing Gentoo on its partition and I could only do this by running fdisk without  trying to align the partitions, and simply run it with the default parameters. What I mean by setup correctly is that when I run a partition tool like fdisk now, it doesn't burp out any warnings, and more importantly, I don't have any corrupted data on any partition. If anyone has successfully aligned their SSD partitions for a dual boot Linux/Windows setup, please feel free to share your experience as well.

Thanks..

----------

## cwr

DFSee is probably worth trying here; it gives a pretty clear indication of which

partitions are set up in accordance with Windows preferences, as well as a lot

of other useful stuff.  I haven't used it with Windows 7, but I'd expect it to be

effective.

Will

----------

## jasn

In case anyone searching, finds this thread..

I was finally able to solve this issue, with information provided by the author, "Chuckula", at the blog posting here. My goal was to install both Gentoo Linux (64bit), as well as Windows 7 Pro, on a single SSD in my laptop, in a dual boot configuration, with the following partition layout;

/dev/sda1 - 32M for /boot

/dev/sda2 - 100G for my Windows 7 OS and Data

/dev/sda3 - (rest of drive for extended partition)

/dev/sda5 - 4G for my Linux swap partition

/dev/sda6 - rest of drive for my Linux root partition

Since I was upgrading my SSD, I decided to revisit this issue, and see if I could again figure out how to align the partitions correctly. So after reading the blog post, I started fdisk with;

```
fdisk -uc /dev/sda
```

and by using the "c" switch to switch off DOS-compatible mode, my first partition automatically started at sector 2048, and every subsequent starting partition offset sector number was divisible by 2048, just as mentioned in the blog post. Now the partitions are aligned correctly, and I was able to install both Windows 7 and Gentoo Linux 2.6.33 64-bit, on this single SSD, in a dual boot configuration, without issue. Now when printing out the partition map with fdisk using the "c" switch, like;

```
fdisk -ucl /dev/sda
```

it will print out the correct partition map as;

```
Disk /dev/sda: 512.1 GB, 512110190592 bytes

255 heads, 63 sectors/track, 62260 cylinders, total 1000215216 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x20139a42

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1            2048       67583       32768   83  Linux

/dev/sda2   *       67584   209782783   104857600    7  HPFS/NTFS

/dev/sda3       209782784  1000215215   395216216    5  Extended

/dev/sda5       209784832   218173439     4194304   82  Linux swap / Solaris

/dev/sda6       218175488  1000215215   391019864   83  Linux
```

If I print the partition map with fdisk without the c switch, similar cylinder boundary error messages appear, as before;

```
Disk /dev/sda: 512.1 GB, 512110190592 bytes

255 heads, 63 sectors/track, 62260 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x20139a42

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1               1           5       32768   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2   *           5       13059   104857600    7  HPFS/NTFS

/dev/sda3           13059       62261   395216216    5  Extended

Partition 3 does not end on cylinder boundary.

/dev/sda5           13059       13581     4194304   82  Linux swap / Solaris

/dev/sda6           13581       62261   391019864   83  Linux
```

I just completed the initial installation, and I can boot to Linux or Windows without issue. I also haven't had any data corruption issues, and I've verified that TRIM is working under both Windows 7 and Linux 2.6.33 with the ext4 file system. It will still take me a few days to complete the entire configuration of DE, applications and tweaks, so if any additional issues crop up, I'll make sure to follow up with the thread, but so far it looks good.

Finally, something interesting is that when I went back and tried to use the Windows utility, diskpart, to partition the drive, the first partition also started at sector 2048. I'm currently using fdisk version 2.17.2 from the SystemRescue CD 1.5.2 now, and I think that what may have been happening here was more to do with fdisk, than the Windows OS. Maybe Windows was trying to align the partitions, but corrupting thingsand getting hung up with the fact that there was no more partition/space on the drive. "Chuckula" seemed to have some suggestions for Linux devs, towards the end of the blog, along the lines of making the Linux tools for SSD partition alignment friendly, so we'll see.

BTW, I did verify that my original dual boot SSD installation used unaligned partitions, which worked fine, except I was curious what kind of performance penalty I might be incurring. So I performed some benchmark testing on both aligned and unaligned NTFS partitions, on the same SSD, under Windows 7, with the AS SSD Benchmark utility, and although the aligned partition performed better, the differences in scores between aligned and unaligned partitions, were small. Here's an example;

```
Aligned Partition

AS SSD Benchmark 1.5.3753.27631

------------------------------

Name: CORSAIR CMFSSD-256GBG2D ATA Device

Firmware: VBM19C1Q

Controller: msahci

Offset: 1024 K - OK

Size: 238.47 GB

Date: 4/21/2010 9:33:43 PM

------------------------------

Sequential:

------------------------------

Read: 222.71 MB/s

Write: 164.00 MB/s

------------------------------

4K:

------------------------------

Read: 14.76 MB/s

Write: 5.81 MB/s

------------------------------

4K-64Threads:

------------------------------

Read: 28.73 MB/s

Write: 2.98 MB/s

------------------------------

Access Times:

------------------------------

Read: 0.370 ms

Write: 0.668 ms

------------------------------

Score:

------------------------------

Read: 66

Write: 25

Total: 128

------------------------------

```

```
Unaligned Partition

AS SSD Benchmark 1.5.3753.27631

------------------------------

Name: CORSAIR CMFSSD-256GBG2D ATA Device

Firmware: VBM19C1Q

Controller: msahci

Offset: 40162 K - BAD

Size: 238.47 GB

Date: 4/21/2010 10:00:53 PM

------------------------------

Sequential:

------------------------------

Read: 205.43 MB/s

Write: 107.90 MB/s

------------------------------

4K:

------------------------------

Read: 13.48 MB/s

Write: 5.01 MB/s

------------------------------

4K-64Threads:

------------------------------

Read: 24.51 MB/s

Write: 3.45 MB/s

------------------------------

Access Times:

------------------------------

Read: 0.278 ms

Write: 0.778 ms

------------------------------

Score:

------------------------------

Read: 59

Write: 19

Total: 109

------------------------------
```

These tests were run with a completely stock Windows 7 system, and these numbers are similar to the Samsung (MLC) numbers, (which is the Corsair P256 drive OEM), posted to the AS SSD Benchmark author's site, here, (scroll towards the bottom for the Samsung results).

Good Luck..

----------

## pigeon768

 *jasn wrote:*   

> my first partition automatically started at sector 2048, and every subsequent starting partition offset sector number was divisible by 2048, just as mentioned in the blog post.

  It's 4096, not 2048.

Fortunately, your partitions are still aligned on 4096 byte boundaries.

----------

## jasn

Does the first partition not begin on sector 2048?

----------

## pigeon768

*facepalm* my bad.

You said sector - I assumed you meant byte. Yeah, if each of your partitions is aligned on a 2048 sector boundary, you're fine - not only will every partition align with your 4k read block size, but they'll align with your 128k write block size.

----------

## jasn

Thanks. I don't really understand most of the issues involved, (just a googling and regurgitating monkey so to speak), so I appreciate the attention and input.

Jason

----------

