partition alignment 4K

News and Announcements related to GhostBSD
Post Reply
ASX
Posts: 988
Joined: Wed May 06, 2015 12:46 pm

partition alignment 4K

Post by ASX »

After install GhostBSD 10.3 alpha in vbox, ZFS setup, I realized that partition alignment is not working as expected:

Code: Select all

[as@as /usr/home/as]$ gpart show -p
=>           34  107861309     ada0  GPT  (51G)
                34            2048  ada0p1  bios-boot  (1.0M)
            2082  105809920  ada0p2  freebsd-zfs  (50G)
  105812002      2045952  ada0p3  freebsd-swap  (999M)
  107857954           3389                 - free -  (1.7M)
As you can see above, the size of bios-boot partition, ada0p1, is 2048 sectors, which is a 4K consistent size, but it start at sector 34 whic is NOT 4K aligned. it should be a mutiple of 8, (4K / 512 = 8).

As a conseguence, the following partition ada0p2 also DOESN'T start at 4K boundary.

What is needed is to start the partitioning at a 4K aligned sector, most likely at sector 40.

Please consider that 4K alignment is very important when using 4K block disks, performance will suffer a lot when using not aligned partitions.
User avatar
ericbsd
Developer
Posts: 2052
Joined: Mon Nov 19, 2012 7:54 pm

Re: partition alignment 4K

Post by ericbsd »

I think This is my fault because pc-sysinstall support that, I will get a look on that.
ASX
Posts: 988
Joined: Wed May 06, 2015 12:46 pm

Re: partition alignment 4K

Post by ASX »

ericbsd wrote:I think This is my fault because pc-sysinstall support that, I will get a look on that.
Thanks!


I have installed 10.3 alpha on a system, and at some point I noticed it was very slow, precisely it was slow while doing disk I/O (building iso, subtask: extracting ports).

After some time, I cancelled the build, and reinstalled using UFS instead of ZFS, performance improved greatly.

That exclude an hardware problem, an highlight the different performance between ZFS and UFS on this specific case.

For now, I'm thinking that the poor performance result could depend from a series of factors:

The disk installed in the system is a 500 GB HGST Deskstar 7100 rpm, which use a physical sector size of 4k and a logical sector size o 512 byte (emulated).

The fact that ZFS is a "copy on write" filesystem is a know factor when copying lot of small files, like in the case of ports extraction, and adding a 4k mis-alignment could result in the poor performance I have experienced.

I will retest ZFS on the same system once the alignment issue is solved.
ASX
Posts: 988
Joined: Wed May 06, 2015 12:46 pm

Re: partition alignment 4K

Post by ASX »

to solve the alignment issue, all partitions needs to be aligned, the default alignments is 512 bytes, which is/was the standard sector size.

newer and larger disk tend to use a 4kb size.

The implementation of the alignement can be done easily, by using an ALIGNMENT variable:

ALIGNMENT=512
or if explicitely selected from the user:
ALIGNMENT=4k

then using in in "gpart add" commands along with the "-a" flag:

Code: Select all

gpart add -s 100M -a $ALIGNMENT .......
User avatar
ericbsd
Developer
Posts: 2052
Joined: Mon Nov 19, 2012 7:54 pm

Re: partition alignment 4K

Post by ericbsd »

I did some change this will need to be test.
ASX
Posts: 988
Joined: Wed May 06, 2015 12:46 pm

Re: partition alignment 4K

Post by ASX »

Full disk UFS result in properly aligned partitions, the boot one is not aligned but that's a minor problem.

Full disk ZFS also result in a properly 4k aligned zfs partition, not sure if the "force 4kb " flag is needed at all, and depeding from me I would remove that request.

Manual partitioning remain to be tested.
ASX
Posts: 988
Joined: Wed May 06, 2015 12:46 pm

Re: partition alignment 4K

Post by ASX »

Installed using: custom partitioning -> Auto (GPT):
The alignment is OK (except freebsd-boot, which is harmless).

I will report another couple of test before closing this completely.
ASX
Posts: 988
Joined: Wed May 06, 2015 12:46 pm

Re: partition alignment 4K

Post by ASX »

installed again with custom partitions, this time tried -> MBR -> AUTO,
the partitions are misaligned. Need to be fixed.
Post Reply