Solved Best practices for adding mirror VDEV to zfs on root

Hi,

I'm deploying my first FreeBSD server and I've run into a gray area. I installed using the automatic partitioning of the installer.

zpool status shows:

Code:
  pool: zroot
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            da0p4   ONLINE       0     0     0
            da1p4   ONLINE       0     0     0

errors: No known data errors

And gpart show returns (note: da2 & da3 are from an orphaned installation):

Code:
=>         40  23437770672  da1  GPT  (11T)
           40       532480    1  efi  (260M)
       532520         1024    2  freebsd-boot  (512K)
       533544          984       - free -  (492K)
       534528     16777216    3  freebsd-swap  (8.0G)
     17311744  23420456960    4  freebsd-zfs  (11T)
  23437768704         2008       - free -  (1.0M)

=>         40  23437770672  da3  GPT  (11T)
           40         1024    1  freebsd-boot  (512K)
         1064          984       - free -  (492K)
         2048     33554432    2  freebsd-swap  (16G)
     33556480  23404212224    3  freebsd-zfs  (11T)
  23437768704         2008       - free -  (1.0M)

=>         40  23437770672  da2  GPT  (11T)
           40         1024    1  freebsd-boot  (512K)
         1064          984       - free -  (492K)
         2048     33554432    2  freebsd-swap  (16G)
     33556480  23404212224    3  freebsd-zfs  (11T)
  23437768704         2008       - free -  (1.0M)

=>         40  23437770672  da0  GPT  (11T)
           40       532480    1  efi  (260M)
       532520         1024    2  freebsd-boot  (512K)
       533544          984       - free -  (492K)
       534528     16777216    3  freebsd-swap  (8.0G)
     17311744  23420456960    4  freebsd-zfs  (11T)
  23437768704         2008       - free -  (1.0M)

I'd like to add da2 & da3 to my zroot as a second mirror VDEV, but I'm unsure if I should just add the whole disk or copy the partition table and copy the boot code.

I've already figured I can backup | restore the partition tables:

Code:
gpart backup da0 | gpart restore -F da2 da3

Then copy the boot code?

Code:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da2 
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da3

This is what came up with from searching the forums, but as I installed using UEFI+BIOS, will this work for both the efi and freebsd-boot partitions?

Then add swap to /etc/fstab

Code:
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/gpt/efiboot0               /boot/efi       msdosfs rw              2       2
/dev/da0p3              none    swap    sw              0       0
/dev/da1p3              none    swap    sw              0       0
/dev/da2p3              none    swap    sw              0       0
/dev/da3p3              none    swap    sw              0       0

And finally, add the mirror to the pool:

Code:
zpool add zroot mirror /dev/da2p4 da3p4

So, do i have it right? Or am I about to bork my installation? Also, adding a mirror to the pool should not require a resilver, but a scrup would be recommended to balance the VDEVs, right?
 
For the additional two disks you don't need to create the partition table. There's no use for the boot partition, you can't boot from those. If both your primary disks are dead the whole pool is toast, so there's nothing to boot to. Also the swap is not necessary, unless you want to increase your swap size.
 
OP is your intent to make a "stripe of mirrors"? Or to add a mirror to the system that can be used for data, user home directories, etc?
My reason for asking is "stripe of mirrors" gives you a bigger "disk", but if one of the vdevs fails completely, you can't boot.
 
OP is your intent to make a "stripe of mirrors"? Or to add a mirror to the system that can be used for data, user home directories, etc?
I want to make a stripe of mirrors, I guess what i know of as RAID10. I expect my final configuration will look something like this:

Code:
  pool: zroot
 state: ONLINE
config:

    NAME        STATE     READ WRITE CKSUM
    zroot       ONLINE       0     0     0
      mirror-0  ONLINE       0     0     0
        da0p4   ONLINE       0     0     0
        da1p4   ONLINE       0     0     0
       mirror-1 ONLINE       0     0     0
         da2    ONLINE       0     0     0
         da3    ONLINE       0     0     0

Although I do actually want to have more swap added to the system, so I may add an 8GB partition before the main partition. still trying to make sure I understand gpart before I commit the partitioned disks to the pool though.
 
In that case, and assuming da2 is entirely empty:
Code:
gpart create -s gpt da2
gpart add -a 4k -t freebsd-swap -s 8G da2
gpart add -a 4k -t freebsd-zfs da2
Do the same on da3. Then add da2p2 and da3p2 to the pool.
 
In that case, and assuming da2 is entirely empty:
Code:
gpart create -s gpt da2
gpart add -a 4k -t freebsd-swap -s 8G da2
gpart add -a 4k -t freebsd-zfs da2
Do the same on da3. Then add da2p2 and da3p2 to the pool.
Thanks!

I had already run gpart destroy on the disks. Now the partition tables looks like this:

Code:
=>         40  23437770672  da0  GPT  (11T)
           40       532480    1  efi  (260M)
       532520         1024    2  freebsd-boot  (512K)
       533544          984       - free -  (492K)
       534528     16777216    3  freebsd-swap  (8.0G)
     17311744  23420456960    4  freebsd-zfs  (11T)
  23437768704         2008       - free -  (1.0M)

=>         40  23437770672  da1  GPT  (11T)
           40       532480    1  efi  (260M)
       532520         1024    2  freebsd-boot  (512K)
       533544          984       - free -  (492K)
       534528     16777216    3  freebsd-swap  (8.0G)
     17311744  23420456960    4  freebsd-zfs  (11T)
  23437768704         2008       - free -  (1.0M)

=>         40  23437770672  da2  GPT  (11T)
           40     16777216    1  freebsd-swap  (8.0G)
     16777256  23420993456    2  freebsd-zfs  (11T)

=>         40  23437770672  da3  GPT  (11T)
           40     16777216    1  freebsd-swap  (8.0G)
     16777256  23420993456    2  freebsd-zfs  (11T)

Now I guess I finish off with zpool add zroot mirror /dev/da2p2 /dev/da3p2 and I'm done. Is there any benefit to running a scrub after this? The current mirror is only half-full and the data is pretty new.
 
Back
Top