How to create a ZFS mirror

gusto

Well-Known Member
Feb 10, 2018
78
0
46
24
A year ago I created a datapool pool (SSD 1TB).

Code:
  pool: datapool
 state: ONLINE
  scan: scrub repaired 0B in 00:00:00 with 0 errors on Sun Jan  9 00:24:01 2022
config:

        NAME                                            STATE     READ WRITE CKSUM
        datapool                                        ONLINE       0     0     0
          usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0  ONLINE       0     0     0

Now I bought the same disk and I want to create a mirror. The existing datapool already contains some data. How to add a new disk to the pool and create a mirror?
 
Hello,

probably this works only on the command line, see man zpool-attach. You need to runs somehing like zpool attach datapool /dev/disk/by-id/usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0 /dev/disk/by-id/your-new-drive-id.

Caution: triple check your command. The standard pitfall is to add a new device as an individual vdev by accident - which is (was?) a really, really problematic fault because it can (could?) not be undone.
 
Last edited:
What should I do if both disks have a by-id of the same name.
Code:
 ls -l /dev/disk/by-id
total 0
....
lrwxrwxrwx 1 root root  9 Mar  7 19:07 usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10 Feb 27 07:37 usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0-part1 -> ../../sdd1
lrwxrwxrwx 1 root root 10 Feb 27 07:37 usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0-part9 -> ../../sdd9
....

Code:
usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0 = sdc
usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0 = sdd
 
You could use the wwn of your new disk. That should be listed there too. These should be different.
 
Last edited:
OK so
Code:
sdc - new disc

=== START OF INFORMATION SECTION ===
Model Family:     WD Blue / Red / Green SSDs
Device Model:     WDC  WDS100T2B0A-00SM50
Serial Number:    2118H3452512
LU WWN Device Id: 5 001b44 4a7d765f3
Firmware Version: 415020WD
...

Code:
sdd - existing disk in datapool

=== START OF INFORMATION SECTION ===
Model Family:     WD Blue / Red / Green SSDs
Device Model:     WDC  WDS100T2B0A-00SM50
Serial Number:    204214A003B9
LU WWN Device Id: 5 001b44 8bbf8f4ce
Firmware Version: 415000WD
...

Should the command to add a disk to the pool look like this?
Code:
zpool attach datapool /dev/disk/by-id/usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0  /dev/disk/by-id/wwn-5x001b444a7d765f3
 
My previous post shows the results from smartctl, where is the line LU WWN Device Id:
I assume this is the correct parameter.
BTW can the command look like this?
Code:
zpool attach datapool /dev/disk/by-id/5x001b448bbf8f4ce  /dev/disk/by-id/wwn-5x001b444a7d765f3
 
Not shown
Code:
ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Mar  9 08:42 ata-Samsung_SSD_870_EVO_250GB_S6PENJ0RB40583V -> ../../sdb
lrwxrwxrwx 1 root root 10 Mar  9 08:42 ata-Samsung_SSD_870_EVO_250GB_S6PENJ0RB40583V-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Mar  9 08:42 ata-Samsung_SSD_870_EVO_250GB_S6PENJ0RB40583V-part2 -> ../../sdb2
lrwxrwxrwx 1 root root 10 Mar  9 08:42 ata-Samsung_SSD_870_EVO_250GB_S6PENJ0RB40583V-part3 -> ../../sdb3
lrwxrwxrwx 1 root root  9 Mar  9 08:42 ata-Samsung_SSD_870_EVO_250GB_S6PENJ0RB40585D -> ../../sda
lrwxrwxrwx 1 root root 10 Mar  9 08:42 ata-Samsung_SSD_870_EVO_250GB_S6PENJ0RB40585D-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Mar  9 08:42 ata-Samsung_SSD_870_EVO_250GB_S6PENJ0RB40585D-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Mar  9 08:42 ata-Samsung_SSD_870_EVO_250GB_S6PENJ0RB40585D-part3 -> ../../sda3
lrwxrwxrwx 1 root root 11 Mar  9 08:42 lvm-pv-uuid-PsS2aq-dT3d-NP8t-Guiu-y0n0-TVva-EGjWJ1 -> ../../zd0p5
lrwxrwxrwx 1 root root  9 Mar  9 11:44 usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0 -> ../../sdd
lrwxrwxrwx 1 root root 10 Mar  9 08:42 usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0-part1 -> ../../sdc1
lrwxrwxrwx 1 root root 10 Mar  9 08:42 usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0-part9 -> ../../sdc9
lrwxrwxrwx 1 root root  9 Mar  9 08:42 wwn-0x5002538f31b23c5d -> ../../sdb
lrwxrwxrwx 1 root root 10 Mar  9 08:42 wwn-0x5002538f31b23c5d-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Mar  9 08:42 wwn-0x5002538f31b23c5d-part2 -> ../../sdb2
lrwxrwxrwx 1 root root 10 Mar  9 08:42 wwn-0x5002538f31b23c5d-part3 -> ../../sdb3
lrwxrwxrwx 1 root root  9 Mar  9 08:42 wwn-0x5002538f31b23c5f -> ../../sda
lrwxrwxrwx 1 root root 10 Mar  9 08:42 wwn-0x5002538f31b23c5f-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Mar  9 08:42 wwn-0x5002538f31b23c5f-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Mar  9 08:42 wwn-0x5002538f31b23c5f-part3 -> ../../sda3
 
Not shown
Code:
ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Mar  9 08:42 wwn-0x5002538f31b23c5d -> ../../sdb
lrwxrwxrwx 1 root root  9 Mar  9 08:42 wwn-0x5002538f31b23c5f -> ../../sda
There are use WWNs you can use with /dev/disk/by-id
 
The last option for me is?
Code:
zpool attach datapool /dev/sdd  /dev/sdc
This can make for a reboote problem
 
As soon as your disk is added it shouldn't be that problematic anymore as ZFS will identify the disks by the metadata stored on the drive itself and not by the /dev/sdc you used to add it to the pool. You just need to be very carefully when editing your pool configuration not to remove/add the wrong disk.
 
My attempt looks like this
Code:
zpool attach datapool usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0  /dev/sdd
Code:
 pool: datapool
 state: DEGRADED
status: One or more devices are faulted in response to persistent errors.
        Sufficient replicas exist for the pool to continue functioning in a
        degraded state.
action: Replace the faulted device, or use 'zpool clear' to mark the device
        repaired.
  scan: scrub repaired 0B in 00:03:08 with 0 errors on Thu Mar 10 12:43:40 2022
config:

        NAME                                              STATE     READ WRITE CKSUM
        datapool                                          DEGRADED     0     0     0
          mirror-0                                        DEGRADED     0     0     0
            usb-WDC_WDS_100T2B0A-00SM50_98765432100C-0:0  ONLINE       0     0     0
            sdd                                           FAULTED      3     2     0  too many errors
The data wasn't lost, but something must have gone wrong.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!