Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Impossible to install to a 4K aligned partition (for SSD)?

    Scheduled Pinned Locked Moved Problems Installing or Upgrading pfSense Software
    17 Posts 8 Posters 4.8k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      thorazine74
      last edited by

      Hello:

      I'll be moving my pfsense system from a HDD to a SSD this week (when the hardware arrives).
      I searched the forums and it seems the CD installer still insists on partitions being aligned to cylinder boundaries instead of 4K sectors as its the standard for SSD.
      Is there a workaround for this? Some way to manually install the filesystem on properly aligned slice/partition created by something else?

      1 Reply Last reply Reply Quote 0
      • J
        jack290
        last edited by

        As a linux user,  the way I've got round this is to connect the SSD into a linux system and partition the disk using the linux fdisk.

        I found that when installing, the PFS installer gets upset if the partitions are not aligned on what it thinks is a cylinder boundary,  and I find the way round this is to choose sectors which align with both 63 (the old cylinder system) and also 4K boundaries.  This requires a little use of a calculator.  There is usually plenty of room on an SSD, hence I align to 63 x 4096 boundaries, ie 258048.

        Typically,

        start 4644864  ( 18 x 258048)  finish 30965759 ( (120 x 258048) -1 )  is 26320896 sectors, 12.5Gb

        Mark the partition as bootable and set a free BSD type (a5).  More partitions can be created by the same method.  The partition marked bootable must be used.

        Put the disk in the PFS box and install.

        When installing, choose own partitioning, pick this partition, do not format then install the bootblocks (bootloader) and complete the install.

        EDIT -  BSD calls partitions slices.  The above should read  "do not slice the disk, pick the slice (partition) you created."  I'm working from memory so I hope there is enough here for you to get started.

        The above is a somewhat blunt approach which works for me because I am familiar with the linux version of fdisk.  It is not much help if you do not have an available linux box to use.    Someone else may offer a better solution,  if you are familiar with the BSD version of fdisk it should be possible to boot the installer to a command line,  fire up the BSD partitioner and then use the approach given above to set the partition start and end points.  ( I'm not familiar with the BSD  version of fdisk and it may insist on cylinder boundaries,  however a little use of a calculator should still allow the problem to be solved.)

        There are differing views on whether or not to set trim, if you want to do so, after installing, boot to a command prompt at the first menu and run:-
            /sbin/tunefs -p /    and 
            /sbin/tunefs -t enable /

        to enable trim.

        Hope some of this helps,  and I might add that 4k is also preferred for many modern spinner disks which use "advanced format".

        1 Reply Last reply Reply Quote 0
        • K
          kpa
          last edited by

          It's the FreeBSD's GEOM MBR class insisting on the ancient C/H/S alignment which makes absolutely no sense now.  There is a sysctl (on by default) that is supposed to control that:

          https://reviews.freebsd.org/D585

          So invoking this in a shell before you let the installer start should allow any alignment, not tested by me though:

          
          sysctl kern.geom.part.mbr.enforce_chs=0
          
          
          1 Reply Last reply Reply Quote 0
          • jimpJ
            jimp Rebel Alliance Developer Netgate
            last edited by

            Use 2.4 and choose ZFS

            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

            1 Reply Last reply Reply Quote 0
            • T
              thorazine74
              last edited by

              @kpa:

              It's the FreeBSD's GEOM MBR class insisting on the ancient C/H/S alignment which makes absolutely no sense now.  There is a sysctl (on by default) that is supposed to control that:

              https://reviews.freebsd.org/D585

              So invoking this in a shell before you let the installer start should allow any alignment, not tested by me though:

              
              sysctl kern.geom.part.mbr.enforce_chs=0
              
              

              I'm unsure how to do that. If I boot from the CD I get a choice of invoking Installer or Recovery. If I boot to Recovery I have a shell but I couldnt figure out how to restart the installer from there.

              If I use a USB stick instead of a CD, can I somehow edit some config file in the stick to set up that variable=?

              1 Reply Last reply Reply Quote 0
              • C
                chrcoluk
                last edited by

                you should see an option to exit to shell on the installer menu, select it, run the sysctl command, then typing exit on the shell will bring you back to the menu and you can proceed from there.

                pfSense CE 2.7.2

                1 Reply Last reply Reply Quote 0
                • R
                  robi
                  last edited by

                  This should be set by default!!!!

                  1 Reply Last reply Reply Quote 0
                  • K
                    kpa
                    last edited by

                    @robi:

                    This should be set by default!!!!

                    I didn't mean to thank your post, that was a misclick How the heck you remove thanks now…

                    As long as there are older systems around that insist on CHS alignment in their BIOS for MBR partitions there's no way to make it the default, those system will flat out refuse to boot from disks that don't follow the proper alignment.

                    1 Reply Last reply Reply Quote 0
                    • jimpJ
                      jimp Rebel Alliance Developer Netgate
                      last edited by

                      With ZFS on 2.4, this is the default.

                      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                      Need help fast? Netgate Global Support!

                      Do not Chat/PM for help!

                      1 Reply Last reply Reply Quote 0
                      • C
                        chrcoluk
                        last edited by

                        @kpa:

                        @robi:

                        This should be set by default!!!!

                        I didn't mean to thank your post, that was a misclick How the heck you remove thanks now…

                        As long as there are older systems around that insist on CHS alignment in their BIOS for MBR partitions there's no way to make it the default, those system will flat out refuse to boot from disks that don't follow the proper alignment.

                        any such systems should be retired by now as that practice stopped a long time ago.  FreeBSD itself defaults to 4k alignment now along with all other major operating systems.

                        pfSense CE 2.7.2

                        1 Reply Last reply Reply Quote 0
                        • T
                          thorazine74
                          last edited by

                          @chrcoluk:

                          you should see an option to exit to shell on the installer menu, select it, run the sysctl command, then typing exit on the shell will bring you back to the menu and you can proceed from there.

                          I can only see an option to exit the installer, but that that triggers a machine reboot, I dont get back to any shell.

                          However I think I found another workaround: I chose [R] to boot to the recovery shell, set the geom variable there, and then launched the installer by running /scripts/lua_installer
                          I'm not sure if thats correct but it seemed to work, the partitioner in the installer stopped complaing about cylinder boundaries.

                          However I'm not sure if the created partitions are correctly aligned yet: if I read gpart output correctly, I ended up with a slice starting at sector 63, then inside of the slice the installer leaves a 16 sectors gap and creates the root partition, 16 sectors gap again, and the swap partition.
                          If I understand that correctly, if ada0s1 slice starts at 63 then the root partition would start at sector 79 so the root filesystem would still be misaligned right?

                          Side note: being an SSD I wanted to leave some free space for overprovisioning, so I tried to create a slice with just 90% of the disk capacity, but it seems the installer also insists that the slice takes the whole free space. So I have to resort to accept that, but once the slice is created it seems you have no problem to leave free space inside of the slice for overprovisioning.

                          1 Reply Last reply Reply Quote 0
                          • D
                            doktornotor Banned
                            last edited by

                            Lets try once again - use ZFS. No need to exit the install and produce whatever shell nonsense.

                            1 Reply Last reply Reply Quote 0
                            • T
                              thorazine74
                              last edited by

                              @doktornotor:

                              Lets try once again - use ZFS. No need to exit the install and produce whatever shell nonsense.

                              Can I do that with 2.3 or do I need to move to 2.4?

                              1 Reply Last reply Reply Quote 0
                              • D
                                doktornotor Banned
                                last edited by

                                No, you cannot do ZFS nor any alignment anywhere with anything but 2.4. (Not that it's ever be a real problem with SSD.)

                                1 Reply Last reply Reply Quote 0
                                • T
                                  thorazine74
                                  last edited by

                                  @jack290:

                                  As a linux user,  the way I've got round this is to connect the SSD into a linux system and partition the disk using the linux fdisk.

                                  I found that when installing, the PFS installer gets upset if the partitions are not aligned on what it thinks is a cylinder boundary,  and I find the way round this is to choose sectors which align with both 63 (the old cylinder system) and also 4K boundaries.  This requires a little use of a calculator.  There is usually plenty of room on an SSD, hence I align to 63 x 4096 boundaries, ie 258048.

                                  Typically,

                                  start 4644864  ( 18 x 258048)  finish 30965759 ( (120 x 258048) -1 )  is 26320896 sectors, 12.5Gb

                                  Mark the partition as bootable and set a free BSD type (a5).  More partitions can be created by the same method.  The partition marked bootable must be used.

                                  Put the disk in the PFS box and install.

                                  When installing, choose own partitioning, pick this partition, do not format then install the bootblocks (bootloader) and complete the install.

                                  EDIT -  BSD calls partitions slices.  The above should read  "do not slice the disk, pick the slice (partition) you created."  I'm working from memory so I hope there is enough here for you to get started.

                                  The above is a somewhat blunt approach which works for me because I am familiar with the linux version of fdisk.  It is not much help if you do not have an available linux box to use.    Someone else may offer a better solution,  if you are familiar with the BSD version of fdisk it should be possible to boot the installer to a command line,  fire up the BSD partitioner and then use the approach given above to set the partition start and end points.  ( I'm not familiar with the BSD  version of fdisk and it may insist on cylinder boundaries,  however a little use of a calculator should still allow the problem to be solved.)

                                  There are differing views on whether or not to set trim, if you want to do so, after installing, boot to a command prompt at the first menu and run:-
                                      /sbin/tunefs -p /    and 
                                      /sbin/tunefs -t enable /

                                  to enable trim.

                                  Hope some of this helps,  and I might add that 4k is also preferred for many modern spinner disks which use "advanced format".

                                  This doesnt seem to work for me either.

                                  I havent tried to use Linux fdisk but apparently you can create a slice starting from any block you wish from the shell with gpart:

                                  • Setting up **sysctl kern.geom.part.mbr.enforce_chs=**0
                                  • Erasing the partition table: gpart destroy -F ada0
                                  • Create a new MBR: gpart create -s MBR ada0
                                  • Create a slice starting from -b block: gpart add -t freebsd -s 64G -b 2048 ada0

                                  However no matter what value you use for -b (I've tried 2048, 258048 and 4644864), the installer fails when running bsdlabel with a "partition extends past end of unit" message.
                                  EDIT: looking at the installer.log it seems the fdisk launched by the installer its hardcoded to use cylinder alignment (I see some warning about "adjusting size of partition to end on a cylinder boundary"…)

                                  So it seems its indeed impossible to do a properly aligned installation with anything lower than 2.4.

                                  1 Reply Last reply Reply Quote 0
                                  • C
                                    chrcoluk
                                    last edited by

                                    you can align on 2.2/2.3 I have a guide here, which also links to a post on here for part of the guide.

                                    http://forum.kitz.co.uk/index.php/topic,18944.msg338041.html#msg338041
                                    https://forum.pfsense.org/index.php?topic=86139.0

                                    The trick is to find an alignment that is both 4k compliant and also complies with the ancient cylinder alignment so the pfsense installer doesnt interfere.

                                    pfSense CE 2.7.2

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Harvy66
                                      last edited by

                                      @jack290:

                                      As a linux user,  the way I've got round this is to connect the SSD into a linux system and partition the disk using the linux fdisk.

                                      I found that when installing, the PFS installer gets upset if the partitions are not aligned on what it thinks is a cylinder boundary,  and I find the way round this is to choose sectors which align with both 63 (the old cylinder system) and also 4K boundaries.  This requires a little use of a calculator.  There is usually plenty of room on an SSD, hence I align to 63 x 4096 boundaries, ie 258048.

                                      Typically,

                                      start 4644864  ( 18 x 258048)  finish 30965759 ( (120 x 258048) -1 )  is 26320896 sectors, 12.5Gb

                                      Mark the partition as bootable and set a free BSD type (a5).  More partitions can be created by the same method.  The partition marked bootable must be used.

                                      Put the disk in the PFS box and install.

                                      When installing, choose own partitioning, pick this partition, do not format then install the bootblocks (bootloader) and complete the install.

                                      EDIT -  BSD calls partitions slices.  The above should read  "do not slice the disk, pick the slice (partition) you created."  I'm working from memory so I hope there is enough here for you to get started.

                                      The above is a somewhat blunt approach which works for me because I am familiar with the linux version of fdisk.  It is not much help if you do not have an available linux box to use.    Someone else may offer a better solution,  if you are familiar with the BSD version of fdisk it should be possible to boot the installer to a command line,  fire up the BSD partitioner and then use the approach given above to set the partition start and end points.  ( I'm not familiar with the BSD  version of fdisk and it may insist on cylinder boundaries,  however a little use of a calculator should still allow the problem to be solved.)

                                      There are differing views on whether or not to set trim, if you want to do so, after installing, boot to a command prompt at the first menu and run:-
                                          /sbin/tunefs -p /    and 
                                          /sbin/tunefs -t enable /

                                      to enable trim.

                                      Hope some of this helps,  and I might add that 4k is also preferred for many modern spinner disks which use "advanced format".

                                      I just do a 16MiB alignment. No thinking involved then and only wastes a minuscule amount of space.

                                      1 Reply Last reply Reply Quote 0
                                      • NollipfSenseN NollipfSense referenced this topic on
                                      • First post
                                        Last post
                                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.