killermist

ZFS 4k

Jan 6th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. As you’re probably aware (since you’re reading this), some of the new hard drives with "Advanced Format" lie about their sector size and thus the partitioning and/or file systems end up unaligned with the disk and performance suffers. Boo, Western Digital. You suck. But, since the WD20EARS was cheap and I didn’t think anyone would design something so stupid, I bought it.
  2.  
  3. Of course, ZFS is smart enough to use the larger sector size through the “ashift” setting, but only if it actually knows the sector size of the drive. This option is set at pool (or rather VDEV) creation and can’t be changed.
  4.  
  5. The easy way around this is to use gnop to prevent the drive from lying.
  6.  
  7. # zpool create tank raidz ada0 ada1 ada2
  8. # zdb | grep ashift
  9. ashift: 9
  10. Oe noes! 2^9 is 512, the wrong sector size. Let’s try that again.
  11.  
  12. # zpool destroy tank
  13. # gnop create -S 4096 ada0
  14. # zpool create tank raidz ada0.nop ada1 ada2
  15. # zdb | grep ashift
  16. ashift: 12
  17. Woohoo! 2^12 is 4096, as it should be. Note that you only need to tag one of the drives. zpool is clever enough to use the largest size of them all. Also note that you need to do this every time you add a new VDEV, otherwise you’ll have varying ashift values within your pool. Only problem now is that the drive list is a bit ugly, but that’s easily fixed.
  18.  
  19. # zpool status
  20. pool: tank
  21. state: ONLINE
  22. scan: none requested
  23. config:
  24. NAME STATE READ WRITE CKSUM
  25. tank ONLINE 0 0 0
  26. raidz1-0 ONLINE 0 0 0
  27. ada0.nop ONLINE 0 0 0
  28. ada1 ONLINE 0 0 0
  29. ada2 ONLINE 0 0 0
  30. # zpool export tank
  31. # gnop destroy ada0.nop
  32. # zpool import tank
  33. # zpool status
  34. pool: tank
  35. state: ONLINE
  36. scan: none requested
  37. config:
  38. NAME STATE READ WRITE CKSUM
  39. tank ONLINE 0 0 0
  40. raidz1-0 ONLINE 0 0 0
  41. ada0 ONLINE 0 0 0
  42. ada1 ONLINE 0 0 0
  43. ada2 ONLINE 0 0 0
  44. There we go. Destroying the gnop node just removes the sector size override, the data is safe and sound. You’ve now got ashift set right without fiddling with patches and such.
  45.  
  46. Simple Mirror Creation Example
  47. nas4free: ~ # bash
  48. [root@nas4free ~]# gnop create -S 4096 ada0
  49. [root@nas4free ~]# gnop create -S 4096 ada1
  50. [root@nas4free ~]# zpool create dancer mirror ada0.nop ada1.nop
  51. [root@nas4free ~]# zpool status -v
  52. pool: dancer
  53. state: ONLINE
  54. scan: none requested
  55. config:
  56.  
  57. NAME STATE READ WRITE CKSUM
  58. dancer ONLINE 0 0 0
  59. mirror-0 ONLINE 0 0 0
  60. ada0.nop ONLINE 0 0 0
  61. ada1.nop ONLINE 0 0 0
  62.  
  63. errors: No known data errors
  64. [root@nas4free ~]# zpool export dancer
  65. [root@nas4free ~]# gnop destroy ada0.nop
  66. [root@nas4free ~]# gnop destroy ada1.nop
  67. [root@nas4free ~]# zpool import dancer
  68. [root@nas4free ~]# zpool status -v
  69. pool: dancer
  70. state: ONLINE
  71. scan: none requested
  72. config:
  73.  
  74. NAME STATE READ WRITE CKSUM
  75. dancer ONLINE 0 0 0
  76. mirror-0 ONLINE 0 0 0
  77. ada0 ONLINE 0 0 0
  78. ada1 ONLINE 0 0 0
  79.  
  80. errors: No known data errors
Add Comment
Please, Sign In to add comment