OPNsense Forum

English Forums => 25.7, 25.10 Series => Topic started by: justmehereinBrisbane on September 15, 2025, 07:29:15 AM

Title: How to add a hot spare to a GEOM Raid 1
Post by: justmehereinBrisbane on September 15, 2025, 07:29:15 AM
Hi

I have an up and running OPNSENSE system with the latest updates  with 2 x 240GB SSDS running in software GEOM raid 1

Is it possible to add a 3rd 240GB SSD to add as a hot spare that would kick in if one of the disks in the raid 1 was to fail?

Or do i have to do this at installation?

Thanking you

J

Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Patrick M. Hausen on September 15, 2025, 08:00:14 AM
A GEOM mirror? Really? Quite unusual. You are sure it's not ZFS? Please post the output of
gpart show
gmirror status
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: justmehereinBrisbane on September 15, 2025, 08:34:08 AM
Hi Patrick

Thank you for your response.


I can confirm it is ZFS as I am able to take snapshots.

gpart show
=>       40  500118112  ada0  GPT  (238G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528   16777216     3  freebsd-swap  (8.0G)
   17311744  482805760     4  freebsd-zfs  (230G)
  500117504        648        - free -  (324K)

=>       40  500118112  ada1  GPT  (238G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528   16777216     3  freebsd-swap  (8.0G)
   17311744  482805760     4  freebsd-zfs  (230G)
  500117504        648        - free -  (324K)

gmirror status produces no output

I have created a os-monit service called raid_check  path is /sbin/gmirror status tests is NonZeroStatus

This shows up in Monit status as

Program 'Raid_Check'
  status                       OK
  monitoring status            Monitored
  monitoring mode              active
  on reboot                    start
  last exit value              0
  last output                  -
  data collected               Mon, 15 Sep 2025 16:31:01



Hope all of this makes sense.

Cheers

J





Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Patrick M. Hausen on September 15, 2025, 09:05:52 AM
Now the output of this command please - you are running a ZFS mirror, not a GEOM one:

zpool status
And yes, you can add a hot spare with ZFS.
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: jade_nekotenshi on September 17, 2025, 04:49:10 PM
With a mirror, a three-way mirror almost makes more sense than a hot spare. Hot spares are more useful for RAIDZ/RAIDZ2.
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: justmehereinBrisbane on September 22, 2025, 07:47:04 AM
Hi Patrick

output of the command zpool status

 zpool status
  pool: zroot
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            ada0p4  ONLINE       0     0     0
            ada1p4  ONLINE       0     0     0

errors: No known data errors
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Patrick M. Hausen on September 22, 2025, 08:28:21 AM
OK, so what's it going to be - 3-way mirror or hotspare?
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: justmehereinBrisbane on September 23, 2025, 06:31:09 AM
Hi Patrick

Hotspare.  Can you tell me how to do this?

Thanking you

J
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Patrick M. Hausen on September 24, 2025, 11:26:39 AM
Sorry for the delay, I was traveling.

So last thing I need: "gpart show" output, please. With the new disk in place.
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: justmehereinBrisbane on September 27, 2025, 05:04:53 AM
 gpart show
=>       40  500118112  ada0  GPT  (238G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528   16777216     3  freebsd-swap  (8.0G)
   17311744  482805760     4  freebsd-zfs  (230G)
  500117504        648        - free -  (324K)

=>       40  500118112  ada1  GPT  (238G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528   16777216     3  freebsd-swap  (8.0G)
   17311744  482805760     4  freebsd-zfs  (230G)
  500117504        648        - free -  (324K)



new disk ada2 had a windows partition on it - so i removed it with the command gpart destroy -F ada2

ls /dev/ shows device ada2 present

thanking you
/
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Patrick M. Hausen on September 29, 2025, 03:43:23 PM
gpart backup ada0 | gpart restore ada2
zpool add zroot spare ada2p4
dd if=/dev/ada0p1 of=/dev/ada2p1 bs=1m
dd if=/dev/ada0p2 of=/dev/ada2p2 bs=1m

Do you want to mirror your swap space? Output of "swapinfo" will tell, but from our first tests with "gmirror" I guess it is not mirrored currently.
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Jose on September 29, 2025, 10:29:45 PM
Quote from: jade_nekotenshi on September 17, 2025, 04:49:10 PMWith a mirror, a three-way mirror almost makes more sense than a hot spare. Hot spares are more useful for RAIDZ/RAIDZ2.

+1 on this.

Also with a single ZFS disk, one can export the latest Boot Environment to a safe place, and can be later imported in case of disk failure and your back to a working order in minutes, and now with the Dashboard Snapshots one can easily update/upgrade with peace of mind ;)

OPNsense-System-Snapshots.png

👉 Been using OPNsense since v 16.x with Root On ZFS way before the initial ZFS installer script was made and I can tell its pretty solid stable.

Regards
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: justmehereinBrisbane on October 01, 2025, 09:39:45 AM
Quote from: Patrick M. Hausen on September 29, 2025, 03:43:23 PMHi Patrick - thank you so much for that - output of zpool status is now as below

zpool status
  pool: zroot
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            ada0p4  ONLINE       0     0     0
            ada1p4  ONLINE       0     0     0
        spares
          ada2p4    AVAIL

errors: No known data errors

a swapinfo results in below

swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/ada0p3       8388608        0  8388608     0%
/dev/ada1p3       8388608        0  8388608     0%
/dev/md98         2097152        0  2097152     0%
Total            18874368        0 18874368     0%


does this look like it is mirrored correctly?

Thanking you

J







Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Patrick M. Hausen on October 01, 2025, 09:44:14 AM
No, it's not mirrored. Do you want that?
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: justmehereinBrisbane on October 02, 2025, 09:44:54 AM
Hi Patrick

What is the benefits of having it mirrored?

Cheers


J
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Patrick M. Hausen on October 02, 2025, 11:49:50 AM
The system won't crash when one of the drives fails ;-)
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: justmehereinBrisbane on October 03, 2025, 02:22:03 AM
Hi Patrick

Well in that case - lets mirror the swap drive.

Thanking you for all your help so far! :)
Title: Re: How to add a hot spare to a GEOM Raid 1
Post by: Patrick M. Hausen on October 03, 2025, 12:57:01 PM
Quote from: justmehereinBrisbane on October 01, 2025, 09:39:45 AMswapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/ada0p3       8388608        0  8388608     0%
/dev/ada1p3       8388608        0  8388608     0%
/dev/md98         2097152        0  2097152     0%
Total            18874368        0 18874368     0%

First remove that swap file. It hurts more than it helps since you have "real" swap partitions.

Go to System > Settings > Miscellaneous and remove that check mark from "Add a 2 GB swap file to the system".

Then on a root shell:

swapoff -a
Edit the file /etc/fstab and remove these two lines:

/dev/ada0p3        none        swap    sw        0    0
/dev/ada1p3        none        swap    sw        0    0

Replace them with this one instead:

/dev/mirror/swap        none        swap    sw        0    0
Then these commands:

gmirror label -b round-robin swap ada0p3
gmirror configure -a swap
gmirror insert swap ada1p3
gmirror status
swapon -a
swapinfo

That should do it.