12

I am wondering what Start and End value to choose when partitioning my ext. SSD using fdisk.

fdisk suggests 2048-250069679, default 2048 but 250069679 cannot be divided by 512 nor by 2048. Wouldn't it be better to set the Start and End value to a number that can be divided by 512 or 2048 or 4096?

For example: Start 4096 and End 250068992

Command (m for help): p

Disk /dev/sda: 119,2 GiB, 128035676160 bytes, 250069680 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: 0xa4b57300


Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-250069679, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-250069679, default 250069679): 

Created a new partition 1 of type 'Linux' and of size 119,2 GiB.


Command (m for help): p
Disk /dev/sda: 119,2 GiB, 128035676160 bytes, 250069680 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: 0xa4b57300

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 250069679 250067632 119,2G 83 Linux

Command (m for help): i
Selected partition 1
         Device: /dev/sda1
          Start: 2048
            End: 250069679
        Sectors: 250067632
      Cylinders: 15566
           Size: 119,2G
             Id: 83
           Type: Linux
    Start-C/H/S: 0/32/33
      End-C/H/S: 206/29/63


mkfs.ext4 /dev/sda1
mke2fs 1.43.4 (31-Jan-2017)
Ein Dateisystems mit 31258454 (4k) Blöcken und 7815168 Inodes wird erzeugt.
UUID des Dateisystems: fdce9286-4545-447c-9cca-7d67f5bb9f43
Superblock-Sicherungskopien gespeichert in den Blöcken: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872


fdisk -l
Disk /dev/sda: 119,2 GiB, 128035676160 bytes, 250069680 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: 0xa4b57300

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 250069679 250067632 119,2G 83 Linux

And how can it be that the Sectors number is lower than the End value?

Command (m for help): i
Selected partition 1
         Device: /dev/sda1
          Start: 2048
            End: 250069679
        Sectors: 250067632
      Cylinders: 15566
           Size: 119,2G
             Id: 83
           Type: Linux
    Start-C/H/S: 0/32/33
      End-C/H/S: 206/29/63

6
  • Sectors is End minus Start. Usually for alignment, only Start matters. Commented Apr 6, 2019 at 8:59
  • have you considered using a higher level (therefore easier to use) tool, such as gparted? Commented Apr 6, 2019 at 10:34
  • @ctrl-alt-delor normaly i use gparted, but this time i have no gui installed. Commented Apr 6, 2019 at 12:01
  • Live OS (boot off of USB, use ssh -X and run it remotely, or parted. Commented Apr 6, 2019 at 14:58
  • @ctrl-alt-delor first: it's a raspberry pi using raspbian lite without gui. second: whats the problem of understanding how to properly align third: did i use the tools fdisk and mkfs.ext4 incorrect? Commented Apr 7, 2019 at 6:37

1 Answer 1

8

Alignment doesn’t matter for the end sector, at least not for performance reasons. Alignment of the start sector affects all the sectors in the partition; alignment of the last sector only affects the last few sectors of the partition, if at all.

Sectors are numbered from 0; fdisk is suggesting the last sector on your disk (which has 250069680 sectors).

  Start: 2048
    End: 250069679
Sectors: 250067632

is correct, 250069679 minus 2048 plus one is 250067632: the partition contains 250067632 sectors, starting at offset 2048. Note that this is aligned to 4096 bytes: 250067632 is a multiple of 8 (the sectors contain 512 bytes here, and 8×512 is 4096).

Depending on how you use the partition, alignment of the end sector might be important; for example, if you’re partitioning a 512e disk (a disk which uses 4096-byte sectors internally, but exposes 512-byte logical sectors), and want to use it with cryptsetup and 4096-byte blocks to improve performance (cryptsetup luksFormat --sector-size=4096), you’ll have to ensure that the partition contains an exact multiple of 4096 bytes (not sectors).

5
  • i am wondering why the end-value is not important. do you know why perhaps? Commented Apr 6, 2019 at 12:01
  • @AlexOnLinux your choices are either to use all the sectors available or not. If you want them all and the disk has a size which is not a multiple of 512/2048/4096 then the end will not be aligned.
    – icarus
    Commented Apr 6, 2019 at 17:35
  • @icarus Having the Start and End aligned gives any performance advantages? Is it usefull to properly align the End-value when using multiple partitions? Commented Apr 7, 2019 at 6:41
  • @AlexOnLinux all partitions should have their start aligned for performance (and wear-and-tear on SSDs, although that’s less of an issue than people make it out to be). If you create partitions with GPT and no space between them, the end of each partition will be aligned, apart from the last one in some cases (as in your situation). Commented Apr 7, 2019 at 6:56
  • Miss alignment, of the start, will affect the whole partition, but of the end only affects the end and the next partition. Commented Apr 7, 2019 at 9:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .