Solved replacing takes whole disk

Hi,
I'm a long time user of FreeBSD, and used zfs from the very beginning. I'm facing a slight problem : I've replaced a faulted disk (pool has been created by installer), but
Code:
zpool replace <faulted-disk> ada0
(note my mistake, I didn't provide slice number) takes the whole disk :
Code:
[root@numenor ~]# zpool status
  pool: zroot
 state: ONLINE
  scan: resilvered 4.90M in 0h0m with 0 errors on Sat Nov 18 16:58:02 2017
config:

   NAME        STATE     READ WRITE CKSUM
   zroot       ONLINE       0     0     0
     raidz1-0  ONLINE       0     0     0
       ada0    ONLINE       0     0     0
       ada1p3  ONLINE       0     0     0
       ada2p3  ONLINE       0     0     0
   cache
     ada3      ONLINE       0     0     0

errors: No known data errors

Th problem is that this configuration, though functionning perfectly, garbages the GPT header of the disk, leaving me without (I presume) boot partition, which is my point.

gpart show shows me the two other disks, but not the first, and if I offline the disk, the GPT is corrupt :

Code:
[root@numenor ~]# gpart show
=>        40  1465149088  ada1  GPT  (699G)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048    12582912     2  freebsd-swap  (6.0G)
    12584960  1452562432     3  freebsd-zfs  (693G)
  1465147392        1736        - free -  (868K)

=>        40  1465149088  ada2  GPT  (699G)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048    12582912     2  freebsd-swap  (6.0G)
    12584960  1452562432     3  freebsd-zfs  (693G)
  1465147392        1736        - free -  (868K)

[root@numenor ~]# zpool offline zroot ada0

[root@numenor ~]# gpart show
=>        40  1465149088  ada1  GPT  (699G)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048    12582912     2  freebsd-swap  (6.0G)
    12584960  1452562432     3  freebsd-zfs  (693G)
  1465147392        1736        - free -  (868K)

=>        40  1465149088  ada2  GPT  (699G)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048    12582912     2  freebsd-swap  (6.0G)
    12584960  1452562432     3  freebsd-zfs  (693G)
  1465147392        1736        - free -  (868K)

=>        40  1953525088  ada0  GPT  (932G) [CORRUPT]
          40         472     1  freebsd-boot  (236K)
         512    12582912     2  freebsd-swap  (6.0G)
    12583424  1940941704     3  freebsd-zfs  (926G)

I even tried to format at disk level
Code:
dd if=/dev/zero of=/dev/ada0 bs=1m count=10
then recreated with gpart the GPT table and the three partitions, with no success :
Code:
zpool replace -f zroot ada0 ada0p3
invalid vdev specification
/dev/ada0p3 is part of active pool 'zroot'

My main concern is that if I have to replace the two other disks (which is intended to extend my pool to 3*1TB) this way, there will be no more boot code at all.

Apologies for this long post, and thanks for any help

Xavier
 
zpool offline the disk.

Remove all traces of ZFS from it: zpool labelclear ada0

Wipe the disk, just to be sure: dd if=/dev/zero of=/dev/ada0 bs=1M

Then create a new GPT label, partition it, install the bootcode, and do the "zpool replace" with the proper partition.
 
Thnaks Phoenix for your quick answer
Unfortunately, zpool refuses to clear ada0 :
Code:
[root@numenor ~]# zpool status
  pool: zroot
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
   Sufficient replicas exist for the pool to continue functioning in a
   degraded state.
action: Online the device using 'zpool online' or replace the device with
   'zpool replace'.
  scan: resilvered 4.90M in 0h0m with 0 errors on Sat Nov 18 16:58:02 2017
config:

   NAME                     STATE     READ WRITE CKSUM
   zroot                    DEGRADED     0     0     0
     raidz1-0               DEGRADED     0     0     0
       8517832621599062110  OFFLINE      0     0     0  was /dev/ada0
       ada1p3               ONLINE       0     0     0
       ada2p3               ONLINE       0     0     0
   cache
     ada3                   ONLINE       0     0     0

errors: No known data errors
[root@numenor ~]# zpool labelclear ada0
/dev/ada0 is a member (ACTIVE) of pool "zroot"
 
You probably need to remove it from the pool, however I don't know if the system will allow this. Even so, you might want to try using # zpool detach zroot ada0. However, according to zpool(8) there are some restrictions in what you can or cannot detach and or remove so I'm not sure if this will work.
 
[SOLVED]
I finally suceeded. I had to wait for resilvering to finish, and only after that wipe the whole disk (took hours), not just the jeader. Then zpool replace zroot ada0 ada0p3 worked. It is now resilvering th right slice.

Many thanks to all.

Xavier
 
Back
Top