0

I have a 2TB Samsung EVO SSD that I just installed to replace on older, smaller, model. This is a shared resource for several OS installations. I have 4 partitions on the drive as not all of the partitions are used for every OS that shares the resource. I did a bonnie++ test and performance on this drive is about half of what I expect it to be.

The output of fsidk -l is,

$ sudo fdisk -l /dev/sdb Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 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 Disk label type: dos Disk identifier: 0x01033206 Device Boot Start End Blocks Id System /dev/sdb1 * 4096 511991549 255993727 7 HPFS/NTFS/exFAT /dev/sdb2 511995904 716795903 102400000 83 Linux /dev/sdb3 716800000 1740799999 512000000 83 Linux /dev/sdb4 1740804096 3907029167 1083112536 83 Linux 

I believe that this is an alignment issue but I am having trouble determining the proper start and end sectors.

Even though the physical sector size is listed as 512, I believe that it is actually 4096 under the hood. This means that the partition should start on a sector boundary that is a multiple of 4096. The first partition (sorry it's ntfs in this case) starts at sector 4096 (2MB), so that looks correct, but I'm not sure where it should end. According to the printout above, this partition covers 255993727 blocks. This value divided by 4096 is 62,498.4685059, which is not a whole number so it seems as if the end sector is not optimal.

The partition needs to be ~250GB. I have no idea how to calculate where the end sector should be. I used GParted to create the partition and you can only specify a partition size in MB. You can align to MiB, cylinders, or none, but I don't know the correct option there either. I could use fdisk to make the partition if that makes more sense.

If the first partition is not optimally aligned, the others probably are not as well. Can I fix this by just resizing partition sdb1 to end at a different sector? If so, how many MB should the partition size be?

I think if I can answer that I can figure out the rest. Please let me know if I need to post additional information.

LMHmedchem

2
  • The start and end values are counted in sectors, so to get things aligned to 4096 the size and start needs to be a multiple of 8 (4096/512). However, I think the blocks inside an SSD are fairly large, so 4096 sectors is likely better than 8. Commented Feb 27, 2020 at 5:46
  • The size of a partition does not matter, there can be space behind it to allow the next partition to be aligned. Check the start value, it's the only one that matters. Commented Feb 27, 2020 at 5:49

1 Answer 1

4

Best practice is to have partitions aligned to 1MiB boundaries. This ensures the best compatibility with sectors, blocks and other segmentation's (e.g. raid, lvm, etc.)

Basics:

1 sector = 512byte 1Kib = 1024byte or 2 sectors 1MiB = 1024 * 1KiB = 1024 *1024byte = 1048576byte or 2048 sectors 1GiB = 1024 * 1MiB = 1024 * 1024 * 1024byte = 1073741824byte or 2097152 sectors 

Since a 1MiB boundary is 1048576byte which is equal to 2048 sectors, your first partition which starts at sector 4096, is aligned to the 2MiB boundary.

If you want 250GiB in the first partition then it's size should be
250GiB = 250 * 1024MiB = 256000MiB
256000MiB * 2048 sectors/MiB =524288000sectors

The last sector of the first partition should then be
(start-sector) - 1 + (size in sectors)
4096 -1 + 524288000 =524292095

Your second partition can then start at sector 524292096 which is aligned to the 256002MiB boundary
524292096 (sectors) / 2048 (sectors per 1MiB) = 256002MiB (boundary)

If you follow this scheme then you can calculate the beginning, size and end of all following partitions.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.