

Code: Select all
dan@leroy ~ $ sudo fdisk -l /dev/sda
Disk /dev/sda: 64.0 GB, 64023257088 bytes
255 heads, 63 sectors/track, 7783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x941a4368
Device Boot Start End Blocks Id System
/dev/sda1 1 2612 20980858+ 83 Linux
/dev/sda2 2613 2744 1060290 82 Linux swap / Solaris
/dev/sda3 2745 7783 40475767+ 8e Linux LVM

You need to do sudo fdisk -lu /dev/sda to see sectors.erik258 wrote:Interesting. It almosts looks as if my SSD is not partitioned on a sector boundary. Since it seems to have worked for you without alignment, may I ask why it matter and what changes I might expect to see if I resized my partitions? I fantasize that it will greatly increase throughput... but in reality, I don't see how it could. Besides, I don't even know if my SSD has 4k sector sizes; maybe it only has 512 byte sectors?
fdisk follows. Thanks for your input!
Code: Select all
dan@leroy ~ $ sudo fdisk -l /dev/sda Disk /dev/sda: 64.0 GB, 64023257088 bytes 255 heads, 63 sectors/track, 7783 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x941a4368 Device Boot Start End Blocks Id System /dev/sda1 1 2612 20980858+ 83 Linux /dev/sda2 2613 2744 1060290 82 Linux swap / Solaris /dev/sda3 2745 7783 40475767+ 8e Linux LVM


Code: Select all
dan@leroy ~ $ sudo fdisk -lu /dev/sda
Disk /dev/sda: 64.0 GB, 64023257088 bytes
255 heads, 63 sectors/track, 7783 cylinders, total 125045424 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x941a4368
Device Boot Start End Blocks Id System
/dev/sda1 63 41961779 20980858+ 83 Linux
/dev/sda2 41961780 44082359 1060290 82 Linux swap / Solaris
/dev/sda3 44082360 125033894 40475767+ 8e Linux LVM
Code: Select all
dan@leroy ~ $ sudo hdparm -i /dev/sda
/dev/sda:
Model=CRUCIAL_CT64M225, FwRev=1819, SerialNo=S598947-AFBX-B269009
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=12288
BuffType=unknown, BuffSize=unknown, MaxMultSect=1, MultSect=1
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=125045424
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-5,6,7

That is a good question regarding the '+' symbols. I am not sure what they mean myself. My system lacks them:erik258 wrote:I must admit this is a little over my head. Performance tweaking isn't something I spend a lot of time doing, but hey, if I can improve hard disk performance, I may as well.
If you'd be so kind as to lend me a guiding hand, here's my fdisk -lu:Do the + symbols mean I'm not sector aligned?Code: Select all
dan@leroy ~ $ sudo fdisk -lu /dev/sda Disk /dev/sda: 64.0 GB, 64023257088 bytes 255 heads, 63 sectors/track, 7783 cylinders, total 125045424 sectors Units = sectors of 1 * 512 = 512 bytes Disk identifier: 0x941a4368 Device Boot Start End Blocks Id System /dev/sda1 63 41961779 20980858+ 83 Linux /dev/sda2 41961780 44082359 1060290 82 Linux swap / Solaris /dev/sda3 44082360 125033894 40475767+ 8e Linux LVM
I have nothing particularly special, just a mid-range SSD from around january. I bought it because I was worried my platter drive would break if I kept biking around with it in my backpack, but the speed boost is a great fringe benefit.
Not sure if it's particularly susceptible to degraded performance due to misalignment.I'd be happy to realign my partitions, if I thought it would make sense to do so. But I don't really understand how I would do such a thing. Any pointers are appreciated.Code: Select all
dan@leroy ~ $ sudo hdparm -i /dev/sda /dev/sda: Model=CRUCIAL_CT64M225, FwRev=1819, SerialNo=S598947-AFBX-B269009 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% } RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=12288 BuffType=unknown, BuffSize=unknown, MaxMultSect=1, MultSect=1 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=125045424 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4 DMA modes: mdma0 mdma1 mdma2 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 AdvancedPM=no WriteCache=enabled Drive conforms to: Unspecified: ATA/ATAPI-5,6,7
Code: Select all
$ sudo fdisk -lu /dev/sda
Disk /dev/sda: 64.0 GB, 64023257088 bytes
255 heads, 63 sectors/track, 7783 cylinders, total 125045424 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: 0x93516c21
Device Boot Start End Blocks Id System
/dev/sda1 * 1024 66559 32768 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 66560 4260863 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 4260864 125045423 60392280 83 LinuxThat is correct, but so far, I have only paid attention to partition boundaries. Do you know any specifics on how to force ext4 to align to specific boundaries?frostschutz wrote:I don't have a SSD, but a 4k sector HDD drive, that claims to be a 512b sector drive to the OS (WD15EARS). So you have alignment problems there too.
This whole alignment business is new, and unfortunately many things still align with 512 bytes (even though a 4k alignment wouldn't really hurt a 512b disk either).
So basically what you have to do is align manually. At least that's what I did with my disk.
So find out what alignment you need (depends on your device). Then go into the partitioning program of your choice (I used parted for GPT partitions) and make it use 512b sectors as units (or see if it supports your alignment - in my case it didn't as my drive is not recognized as 4k drive). Then create the partitions, which each starting sector using the correct align (in my case dividable by 8, since 8 512byte sectors = 4k). Ideally the size of the partition should also be a multiple of your alignment (in my case x*4k, i.e. x*8 512b sectors). Whether that makes a difference depends on whether your storage system stores metadata at the beginning (most filesystems do) or end (hello software raid superblock 0.9).
The alignment must also be respected by all layers you put on the drive, i.e. not only partitions, but raid (stripe size, payload offset?), lvm (payload offset?), filesystems (block size?), etc.


How do you want to partition your drive? I partitioned mine by following the Gentoo manual with two minor changes. One, I used a 2GB swap partition and two, I made certain that the partitions were properly aligned. If you want to do the same, you could just press 'u' when you open fdisk and when you make the partitions, you could specify the exact sectors that I used for my SSD, although you will likely need to let fdisk automatically choose the last sector for the root partition. Pressing 'u' will cause fdisk to ask for sector numbers when you make partitions, so you will not need to worry about how you should specify them.completemongerel wrote:i've just got an ssd. if this were any further over my head i'd be on mars. is there a concise guide anywher to deal with this? or better still \software that'll do it for me

Whew, thanks for making it sound like a math assignment. Kidding. Very well defined. Thank you. I am going to try to walk through how you got these numbers for my partitions, so others can apply these concepts for themselves. Then, hopefully soon, I'll back up my data and see what happens when I re-align.Therefore, aligned partition boundaries must be of the form [u, v], where u is a function u(x) = kx, v is a function v(y) = ky - 1, x < y, x and y are positive integers and k is 1024.
[ ... ]
/dev/sda1 = [1024, 41962495]
/dev/sda2 = [41962496, 44083199]
/dev/sda3 = [44083200, 125033471]
Code: Select all
Device Boot Start End Blocks Id System
/dev/sda1 63 41961779 20980858+ 83 Linux
/dev/sda2 41961780 44082359 1060290 82 Linux swap / Solaris
/dev/sda3 44082360 125033894 40475767+ 8e Linux LVM
Code: Select all
41961779/1024=40978
41961779%1024=307
Code: Select all
44082359%1024=183
183+1=184
Code: Select all
125045424%1024=688.
688+1=689.
125045424-689=125044735

And the drive in question (well at least its 1Tb cousin) has a jumper 'for windows XP' which cheats the drive think the first partition starts at sector 64.Shining Arcanine wrote:
By the way, dealing with your advanced format hard drive is easier than dealing with SSDs, because with your drive only have to worry about sectors while SSDs have both pages (smallest unit that can be written) and erase blocks (smallest unit that can be erased). It is my understanding that SSD pages are 4KB in size, which is 8 sectors while SSD erase blocks are 128 pages, which is 512KB in size and therefore 1024 sectors. On your advanced format drive, you just need to start your partition at sector 64 (because anything prior to sector 63 is reserved) to align your partitions. You can use k = 8 in the equations I posted above, because there is no distinction between writing and erasing on mechanical hard drives.

That works too, but that could lead to confusion down the road. I use fdisk to properly partition drives.dmpogo wrote:And the drive in question (well at least its 1Tb cousin) has a jumper 'for windows XP' which cheats the drive think the first partition starts at sector 64.Shining Arcanine wrote:
By the way, dealing with your advanced format hard drive is easier than dealing with SSDs, because with your drive only have to worry about sectors while SSDs have both pages (smallest unit that can be written) and erase blocks (smallest unit that can be erased). It is my understanding that SSD pages are 4KB in size, which is 8 sectors while SSD erase blocks are 128 pages, which is 512KB in size and therefore 1024 sectors. On your advanced format drive, you just need to start your partition at sector 64 (because anything prior to sector 63 is reserved) to align your partitions. You can use k = 8 in the equations I posted above, because there is no distinction between writing and erasing on mechanical hard drives.

sure. In few days I have to deal with this disk on my wife's Mac, which I know little aboutfrostschutz wrote:You shouldn't use this jumper for Linux... it's only for Windows XP really. It adds an offset to the drive that makes the Windows XP standard install (one partition whole drive) just happen to be 4k aligned.
In Linux (and if you're tech savvy in Windows too) you're better off aligning it directly and you can not do that anymore with the jumper because with it, you won't know what the right offset is anymore.

I am not familar with Mac OS X, but as far as I know, it is BSD with Apple's eye candy running on top of it, so the instructions in this thread should work for it.dmpogo wrote:sure. In few days I have to deal with this disk on my wife's Mac, which I know little aboutfrostschutz wrote:You shouldn't use this jumper for Linux... it's only for Windows XP really. It adds an offset to the drive that makes the Windows XP standard install (one partition whole drive) just happen to be 4k aligned.
In Linux (and if you're tech savvy in Windows too) you're better off aligning it directly and you can not do that anymore with the jumper because with it, you won't know what the right offset is anymore.I wonder if it has fdisk on its *BSD level
Code: Select all
fdisk -H 128 -S 32 /dev/sda

Code: Select all
[root@myhost lg]# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 770 MB in 3.00 seconds = 256.30 MB/sec
but...
Don't know, I tried doing that on my new install, and all partitions end sectors were 'off by one'. I.e I start say at at 1024, add + 128Mb, and my end sector will be divisible by 8, not the beginning of the next partition. So I went with -u explicit sector countdevsk wrote:Easiest way to align the partitions is to use something like:
while creating the partition table. You get cylinders of 2MB each. Every partition except for the first is aligned automatically. Since I typically create a 100MB boot partition as first partition, that gets taken care of because boot is not really performance sensitive.Code: Select all
fdisk -H 128 -S 32 /dev/sda
One thing to note, and which has not been mentioned so far, is that when you create extended partitions (lets say you want more than 4 partitions), you need to be extra careful for aligning because the first logical partition inside the extended partition will get a 16KB offset in the beginning e.g. if your extended partition is /dev/sda4 and it starts at cylinder 2034, you first logical partition /dev/sda5 will also appear to start on cylinder 2034 in 'fdisk -l /dev/sda' output but will have an offset of 16KB applied to it. That can be seen in 'fdisk -lu /dev/sda'. In this case, it is better to use -u option and create logical partitions at sector level and just skip 512KB (assuming your drive's erase block size is 512KB) instead of 16KB.
PS: Disk geometry is of no consequence in SSD world, so "-H 128 -S 32" is not insane.

After you specify the first partition manually, you can use 'c' to toggle DOS compatibility, that will disable the off by the one issue, allowing you to do +128M and actually make partitions of size +128M, rather than +128M and one extra sector.dmpogo wrote:Don't know, I tried doing that on my new install, and all partitions end sectors were 'off by one'. I.e I start say at at 1024, add + 128Mb, and my end sector will be divisible by 8, not the beginning of the next partition. So I went with -u explicit sector countdevsk wrote:Easiest way to align the partitions is to use something like:
while creating the partition table. You get cylinders of 2MB each. Every partition except for the first is aligned automatically. Since I typically create a 100MB boot partition as first partition, that gets taken care of because boot is not really performance sensitive.Code: Select all
fdisk -H 128 -S 32 /dev/sda
One thing to note, and which has not been mentioned so far, is that when you create extended partitions (lets say you want more than 4 partitions), you need to be extra careful for aligning because the first logical partition inside the extended partition will get a 16KB offset in the beginning e.g. if your extended partition is /dev/sda4 and it starts at cylinder 2034, you first logical partition /dev/sda5 will also appear to start on cylinder 2034 in 'fdisk -l /dev/sda' output but will have an offset of 16KB applied to it. That can be seen in 'fdisk -lu /dev/sda'. In this case, it is better to use -u option and create logical partitions at sector level and just skip 512KB (assuming your drive's erase block size is 512KB) instead of 16KB.
PS: Disk geometry is of no consequence in SSD world, so "-H 128 -S 32" is not insane.
Code: Select all
# gdisk -l /dev/sdh
GPT fdisk (gdisk) version 0.6.8
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/sdh: 195371568 sectors, 93.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 87FFF7CE-540E-4DF2-9EF2-6059B3855B3F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 195371534
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 4095 1024.0 KiB EF02 BIOS boot partition
2 4096 135167 64.0 MiB 0700 Linux/Windows data
3 135168 195371534 93.1 GiB 8E00 Linux LVMCode: Select all
# pvcreate /dev/sdh3 --dataalignment 512K
Physical volume "/dev/sdh3" successfully created
# pvs /dev/sdh3 -o+pe_start
PV VG Fmt Attr PSize PFree 1st PE
/dev/sdh3 lvm2 a- 93.10g 93.10g 512.00kCode: Select all
menuentry "Gentoo GNU/Linux, with Linux x86_64-2.6.34-gentoo" --class gentoo --class gnu-linux --class gnu --class os {
insmod ext2
set root='(hd8,2)'
search --no-floppy --fs-uuid --set 87b0e6f1-d00a-4fe3-b39e-6b830707672b
echo Loading Linux x86_64-2.6.34-gentoo ...
linux /kernel-genkernel-x86_64-2.6.34-gentoo root=UUID=c817e1c1-baa8-4173-90b1-19e00589f55c ro domdraid dolvm
echo Loading initial ramdisk ...
initrd /initramfs-genkernel-x86_64-2.6.34-gentoo
}
Code: Select all
cfdisk -h 128 -s 32 /dev/sd<whatever>Code: Select all
fdisk -H 128 -S 32 /dev/sd<whatever>