Solved gmirror swap doesn't boot

Every time, I enable gmirror swap, the system doesn't boot, when I enable it manually it doesn't complain and works fine?

Code:
% gpart show
=>  34  3907029101  ada0  GPT  (1.8T)
  34  6  - free -  (3.0K)
  40  1024  1  freebsd-boot  (512K)
  1064  4194304  2  freebsd-swap  (2.0G)
  4195368  3902833760  3  freebsd-zfs  (1.8T)
  3907029128  7  - free -  (3.5K)

=>  34  3907029101  ada1  GPT  (1.8T)
  34  6  - free -  (3.0K)
  40  1024  1  freebsd-boot  (512K)
  1064  4194304  2  freebsd-swap  (2.0G)
  4195368  3902833760  3  freebsd-zfs  (1.8T)
  3907029128  7  - free -  (3.5K)

Code:
% cat /etc/fstab
# Device       Mountpoint   FStype     Options   Dump   Pass#
/dev/mirror/swap     none     swap     sw   0   0
fdesc         /dev/fd     fdescfs     rw   0   0
Code:
% gmirror status
  Name  Status  Components
mirror/swap  COMPLETE  ada0p2 (ACTIVE)
  ada1p2 (ACTIVE)
 
Labeling your swap partitions may help with consistency between boots. Also, encrypting swap is a good idea.
Code:
# gmirror destroy swap
# gpart modify -l swap0 -i 2 ada0
# gpart modify -l swap1 -i 2 ada1
# gmirror label -F -h -b round-robin swap /dev/gpt/swap0 /dev/gpt/swap1
New /etc/fstab:
Code:
# Device Mountpoint FStype Options Dump Pass#

/dev/mirror/swap.eli none swap sw 0 0

fdesc /dev/fd fdescfs rw 0 0
 
gpart(8) does not have a label subcommand, it would be
gpart modify -l swap0 -i2 ada0
gpart modify -l swap1 -i2 ada1

The gmirror command is missing a name for the new mirror.
 
And how would you introduce encryption to that swap? Isn't it useless since there isn't any disk encryption? Or is it a self generating key which changes each boot and is stored in real RAM?
 
So for me, that would be:
Code:
/dev/mirror/swap.eli  none  swap  sw  0  0
Yes, Like in my previous example.

If you'd like a stronger key or a different encryption algorithm than the defaults (AES-XTS, 128) you can set it according to geli(8), like so:

Code:
/dev/mirror/swap.eli       none                    swap    sw,ealgo=Blowfish-CBC,keylen=448      0       0

Encrypting swap is not really useless in the absence of disk encryption, since it may contain personal information that was only stored in memory, including keys, user-names and passwords, which can be easily recovered from the disk. Since it's painless to implement in FreeBSD, I don't see any reason not to do it.
 
Back
Top