Bug 203180

Summary: bsdinstall 4K sector option could/should be persisted in /boot/loader.conf
Product: Base System Reporter: Oliver Schonrock <oliver>
Component: confAssignee: Allan Jude <allanjude>
Status: Closed FIXED    
Severity: Affects Only Me CC: allanjude
Priority: ---    
Version: 10.2-RELEASE   
Hardware: amd64   
OS: Any   

Description Oliver Schonrock 2015-09-17 19:21:33 UTC
I wouldn't really classify this as a "bug", but really an improvement to the bsdinstall "experimental" zfs on root feature => sane defaults.

If you choose "4K Sectors" during a zfs-on-root install in 10.2 RELEASE bsdinstall correctly sets vfs.zfs.min_auto_ashift=12 and creates the initial zroot pool vdev using 4K minimum sector size. In my case this was a 2-disk mirror. 

Further vdevs which are created, in my case with this command, adding a second mirror to the zroot pool:

zpool add zroot mirror ada2 ada3

This results in the following sector sizes:

root@zfsroot:~ # zdb -l /dev/ada0p3 | grep ashift
        ashift: 12
root@zfsroot:~ # zdb -l /dev/ada1p3 | grep ashift
        ashift: 12
root@zfsroot:~ # zdb -l /dev/ada2 | grep ashift
        ashift: 9
root@zfsroot:~ # zdb -l /dev/ada3 | grep ashift
        ashift: 9

ie, fine (following the installer option) on initial vdev, and back to the OS default for the next vdev. 

Knowing this I could easily set the sysctl before adding the mirror. My humble suggestion is that this might be a nice-to-have "sane default" set by bsdinstall. 

Given the sysadmin has chosen 4K sectors for the initial it is "reasonable" (?) to assume that this is a modern'ish machine and 4K sectors are better for the hardware or desired for other reasons. Further, future vdevs created are probably subject to the same context. 

Could bsdinstall just add the sysctl setting for 4K settings to /boot/loader.conf if that option is chose during install? After the initial reboot, the sysadmin would then naturally create vdevs of the same sector size as chosen at bootup or can change the setting back to 512b (ashift=9). 

It might be worth communicating this loader.conf adjustment to the sysadmin at an appropriate point.
Comment 1 Oliver Schonrock 2015-09-21 20:44:34 UTC
thanks for picking this up. 

I actually played around with setting 

vfs.zfs.min_auto_ashift=12

in /boot/loader.conf

but couldn't get it to "stick". ie 

syctl vfs.zfs.min_auto_ashift 

still reported 9 after reboot. 

Not sure why that would be?
Comment 2 Allan Jude freebsd_committer freebsd_triage 2015-09-21 21:37:54 UTC
It is a sysctl, not a loader tunable.

It also depends on the ZFS module being loaded, because the sysctl exists
Comment 3 Allan Jude freebsd_committer freebsd_triage 2018-05-21 02:39:49 UTC
this was fixed in r319863