Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 May 2022 01:18:03 +0300
From:      Christos Chatzaras <chris@cretaforce.gr>
To:        FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: ZFS replace a mirrored disk
Message-ID:  <B911CBE8-F384-4E94-99B4-A2D558CB7754@cretaforce.gr>
In-Reply-To: <20220511121422.baddv74m65xsbwmj@x1>
References:  <C46DD702-BED7-466F-986D-289A4A56DC4F@cretaforce.gr> <20220511121422.baddv74m65xsbwmj@x1>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_E0EC61B8-EC1C-4B88-80CA-64CAA297954D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii


> First please define "without success", what doesn't work?
>=20
> please paste output of:
>=20
> $> gpart show nvd1
>=20
> also, is it an UEFI system or classicla BIOS with GPT? What FreeBSD
> version?
>=20
> zpool replace zroot nvd0 is invalid, you should use:
>=20
> $> zpool replace zroot nvd1 nvd0 (but it uses the entire disk, which =
is
> probably incorrect too)



It's legacy BIOS with GPT.

What I want to do is "simulate" a disk failure and rebuild the RAID-1.

First I run these commands from the main OS:

------------------------

$> gpart show
=3D>        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)

=3D>        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


------------------------------


Then I boot with mfsBSD and run this command to "simulate" a disk =
failure:

$> gpart destroy -F nvd0


------------------------------


Then I boot again in main OS and I run these commands:

$> zpool status
  pool: zroot
 state: DEGRADED
status: One or more devices could not be used because the label is =
missing or
        invalid.  Sufficient replicas exist for the pool to continue
        functioning in a degraded state.
action: Replace the device using 'zpool replace'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4J
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       DEGRADED     0     0     0
          mirror-0  DEGRADED     0     0     0
            nvd0    UNAVAIL      0     0     0  invalid label
            nvd1p3  ONLINE       0     0     0

errors: No known data errors


$> gmirror status
       Name    Status  Components
mirror/swap  DEGRADED  nvd1p2 (ACTIVE)


------------------------------


Then I backup / restore the partitions:

$> gpart backup nvd1 | gpart restore -F nvd0

$> gpart show
=3D>        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)

=3D>        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)


------------------------------


Without doing a "gmirror forget swap" and "gmirror insert swap =
/dev/nvd0p2" I see that swap is already mirrored:

$> gmirror status
       Name    Status  Components
mirror/swap  COMPLETE  nvd1p2 (ACTIVE)
                       nvd0p2 (ACTIVE)

So first question is if the swap is mirrored automatically because nvd0 =
is the same disk (not replaced by a new disk).


-------------------------------


Then I write the bootloader:

$> gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 nvd0=20

--------------------------------


Then I want to add this disk to zpool but these commands don't do it:


$> zpool replace zroot nvd0
invalid vdev specification
use '-f' to override the following errors:
/dev/nvd0 is part of active pool 'zroot'


$> zpool replace -f zroot nvd0
invalid vdev specification
the following errors must be manually repaired:
/dev/nvd0 is part of active pool 'zroot'


-----------------------------------

Also these commands don't work:

$> zpool replace zroot nvd1 nvd0
invalid vdev specification
use '-f' to override the following errors:
/dev/nvd0 is part of active pool 'zroot'

$> zpool replace -f zroot nvd1 nvd0
invalid vdev specification
the following errors must be manually repaired:
/dev/nvd0 is part of active pool 'zroot'


-----------------------------------


Instead these commands work:

$> zpool offline zroot nvd0

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'.
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       DEGRADED     0     0     0
          mirror-0  DEGRADED     0     0     0
            nvd0    OFFLINE      0     0     0
            nvd1p3  ONLINE       0     0     0

errors: No known data errors


$> zpool online zroot nvd0


$> zpool status
  pool: zroot
 state: ONLINE
  scan: resilvered 5.55M in 00:00:00 with 0 errors on Thu May 12 =
00:22:13 2022
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


------------------------------------


The second question is if instead of "zpool replace zroot nvd0" I had to =
use "zpool offline zroot nvd0" and "zpool online zroot nvd0" because =
nvd0 is the same disk (not replaced by a new disk).

Also I notice that if I don't do "zpool offline zroot nvd0" and "zpool =
online zroot nvd0" , but do a server reboot instead then zpool =
automatically puts nvd0 online:

$> zpool status
  pool: zroot
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are =
unaffected.
action: Determine if the device needs to be replaced, and clear the =
errors
        using 'zpool clear' or replace the device with 'zpool replace'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P
  scan: resilvered 3.50M in 00:00:00 with 0 errors on Thu May 12 =
01:04:09 2022
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            nvd0p3  ONLINE       0     0     2
            nvd1p3  ONLINE       0     0     0

errors: No known data errors


$> zpool clear zroot

$> zpool status
  pool: zroot
 state: ONLINE
  scan: resilvered 3.50M in 00:00:00 with 0 errors on Thu May 12 =
01:04:09 2022
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



--Apple-Mail=_E0EC61B8-EC1C-4B88-80CA-64CAA297954D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D""><div><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D""><span style=3D"caret-color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: 400; letter-spacing: normal; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: =
none; float: none; display: inline !important;" class=3D"">First please =
define "without success", what doesn't work?</span><br =
style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: 400; =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><br =
style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: 400; =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><span =
style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: 400; =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; =
display: inline !important;" class=3D"">please paste output =
of:</span><br style=3D"caret-color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: 400; letter-spacing: normal; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: =
none;" class=3D""><br style=3D"caret-color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: 400; letter-spacing: normal; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: =
none;" class=3D""><span style=3D"caret-color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: 400; letter-spacing: normal; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: =
none; float: none; display: inline !important;" class=3D"">$&gt; gpart =
show nvd1</span><br style=3D"caret-color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: 400; letter-spacing: normal; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: =
none;" class=3D""><br style=3D"caret-color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: 400; letter-spacing: normal; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: =
none;" class=3D""><span style=3D"caret-color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: 400; letter-spacing: normal; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: =
none; float: none; display: inline !important;" class=3D"">also, is it =
an UEFI system or classicla BIOS with GPT? What FreeBSD</span><br =
style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: 400; =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><span =
style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: 400; =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; =
display: inline !important;" class=3D"">version?</span><br =
style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: 400; =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><br =
style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: 400; =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><span =
style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant-caps: normal; font-weight: 400; =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; =
display: inline !important;" class=3D"">zpool replace zroot nvd0 is =
invalid, you should use:</span><br style=3D"caret-color: rgb(0, 0, 0); =
font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: 400; letter-spacing: normal; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
text-decoration: none;" class=3D""><br style=3D"caret-color: rgb(0, 0, =
0); font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: 400; letter-spacing: normal; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
text-decoration: none;" class=3D""><span style=3D"caret-color: rgb(0, 0, =
0); font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: 400; letter-spacing: normal; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
text-decoration: none; float: none; display: inline !important;" =
class=3D"">$&gt; zpool replace zroot nvd1 nvd0 (but it uses the entire =
disk, which is</span><br style=3D"caret-color: rgb(0, 0, 0); =
font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: 400; letter-spacing: normal; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
text-decoration: none;" class=3D""><span style=3D"caret-color: rgb(0, 0, =
0); font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant-caps: normal; font-weight: 400; letter-spacing: normal; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
text-decoration: none; float: none; display: inline !important;" =
class=3D"">probably incorrect too)</span><br style=3D"caret-color: =
rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: =
normal; font-variant-caps: normal; font-weight: 400; letter-spacing: =
normal; text-align: start; text-indent: 0px; text-transform: none; =
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
text-decoration: none;" class=3D""></div></blockquote></div><br =
class=3D""><div class=3D""><br class=3D""></div><div class=3D""><br =
class=3D"">It's legacy BIOS with GPT.<br class=3D""><br class=3D"">What =
I want to do is "simulate" a disk failure and rebuild the RAID-1.<br =
class=3D""><br class=3D"">First I run these commands from the main =
OS:<br class=3D""><br class=3D"">------------------------<br =
class=3D""><br class=3D"">$&gt; gpart show<br class=3D"">=3D&gt;&nbsp; =
&nbsp; &nbsp; =
&nbsp;&nbsp;40&nbsp;&nbsp;7501476448&nbsp;&nbsp;nvd0&nbsp;&nbsp;GPT&nbsp;&=
nbsp;(3.5T)<br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;40&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;1024&nbsp;&nbsp; =
&nbsp;&nbsp;1&nbsp;&nbsp;freebsd-boot&nbsp;&nbsp;(512K)<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;1064&nbsp;&nbsp; &nbsp; =
&nbsp; &nbsp;&nbsp;984&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- free =
-&nbsp;&nbsp;(492K)<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;2048&nbsp; &nbsp;&nbsp;33554432&nbsp;&nbsp; =
&nbsp;&nbsp;2&nbsp;&nbsp;freebsd-swap&nbsp;&nbsp;(16G)<br =
class=3D"">&nbsp; &nbsp;&nbsp;33556480&nbsp;&nbsp;7467919360&nbsp;&nbsp; =
&nbsp;&nbsp;3&nbsp;&nbsp;freebsd-zfs&nbsp;&nbsp;(3.5T)<br =
class=3D"">&nbsp;&nbsp;7501475840&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;648&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- free =
-&nbsp;&nbsp;(324K)<br class=3D""><br class=3D"">=3D&gt;&nbsp; &nbsp; =
&nbsp; =
&nbsp;&nbsp;40&nbsp;&nbsp;7501476448&nbsp;&nbsp;nvd1&nbsp;&nbsp;GPT&nbsp;&=
nbsp;(3.5T)<br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;40&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;1024&nbsp;&nbsp; =
&nbsp;&nbsp;1&nbsp;&nbsp;freebsd-boot&nbsp;&nbsp;(512K)<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;1064&nbsp;&nbsp; &nbsp; =
&nbsp; &nbsp;&nbsp;984&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- free =
-&nbsp;&nbsp;(492K)<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;2048&nbsp; &nbsp;&nbsp;33554432&nbsp;&nbsp; =
&nbsp;&nbsp;2&nbsp;&nbsp;freebsd-swap&nbsp;&nbsp;(16G)<br =
class=3D"">&nbsp; &nbsp;&nbsp;33556480&nbsp;&nbsp;7467919360&nbsp;&nbsp; =
&nbsp;&nbsp;3&nbsp;&nbsp;freebsd-zfs&nbsp;&nbsp;(3.5T)<br =
class=3D"">&nbsp;&nbsp;7501475840&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;648&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- free =
-&nbsp;&nbsp;(324K)<br class=3D""><br class=3D""><br class=3D"">$&gt; =
zpool status<br class=3D"">&nbsp;&nbsp;pool: zroot<br =
class=3D"">&nbsp;state: ONLINE<br class=3D"">config:<br class=3D""><br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;NAME&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;STATE&nbsp;&nbsp; &nbsp;&nbsp;READ WRITE CKSUM<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;zroot&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br class=3D"">&nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;mirror-0&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd0p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd1p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D""><br class=3D"">errors: No known data errors<br class=3D""><br =
class=3D""><br class=3D"">------------------------------<br class=3D""><br=
 class=3D""><br class=3D"">Then I boot with mfsBSD and run this command =
to "simulate" a disk failure:<br class=3D""><br class=3D"">$&gt; gpart =
destroy -F nvd0<br class=3D""><br class=3D""><br =
class=3D"">------------------------------<br class=3D""><br class=3D""><br=
 class=3D"">Then I boot again in main OS and I run these commands:<br =
class=3D""><br class=3D"">$&gt; zpool status<br =
class=3D"">&nbsp;&nbsp;pool: zroot<br class=3D"">&nbsp;state: =
DEGRADED<br class=3D"">status: One or more devices could not be used =
because the label is missing or<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;invalid.&nbsp;&nbsp;Sufficient replicas exist for the pool =
to continue<br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;functioning =
in a degraded state.<br class=3D"">action: Replace the device using =
'zpool replace'.<br class=3D"">&nbsp; &nbsp;see: <a =
href=3D"https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4J" =
class=3D"">https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4J</a><br =
class=3D"">config:<br class=3D""><br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;NAME&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;STATE&nbsp;&nbsp; =
&nbsp;&nbsp;READ WRITE CKSUM<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;zroot&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;DEGRADED&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;mirror-0&nbsp;&nbsp;DEGRADED&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;nvd0&nbsp; =
&nbsp;&nbsp;UNAVAIL&nbsp; &nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp;invalid label<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd1p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D""><br class=3D"">errors: No known data errors<br class=3D""><br =
class=3D""><br class=3D"">$&gt; gmirror status<br class=3D"">&nbsp; =
&nbsp; &nbsp; &nbsp;Name&nbsp; =
&nbsp;&nbsp;Status&nbsp;&nbsp;Components<br =
class=3D"">mirror/swap&nbsp;&nbsp;DEGRADED&nbsp;&nbsp;nvd1p2 (ACTIVE)<br =
class=3D""><br class=3D""><br class=3D"">------------------------------<br=
 class=3D""><br class=3D""><br class=3D"">Then I backup / restore the =
partitions:<br class=3D""><br class=3D"">$&gt; gpart backup nvd1 | gpart =
restore -F nvd0<br class=3D""><br class=3D"">$&gt; gpart show<br =
class=3D"">=3D&gt;&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;40&nbsp;&nbsp;7501476448&nbsp;&nbsp;nvd1&nbsp;&nbsp;GPT&nbsp;&=
nbsp;(3.5T)<br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;40&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;1024&nbsp;&nbsp; =
&nbsp;&nbsp;1&nbsp;&nbsp;freebsd-boot&nbsp;&nbsp;(512K)<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;1064&nbsp;&nbsp; &nbsp; =
&nbsp; &nbsp;&nbsp;984&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- free =
-&nbsp;&nbsp;(492K)<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;2048&nbsp; &nbsp;&nbsp;33554432&nbsp;&nbsp; =
&nbsp;&nbsp;2&nbsp;&nbsp;freebsd-swap&nbsp;&nbsp;(16G)<br =
class=3D"">&nbsp; &nbsp;&nbsp;33556480&nbsp;&nbsp;7467919360&nbsp;&nbsp; =
&nbsp;&nbsp;3&nbsp;&nbsp;freebsd-zfs&nbsp;&nbsp;(3.5T)<br =
class=3D"">&nbsp;&nbsp;7501475840&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;648&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- free =
-&nbsp;&nbsp;(324K)<br class=3D""><br class=3D"">=3D&gt;&nbsp; &nbsp; =
&nbsp; =
&nbsp;&nbsp;40&nbsp;&nbsp;7501476448&nbsp;&nbsp;nvd0&nbsp;&nbsp;GPT&nbsp;&=
nbsp;(3.5T)<br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;40&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;1024&nbsp;&nbsp; =
&nbsp;&nbsp;1&nbsp;&nbsp;freebsd-boot&nbsp;&nbsp;(512K)<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;1064&nbsp;&nbsp; &nbsp; =
&nbsp; &nbsp;&nbsp;984&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- free =
-&nbsp;&nbsp;(492K)<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;2048&nbsp; &nbsp;&nbsp;33554432&nbsp;&nbsp; =
&nbsp;&nbsp;2&nbsp;&nbsp;freebsd-swap&nbsp;&nbsp;(16G)<br =
class=3D"">&nbsp; &nbsp;&nbsp;33556480&nbsp;&nbsp;7467919360&nbsp;&nbsp; =
&nbsp;&nbsp;3&nbsp;&nbsp;freebsd-zfs&nbsp;&nbsp;(3.5T)<br =
class=3D"">&nbsp;&nbsp;7501475840&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;648&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- free =
-&nbsp;&nbsp;(324K)<br class=3D""><br class=3D""><br =
class=3D"">------------------------------<br class=3D""><br class=3D""><br=
 class=3D"">Without doing a "gmirror forget swap" and "gmirror insert =
swap /dev/nvd0p2" I see that swap is already mirrored:<br class=3D""><br =
class=3D"">$&gt; gmirror status<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;Name&nbsp; &nbsp;&nbsp;Status&nbsp;&nbsp;Components<br =
class=3D"">mirror/swap&nbsp;&nbsp;COMPLETE&nbsp;&nbsp;nvd1p2 (ACTIVE)<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp;nvd0p2 (ACTIVE)<br class=3D""><br class=3D"">So=
 first question is if the swap is mirrored automatically because nvd0 is =
the same disk (not replaced by a new disk).<br class=3D""><br =
class=3D""><br class=3D"">-------------------------------<br =
class=3D""><br class=3D""><br class=3D"">Then I write the bootloader:<br =
class=3D""><br class=3D"">$&gt; gpart bootcode -b /boot/pmbr -p =
/boot/gptzfsboot -i 1 nvd0&nbsp;<br class=3D""><br =
class=3D"">--------------------------------<br class=3D""><br =
class=3D""><br class=3D"">Then I want to add this disk to zpool but =
these commands don't do it:<br class=3D""><br class=3D""><br =
class=3D"">$&gt; zpool replace zroot nvd0<br class=3D"">invalid vdev =
specification<br class=3D"">use '-f' to override the following =
errors:<br class=3D"">/dev/nvd0 is part of active pool 'zroot'<br =
class=3D""><br class=3D""><br class=3D"">$&gt; zpool replace -f zroot =
nvd0<br class=3D"">invalid vdev specification<br class=3D"">the =
following errors must be manually repaired:<br class=3D"">/dev/nvd0 is =
part of active pool 'zroot'<br class=3D""><br class=3D""><br =
class=3D"">-----------------------------------<br class=3D""><br =
class=3D"">Also these commands don't work:<br class=3D""><br =
class=3D"">$&gt; zpool replace zroot nvd1 nvd0<br class=3D"">invalid =
vdev specification<br class=3D"">use '-f' to override the following =
errors:<br class=3D"">/dev/nvd0 is part of active pool 'zroot'<br =
class=3D""><br class=3D"">$&gt; zpool replace -f zroot nvd1 nvd0<br =
class=3D"">invalid vdev specification<br class=3D"">the following errors =
must be manually repaired:<br class=3D"">/dev/nvd0 is part of active =
pool 'zroot'<br class=3D""><br class=3D""><br =
class=3D"">-----------------------------------<br class=3D""><br =
class=3D""><br class=3D"">Instead these commands work:<br class=3D""><br =
class=3D"">$&gt; zpool offline zroot nvd0<br class=3D""><br =
class=3D"">zpool status<br class=3D"">&nbsp;&nbsp;pool: zroot<br =
class=3D"">&nbsp;state: DEGRADED<br class=3D"">status: One or more =
devices has been taken offline by the administrator.<br class=3D"">&nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;Sufficient replicas exist for the pool to =
continue functioning in a<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;degraded state.<br class=3D"">action: Online the device =
using 'zpool online' or replace the device with<br class=3D"">&nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;'zpool replace'.<br class=3D"">config:<br =
class=3D""><br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;NAME&nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;STATE&nbsp;&nbsp; &nbsp;&nbsp;READ WRITE =
CKSUM<br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;zroot&nbsp;&nbsp; =
&nbsp; &nbsp;&nbsp;DEGRADED&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br class=3D"">&nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;mirror-0&nbsp;&nbsp;DEGRADED&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;nvd0&nbsp; =
&nbsp;&nbsp;OFFLINE&nbsp; &nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br class=3D"">&nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;nvd1p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; =
&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; =
&nbsp;&nbsp;0<br class=3D""><br class=3D"">errors: No known data =
errors<br class=3D""><br class=3D""><br class=3D"">$&gt; zpool online =
zroot nvd0<br class=3D""><br class=3D""><br class=3D"">$&gt; zpool =
status<br class=3D"">&nbsp;&nbsp;pool: zroot<br class=3D"">&nbsp;state: =
ONLINE<br class=3D"">&nbsp;&nbsp;scan: resilvered 5.55M in 00:00:00 with =
0 errors on Thu May 12 00:22:13 2022<br class=3D"">config:<br =
class=3D""><br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;NAME&nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;STATE&nbsp;&nbsp; &nbsp;&nbsp;READ WRITE =
CKSUM<br class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;zroot&nbsp;&nbsp; =
&nbsp; &nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br class=3D"">&nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;mirror-0&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd0p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd1p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D""><br class=3D"">errors: No known data errors<br class=3D""><br =
class=3D""><br class=3D"">------------------------------------</div><div =
class=3D""><br class=3D""><br class=3D"">The second question is if =
instead of "zpool replace zroot nvd0" I had to use "zpool offline zroot =
nvd0" and "zpool online zroot nvd0"&nbsp;because nvd0 is the same disk =
(not replaced by a new disk).<br class=3D""><br class=3D"">Also I notice =
that if I don't do "zpool offline zroot nvd0" and "zpool online zroot =
nvd0" , but do a server reboot instead then zpool&nbsp;automatically =
puts nvd0 online:<br class=3D""><br class=3D"">$&gt; zpool status<br =
class=3D"">&nbsp;&nbsp;pool: zroot<br class=3D"">&nbsp;state: ONLINE<br =
class=3D"">status: One or more devices has experienced an unrecoverable =
error.&nbsp;&nbsp;An<br class=3D"">&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;attempt was made to correct the =
error.&nbsp;&nbsp;Applications are unaffected.<br class=3D"">action: =
Determine if the device needs to be replaced, and clear the errors<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;using 'zpool clear' or =
replace the device with 'zpool replace'.<br class=3D"">&nbsp; &nbsp;see: =
<a href=3D"https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P" =
class=3D"">https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P</a><br =
class=3D"">&nbsp;&nbsp;scan: resilvered 3.50M in 00:00:00 with 0 errors =
on Thu May 12 01:04:09 2022<br class=3D"">config:<br class=3D""><br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;NAME&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;STATE&nbsp;&nbsp; &nbsp;&nbsp;READ WRITE CKSUM<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;zroot&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br class=3D"">&nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;mirror-0&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd0p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;2<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd1p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D""><br class=3D"">errors: No known data errors<br class=3D""><br =
class=3D""><br class=3D"">$&gt; zpool clear zroot<br class=3D""><br =
class=3D"">$&gt;&nbsp;zpool status<br class=3D"">&nbsp;&nbsp;pool: =
zroot<br class=3D"">&nbsp;state: ONLINE<br class=3D"">&nbsp;&nbsp;scan: =
resilvered 3.50M in 00:00:00 with 0 errors on Thu May 12 01:04:09 =
2022<br class=3D"">config:<br class=3D""><br class=3D"">&nbsp; &nbsp; =
&nbsp; &nbsp;&nbsp;NAME&nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;STATE&nbsp;&nbsp; &nbsp;&nbsp;READ WRITE CKSUM<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;zroot&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br class=3D"">&nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;mirror-0&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd0p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;&nbsp;nvd1p3&nbsp;&nbsp;ONLINE&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0&nbsp;&nbsp; &nbsp;&nbsp;0<br =
class=3D""><br class=3D"">errors: No known data errors<br class=3D""><br =
class=3D""><br class=3D""></div></body></html>=

--Apple-Mail=_E0EC61B8-EC1C-4B88-80CA-64CAA297954D--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B911CBE8-F384-4E94-99B4-A2D558CB7754>