6

When partitioning with fdisk the last few sectors cannot be included in a partition, as far as I have experienced. I always thought this is due to MiB- or IO-block-alignment, but I just realized that the last sector it allows me to use is not aligned! I tried several tools with several HDDs from different vendors, and it's always the last 30-something sectors. For example:

Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors
last MiB-aligned sector:                      976773119
last IO-block-aligned (4KiB) sector:          976773167 (the last one)
last usable sector:                           976773134

This is of course not a big problem, but I'm curious of the reason. Does it have to do with bad sectors?

  • 2
    I doubt it has to do with bad sectors - I postulate that this has to do with GPT and/or protective GPT - While the old MBR style partition uses only the beginning of the disk (last part of the first 512 bytes), GPT additionally uses the last 33 disk sectors to map partitions 5 - 128 - and it would otherwise seem quite coincidental that the last usable sector is 33 sectors less then what is available on the disk. – davidgo Apr 3 '18 at 20:30
6

I bet you created a GUID Partition Table (GPT) on the disk to get the "last usable sector" number.

Did you notice that the last usable sector is 34 sectors less than the total number of sectors?

Check this out:

GUID Partition Table Scheme (source)

Those "unusable" 33 sectors are actually for the backup GPT! (That's LBA -34 to the end.)


We can also derive why the last MiB-aligned sector and the last I/O block aligned sector are the way they are.

Note: You likely arrived at your last sector numbers without using a GPT. The legacy MS-DOS partition table only takes up 512 bytes (1 logical sector) at the beginning of the disk with nothing at the end.

Disk Information

Logical sector size:            512 (used in calculations)
Physical sector size:          4096 (used for I/O block alignment)

Physical Block Alignment

Your last aligned sector: 976773167

Physical sector size:          4096
Divide by logical sector size: ÷512
                               ----
Sectors for block alignment:      8

Total sector count:       976773168
Divide by alignment sectors:     ÷8
                          ---------
Max 4KiB blocks:          122096646
Unusable sectors remainder:       0

Total sector count:       976773168
Subtract remainder:              -0
                          ---------
First unalignable sector: 976773168
Your last aligned sector: 976773167

1MiB Block Alignment

Your last aligned sector: 976773119

1MiB in bytes:              1048576
Divide by logical sector size: ÷512
                            -------
Sectors for 1MiB alignment:    2048

Total sector count:       976773168
Divide by alignment sectors:  ÷2048
                          ---------
Max 1MiB blocks:             476940
Unusable sectors remainder:      48

Total sector count:       976773168
Subtract remainder:             -48
                          ---------
First unalignable sector: 976773120
Your last aligned sector: 976773119
| improve this answer | |
  • You are right of course, it was GPT. – Simon S Apr 4 '18 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.