Other How to name partitions in geom_mirror as gpt/myswap1 instead of ada0p2?

I usually name the devices in the ZFS device pool like this:
Code:
        NAME                         STATE        READ WRITE CKSUM
        zpool                        ONLINE       0     0     0
          mirror-0                   ONLINE       0     0     0
            gpt/system_on disk1      ONLINE       0     0     0
            gpt/system_on_disk2      ONLINE       0     0     0
However, then I decided to mirror swap partitions with geom_mirror:
Code:
# gmirror label -v -b round-robin swap /dev/gpt/swap_on_disk1 /dev/gpt/swap_on_disk2
Metadata value stored on /dev/gpt/swap_on_disk1
Metadata value stored on /dev/gpt/swap_on_disk2
Done
# gmirror status
       Name    Status  Components
mirror/swap  COMPLETE  ada0p2 (ACTIVE)
                       ada1p2 (ACTIVE)
Done.

As you can see in the output of gmirror status command, the partitions are named ada0p2 instead of gpt/swap_on_disk1.

My /boot/loader.conf:
Code:
coretemp_load="YES"
geom_mirror_load="YES"
zfs_load="YES"

The following frequently recommended options did not help me at all:
  • kern.geom.label.disk_ident.enable="0" - after enabling geom_mirror for swap partitions, the /dev/diskid directory disappeared, even with kern.geom.label.disk_ident.enable="1".
  • kern.geom.label.gptid.enable="0" - Yes, the /dev/gptid path has disappeared, but it didn’t bother me before.
  • geom_label_enable="YES" - also did not affect the problem.
However, I have seen in a number of manuals that it is still possible to unambiguously name the sections of the mirror:

  1. Option with /dev/diskid/DISK-11111111: https://dan.langille.org/2017/07/28/creating-a-gmirror-swap/ In my case, using geom_mirror after a reboot makes the names of all zpool and geom_mirror sections look like this: ada0p2
  2. Option with /dev/gpt/swap0: https://www.ateamsystems.com/tech-blog/installing-freebsd-9-gmirror-gpt-partitions-raid-1/ As you already understand, this option does not work for me.
Q: As a result, I was unable to make unambiguous names for the partitions included in the ZFS device pool and the partitions included in the geom_mirror. I need either diskid/DISK-11111111 or gpt/my_patition, but not ada0p2
 
what is the value of kern.geom.label.gpt.enable? I'm assuming it's going to be 1.
if you do swapoff on the mirror/swap do you see /dev/gpt/swap_on_disk1? If swapon is enabled for that do you see /dev/gpt entries for swap?
Did you actually use gpart to label the swap partitions?

I'm not using geom_mirror on swap, but:
Code:
gpart show -l
=>       40  488397088  ada0  GPT  (233G)
         40       1024     1  gptboot0  [bootme]  (512K)
       1064        984        - free -  (492K)
       2048    4194304     2  swap0  (2.0G)
    4196352  484200448     3  zfs0  (231G)
  488396800        328        - free -  (164K)
 cat /etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass#
#/dev/ada0p2.eli                none    swap    sw                      0       0
#/dev/ada0p2            none    swap    sw                      0       0
/dev/gpt/swap0          none    swap    sw                      0       0
/dev/da0s1              /flash  msdosfs rw,noauto               0       0
/dev/da0                /flash1 msdosfs rw,noauto               0       0
fdesc                   /dev/fd fdescfs rw,noauto               0       0
proc                    /proc   procfs  rw,noauto               0       0
/dev/gpt/extdata        /extbackup      ufs rw,noasync,noauto   0       0
 swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/gpt/swap0    2097152        0  2097152     0%
 
  • Thanks
Reactions: dnb
A question if I may:
What advantage is there to mirroring swap?
Typically mirrors are used to provide data security and read performance and I'm having trouble understanding why that would be useful for swap.
 
  • Thanks
Reactions: dnb
I can't answer for the OP, why they do it, but here is a potential explanation:

RAID is used to improve availability, durability, and performance. Durability is the long-term survival of the data, availability is the short-term ability to read it. If the swap device fails, the OS would probably crash, or at least processes that need to be swapped back in would suffer errors or be terminated. In either case, a complete reboot would fix that. So mirroring swap would help keeping the current OS running and prevent reboots. Whether that's worth the investment of disk space and extra complexity depends on the situation.
 
  • Thanks
Reactions: dnb
Thanks ralphbsz all that makes sense if the workload creates swap usage. I was asking because it's been a very long time since I've had a FreeBSD system actually use any swap, and yes I recognize that my typical workloads don't require it.
 
what is the value of kern.geom.label.gpt.enable? I'm assuming it's going to be 1.
1
if you do swapoff on the mirror/swap do you see /dev/gpt/swap_on_disk1? If swapon is enabled for that do you see /dev/gpt entries for swap?
When geom_mirror is running, there are no swap entries in /dev/gpt, regardless of 'swapon /dev/mirror/swap' or 'swapoff /dev/mirror/swap'. However, if I destroy the mirror with the command 'gmirror destroy -fv swap', then entries will appear in /dev/gpt.
Did you actually use gpart to label the swap partitions?
Yes, definitely! I created the swap partition like this:
Code:
gpart add -a 4k -i 2 -l 11111111-swap -s 64G -t freebsd-swap /dev/diskid/DISK-11111111
A question if I may:
What advantage is there to mirroring swap?
Typically mirrors are used to provide data security and read performance and I'm having trouble understanding why that would be useful for swap.
It's just a type of redundancy. I saw that the installer offered this option, and I was wondering how this could be done manually, without the installer. And I repeated it manually exactly the same way the installer does it. Unfortunately, the installer also uses notations like ada0p2.
 
Thanks ralphbsz all that makes sense if the workload creates swap usage. I was asking because it's been a very long time since I've had a FreeBSD system actually use any swap, and yes I recognize that my typical workloads don't require it.
I decided to use swap because there are no obvious cons in my case, according to the following article:
 
I do not see so much problem gmirror component name being like /dev/ada0p2.
geom_mirror module reads the metadata on partitions and if it is written to be a component of gmirror, it imports the partition into gmirror. So, even if you move ada0 to ada1, geom_mirror then imports the partition ada1p2, not ada0p2.
 
  • Thanks
Reactions: dnb
When geom_mirror is running, there are no swap entries in /dev/gpt, regardless of 'swapon /dev/mirror/swap' or 'swapoff /dev/mirror/swap'. However, if I destroy the mirror with the command 'gmirror destroy -fv swap', then entries will appear in /dev/gpt.
So complete speculation on my part:
it sounds like gmirror finds the two partitions before anything else (basically what Hiroo Ono is saying) and ignores any gpart labels. That causes it to use the notation it found and then withers the others (why /dev/gpt doesn't show anything).
Can you force it otherwise? I don't know.
 
  • Thanks
Reactions: dnb
So complete speculation on my part:
it sounds like gmirror finds the two partitions before anything else (basically what Hiroo Ono is saying) and ignores any gpart labels. That causes it to use the notation it found and then withers the others (why /dev/gpt doesn't show anything).
Can you force it otherwise? I don't know.
In the second article we can see that gmirror status shows gpt/swap:
 
Ok, so if you destroy the gmirror, you see the labels in /dev/gpt, yes?
If you then create the gmirror with those labels, does gmirror status show the desired data (the labels rather than the partition)?
If you reboot, gmirror status then shows the partition instead of the label?

Is that a correct summary? The issue is only after a reboot?
If that is correct, then it seems like during the reboot, the swap mirror is getting rebuilt based on the partition information, so whatever is in the metadata could be pointing to that.
 
gmirror immediately after creation shows ada0p2-like symbols, although gtp/myswap was used when creating the mirror.
 
  • Like
Reactions: mer
As you can see in the output of gmirror status command, the partitions are named ada0p2 instead of gpt/swap_on_disk1.
You can use glabel(8) for labelization.

Code:
 $ gmirror status
        Name    Status  Components
mirror/swap   COMPLETE  label/swap_on_disk1 (ACTIVE)
                        label/swap_on_disk2 (ACTIVE)
 
  • Thanks
Reactions: dnb
You can use glabel(8) for labelization.

Code:
 $ gmirror status
        Name    Status  Components
mirror/swap   COMPLETE  label/swap_on_disk1 (ACTIVE)
                        label/swap_on_disk2 (ACTIVE)
Even before my swap partitions were added to geom_mirror, these partitions already had the necessary labels: gpt/swap_on_disk1 and gpt/swap_on_disk2. They had the correct labels from the start:

Code:
gpart add -a 4k -i 2 -l swap_on_disk1 -s 64G -t freebsd-swap /dev/diskid/DISK-11111111

But after using the command:
Code:
gmirror label -v -b round-robin swap gpt/swap_on_disk1 gpt/swap_on_disk2
these partitions disappear from /dev/gpt! And at the same time they turn into ada0p2 in the output of the gmirror status command. I think all this is absolutely normal behavior. Apparently this is done so that no one can operate with these partitions while they are in the mirror.

As stated above
none of this seems to be a problem.

But I would like to understand: why in this article
command:
Code:
gmirror label -h swap /dev/gpt/swap0 /dev/gpt/swap1
leads to this output:
Code:
gmirror status
mirror/swap COMPLETE gpt/swap1 (ACTIVE)
                        gpt/swap0 (ACTIVE)
But in my case, using the -h flag does nothing and the names change?
 
But in my case, using the -h flag does nothing and the names change?
No problem here (14.0-RELEASE-p6), except, apparently gmirror(8) 'label' accepts a limited number of characters in GPT labels.

For example, setting GPT label to 'swap_on_disk1' doesn't create a mirror at all on my test system. The command is executed without a error message, but no mirror is created.

gmirror01.png



There is no problem with short GPT labels (or long labels created by glabel(8) and mirror created without the gmirror(8) -h option). Also, the labels survive a reboot.

gmirror.png


On which FreeBSD version are you trying to create gmirrors? Have you tried short GPT labels?
 
  • Thanks
Reactions: dnb
No problem here (14.0-RELEASE-p6), except, apparently gmirror(8) 'label' accepts a limited number of characters in GPT labels.
Experimentally I was able to conclude that the maximum allowed number of characters after gpt/ is 11 characters. My system: FreeBSD 13.3.

I modified labels with the command:
Code:
gpart modify -l 2 swap0 -i 2 ada0
 
Back
Top