Create zfs mirror by adding a drive?

mjflower

Dabbler
Joined
Sep 14, 2020
Messages
25
gpart won't be available on Linux and the partition type freebsd-swap is most certainly not suitable, either. I can have a look at my scale installation later, if nobody more Linux savvy jumps in.

  • find out how partitions are referenced in the zpool
  • find out which of the dozen of different partitioning tools is actually present in SCALE
  • find out the partitioning scheme for the existing disk
  • recreate on the new disk
  • run zpool attach ...
Thank you. I had actually installed gpart on it but the switches were different so I backed out. My suspicions were correct and I'll wait till someone spells it out for a linux no-nothing like myself, or I might have a read and see if I can work out the missing pieces in relation to how the partitions are referenced. It's only the first two parts i'm not sure of. :)

Thanks for getting back to me.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
OK, so if I look at pool status in the UI it shows my single disk pool is on nvme0n1. Let's copy the partition table to nvme1n1:
Code:
truenas# sgdisk /dev/nvme0n1 -R /dev/nvme1n1
The operation has completed successfully.
truenas# sgdisk -G /dev/nvme1n1
The operation has completed successfully.
The first command copies the partition table, the second command recreates random UUIDs for the partitions. We will need these just as in CORE to manage the ZFS vdev components.

Code:
truenas# zpool status zfs
  pool: zfs
state: ONLINE
config:

    NAME                                    STATE     READ WRITE CKSUM
    zfs                                     ONLINE       0     0     0
      0bda215e-b9de-4c8c-884d-ed95beb81790  ONLINE       0     0     0

errors: No known data errors
This shows the UUID of the partition already in the pool (on nvme0n1).

Let's find the UUID for the second disk:
Code:
# Find the partition number
truenas# sgdisk -p /dev/nvme1n1
Disk /dev/nvme1n1: 488397168 sectors, 232.9 GiB
Model: Samsung SSD 970 EVO Plus 250GB         
[...]
Number  Start (sector)    End (sector)  Size       Code  Name
   1             128         4194304   2.0 GiB     8200 
   2         4194432       488397134   230.9 GiB   BF01 
# Now print detail for partition 2
truenas# sgdisk -i 2 /dev/nvme1n1
Partition GUID code: 6A898CC3-1DD2-11B2-99A6-080020736631 (Solaris /usr & Mac ZFS)
Partition unique GUID: 3EBE4772-FC42-474F-9605-8731D6ED3FF9
[...]


Now attach as usual:
Code:
truenas# zpool attach zfs 0bda215e-b9de-4c8c-884d-ed95beb81790 /dev/disk/by-partuuid/3ebe4772-fc42-474f-9605-8731d6ed3ff9
truenas# zpool status zfs
  pool: zfs
state: ONLINE
  scan: resilvered 64.2M in 00:00:00 with 0 errors on Sun Aug  8 07:25:24 2021
config:

    NAME                                      STATE     READ WRITE CKSUM
    zfs                                       ONLINE       0     0     0
      mirror-0                                ONLINE       0     0     0
        0bda215e-b9de-4c8c-884d-ed95beb81790  ONLINE       0     0     0
        3ebe4772-fc42-474f-9605-8731d6ed3ff9  ONLINE       0     0     0

errors: No known data errors


If SCALE behaves like CORE in that regard, the swap space will be detected and activated automatically on next reboot.

HTH,
Patrick
 

mjflower

Dabbler
Joined
Sep 14, 2020
Messages
25
Wow, thank you so much for the detailed explanation and sample. I'll give it a go. Thank you again..
 

mjflower

Dabbler
Joined
Sep 14, 2020
Messages
25
I thought I did the above but it throws an error on attaching.. i might have messed something up?

Code:
#                                                                                                                                                                                                                                                                                                                               
truenas# sgdisk /dev/sdi -R /dev/sdh
The operation has completed successfully.
#                                                                                                                                                                                                                                                                                                                               
truenas# sgdisk -G /dev/sdh
The operation has completed successfully.
#                                                                                                                                                                                                                                                                                                                               
truenas# zpool status test
  pool: test
 state: ONLINE
status: Some supported and requested 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: scrub repaired 0B in 14:45:23 with 0 errors on Sun Jul 25 14:45:25 2021
config:

        NAME                                    STATE     READ WRITE CKSUM
        test                                    ONLINE       0     0     0
          6114ab20-bcd3-4c3b-accf-53aab0822aa1  ONLINE       0     0     0

errors: No known data errors
#                                                                                                                                                                                                                                                                                                                               
truenas# 
#                                                                                                                                                                                                                                                                                                                               
truenas# sgdisk -p /dev/sdh
Disk /dev/sdh: 19532873728 sectors, 9.1 TiB
Model: ST10000DM0004-1Z
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): FA526E52-AACA-4C22-83E1-39E9A51E1BD1
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 19532873694
Partitions will be aligned on 128-sector boundaries
Total free space is 221 sectors (110.5 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1             128         4194304   2.0 GiB     8200  
   2         4194432     19532873694   9.1 TiB     BF01  
#                                                                                                                                                                                                                                                                                                                               
truenas# sgdisk -i 2 /dev/sdh 
Partition GUID code: 6A898CC3-1DD2-11B2-99A6-080020736631 (Solaris /usr & Mac ZFS)
Partition unique GUID: 5259A819-384F-4C73-9D43-43483C7DB54F
First sector: 4194432 (at 2.0 GiB)
Last sector: 19532873694 (at 9.1 TiB)
Partition size: 19528679263 sectors (9.1 TiB)
Attribute flags: 0000000000000000
Partition name: ''
#                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
truenas# zpool attach test 6114ab20-bcd3-4c3b-accf-53aab0822aa1 /dev/disk/by-partuuid/5259A819-384F-4C73-9D43-43483C7DB54F
cannot resolve path '/dev/disk/by-partuuid/5259A819-384F-4C73-9D43-43483C7DB54F'
#                                                                                                                                                                                                                                                                                                                               
truenas# 
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
You need to write the UUID with small letters. Use the TAB key to expand automatically after typing the first few ...
 

mjflower

Dabbler
Joined
Sep 14, 2020
Messages
25
wow, and just like that, it works! wow thanks so much Patrick.. I've learnt something too.
 
Top