Creating a gmirror swap

This is mostly a note to myself.

####

Edit: 2018.09.08 : If you see messages like this:

$ sudo gmirror insert swap /dev/da5p2
gmirror: Class not found

$ gmirror list -a
gmirror: Command 'list' not available.

You probably need to do this:

sudo kldload geom_mirror

####

I had these drives:

=>        34  9767541101  diskid/DISK-653DK7WBFS9A  GPT  (4.5T)
          34           6                            - free -  (3.0K)
          40        1024                         1  freebsd-boot  (512K)
        1064         984                            - free -  (492K)
        2048     8388608                         2  freebsd-swap  (4.0G)
     8390656  9758048256                         3  freebsd-zfs  (4.5T)
  9766438912     1102223                            - free -  (538M)

=>        40  9767541088  diskid/DISK-4725K6DVF57D  GPT  (4.5T)
          40        2008                            - free -  (1.0M)
        2048        1024                         1  freebsd-boot  (512K)
        3072        1024                            - free -  (512K)
        4096     8388608                         2  freebsd-swap  (4.0G)
     8392704  9758048256                         3  freebsd-zfs  (4.5T)
  9766440960     1100168                            - free -  (537M)

=>        40  9767541088  diskid/DISK-4725K6ECF57D  GPT  (4.5T)
          40        2008                            - free -  (1.0M)
        2048        1024                         1  freebsd-boot  (512K)
        3072        1024                            - free -  (512K)
        4096     8388608                         2  freebsd-swap  (4.0G)
     8392704  9758048256                         3  freebsd-zfs  (4.5T)
  9766440960     1100168                            - free -  (537M)

=>        40  9767541088  diskid/DISK-652FK58FFS9A  GPT  (4.5T)
          40        2008                            - free -  (1.0M)
        2048        1024                         1  freebsd-boot  (512K)
        3072        1024                            - free -  (512K)
        4096     8388608                         2  freebsd-swap  (4.0G)
     8392704  9758048256                         3  freebsd-zfs  (4.5T)
  9766440960     1100168                            - free -  (537M)

=>        40  9767541088  diskid/DISK-653BK12IFS9A  GPT  (4.5T)
          40        2008                            - free -  (1.0M)
        2048        1024                         1  freebsd-boot  (512K)
        3072        1024                            - free -  (512K)
        4096     8388608                         2  freebsd-swap  (4.0G)
     8392704  9758048256                         3  freebsd-zfs  (4.5T)
  9766440960     1100168                            - free -  (537M)

=>        40  9767541088  diskid/DISK-653EK93XFS9A  GPT  (4.5T)
          40        2008                            - free -  (1.0M)
        2048        1024                         1  freebsd-boot  (512K)
        3072        1024                            - free -  (512K)
        4096     8388608                         2  freebsd-swap  (4.0G)
     8392704  9758048256                         3  freebsd-zfs  (4.5T)
  9766440960     1100168                            - free -  (537M)

They are involved in this zpool:

[dan@slocum:~] $  zpool status
  pool: system
 state: ONLINE
  scan: scrub repaired 0 in 15h30m with 0 errors on Thu Jul 27 18:34:28 2017
config:

	NAME                            STATE     READ WRITE CKSUM
	system                          ONLINE       0     0     0
	  raidz2-0                      ONLINE       0     0     0
	    diskid/DISK-653BK12IFS9Ap3  ONLINE       0     0     0
	    diskid/DISK-4725K6DVF57Dp3  ONLINE       0     0     0
	    diskid/DISK-652FK58FFS9Ap3  ONLINE       0     0     0
	    diskid/DISK-653EK93XFS9Ap3  ONLINE       0     0     0
	    diskid/DISK-4725K6ECF57Dp3  ONLINE       0     0     0
	    diskid/DISK-653DK7WBFS9Ap3  ONLINE       0     0     0

errors: No known data errors
[dan@slocum:~] $ 

I decided to create a 6-way mirror for swap:

sudo gmirror label -v -b round-robin swap diskid/DISK-653DK7WBFS9Ap2

You will notice that the device named used corresponds to an item in the gpart show output but with p2 appended, as in partition 2. That is because partition 2 on each drive is my swap parition.

Then I added in each of the remaining drives, one at a time, but you can do them all on one line. For example:

sudo gmirror insert swap diskid/DISK-653BK12IFS9Ap2

At the end, I had this:

$ gmirror status
       Name    Status  Components
mirror/swap  DEGRADED  diskid/DISK-653DK7WBFS9Ap2 (ACTIVE)
                       diskid/DISK-4725K6DVF57Dp2 (ACTIVE)
                       diskid/DISK-652FK58FFS9Ap2 (ACTIVE)
                       diskid/DISK-653EK93XFS9Ap2 (ACTIVE)
                       diskid/DISK-4725K6ECF57Dp2 (ACTIVE)
                       diskid/DISK-653BK12IFS9Ap2 (SYNCHRONIZING, 11%)

I added this to /etc/fstab:

/dev/mirror/swap none swap sw         0 0

The swap in /dev/mirror/swap corresponds to the name specified in the initial gmirror label above.

The last step is to activate that swap:

[dan@slocum:~] $ sudo swapon -a
swapon: adding /dev/mirror/swap as swap device

[dan@slocum:~] $ swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/mirror/swap   4194300        0  4194300     0%

That activation is done automatically at boot time, as specified by the entry I added to /etc/fstab.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top