3

My machine boots from a mirrored zfs pool of two USB devices. The pool used to look like this:

sudo zpool status
pool: freenas-boot
state: ONLINE
scan: resilvered 891M in 15h19m with 0 errors on Wed Mar 29 03:29:55 2017
config:

    NAME        STATE     READ WRITE CKSUM
    freenas-boot  ONLINE     0     0     0
      mirror-0  ONLINE       0     0     0
        da0p2   ONLINE       0     0     3
        da1p2   ONLINE       0     0     0

errors: No known data errors

I tried to replace the media with the checksum error, but through a series of incorrectly used commands I ended up "adding" the new drive instead of "attaching" it. The pool is now a concatenation of two devices and no longer mirrored:

  NAME        STATE     READ WRITE CKSUM
    freenas-boot  ONLINE     0     0     0
      da0p2     ONLINE       0     0     0
      da1p2     ONLINE       0     0     0

I learned that I cannot remove the device from the pool any more and the obvious

 zpool attach -f pool device new_device

command does not work.

I planned to mirror all the data on (large enough) third and fourth drives and then get rid of the concatenated first and second. However, it appears that mirroring only works on a device basis. I would need four devices for a mirrored configuration, which is unfavourable as only two USB ports are inside the machine's casing.

What would be a good way to move towards a bootable mirrored pool of two devices? Please keep in mind that the machine in question is a server and its failure to boot would make several users unhappy.

patmin
  • 117
  • 1
  • 10

1 Answers1

1
  1. Recursively zfs snapshot your root pool
  2. zfs send/recv this snapshot to another stick or volume of equal size, configured as a separate root pool
  3. Make this separate root pool with your copied data bootable
  4. Reboot the system and boot from your new root pool
  5. Add both sticks as mirrors to the new pool, thereby destroying the old one
  6. If resilvering has finished, remove the initial stick or volume and destroy it

You now have a correctly mirrored pool with both initial sticks.

user121391
  • 577
  • 5
  • 16
  • Sounds good but how do I snapshot the filesystem of the boot device? Its mountpoint is / , isn't it? – patmin Apr 12 '17 at 09:58
  • @patmin You can show all mountpoints of all filesystems of all pools with `zfs list -o name,mountpoint`, then look for `/`. I don't know the layout on Linux systems exactly, so I cannot be more specific, sorry. – user121391 Apr 12 '17 at 11:37
  • I triedsudo zfs send freenas-boot | sudo zfs recv -F newpool – patmin Apr 12 '17 at 12:00
  • I am working on a BSD system. From sudo zfs list -r I see freenas-boot, freenas-boot/ROOT, freenas-boot/ROOT/9.10.2-U2, freenas-boot/ROOT/Initial-Install, freenas-boot/ROOT/default, freenas-boot/grub. I tried to skip creating snapshots and go for a direct send/receive with "sudo zfs send freenas-boot | sudo zfs recv -F newpool" -- but only 376k of 801M seem to get copied. – patmin Apr 12 '17 at 12:08
  • @patmin Sorry, I mixed up Linux and BSD, but I don't know either of them. ;) You have to send recursively, otherwise you would send only the top-most file system. – user121391 Apr 12 '17 at 12:15
  • that was good advice, thank you. I have everything cloned on the second stick and am ready to reboot. I wonder if grub will detect the second stick as boot option... – patmin Apr 12 '17 at 12:58
  • @patmin Glad it worked for you! If you have problems booting, you still have the old stick to retry. Also, at least on Solaris you can just copy the boot information from the old to the new stick, maybe this is also possible on BSD. Finally, if my answer was helpful for you, it would be nice if you could accept it (green checkmark). – user121391 Apr 13 '17 at 07:11