I like the approach by Shane Madden, but there is another solution. Darren Moffat's comment points to a dead link.
The solution is via zfs attach
. For example:
Create a test pool:
root@test:~# zpool create storage scsi-36002248097081fa717c55d6b0d8cf10f
root@test:~# zpool status
pool: storage
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
storage ONLINE 0 0 0
scsi-36002248097081fa717c55d6b0d8cf10f ONLINE 0 0 0
errors: No known data errors
Fill some data:
root@test:~# dd if=/dev/urandom of=/storage/data.txt bs=64M count=12
Attach the new drive, note the syntax: you have to specify to which drive you want to attach:
root@test:~# zpool attach storage scsi-36002248097081fa717c55d6b0d8cf10f scsi-36002248027420d0aa88109aea4d03c5b
root@test:~# zpool status
pool: storage
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scan: resilver in progress since Mon Jul 29 14:49:20 2019
34.6M scanned out of 385M at 3.15M/s, 0h1m to go
30.5M resilvered, 8.98% done
config:
NAME STATE READ WRITE CKSUM
storage ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
scsi-36002248097081fa717c55d6b0d8cf10f ONLINE 0 0 0
scsi-36002248027420d0aa88109aea4d03c5b ONLINE 0 0 0 (resilvering)
errors: No known data errors
As you can see it creates a mirror (i.e. RAID1) as you wanted. This procedure can be used to add more drives to the mirror too.
After the ZFS resilvering, all of your data will be redundant and not just the newly written one.