Page 1 of 1
partition alignment 4K
Posted: Mon May 02, 2016 3:45 am
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.
Re: partition alignment 4K
Posted: Mon May 02, 2016 6:03 pm
by ericbsd
I think This is my fault because pc-sysinstall support that, I will get a look on that.
Re: partition alignment 4K
Posted: Sun May 08, 2016 12:05 pm
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.
Re: partition alignment 4K
Posted: Thu May 12, 2016 9:16 am
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 .......
Re: partition alignment 4K
Posted: Sun May 15, 2016 9:20 pm
by ericbsd
I did some change this will need to be test.
Re: partition alignment 4K
Posted: Mon May 16, 2016 11:12 am
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.
Re: partition alignment 4K
Posted: Tue May 17, 2016 4:11 pm
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.
Re: partition alignment 4K
Posted: Tue May 17, 2016 5:20 pm
by ASX
installed again with custom partitions, this time tried -> MBR -> AUTO,
the partitions are misaligned. Need to be fixed.