0

I have a 1TB WD hard drive with Windows 10 and Devuan Linux Beowulf. I had partitioned with gparted IIRC prior to installation of both OS's. How to veerify if it is 4k aligned? If it's not so, how to adjust partitions for 4k alignment?

:~# fdisk -l -u /dev/sdb
Disk /dev/sdb: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: WDC WD10EZEX-00B
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: ~~

Device Start End Sectors Size Type /dev/sdb1 233455616 799057919 565602304 269.7G Linux filesystem /dev/sdb2 799057920 1132386303 333328384 159G Linux filesystem /dev/sdb3 1132386304 1214937087 82550784 39.4G Linux filesystem /dev/sdb4 1214937088 1302333439 87396352 41.7G Linux filesystem /dev/sdb5 1302333440 1631836159 329502720 157.1G Linux filesystem /dev/sdb6 1631836160 1734492159 102656000 49G Microsoft basic data /dev/sdb7 1734492160 1925926911 191434752 91.3G Microsoft basic data /dev/sdb8 1925926912 1925959679 32768 16M Microsoft reserved

:~# sfdisk -d /dev/sdb label: gpt label-id: ~~ device: /dev/sdb unit: sectors first-lba: 34 last-lba: 1953525134

/dev/sdb1 : start= 233455616, size= 565602304, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=5DD63D2A-3ABF-4BB3-AE6F-A1815BC17064, name="Linux filesystem" /dev/sdb2 : start= 799057920, size= 333328384, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=2DED301A-37F7-4A96-BCF4-01E4DE66E5E2, name="Linux filesystem" /dev/sdb3 : start= 1132386304, size= 82550784, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=C136ED50-3AD2-4A8A-B31E-562479C46047, name="Devuan home" /dev/sdb4 : start= 1214937088, size= 87396352, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=00F33DAC-24A9-4715-A561-CE5DC8100552, name="Devuan" /dev/sdb5 : start= 1302333440, size= 329502720, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=0026F9E4-12E8-4C56-8E06-F18842201377, name="Linux filesystem" /dev/sdb6 : start= 1631836160, size= 102656000, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=EBD4DD74-CBC0-41BC-91C0-E5C3DE1FDE07, name="Basic data partition" /dev/sdb7 : start= 1734492160, size= 191434752, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=D5BDB9D1-986A-4956-B65E-8662F2471F18 /dev/sdb8 : start= 1925926912, size= 32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=DF6D1F70-A8DB-4463-AE92-D355AC31981F, name="Microsoft reserved partition"

I intent to install FreeBSD 12.1 on to this drive, and it is a little tricky to partition for FreeBSD through bsdinstall (cui/tui). FreeBSD tool recommends 4k aligned boundaries. (gpart -a 4k ...)

2 Answers2

3

How to verify if it is 4k aligned?

Let's take /dev/sdb1 as an example. It starts at the logical sector 233455616. Your logical sectors are of the size 512 bytes. Sectors are numbered from 0, so there are exactly 233455616 logical sectors before the partition, each taking 512 bytes.

To verify the 4k-alignment you need to check if this offset can be expressed as an integer number of sectors of the size 4096 bytes. These sectors are 8 times bigger than 512-byte sectors, so it's enough to check if 233455616 is divisible by 8. It is.

Do this for every offset, i.e. every starting sector (233455616, 799057920, ...). My calculations indicate all the partitions are aligned.

FreeBSD tool recommends 4k aligned boundaries.

Your disk uses physical sectors of the size 4096 bytes. This means the 4k-alignment is advised because of the properties of the disk itself, not because of some tool.


Side note: there is about 111 GiB of unpartitioned space before /dev/sdb1.

2

The logical sector size is 512 bytes, so in order to be 4k-aligned (to match your physical sectors), the partition's starting sector must be an exact multiple of 4096⁄512 = 8.

So just go through all numbers in the "Start" column and divide each by 8. If you get a whole number, that partition is aligned; if you get decimals, it isn't. For example, 233455616 divided by 8 is 29181952.0, so the first partition is correctly aligned.

Many Linux-based partitioning tools default to 1MiB alignment, which is also good – it automatically means the partition will be aligned to 4k (and 8k, and 16k…). So if you're using Linux fdisk or GParted, just stick to the defaults.

grawity
  • 501,077