Bug #5242
openzpool won't allow attachment of larger sector drive to mirror
0%
Description
Trying to attach a replacement drive (that despite my best efforts, ended up being a 512e / 4k drive) for a 512byte/sector drive that failed in a simple mirror configuration.
Even with -f, zpool attach will not allow the new drive to attach, failing with 'devices have different sector alignment'. It should probably succeed in the -f instance.
Related issues
Updated by David Stes 10 months ago
- Related to Bug #14782: sd.c warning message: "Unable to clean up memory" misguided added
Updated by David Stes 10 months ago
I am not sure this is a relevant remark but I had Western Digital disk in my system 500 GB, and I added a Seagate Barracuda 500GB which is sold as (said to be a) 512e disk. That is, the Seagate Barracuda disk is 512e.
On OpenIndiana 2022.11 on my system with Dell firmware/UEFI bios 1.18
zpool attach rpool c5t0d0 c5t2d0
seems to work fine, the mirror works.
According to the datasheet for the 3'5 HDD :
[[
https://www.seagate.com/www-content/datasheets/pdfs/3-5-barracudaDS1900-14-2007US-en_US.pdf
]]
the sector size physically is supposed to be 4096 bytes.
The attach works fine and the status seems ok in OI 2022 11
zpool status config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c5t0d0 ONLINE 0 0 0 c5t2d0 ONLINE 0 0 0 errors: No known data errors
So this is a mirror with a SATA 512e disk.
My understanding is that those disks emulate 512b disks but are physically socalled 4kn disks.
Updated by David Stes 10 months ago
Both the WDC western digital 500GB and Seagate disk report in prvtoc and format what seem to be sector size of 512 bytes. The datasheet of the Seagate Barracuda disk claims sector size physically of 4096, and presumably logical size emulation of 512 bytes. In any case case OpenIndiana 2022 11 seems to support my SATA disks so perhaps the bug report that zpool does not allow attachement of larger sector drives is obsolete.
Updated by David Stes 7 months ago
The command
zdb -C rpool
reports in my case for my ZFS mirror between 2 512e drives a value of "ashift 12". According to some documentation that I found on the internet this means 'sector size 4K'.
Ashift tells ZFS what the underlying physical block size your disks use is. It’s in bits, so ashift=9 means 512B sectors (used by all ancient drives), ashift=12 means 4K sectors (used by most modern hard drives), and ashift=13 means 8K sectors (used by some modern SSDs).
However because the following document claims that ashift can be set at pool creation time:
[[https://jrs-s.net/2018/08/17/zfs-tuning-cheat-sheet/]]
perhaps the issue can be resolved by creating a pool with ashift 9 (512bytes) at pool creation time.
Updated by Stephan Althaus 7 months ago
Hello!
With "zpool attach" we have the option "-o ashift=<n>", maybe the rror message should suggest that there is an option...
Updated by David Stes 7 months ago
I agree, this may perhaps be "not a bug".
In any case I can confirm that on my system, I have no problem to mirror a drive which is sold as a "512e" drive. However, I suspect I actually have 2 modern drives so probably both drives are 512e.
But the original report seems to be covered in the zpool documentation.
The zpool manpage discusses the case of addrng a drive to a "dying 512 byte sector drive" by explicitely setting ashit :
The documentation on "ashift" says :
it can be used, for instance, to replace
a dying 512B sectors disk with a newer 4KiB sectors device: this
will probably result in bad performance but at the same time could
prevent loss of data.
See the ashift documentation at [[
https://illumos.org/man/8/zpool
]]
The "pool sector size exponent" supposedly can be set at zpool creation time.
ashift=ashift
Pool sector size exponent
I have not tried it and it seems a dangereous parameter to set or modify anyway.
In my case of a mirror with a 512e disk drive, I did not have to do anything special and the system seems to have automaitcally set ashit to 12 for me.
Updated by David Stes 7 months ago
- Related to Feature #11640: add zpool ashift property tunable added
Updated by David Stes 7 months ago
There is some documentation at openzfs.org about ashift.
[[https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Workload%20Tuning.html]]
Also apparently there exist configuration files sd.conf and nvme.conf for specifying various parameters that relate to the "ashift" that will be used at pool creation time.
In my case on the zpool level with the 512e Barracuda and WDC drives at the pool level ashift is 0 (that is meant to be "default" or autoconfigure) and at the zdb level ashift reports 12. So the values for ashift are 0 and 12
zpool get ashift rpool
reports 0 for me. zdb reports 12.
I have no intention to change these values in my case of the mirror of the SATA mechanical drives (512e drives) that actually seems to work well, but theoretically I think perhaps I could have created the zpool with ashift 9 for block size 512. I am not sure whether it will work, but it could be the solution for the iissue of no attachement of larger sector drive to mirror.
The bug report contradicts in any case the zpool ashift documentation which specifically lists the possibility to use "ashift" in order to use a 4k drive to add to a mirror for a "dying" 512 byte sector old drive.
Updated by David Stes 7 months ago
- Related to Bug #7377: want mechanism to override physical block size of NVMe devices added
Updated by David Stes 7 months ago
- Related to Bug #8953: manpage for sd does not list all available options added
Updated by Stephan Althaus 7 months ago
"it can be used, for instance, to replace
a dying 512B sectors disk with a newer 4KiB sectors device: this
will probably result in bad performance but at the same time could
prevent loss of data."
The performance loss will be there if your pool where ashift=9. Yours is ashift=12 so a replacement drive with 4K sector size seems reasonable. "512e" is an emulation of 512 sector size, the drive's internal representation of one sector will be bigger, so the ashift=12 may give a hint of a sector size of 4K for your 512e drives..
zpool attach -o ashift=12 ... could do the job of adding a mirror drive with 4K sector size for your pool with actually uses ashift=12.