Create partition aligned using parted

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












60















I'm partitioning a non-SSD hard disk with parted because I want a GPT partition table.



parted /dev/sda mklabel gpt


Now, I'm trying to create the partitions correctly aligned so I use the following command to know where the first sector begins:



parted /dev/sda unit s p free

Disk /dev/sda: 488397168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
34s 488397134s 488397101s Free Space


We can see that it starts in sector 34 (that's the default when this partition table is used).



So, to create the first partition I tried:



parted /dev/sda mkpart primary 63s 127s


to align it on sector 64 since it's a multiple of 8 but it shows:



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



The logical and physical sector sizes in my hard disk are both 512 bytes:



cat /sys/block/sda/queue/physical_block_size
512

cat /sys/block/sda/queue/logical_block_size
512


How do I create partitions correctly aligned? What am I doing wrong?










share|improve this question
























  • Are you sure sector numbers start at zero?

    – Burton Samograd
    May 8 '12 at 19:35






  • 1





    I tried too parted /dev/sda mkpart primary 64s 128s (in case it starts in 1) but it returns the same warning.

    – Marc
    May 8 '12 at 20:23












  • It looks like there's a command to check if a value is aligned: gnu.org/software/parted/manual/html_node/align_002dcheck.html. Maybe try that with various values using a for loop and spit out the values that are ok?

    – Burton Samograd
    May 8 '12 at 20:26











  • Burton, I didn't know about that command but it cann't be used until to have a partition.

    – Marc
    May 8 '12 at 20:34











  • Sorry about that, I didn't read the description carefully enough.

    – Burton Samograd
    May 8 '12 at 20:52















60















I'm partitioning a non-SSD hard disk with parted because I want a GPT partition table.



parted /dev/sda mklabel gpt


Now, I'm trying to create the partitions correctly aligned so I use the following command to know where the first sector begins:



parted /dev/sda unit s p free

Disk /dev/sda: 488397168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
34s 488397134s 488397101s Free Space


We can see that it starts in sector 34 (that's the default when this partition table is used).



So, to create the first partition I tried:



parted /dev/sda mkpart primary 63s 127s


to align it on sector 64 since it's a multiple of 8 but it shows:



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



The logical and physical sector sizes in my hard disk are both 512 bytes:



cat /sys/block/sda/queue/physical_block_size
512

cat /sys/block/sda/queue/logical_block_size
512


How do I create partitions correctly aligned? What am I doing wrong?










share|improve this question
























  • Are you sure sector numbers start at zero?

    – Burton Samograd
    May 8 '12 at 19:35






  • 1





    I tried too parted /dev/sda mkpart primary 64s 128s (in case it starts in 1) but it returns the same warning.

    – Marc
    May 8 '12 at 20:23












  • It looks like there's a command to check if a value is aligned: gnu.org/software/parted/manual/html_node/align_002dcheck.html. Maybe try that with various values using a for loop and spit out the values that are ok?

    – Burton Samograd
    May 8 '12 at 20:26











  • Burton, I didn't know about that command but it cann't be used until to have a partition.

    – Marc
    May 8 '12 at 20:34











  • Sorry about that, I didn't read the description carefully enough.

    – Burton Samograd
    May 8 '12 at 20:52













60












60








60


26






I'm partitioning a non-SSD hard disk with parted because I want a GPT partition table.



parted /dev/sda mklabel gpt


Now, I'm trying to create the partitions correctly aligned so I use the following command to know where the first sector begins:



parted /dev/sda unit s p free

Disk /dev/sda: 488397168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
34s 488397134s 488397101s Free Space


We can see that it starts in sector 34 (that's the default when this partition table is used).



So, to create the first partition I tried:



parted /dev/sda mkpart primary 63s 127s


to align it on sector 64 since it's a multiple of 8 but it shows:



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



The logical and physical sector sizes in my hard disk are both 512 bytes:



cat /sys/block/sda/queue/physical_block_size
512

cat /sys/block/sda/queue/logical_block_size
512


How do I create partitions correctly aligned? What am I doing wrong?










share|improve this question
















I'm partitioning a non-SSD hard disk with parted because I want a GPT partition table.



parted /dev/sda mklabel gpt


Now, I'm trying to create the partitions correctly aligned so I use the following command to know where the first sector begins:



parted /dev/sda unit s p free

Disk /dev/sda: 488397168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
34s 488397134s 488397101s Free Space


We can see that it starts in sector 34 (that's the default when this partition table is used).



So, to create the first partition I tried:



parted /dev/sda mkpart primary 63s 127s


to align it on sector 64 since it's a multiple of 8 but it shows:



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



The logical and physical sector sizes in my hard disk are both 512 bytes:



cat /sys/block/sda/queue/physical_block_size
512

cat /sys/block/sda/queue/logical_block_size
512


How do I create partitions correctly aligned? What am I doing wrong?







partition gpt






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 18 '16 at 12:06









psmears

44128




44128










asked May 8 '12 at 18:58









MarcMarc

7012915




7012915












  • Are you sure sector numbers start at zero?

    – Burton Samograd
    May 8 '12 at 19:35






  • 1





    I tried too parted /dev/sda mkpart primary 64s 128s (in case it starts in 1) but it returns the same warning.

    – Marc
    May 8 '12 at 20:23












  • It looks like there's a command to check if a value is aligned: gnu.org/software/parted/manual/html_node/align_002dcheck.html. Maybe try that with various values using a for loop and spit out the values that are ok?

    – Burton Samograd
    May 8 '12 at 20:26











  • Burton, I didn't know about that command but it cann't be used until to have a partition.

    – Marc
    May 8 '12 at 20:34











  • Sorry about that, I didn't read the description carefully enough.

    – Burton Samograd
    May 8 '12 at 20:52

















  • Are you sure sector numbers start at zero?

    – Burton Samograd
    May 8 '12 at 19:35






  • 1





    I tried too parted /dev/sda mkpart primary 64s 128s (in case it starts in 1) but it returns the same warning.

    – Marc
    May 8 '12 at 20:23












  • It looks like there's a command to check if a value is aligned: gnu.org/software/parted/manual/html_node/align_002dcheck.html. Maybe try that with various values using a for loop and spit out the values that are ok?

    – Burton Samograd
    May 8 '12 at 20:26











  • Burton, I didn't know about that command but it cann't be used until to have a partition.

    – Marc
    May 8 '12 at 20:34











  • Sorry about that, I didn't read the description carefully enough.

    – Burton Samograd
    May 8 '12 at 20:52
















Are you sure sector numbers start at zero?

– Burton Samograd
May 8 '12 at 19:35





Are you sure sector numbers start at zero?

– Burton Samograd
May 8 '12 at 19:35




1




1





I tried too parted /dev/sda mkpart primary 64s 128s (in case it starts in 1) but it returns the same warning.

– Marc
May 8 '12 at 20:23






I tried too parted /dev/sda mkpart primary 64s 128s (in case it starts in 1) but it returns the same warning.

– Marc
May 8 '12 at 20:23














It looks like there's a command to check if a value is aligned: gnu.org/software/parted/manual/html_node/align_002dcheck.html. Maybe try that with various values using a for loop and spit out the values that are ok?

– Burton Samograd
May 8 '12 at 20:26





It looks like there's a command to check if a value is aligned: gnu.org/software/parted/manual/html_node/align_002dcheck.html. Maybe try that with various values using a for loop and spit out the values that are ok?

– Burton Samograd
May 8 '12 at 20:26













Burton, I didn't know about that command but it cann't be used until to have a partition.

– Marc
May 8 '12 at 20:34





Burton, I didn't know about that command but it cann't be used until to have a partition.

– Marc
May 8 '12 at 20:34













Sorry about that, I didn't read the description carefully enough.

– Burton Samograd
May 8 '12 at 20:52





Sorry about that, I didn't read the description carefully enough.

– Burton Samograd
May 8 '12 at 20:52










5 Answers
5






active

oldest

votes


















60














In order to align partition with parted you can use --align option. Valid alignment types are:




  • none - Use the minimum alignment allowed by the disk type.


  • cylinder - Align partitions to cylinders.


  • minimal - Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.


  • optimal Use optimum alignment as given by the disk topology information. This aligns to a multiple of the physical block size in a way that guarantees optimal performance.

Other useful tip is that you can set the size with percentages to get it aligned. Start at 0% and end at 100%. For example:



parted -a optimal /dev/sda mkpart primary 0% 4096MB






share|improve this answer


















  • 4





    Should the command not end 0% 100%? Where does 4096MB come from?

    – njahnke
    Jun 8 '14 at 18:08






  • 3





    Value 4096MB is used here just an example to show ability of mixing % and specific size numbers

    – lik
    Jun 9 '14 at 6:24






  • 1





    Just a note, I had to enclose the '0%' in quotes for my shell to execute the command properly.

    – Adam Eberlin
    Jan 26 '15 at 14:48











  • @lik do you have suggestion for this post unix.stackexchange.com/questions/248939/…

    – AnkurTank
    Dec 12 '15 at 12:58






  • 1





    Nevermind the above, I just noticed the parted print uses kB as 1000 bytes...

    – jiggunjer
    Feb 1 '17 at 11:45


















8














My solution has been to use gdisk which can perform partitions alignment automatically on a 2048 sectors (1024KiB) by default, although it can be changed in the expert menu.






share|improve this answer






























    6














    From the Arch Wiki:



    When creating a partition, parted might warn about improper partition alignment but does not hint about proper alignment. For example:



    (parted) mkpart primary fat16 0 32M
    Warning: The resulting partition is not properly aligned for best performance.
    Ignore/Cancel?


    The warning means the partition start is not aligned.



    Enter Ignore to go ahead anyway, print the partition table in sectors to see where it starts, and remove/recreate the partition with the start sector rounded up to increasing powers of 2 until the warning stops. As one example, on a flash drive with 512B sectors, Parted wanted partitions to start on sectors that were a multiple of 2048, which is 1MB alignment.



    Additionally, just above this section, they state that the more precise IEC binary units of KiB, MiB, GiB, etc., are acceptable for units as well as the less precise KB, MB, GB, etc.



    Personally, my exact command that solved this was:



    mkpart hd ext4 1024KiB 8470MB


    It didn't complain, I guess it wanted 1MB alignments.






    share|improve this answer
































      5














      A minor correction. As I understand it, GPT disks don't have partition types anymore, they are all "primary". Command 'mkpart primary' doesn't create a primary partition like it does on msdos disks, it just creates a partition called primary. You can just as well use command



      (parted) mkpart Parted-FUN! 21476MB 4000787MB
      (parted) print
      Model: ATA ST4000DM000-1F21 (scsi)
      Disk /dev/sdf: 4000787MB
      Sector size (logical/physical): 512B/4096B
      Partition Table: gpt

      Number Start End Size File system Name Flags
      1 1.05MB 17181MB 17180MB ext4 raid-var
      2 17181MB 21476MB 4295MB raid-swap
      3 21476MB 4000786MB 3979310MB Parted-FUN!


      This may cause confusion if you try creating logical partitions, I know it did for me.



      (parted) mkpart extended 21476MB 4000787MB
      (parted) mkpart logical 21476MB 1000787MB
      Warning: You requested a partition from 21476MB to 1000787MB.
      The closest location we can manage is 4000786MB to 4000786MB.
      Is this still acceptable to you?
      Yes/No? Yes
      (parted) print
      Model: ATA ST4000DM000-1F21 (scsi)
      Disk /dev/sdf: 4000787MB
      Sector size (logical/physical): 512B/4096B
      Partition Table: gpt

      Number Start End Size File system Name Flags
      1 1.05MB 17181MB 17180MB ext4 raid-var
      2 17181MB 21476MB 4295MB raid-swap
      3 21476MB 4000786MB 3979310MB extended
      4 4000786MB 4000786MB 0.00MB logical


      You can't create a partition called "logical" inside a partition called "extended".






      share|improve this answer























      • thank you, I just wasted quite a bit of time thanks to this tools bad cli, and you made me figure out what's going on.

        – Florian Heigl
        Mar 16 '16 at 23:59


















      4














      The accepted answer by @lik shows how you can specify the preferred alignment. However, parted always uses that alignment for checking the resulting partition, but not always creates partitions with that alignment.



      TL;DR: When 1MiB is the optimal alignment, specifying 0% will work for disks of 200MiB and bigger. For smaller disks or larger alignment, specifying 0G could work where 0% does not. See below about why.



      Parted does try to satisfy the alignment constraints when creating a partition, but it also will not deviate from your requested values too much. What counts as "too much" depends on how you specified the postions.



      When you specify a start (or end) position to the mkpart command, it internally generates a range of acceptable values. This range is centered on the value you specify, and extends equally on both sides by half the unit size you used (that's what I read from the code, the comments say one full unit size on both ends).



      For example, when you specify "10M", it will try to use any position between 9.5M and 10.5M. The same goes for percentages, so if you specify 0% it will use any value between 0% and 0.5% (it does not go negative, obviously).



      One exception is that when using power-of-two-units (such as KiB for 1024, as opposed to K for 1000) parted assumes you're trying to specify an exact position and only considers the exact value you specified.



      Since optimal alignment typically seems to be 1MiB-aligned, the K and M units will often not have sufficient room to reach optimal alignment. Specifying positions in G should have plenty room, but % is usually also fine.



      So, this is why 0% usually works, though even that has limits.






      share|improve this answer

























      • Could you summarize a practical TLDR of your answer: what exactly should be better done in a different way as compared to the accepted answer?

        – yurkennis
        Jan 30 at 11:36











      • Good suggestion, I added a TL;DR. In practice, I think the 0% will work for all but really small disks, but my answer adds a little background on how it works exactly.

        – Matthijs Kooijman
        Jan 30 at 15:14










      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f38164%2fcreate-partition-aligned-using-parted%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      60














      In order to align partition with parted you can use --align option. Valid alignment types are:




      • none - Use the minimum alignment allowed by the disk type.


      • cylinder - Align partitions to cylinders.


      • minimal - Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.


      • optimal Use optimum alignment as given by the disk topology information. This aligns to a multiple of the physical block size in a way that guarantees optimal performance.

      Other useful tip is that you can set the size with percentages to get it aligned. Start at 0% and end at 100%. For example:



      parted -a optimal /dev/sda mkpart primary 0% 4096MB






      share|improve this answer


















      • 4





        Should the command not end 0% 100%? Where does 4096MB come from?

        – njahnke
        Jun 8 '14 at 18:08






      • 3





        Value 4096MB is used here just an example to show ability of mixing % and specific size numbers

        – lik
        Jun 9 '14 at 6:24






      • 1





        Just a note, I had to enclose the '0%' in quotes for my shell to execute the command properly.

        – Adam Eberlin
        Jan 26 '15 at 14:48











      • @lik do you have suggestion for this post unix.stackexchange.com/questions/248939/…

        – AnkurTank
        Dec 12 '15 at 12:58






      • 1





        Nevermind the above, I just noticed the parted print uses kB as 1000 bytes...

        – jiggunjer
        Feb 1 '17 at 11:45















      60














      In order to align partition with parted you can use --align option. Valid alignment types are:




      • none - Use the minimum alignment allowed by the disk type.


      • cylinder - Align partitions to cylinders.


      • minimal - Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.


      • optimal Use optimum alignment as given by the disk topology information. This aligns to a multiple of the physical block size in a way that guarantees optimal performance.

      Other useful tip is that you can set the size with percentages to get it aligned. Start at 0% and end at 100%. For example:



      parted -a optimal /dev/sda mkpart primary 0% 4096MB






      share|improve this answer


















      • 4





        Should the command not end 0% 100%? Where does 4096MB come from?

        – njahnke
        Jun 8 '14 at 18:08






      • 3





        Value 4096MB is used here just an example to show ability of mixing % and specific size numbers

        – lik
        Jun 9 '14 at 6:24






      • 1





        Just a note, I had to enclose the '0%' in quotes for my shell to execute the command properly.

        – Adam Eberlin
        Jan 26 '15 at 14:48











      • @lik do you have suggestion for this post unix.stackexchange.com/questions/248939/…

        – AnkurTank
        Dec 12 '15 at 12:58






      • 1





        Nevermind the above, I just noticed the parted print uses kB as 1000 bytes...

        – jiggunjer
        Feb 1 '17 at 11:45













      60












      60








      60







      In order to align partition with parted you can use --align option. Valid alignment types are:




      • none - Use the minimum alignment allowed by the disk type.


      • cylinder - Align partitions to cylinders.


      • minimal - Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.


      • optimal Use optimum alignment as given by the disk topology information. This aligns to a multiple of the physical block size in a way that guarantees optimal performance.

      Other useful tip is that you can set the size with percentages to get it aligned. Start at 0% and end at 100%. For example:



      parted -a optimal /dev/sda mkpart primary 0% 4096MB






      share|improve this answer













      In order to align partition with parted you can use --align option. Valid alignment types are:




      • none - Use the minimum alignment allowed by the disk type.


      • cylinder - Align partitions to cylinders.


      • minimal - Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.


      • optimal Use optimum alignment as given by the disk topology information. This aligns to a multiple of the physical block size in a way that guarantees optimal performance.

      Other useful tip is that you can set the size with percentages to get it aligned. Start at 0% and end at 100%. For example:



      parted -a optimal /dev/sda mkpart primary 0% 4096MB







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Sep 27 '12 at 8:44









      liklik

      3,6962156




      3,6962156







      • 4





        Should the command not end 0% 100%? Where does 4096MB come from?

        – njahnke
        Jun 8 '14 at 18:08






      • 3





        Value 4096MB is used here just an example to show ability of mixing % and specific size numbers

        – lik
        Jun 9 '14 at 6:24






      • 1





        Just a note, I had to enclose the '0%' in quotes for my shell to execute the command properly.

        – Adam Eberlin
        Jan 26 '15 at 14:48











      • @lik do you have suggestion for this post unix.stackexchange.com/questions/248939/…

        – AnkurTank
        Dec 12 '15 at 12:58






      • 1





        Nevermind the above, I just noticed the parted print uses kB as 1000 bytes...

        – jiggunjer
        Feb 1 '17 at 11:45












      • 4





        Should the command not end 0% 100%? Where does 4096MB come from?

        – njahnke
        Jun 8 '14 at 18:08






      • 3





        Value 4096MB is used here just an example to show ability of mixing % and specific size numbers

        – lik
        Jun 9 '14 at 6:24






      • 1





        Just a note, I had to enclose the '0%' in quotes for my shell to execute the command properly.

        – Adam Eberlin
        Jan 26 '15 at 14:48











      • @lik do you have suggestion for this post unix.stackexchange.com/questions/248939/…

        – AnkurTank
        Dec 12 '15 at 12:58






      • 1





        Nevermind the above, I just noticed the parted print uses kB as 1000 bytes...

        – jiggunjer
        Feb 1 '17 at 11:45







      4




      4





      Should the command not end 0% 100%? Where does 4096MB come from?

      – njahnke
      Jun 8 '14 at 18:08





      Should the command not end 0% 100%? Where does 4096MB come from?

      – njahnke
      Jun 8 '14 at 18:08




      3




      3





      Value 4096MB is used here just an example to show ability of mixing % and specific size numbers

      – lik
      Jun 9 '14 at 6:24





      Value 4096MB is used here just an example to show ability of mixing % and specific size numbers

      – lik
      Jun 9 '14 at 6:24




      1




      1





      Just a note, I had to enclose the '0%' in quotes for my shell to execute the command properly.

      – Adam Eberlin
      Jan 26 '15 at 14:48





      Just a note, I had to enclose the '0%' in quotes for my shell to execute the command properly.

      – Adam Eberlin
      Jan 26 '15 at 14:48













      @lik do you have suggestion for this post unix.stackexchange.com/questions/248939/…

      – AnkurTank
      Dec 12 '15 at 12:58





      @lik do you have suggestion for this post unix.stackexchange.com/questions/248939/…

      – AnkurTank
      Dec 12 '15 at 12:58




      1




      1





      Nevermind the above, I just noticed the parted print uses kB as 1000 bytes...

      – jiggunjer
      Feb 1 '17 at 11:45





      Nevermind the above, I just noticed the parted print uses kB as 1000 bytes...

      – jiggunjer
      Feb 1 '17 at 11:45













      8














      My solution has been to use gdisk which can perform partitions alignment automatically on a 2048 sectors (1024KiB) by default, although it can be changed in the expert menu.






      share|improve this answer



























        8














        My solution has been to use gdisk which can perform partitions alignment automatically on a 2048 sectors (1024KiB) by default, although it can be changed in the expert menu.






        share|improve this answer

























          8












          8








          8







          My solution has been to use gdisk which can perform partitions alignment automatically on a 2048 sectors (1024KiB) by default, although it can be changed in the expert menu.






          share|improve this answer













          My solution has been to use gdisk which can perform partitions alignment automatically on a 2048 sectors (1024KiB) by default, although it can be changed in the expert menu.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 9 '12 at 13:01









          MarcMarc

          7012915




          7012915





















              6














              From the Arch Wiki:



              When creating a partition, parted might warn about improper partition alignment but does not hint about proper alignment. For example:



              (parted) mkpart primary fat16 0 32M
              Warning: The resulting partition is not properly aligned for best performance.
              Ignore/Cancel?


              The warning means the partition start is not aligned.



              Enter Ignore to go ahead anyway, print the partition table in sectors to see where it starts, and remove/recreate the partition with the start sector rounded up to increasing powers of 2 until the warning stops. As one example, on a flash drive with 512B sectors, Parted wanted partitions to start on sectors that were a multiple of 2048, which is 1MB alignment.



              Additionally, just above this section, they state that the more precise IEC binary units of KiB, MiB, GiB, etc., are acceptable for units as well as the less precise KB, MB, GB, etc.



              Personally, my exact command that solved this was:



              mkpart hd ext4 1024KiB 8470MB


              It didn't complain, I guess it wanted 1MB alignments.






              share|improve this answer





























                6














                From the Arch Wiki:



                When creating a partition, parted might warn about improper partition alignment but does not hint about proper alignment. For example:



                (parted) mkpart primary fat16 0 32M
                Warning: The resulting partition is not properly aligned for best performance.
                Ignore/Cancel?


                The warning means the partition start is not aligned.



                Enter Ignore to go ahead anyway, print the partition table in sectors to see where it starts, and remove/recreate the partition with the start sector rounded up to increasing powers of 2 until the warning stops. As one example, on a flash drive with 512B sectors, Parted wanted partitions to start on sectors that were a multiple of 2048, which is 1MB alignment.



                Additionally, just above this section, they state that the more precise IEC binary units of KiB, MiB, GiB, etc., are acceptable for units as well as the less precise KB, MB, GB, etc.



                Personally, my exact command that solved this was:



                mkpart hd ext4 1024KiB 8470MB


                It didn't complain, I guess it wanted 1MB alignments.






                share|improve this answer



























                  6












                  6








                  6







                  From the Arch Wiki:



                  When creating a partition, parted might warn about improper partition alignment but does not hint about proper alignment. For example:



                  (parted) mkpart primary fat16 0 32M
                  Warning: The resulting partition is not properly aligned for best performance.
                  Ignore/Cancel?


                  The warning means the partition start is not aligned.



                  Enter Ignore to go ahead anyway, print the partition table in sectors to see where it starts, and remove/recreate the partition with the start sector rounded up to increasing powers of 2 until the warning stops. As one example, on a flash drive with 512B sectors, Parted wanted partitions to start on sectors that were a multiple of 2048, which is 1MB alignment.



                  Additionally, just above this section, they state that the more precise IEC binary units of KiB, MiB, GiB, etc., are acceptable for units as well as the less precise KB, MB, GB, etc.



                  Personally, my exact command that solved this was:



                  mkpart hd ext4 1024KiB 8470MB


                  It didn't complain, I guess it wanted 1MB alignments.






                  share|improve this answer















                  From the Arch Wiki:



                  When creating a partition, parted might warn about improper partition alignment but does not hint about proper alignment. For example:



                  (parted) mkpart primary fat16 0 32M
                  Warning: The resulting partition is not properly aligned for best performance.
                  Ignore/Cancel?


                  The warning means the partition start is not aligned.



                  Enter Ignore to go ahead anyway, print the partition table in sectors to see where it starts, and remove/recreate the partition with the start sector rounded up to increasing powers of 2 until the warning stops. As one example, on a flash drive with 512B sectors, Parted wanted partitions to start on sectors that were a multiple of 2048, which is 1MB alignment.



                  Additionally, just above this section, they state that the more precise IEC binary units of KiB, MiB, GiB, etc., are acceptable for units as well as the less precise KB, MB, GB, etc.



                  Personally, my exact command that solved this was:



                  mkpart hd ext4 1024KiB 8470MB


                  It didn't complain, I guess it wanted 1MB alignments.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 8 '15 at 5:52









                  HalosGhost

                  3,75392236




                  3,75392236










                  answered Feb 8 '15 at 5:03









                  Travis RodmanTravis Rodman

                  22633




                  22633





















                      5














                      A minor correction. As I understand it, GPT disks don't have partition types anymore, they are all "primary". Command 'mkpart primary' doesn't create a primary partition like it does on msdos disks, it just creates a partition called primary. You can just as well use command



                      (parted) mkpart Parted-FUN! 21476MB 4000787MB
                      (parted) print
                      Model: ATA ST4000DM000-1F21 (scsi)
                      Disk /dev/sdf: 4000787MB
                      Sector size (logical/physical): 512B/4096B
                      Partition Table: gpt

                      Number Start End Size File system Name Flags
                      1 1.05MB 17181MB 17180MB ext4 raid-var
                      2 17181MB 21476MB 4295MB raid-swap
                      3 21476MB 4000786MB 3979310MB Parted-FUN!


                      This may cause confusion if you try creating logical partitions, I know it did for me.



                      (parted) mkpart extended 21476MB 4000787MB
                      (parted) mkpart logical 21476MB 1000787MB
                      Warning: You requested a partition from 21476MB to 1000787MB.
                      The closest location we can manage is 4000786MB to 4000786MB.
                      Is this still acceptable to you?
                      Yes/No? Yes
                      (parted) print
                      Model: ATA ST4000DM000-1F21 (scsi)
                      Disk /dev/sdf: 4000787MB
                      Sector size (logical/physical): 512B/4096B
                      Partition Table: gpt

                      Number Start End Size File system Name Flags
                      1 1.05MB 17181MB 17180MB ext4 raid-var
                      2 17181MB 21476MB 4295MB raid-swap
                      3 21476MB 4000786MB 3979310MB extended
                      4 4000786MB 4000786MB 0.00MB logical


                      You can't create a partition called "logical" inside a partition called "extended".






                      share|improve this answer























                      • thank you, I just wasted quite a bit of time thanks to this tools bad cli, and you made me figure out what's going on.

                        – Florian Heigl
                        Mar 16 '16 at 23:59















                      5














                      A minor correction. As I understand it, GPT disks don't have partition types anymore, they are all "primary". Command 'mkpart primary' doesn't create a primary partition like it does on msdos disks, it just creates a partition called primary. You can just as well use command



                      (parted) mkpart Parted-FUN! 21476MB 4000787MB
                      (parted) print
                      Model: ATA ST4000DM000-1F21 (scsi)
                      Disk /dev/sdf: 4000787MB
                      Sector size (logical/physical): 512B/4096B
                      Partition Table: gpt

                      Number Start End Size File system Name Flags
                      1 1.05MB 17181MB 17180MB ext4 raid-var
                      2 17181MB 21476MB 4295MB raid-swap
                      3 21476MB 4000786MB 3979310MB Parted-FUN!


                      This may cause confusion if you try creating logical partitions, I know it did for me.



                      (parted) mkpart extended 21476MB 4000787MB
                      (parted) mkpart logical 21476MB 1000787MB
                      Warning: You requested a partition from 21476MB to 1000787MB.
                      The closest location we can manage is 4000786MB to 4000786MB.
                      Is this still acceptable to you?
                      Yes/No? Yes
                      (parted) print
                      Model: ATA ST4000DM000-1F21 (scsi)
                      Disk /dev/sdf: 4000787MB
                      Sector size (logical/physical): 512B/4096B
                      Partition Table: gpt

                      Number Start End Size File system Name Flags
                      1 1.05MB 17181MB 17180MB ext4 raid-var
                      2 17181MB 21476MB 4295MB raid-swap
                      3 21476MB 4000786MB 3979310MB extended
                      4 4000786MB 4000786MB 0.00MB logical


                      You can't create a partition called "logical" inside a partition called "extended".






                      share|improve this answer























                      • thank you, I just wasted quite a bit of time thanks to this tools bad cli, and you made me figure out what's going on.

                        – Florian Heigl
                        Mar 16 '16 at 23:59













                      5












                      5








                      5







                      A minor correction. As I understand it, GPT disks don't have partition types anymore, they are all "primary". Command 'mkpart primary' doesn't create a primary partition like it does on msdos disks, it just creates a partition called primary. You can just as well use command



                      (parted) mkpart Parted-FUN! 21476MB 4000787MB
                      (parted) print
                      Model: ATA ST4000DM000-1F21 (scsi)
                      Disk /dev/sdf: 4000787MB
                      Sector size (logical/physical): 512B/4096B
                      Partition Table: gpt

                      Number Start End Size File system Name Flags
                      1 1.05MB 17181MB 17180MB ext4 raid-var
                      2 17181MB 21476MB 4295MB raid-swap
                      3 21476MB 4000786MB 3979310MB Parted-FUN!


                      This may cause confusion if you try creating logical partitions, I know it did for me.



                      (parted) mkpart extended 21476MB 4000787MB
                      (parted) mkpart logical 21476MB 1000787MB
                      Warning: You requested a partition from 21476MB to 1000787MB.
                      The closest location we can manage is 4000786MB to 4000786MB.
                      Is this still acceptable to you?
                      Yes/No? Yes
                      (parted) print
                      Model: ATA ST4000DM000-1F21 (scsi)
                      Disk /dev/sdf: 4000787MB
                      Sector size (logical/physical): 512B/4096B
                      Partition Table: gpt

                      Number Start End Size File system Name Flags
                      1 1.05MB 17181MB 17180MB ext4 raid-var
                      2 17181MB 21476MB 4295MB raid-swap
                      3 21476MB 4000786MB 3979310MB extended
                      4 4000786MB 4000786MB 0.00MB logical


                      You can't create a partition called "logical" inside a partition called "extended".






                      share|improve this answer













                      A minor correction. As I understand it, GPT disks don't have partition types anymore, they are all "primary". Command 'mkpart primary' doesn't create a primary partition like it does on msdos disks, it just creates a partition called primary. You can just as well use command



                      (parted) mkpart Parted-FUN! 21476MB 4000787MB
                      (parted) print
                      Model: ATA ST4000DM000-1F21 (scsi)
                      Disk /dev/sdf: 4000787MB
                      Sector size (logical/physical): 512B/4096B
                      Partition Table: gpt

                      Number Start End Size File system Name Flags
                      1 1.05MB 17181MB 17180MB ext4 raid-var
                      2 17181MB 21476MB 4295MB raid-swap
                      3 21476MB 4000786MB 3979310MB Parted-FUN!


                      This may cause confusion if you try creating logical partitions, I know it did for me.



                      (parted) mkpart extended 21476MB 4000787MB
                      (parted) mkpart logical 21476MB 1000787MB
                      Warning: You requested a partition from 21476MB to 1000787MB.
                      The closest location we can manage is 4000786MB to 4000786MB.
                      Is this still acceptable to you?
                      Yes/No? Yes
                      (parted) print
                      Model: ATA ST4000DM000-1F21 (scsi)
                      Disk /dev/sdf: 4000787MB
                      Sector size (logical/physical): 512B/4096B
                      Partition Table: gpt

                      Number Start End Size File system Name Flags
                      1 1.05MB 17181MB 17180MB ext4 raid-var
                      2 17181MB 21476MB 4295MB raid-swap
                      3 21476MB 4000786MB 3979310MB extended
                      4 4000786MB 4000786MB 0.00MB logical


                      You can't create a partition called "logical" inside a partition called "extended".







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Feb 2 '15 at 23:54









                      MiksaMiksa

                      5111




                      5111












                      • thank you, I just wasted quite a bit of time thanks to this tools bad cli, and you made me figure out what's going on.

                        – Florian Heigl
                        Mar 16 '16 at 23:59

















                      • thank you, I just wasted quite a bit of time thanks to this tools bad cli, and you made me figure out what's going on.

                        – Florian Heigl
                        Mar 16 '16 at 23:59
















                      thank you, I just wasted quite a bit of time thanks to this tools bad cli, and you made me figure out what's going on.

                      – Florian Heigl
                      Mar 16 '16 at 23:59





                      thank you, I just wasted quite a bit of time thanks to this tools bad cli, and you made me figure out what's going on.

                      – Florian Heigl
                      Mar 16 '16 at 23:59











                      4














                      The accepted answer by @lik shows how you can specify the preferred alignment. However, parted always uses that alignment for checking the resulting partition, but not always creates partitions with that alignment.



                      TL;DR: When 1MiB is the optimal alignment, specifying 0% will work for disks of 200MiB and bigger. For smaller disks or larger alignment, specifying 0G could work where 0% does not. See below about why.



                      Parted does try to satisfy the alignment constraints when creating a partition, but it also will not deviate from your requested values too much. What counts as "too much" depends on how you specified the postions.



                      When you specify a start (or end) position to the mkpart command, it internally generates a range of acceptable values. This range is centered on the value you specify, and extends equally on both sides by half the unit size you used (that's what I read from the code, the comments say one full unit size on both ends).



                      For example, when you specify "10M", it will try to use any position between 9.5M and 10.5M. The same goes for percentages, so if you specify 0% it will use any value between 0% and 0.5% (it does not go negative, obviously).



                      One exception is that when using power-of-two-units (such as KiB for 1024, as opposed to K for 1000) parted assumes you're trying to specify an exact position and only considers the exact value you specified.



                      Since optimal alignment typically seems to be 1MiB-aligned, the K and M units will often not have sufficient room to reach optimal alignment. Specifying positions in G should have plenty room, but % is usually also fine.



                      So, this is why 0% usually works, though even that has limits.






                      share|improve this answer

























                      • Could you summarize a practical TLDR of your answer: what exactly should be better done in a different way as compared to the accepted answer?

                        – yurkennis
                        Jan 30 at 11:36











                      • Good suggestion, I added a TL;DR. In practice, I think the 0% will work for all but really small disks, but my answer adds a little background on how it works exactly.

                        – Matthijs Kooijman
                        Jan 30 at 15:14















                      4














                      The accepted answer by @lik shows how you can specify the preferred alignment. However, parted always uses that alignment for checking the resulting partition, but not always creates partitions with that alignment.



                      TL;DR: When 1MiB is the optimal alignment, specifying 0% will work for disks of 200MiB and bigger. For smaller disks or larger alignment, specifying 0G could work where 0% does not. See below about why.



                      Parted does try to satisfy the alignment constraints when creating a partition, but it also will not deviate from your requested values too much. What counts as "too much" depends on how you specified the postions.



                      When you specify a start (or end) position to the mkpart command, it internally generates a range of acceptable values. This range is centered on the value you specify, and extends equally on both sides by half the unit size you used (that's what I read from the code, the comments say one full unit size on both ends).



                      For example, when you specify "10M", it will try to use any position between 9.5M and 10.5M. The same goes for percentages, so if you specify 0% it will use any value between 0% and 0.5% (it does not go negative, obviously).



                      One exception is that when using power-of-two-units (such as KiB for 1024, as opposed to K for 1000) parted assumes you're trying to specify an exact position and only considers the exact value you specified.



                      Since optimal alignment typically seems to be 1MiB-aligned, the K and M units will often not have sufficient room to reach optimal alignment. Specifying positions in G should have plenty room, but % is usually also fine.



                      So, this is why 0% usually works, though even that has limits.






                      share|improve this answer

























                      • Could you summarize a practical TLDR of your answer: what exactly should be better done in a different way as compared to the accepted answer?

                        – yurkennis
                        Jan 30 at 11:36











                      • Good suggestion, I added a TL;DR. In practice, I think the 0% will work for all but really small disks, but my answer adds a little background on how it works exactly.

                        – Matthijs Kooijman
                        Jan 30 at 15:14













                      4












                      4








                      4







                      The accepted answer by @lik shows how you can specify the preferred alignment. However, parted always uses that alignment for checking the resulting partition, but not always creates partitions with that alignment.



                      TL;DR: When 1MiB is the optimal alignment, specifying 0% will work for disks of 200MiB and bigger. For smaller disks or larger alignment, specifying 0G could work where 0% does not. See below about why.



                      Parted does try to satisfy the alignment constraints when creating a partition, but it also will not deviate from your requested values too much. What counts as "too much" depends on how you specified the postions.



                      When you specify a start (or end) position to the mkpart command, it internally generates a range of acceptable values. This range is centered on the value you specify, and extends equally on both sides by half the unit size you used (that's what I read from the code, the comments say one full unit size on both ends).



                      For example, when you specify "10M", it will try to use any position between 9.5M and 10.5M. The same goes for percentages, so if you specify 0% it will use any value between 0% and 0.5% (it does not go negative, obviously).



                      One exception is that when using power-of-two-units (such as KiB for 1024, as opposed to K for 1000) parted assumes you're trying to specify an exact position and only considers the exact value you specified.



                      Since optimal alignment typically seems to be 1MiB-aligned, the K and M units will often not have sufficient room to reach optimal alignment. Specifying positions in G should have plenty room, but % is usually also fine.



                      So, this is why 0% usually works, though even that has limits.






                      share|improve this answer















                      The accepted answer by @lik shows how you can specify the preferred alignment. However, parted always uses that alignment for checking the resulting partition, but not always creates partitions with that alignment.



                      TL;DR: When 1MiB is the optimal alignment, specifying 0% will work for disks of 200MiB and bigger. For smaller disks or larger alignment, specifying 0G could work where 0% does not. See below about why.



                      Parted does try to satisfy the alignment constraints when creating a partition, but it also will not deviate from your requested values too much. What counts as "too much" depends on how you specified the postions.



                      When you specify a start (or end) position to the mkpart command, it internally generates a range of acceptable values. This range is centered on the value you specify, and extends equally on both sides by half the unit size you used (that's what I read from the code, the comments say one full unit size on both ends).



                      For example, when you specify "10M", it will try to use any position between 9.5M and 10.5M. The same goes for percentages, so if you specify 0% it will use any value between 0% and 0.5% (it does not go negative, obviously).



                      One exception is that when using power-of-two-units (such as KiB for 1024, as opposed to K for 1000) parted assumes you're trying to specify an exact position and only considers the exact value you specified.



                      Since optimal alignment typically seems to be 1MiB-aligned, the K and M units will often not have sufficient room to reach optimal alignment. Specifying positions in G should have plenty room, but % is usually also fine.



                      So, this is why 0% usually works, though even that has limits.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Feb 1 at 20:23









                      yurkennis

                      1033




                      1033










                      answered Oct 28 '17 at 18:55









                      Matthijs KooijmanMatthijs Kooijman

                      1713




                      1713












                      • Could you summarize a practical TLDR of your answer: what exactly should be better done in a different way as compared to the accepted answer?

                        – yurkennis
                        Jan 30 at 11:36











                      • Good suggestion, I added a TL;DR. In practice, I think the 0% will work for all but really small disks, but my answer adds a little background on how it works exactly.

                        – Matthijs Kooijman
                        Jan 30 at 15:14

















                      • Could you summarize a practical TLDR of your answer: what exactly should be better done in a different way as compared to the accepted answer?

                        – yurkennis
                        Jan 30 at 11:36











                      • Good suggestion, I added a TL;DR. In practice, I think the 0% will work for all but really small disks, but my answer adds a little background on how it works exactly.

                        – Matthijs Kooijman
                        Jan 30 at 15:14
















                      Could you summarize a practical TLDR of your answer: what exactly should be better done in a different way as compared to the accepted answer?

                      – yurkennis
                      Jan 30 at 11:36





                      Could you summarize a practical TLDR of your answer: what exactly should be better done in a different way as compared to the accepted answer?

                      – yurkennis
                      Jan 30 at 11:36













                      Good suggestion, I added a TL;DR. In practice, I think the 0% will work for all but really small disks, but my answer adds a little background on how it works exactly.

                      – Matthijs Kooijman
                      Jan 30 at 15:14





                      Good suggestion, I added a TL;DR. In practice, I think the 0% will work for all but really small disks, but my answer adds a little background on how it works exactly.

                      – Matthijs Kooijman
                      Jan 30 at 15:14

















                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f38164%2fcreate-partition-aligned-using-parted%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown






                      Popular posts from this blog

                      Peggy Mitchell

                      Palaiologos

                      The Forum (Inglewood, California)