Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 May 2022 17:06:58 -0700
From:      David Christensen <dpchrist@holgerdanske.com>
To:        questions@freebsd.org
Subject:   Re: ZFS replace a mirrored disk
Message-ID:  <45d910fe-6e85-9736-4224-89983a2d8dbd@holgerdanske.com>
In-Reply-To: <B911CBE8-F384-4E94-99B4-A2D558CB7754@cretaforce.gr>
References:  <C46DD702-BED7-466F-986D-289A4A56DC4F@cretaforce.gr> <20220511121422.baddv74m65xsbwmj@x1> <B911CBE8-F384-4E94-99B4-A2D558CB7754@cretaforce.gr>

next in thread | previous in thread | raw e-mail | index | archive | help
On 5/11/22 03:22, Christos Chatzaras wrote:
 > When a disk fails and want to replace it with a NEW disk ...

> On 5/11/22 05:14, Julien Cigar wrote:

>> please paste output of:
>>
>> $> gpart show nvd1
>>
>> also, is it an UEFI system or classicla BIOS with GPT? What FreeBSD
>> version?

> It's legacy BIOS with GPT.


Please post:

$ freebsd-version ; uname -a


> $> gpart show
> =>        40  7501476448  nvd0  GPT  (3.5T)
>            40        1024     1  freebsd-boot  (512K)
>          1064         984        - free -  (492K)
>          2048    33554432     2  freebsd-swap  (16G)
>      33556480  7467919360     3  freebsd-zfs  (3.5T)
>    7501475840         648        - free -  (324K)
> 
> =>        40  7501476448  nvd1  GPT  (3.5T)
>            40        1024     1  freebsd-boot  (512K)
>          1064         984        - free -  (492K)
>          2048    33554432     2  freebsd-swap  (16G)
>      33556480  7467919360     3  freebsd-zfs  (3.5T)
>    7501475840         648        - free -  (324K)
> 
> 
> $> zpool status
>    pool: zroot
>   state: ONLINE
> config:
> 
>          NAME        STATE     READ WRITE CKSUM
>          zroot       ONLINE       0     0     0
>            mirror-0  ONLINE       0     0     0
>              nvd0p3  ONLINE       0     0     0
>              nvd1p3  ONLINE       0     0     0
> 
> errors: No known data errors


Thank you for posting facts.


So, your OS is on two 4 TB NVMe drives with ZFS mirror boot, geom(8) 
mirror swap, and ZFS mirror root (?).


Was this arrangement created by the FreeBSD installer?


> Then I boot with mfsBSD and run this command to "simulate" a disk failure:
> 
> $> gpart destroy -F nvd0


> Then I backup / restore the partitions:
> 
> $> gpart backup nvd1 | gpart restore -F nvd0


Your "disk fails" simulation destroys (zeros?) the partition table on 
drive /dev/nvd0, but leaves the rest of the disk contents intact; 
including ZFS metadata, swap metadata, and data.  Also, drive permanent 
metadata is unchanged.  (Does ZFS use drive metadata?)


Your "replace it with a NEW disk" simulation dumps the partition table 
of nvd1 and restores it onto nvd0.  AIUI the net result is the same as 
re-imaging nvd0 from a pre-failure image.  I assume ZFS and geom are 
designed to detect and recover from this condition, so it just works.


If you do not have another 4 TB drive to play with, I would zero-fill or 
secure erase nvd0 to simulate "disk fails".  Figuring out how to recover 
from that is a better simulation of "When a disk fails and want to 
replace it with a NEW disk".


David



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45d910fe-6e85-9736-4224-89983a2d8dbd>