Tuesday, 14 February 2017

Warning: The resulting partition is not properly aligned for best performance.

When create a new partition on an old disk via parted I received the following warning:

mkpart pri 0 -1

Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel?

This message appears because the logical sector (4kb) does not fit directly onto the physical sector (4kb) and as a result if you needed to read the logical sector - you would have to read both physical sectors resulting in loss of performance.

A sector is the smallest unit on a disk and will vary in size from drive to drive - although most modern drives use 4kb / 4096 byte sectors now to save physical space on a hard drive - opposed to 512 byte sectors. This is because each sector has a small amount of error correction data on it - so instead of 4 x 512 byte error correction data you have x1 4096 sector with error correction data on it.

Blocks in contrast are typically made up of multiple sectors and are effectvily a way of abstracting the physical sectors.

However we can get this information from the sys filesystem:

cat /sys/block/sda/queue/hw_sector_size
512

We can then define the sector size:

parted /dev/sdb
mkpart pri 512s 100%

However this still failed!

Instead I found that using percentages instead of from X sector to Y sector does the trick and forces parted to work it out itself - for example:

parted /dev/sdb
mkpart pri xfs 0% 100%

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  10.7GB  10.7GB  primary

0 comments:

Post a Comment