Guest User

Jonathan - Magical ZFS

a guest
Nov 30th, 2016
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I thought that I'd share something surprising that happened with me and ZFS
  2. the other day.
  3.  
  4. For a while now, I've had my desktop system set up so that it has 2 SSDs for
  5. the OS and home directory, and most of my data sits on a bunch of spinning
  6. hard drives. The two SSDs are in a zpool as mirrors, and the spinning drives
  7. are mirrored pairs in another pool. The interesting thing here is that one
  8. of the two SSDs is 512GB, and the other is 1TB, which of course, leaves
  9. 512GB free on the second drive. PC-BSD is smart enough that if I pick the
  10. smaller drive for the OS and the second drive as its mirror, the installer
  11. gives the second drive a partition which is identical in size to the one of
  12. the first drive rather than making the partition cover the whole disk and
  13. then ZFS just not using it, because the other drive in the vdev was too
  14. small.
  15.  
  16. So, I've had 512GB to play around with. At times I've used it as a cache for
  17. my data pool, and other times, I've just used it as a place to put some
  18. extra data (so long as I can afford to lose it, since it's then in a pool by
  19. itself with no redundancy). Recently, I've used it for extra storage, and
  20. when something went wrong with my computer that necessitated that I
  21. reinstall the OS, I sent the data from that extra pool to another pool so
  22. that I could restore it after PC-BSD had wiped out my installation when
  23. putting the new one on.
  24.  
  25. So, I installed PC-BSD and then re-added the partition to the end of the 1TB
  26. drive so that I could re-add the extra zpool, and lo and behold, what
  27. happens? zpool complains that there's already a pool there. _That_ was
  28. unexpected. The disk was repartitioned. Its data should be gone.
  29.  
  30. Now, gpart obviously doesn't overwrite the whole drive when you repartition
  31. a drive. It just rewrites the partition table. But I'm used to thinking that
  32. if you repartation a drive, everything on it is toast. But apparently, if
  33. you line up your new partition in exactly the same spot that it was before,
  34. ZFS is capable of recognizing what's there and using it.
  35.  
  36. I did a scrub of that pool, and it was completely fine. I didn't need to
  37. restore it at all. It was completely unharmed in spite of the disk being
  38. repartationed. It makes some sense when I think through the details of how
  39. partitions and ZFS work, but it's not something that I ever would have
  40. expected.
  41.  
  42. - Jonathan
RAW Paste Data