How can I set the disk partition alignment using linux tools?
Solution 1
I took this from the Netapp best practices guide for aligning partitions on iscsi volumes but it should hold true since your goal is to set the starting sector to the appropriate value. In your case, the 64 can be changed to whatever is applicable per the SQL best practices guide.
Enter expert mode in fdisk and change the starting LBA of the partition to a value that is evenly divisible by 8. In the following example, the default starting sector is 63 and we will change it to 64 because 64 is evenly divisible by 8. The default starting sector chosen by fdisk is based on the size of the LUN. fdisk uses the LUN size to calculate a pseudo geometry which can vary between different versions of fdisk.
Command (m for help): x Expert command (m for help): b Partition number (1-4): 1 New beginning of data (63-62926604, default 63): 64
Solution 2
Due to 4 KiB sector issues, most of the tools will be updated:
Related videos on Youtube
Scott Pedersen
Updated on September 17, 2022Comments
-
Scott Pedersen over 1 year
After reading Disk Partition Alignment Best Practices for SQL Server, I just want to give those advices a try, but on my linux test server. What are the required parameters in order to set the partition offset (for fdisk if possible, or any other partitioning tool available on a linux live cd)?
-
David Z almost 15 yearsMight I recommend GParted for this? It has a nice GUI and (both in my experience and from what I've heard) it's quite reliable and capable.
-
Scott Pedersen almost 15 years@David: of course, as long as you explain where can I set and check the partition offset.
-
-
Scott Pedersen almost 15 years+1 it works just fine
-
Rahim over 14 yearsI'd be interested in seeing some benchmarks that show that this makes any difference.
-
Randall Salas over 14 yearsYour mileage (and proper alignment values) will vary based on your storage's chunk size. The chunk size depends on the device. If you're directly attached to a physical HDD (ATA/SCSI/SATA/SAS) your chunk size is 512 bytes (what OSs label as a sector). If you're attaching to a RAID logical volume or a LUN, your OS probably still thinks it's being served storage in 512-byte sectors, whereas the underlying storage is actually being served in larger chunks (usually multiple Kbytes, depending on the device/solution). This means some I/O work may require more ops than if the partition was aligned.
-
Lennert almost 14 yearsI have a theory, that I haven't gotten anyone else to vet. This is a moot point if you just use no partition table and have LVM use the block device raw. Then instead of trying to nudge your start point one sector out to 64, you're just cleanly starting at zero. Am I missing something?
-
JakeRobinson about 13 yearsThis was brought up on another question I was just reading, but doesn't the block start at 0, which would make 63 divisible by 8?