Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
General Discussion
»
[SOLVED] Partition Alignment for SSD
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Partition Alignment for SSD (Read 7888 times)
mibtac
Newbie
Posts: 7
Karma: 1
[SOLVED] Partition Alignment for SSD
«
on:
June 29, 2016, 03:54:19 pm »
I just built a new router/firewall box with an SSD. I tested OPNSense in a VM and found that the installer does not align the main partition on a 4K boundary, which would result in non-optimal drive performance and higher write amplification when I later install it on the SSD. Is it somehow possible to force the installer to use something like gpart -a4k when creating the partition?
«
Last Edit: July 11, 2016, 09:08:29 am by franco
»
Logged
franco
Administrator
Hero Member
Posts: 17670
Karma: 1612
Re: Partition Alignment for SSD
«
Reply #1 on:
June 29, 2016, 07:56:51 pm »
It's a good idea to do this by default, but I think the installer predates gpart so at the moment I wouldn't know where to start.
Just for reference, the code is in here:
https://github.com/opnsense/ports/tree/master/opnsense/bsdinstaller/files/installer
And I created a ticket
https://github.com/opnsense/ports/issues/22
Any help, hints, prodding and knowledge is welcome to speed this up.
Logged
mibtac
Newbie
Posts: 7
Karma: 1
Re: Partition Alignment for SSD
«
Reply #2 on:
June 29, 2016, 08:57:00 pm »
Hi Franco,
thanks for the reply! I was able to work around it manually in a VM. I first booted into single user mode from the installer ISO, then created a slice manually using gpart. I set the slice to start at the least common multiple of 63 and 4096/512=8 (which is 504), so it would land on both a cylinder and a 4k boundary. Then I used advanced mode in the OPNSense installer and used the partition editor to create a partition in the new slice. The installer complained about a non-standard partition layout, but it seems to work just fine.
I took a quick look at the installer code. I found a place in the partitioning LUA file where it makes sure that the starting block is on a cylinder (i.e. 63 sector) boundary. It should be easy to add an LCM calculation like the above there. I don't really have time to set up a build environment for OPNSense right now, otherwise I might have tried it myself.
Logged
franco
Administrator
Hero Member
Posts: 17670
Karma: 1612
Re: Partition Alignment for SSD
«
Reply #3 on:
June 30, 2016, 07:53:18 am »
Hi mibtac,
Neat, thanks for the analysis. I have no problem building and providing an ISO with a devel versions of the installer given you let me know what to add and where.
I'd only want to make sure the whole thing is done with the least minimum impact and maybe that it works by default for all installer types (auto and manual), but let me worry about that.
Cheers,
Franco
Logged
mibtac
Newbie
Posts: 7
Karma: 1
Re: Partition Alignment for SSD
«
Reply #4 on:
June 30, 2016, 09:45:22 pm »
Yeah, it should be fairly easy to hack in.
Long term, the best solution would be if FreeBSD finally stopped obeing constraints originating from the archaic cylinder/head/sector addressing. All of the FreeBSD tools still enforce the stupid 63 sector alignment, even though drives that used cylinders with constant sector counts on the physical level have long gone extinct. Windows and Linux have used sector 2048 as the start of the first partition for years, and even OpenBSD switched to 64.
Logged
franco
Administrator
Hero Member
Posts: 17670
Karma: 1612
Re: Partition Alignment for SSD
«
Reply #5 on:
July 05, 2016, 01:04:50 pm »
I realised I have some more work in the bsdinstaller for UEFI that also requires GPT, so if you can let me know what commands to run I will try to takle this alongside and push it all to 16.7.
Logged
mibtac
Newbie
Posts: 7
Karma: 1
Re: Partition Alignment for SSD
«
Reply #6 on:
July 06, 2016, 04:41:14 pm »
If you're going to support GPT everthing becomes much easier, since that uses only LBA addressing (so no need to bother with cylinder boundaries). Just make sure that the start sector and partition size are divisible by 8 (8*512=4096). But I imagine adding GPT support would be a lot of work in other ways ...
Logged
franco
Administrator
Hero Member
Posts: 17670
Karma: 1612
Re: Partition Alignment for SSD
«
Reply #7 on:
July 08, 2016, 09:18:26 am »
Hi mibtac ,
Yeah, so for UEFI we needed GPT and one thing led to another and now the UEFI install mode is a hybrid mode that can do EFI or normal boot just like the memstick will do. All partitions are aligned using "-a 4k" so I guess we're good here?
The changes will be ready for broader testing with RC2 next week. Will you be interested in trying them beforehand?
Thanks,
Franco
Logged
mibtac
Newbie
Posts: 7
Karma: 1
Re: Partition Alignment for SSD
«
Reply #8 on:
July 08, 2016, 10:32:06 pm »
Yes, with -a4k you should be good.
I cannot spare a physical machine for testing ATM, but I can try installing it on VMWare in UEFI mode.
Logged
franco
Administrator
Hero Member
Posts: 17670
Karma: 1612
Re: Partition Alignment for SSD
«
Reply #9 on:
July 11, 2016, 09:08:19 am »
Thanks for the hint, I tried this just now, also adjusting the cdrom images to boot uefi too.
I'll release RC2 will all of this, it should work as expected so no need for further testing.
Thank you for your help, marking this solved.
Logged
mibtac
Newbie
Posts: 7
Karma: 1
Re: [SOLVED] Partition Alignment for SSD
«
Reply #10 on:
July 12, 2016, 05:22:32 am »
Fantastic, thanks! Looking forward to the new release. I've been using OPNsense in our lab for a few days now and it's very pleasant to use overall. Much easier than the hand-configured Linux box I used before.
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
English Forums
»
General Discussion
»
[SOLVED] Partition Alignment for SSD