How to create zfs mirror with default installation?

ozgurerdogan

Renowned Member
May 2, 2010
621
6
83
Bursa, Turkey, Turkey
I want to create mirror zfs pool. I installed pve as zfs file system and tried:
Code:
zpool create STORAGE mirror /rpool/data /dev/sdb
cannot use '/rpool/data': must be a block device or regular file

Or
Code:
root@ns302028:~# zpool add rpool mirror /rpool/data /dev/sdb
cannot use '/rpool/data': must be a block device or regular file

So It does not allow. Must I go with non-zfs root install and create mirror pool by then?
 
You installed on a single drive with ZFS and want to mirror now?
 
Replace what?
Post output of
Code:
zpool status
If it's a single drive pool, you can convert it in a raid-1 mirror with zpool attach <actual drive> <new drive>
 
if you want to create another pool for another ZFS RAID this example is for raid 10
Code:
zpool create -f -o ashift=12 vmdata mirror /dev/sdc /dev/sdd mirror /dev/sde /dev/sdf
then you would import with
Code:
zpool import vmdata

if you want to replace a failed disk
pull out the bad disk then put in the new one run this command to find out which disk
Code:
lsblk
then once you found your disk you replicate from the virgin disk to the zfs disk meaning that the new disk will get the partitions of other mirror
Code:
sgdisk --replicate=/dev/sdb /dev/sda
then randomize the guids
Code:
sgdisk --randomize-guids /dev/sdb
and if its the OS proxmox you need to install grub if not then ignore this part
Code:
grub-install /dev/sdb
and finally replace
Code:
zpool replace rpool /dev/sdb2
wait to resilver then reboot
 
I am testing to replace rpool with an os reinstall. I install pve with zfs root install. And create mirror with second this with command:
Code:
zpool attach rpool /dev/sda2 /dev/sdb


And added some files then reinstall pve. Now I want to import/recreate same mirror. So when I zpool status, I see:
Code:
pool: rpool
 state: ONLINE
status: Some supported features are not enabled on the pool. The pool can
        still be used, but some features are unavailable.
action: Enable all features using 'zpool upgrade'. Once this is done,
        the pool may no longer be accessible by software that does not support
        the features. See zpool-features(5) for details.
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          sda2      ONLINE       0     0     0

errors: No known data errors

  pool: rpool-13701826336599050226
 state: DEGRADED
status: One or more devices could not be used because the label is missing or
        invalid.  Sufficient replicas exist for the pool to continue
        functioning in a degraded state.
action: Replace the device using 'zpool replace'.
   see: http://zfsonlinux.org/msg/ZFS-8000-4J
  scan: resilvered 1.04G in 0h0m with 0 errors on Sun Dec  3 18:04:16 2017
config:

        NAME                     STATE     READ WRITE CKSUM
        rpool-13701826336599050226  DEGRADED     0     0     0
          mirror-0               DEGRADED     0     0     0
            7084915294388246136  FAULTED      0     0     0  was /dev/sda2
            sdb                  ONLINE       0     0     0

errors: No known data errors

So now how should I attach sda2 again with mirroring to sdb ?