If you’re in a hurry, you can skip to the third chapter (“The proper method”).
As mentioned in a previous post, I wanted to find a solution using fdisk and gparted. I used the latest ones available for Ubuntu 10.04 by the beginning of August, but since we’ll be doing everything quite manually, older versions have a fair chance to work decently too. Note that I only wanted to create one big extended partitions with many logical ones inside. Also, when I’ll talk about a sector, I’ll refer to the virtual 512 bytes sectors.
I had great hope after finding what seemed to be a great tutorial on Linuxconfig.org. Pretty short and crystal clear: to make it even shorter:
- change fdisk units to sectors (once fdisk is running, type “u”)
- start the extended partition at sector 64 (the default is 63), and end it at sector (total amount of sectors on the drive – 1)
- then make partitions with a size which is a multiple of 64 sectors, leaving a space of 64 sectors between them
So I made myself a little OpenOffice spreadsheet (first sheet) to help me calculate all this, and then applied to the drive with fdisk (we’ll see the syntax in the paragraph where the partition scheme actually works). I then formatted using gparted (don’t edit the partitions, just right-click the partitions and select Format to).
Checking and correcting
I used the Paragon version of WD Align, because I started using it when I used to have a few data on the drive. I guess you won’t have data at that point, so you should rather get the Acronis version, which is way much faster, not even for fixing but also for detection/testing (I used it too, later). Anyway, I ran the thing and only one partition was properly aligned… so I made the software fix them, then analyzed the correction. If you want to details (not really explained though, that’s just some of the raw calculations I tried), check out the second sheet on the previously-mentioned OpenOffice spreadsheet.
The proper method
Here are my conclusions from the correction performed by the WD Align tool:
- The extended partition should start at sector 64 (it could probably start elsewhere too, like maybe at 2048 or 4096, but 64 is just fine according to the WD Align software, so why waste more? ) and end at sector (total amount of sectors on the drive – 1).
- The first logical partition should start at sector 4096 (I don’t know where it should start if the extended partition started somewhere else than s64).
- Logical partitions should have a size, in 512B sectors, in the form of 2048*n, where n is an integer. Since this include both the first and last sectors, this means that the last sector will be [first sector]+(2048*n)-1 (I know, the parenthesis aren’t necessary, but just in case someone wouldn’t know, it does no harm either).
- Any logical partition should start 2049 sectors after the previous one ended. Or, more accurately: [first sector of partition 2]=[last sec of P1]+2049. Which means there’s a gap of 2048 sectors between 2 partitions.
A quite noticeable consequence of those rules is that partitions will start on an even sector, and (except maybe for the extended one) end on an odd sector. Another noticeable thing is that partitions size will be best determined in mebibytes (MiB), since 1 MiB = 2^20 Bytes = 2048 sectors. So on the third and final sheet of the spreadsheet, the partition size will be measured in MiB.
Creating and formatting the partitions
Now that you figured out the proper partition sizes, you can create them with fdisk. The quick syntax guide for this would be:
- su: login as root (“super user”)
- fdisk /dev/sda: launch fdisk for drive sda. If you’re on en external drive, this will probably be sdb or more. Make sure you’re working on the right drive before messing with it! A good check could be simply to list the existing partitions (see next step)
- p: displays the partition table (very important: this includes all pending operations on the drive – fdisk won’t write anything to the disk until you “write table to disk” – see later)
- u: toggles between cylinders and sectors as the display and entry unit. You’ll want to use it to switch to sectors before doing anything else, as sectors are all what this guide is about!
- n: create a new partition, it will then ask whether you want a primary (“p”), extended (“e”) or logical (“l”) partition, then ask for starting sector then ending sector.
- w: “write table to disk and exit”: this will execute all pending operations and close fdisk. If you don’t want to apply your changes, use “q” instead.
That’s pretty much all you should need. In case you need more, you can always list the commands by using “m” (menu). Finally, here are the commands I used to create the partitions on my WD20EARS (NB: that’s only the part when I delimit the partitions, I removed the preparation and final execution):
After you’ve created the partitions (and written the changes), you can simply format them using gparted, as mentioned at the end of chapter 1. The only weird thing is that gparted will display unallocated 1MiB blocks between every partitions. Just ignore those. That’s how it will look:
And here you are, with a properly aligned drive (you can switch back to Windows and run Acronis WD Align to be sure).
After such a long time without any Dr Who trailers, I couldn’t resist the temptation in such an appropriate setting ^^