Partition Alignment Verification
[moved from Talk:Solid State Drives#Partition Alignment Verification -- Lahwaacz (talk) 20:13, 10 July 2014 (UTC)]
On my system 'blockdev --getalignoff /dev/sda5' returns zero, even though the partition seems not to be aligned optimally:
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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 Disklabel type: dos Disk identifier: 0xd9a92553 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 7 HPFS/NTFS/exFAT /dev/sda2 1026048 479475711 239224832 7 HPFS/NTFS/exFAT /dev/sda3 946051072 976771071 15360000 7 HPFS/NTFS/exFAT /dev/sda4 479475712 946051071 233287680 5 Extended /dev/sda5 479475775 518545791 19535008+ 83 Linux /dev/sda6 518545855 541984626 11719386 83 Linux /dev/sda7 541984690 557615871 7815591 82 Linux swap / Solaris /dev/sda8 557615935 946051071 194217568+ 83 Linux
The command 'parted /dev/sda align-check optimal' gives the right message in my opinion: 'not aligned'. Should we replace blockdev command?
- It seems you're right. After reading the warning about cfdisk alignment ("Warning: The first partition created by cfdisk starts at sector 63, instead of the usual 2048. This can lead to reduced performance on SSD and advanced format (4k sector) drives. It will cause problems with GRUB2, but GRUB legacy and Syslinux should work fine."), I created the first partition of the SSD I was working on with cfdisk - thus creating a bad alignment (I checked with fdisk -l /dev/sda, the first partition effectively starts at sector 63 and not 2048).
- The blockdev --getalignoff /dev/sda1 command returned zero (it shouldn't have) while your command parted /dev/sda align-check optimal returned 'not aligned', as expected.
- It seems to be a bug of blockdev in ArchLinux, as of util-linux v.2.24.
- I upgraded to util-linux v.2.25-3, and the problem is still present in blockdev. However, cfdisk has been entirely rewritten for util-linux 2.25 as described in this blog post and now correctly starts the first partition at sector 2048 when creating it.
- So should we edit the wiki page for recommanding upgrade to util-linux 2.25 in order to use cfdisk with correct partition alignment ? As util-linux integrates multiple essential softwares, I don't know if upgrading it will or not break something with the other utilities it includes.
- In any case, I think we should disrecommend using blockdev to check partition alignment, and recommend using parted instead for the time being. Can anyone else confirm this bug, especially on other distributions ? We need to know if the problem is inherent to Arch's implementation of blockdev or to blockdev itself.
However, I think the basic idea is a sound one, but perhaps more expansive. We could include suggested File systems, as well as more complex examples such as
/var and GRUB Boot partitions.
|UEFI/GPT example layout|
|Mount point||Partition||Partition type (GUID)||Bootable flag||Suggested size|
|/boot||/dev/sdx1||EFI System Partition||Yes||260–512 MiB|
|[SWAP]||/dev/sdx2||Linux swap||No||More than 512 MiB|
|/||/dev/sdx3||Linux||No||Remainder of the device|
|MBR/BIOS example layout|
|Mount point||Partition||Partition type||Bootable flag||Suggested size|
|[SWAP]||/dev/sdx1||Linux swap||No||More than 512 MiB|
|/||/dev/sdx2||Linux||Yes||Remainder of the device|
- I added these tables to the page. I also added one using a separate
/homesince I imagine that is the most common scenario. I think 3 examples could be enough, but I am open to more. -- Rdeckard (talk) 18:53, 11 October 2016 (UTC)
- Nice work. One thing I was considering is to have multiple small tables under the various partition sections (like /home), instead of a single large one. Thoughts? -- Alad (talk) 18:56, 13 October 2016 (UTC)
- edit: I noticed you already split the tables; that leaves whether it makes sense to have them under sections like Partitioning#.2Fhome rather than Partitioning#Example layouts. -- Alad (talk) 19:01, 13 October 2016 (UTC)
Regarding ,  and , I think it would be best to keep the info in one place, on this page. No idea what's wrong with the technical explanation - users should be able to understand the problem and verify that the result is OK. -- Lahwaacz (talk) 15:13, 13 October 2016 (UTC)
- I'm fine with leaving the detailed explanation. It's just odd to me to introduce a problem to the reader and in the end say that its not really a problem since the tools handle it. Also, my idea was that fdisk and parted have different ways of verifying alignment (just like different ways of creating a table, partition, etc). So if you are creating partitions with fdisk going through the fdisk page, it would be good to have how to verify alignment on that page (although it looks like fdisk has no built in way to verify it, probably because fdisk aligns things on its own, so we might have to refer to parted in the end anyway). -- Rdeckard (talk) 15:32, 13 October 2016 (UTC)