zvol swap and fstab

i figured out how to do swap on a zvol but i'm currious if theres any special thing to adding it to the fstab file. I'm not sure how freebsd brings things up, in which order and if it will have a problem with adding /dev/zvol/pool/swap to fstab or not...anyone who knows more fill me in.
thanks
 
$ zfs set org.freebsd:swap=on pool/swap
and /etc/rc.d/zfs will enable swapping on that ZVOL
Code:
zfs_start_main() {
...
        # Enable swap on ZVOLs with property org.freebsd:swap=on.
        zfs list -H -o org.freebsd:swap,name -t volume | \
        while read state name; do
                case "${state}" in
                [oO][nN])
                        swapon /dev/zvol/${name}
                        ;;
                esac
        done
Also see, User Properties in zfs(8).
 
blah said:
$ zfs set org.freebsd:swap=on pool/swap
and /etc/rc.d/zfs will enable swapping on that ZVOL
Code:
zfs_start_main() {
...
        # Enable swap on ZVOLs with property org.freebsd:swap=on.
        zfs list -H -o org.freebsd:swap,name -t volume | \
        while read state name; do
                case "${state}" in
                [oO][nN])
                        swapon /dev/zvol/${name}
                        ;;
                esac
        done
Also see, User Properties in zfs(8).

so this is a one time command? kind of like how zfs remember all the mountpoints?

thanks
 
I've never been able to get the auto-mount/use for swap volumes via the rc.d script to work. Most likely, though, it's related to the order that the filesystems are mounted, and that /etc/fstab is read in relation to ZFS mount order. Never played with it much, though.

On our systems, I just add the following to /etc/rc.local, which gets run at the very end of the RC portion of the boot (for a zvol named swap):
Code:
swapon /dev/zvol/<poolname>/swap
 
wonslung said:
so this is a one time command?
Yep, unless you remove zfs_enable=YES from rc.conf so that zfs_start_main() won't be called. In that case you'll have to run swapon(8) on ZVOL manually.
 
one more thing...the command
Code:
$ zfs set org.freebsd:swap=on pool/swap

of my zvol is /dev/zvol/wonspool/swap would the command be
Code:
zfs set org.freebsd:swap=on /dev/zvol/wonspool/swap

i'm kind of confused about 2 parts.

i didn't think you ran swap on a normal zfs filesyste (pool/whatever) i thought it had to be a zvol with the /dev/zvol heading

the second thing i was confused about is the org.freebsd part...is that standard across all systems or is it supposed to be some kind of reverse hostname?


sorry, i know these are stupid questionms.
 
"pool/swap" is the name of the dataset, and the path to it on the zpool. Note the lack of a leading / in the name.

"/dev/zvol/pool/swap" is the path to the device node used to access the volume. Note the leading / in the name.

The difference is subtle, but makes a big difference. One is the logical location of the dataset in relation to the pool. The other is the "physical" or absolute location of the dataset in relation to the root of the filesystem.

When running zpool and zfs commands, you always use the logical name.

In your case, the correct command would be zfs set org.freebsd:swap=on wonspool/swap
 
phoenix said:
I've never been able to get the auto-mount/use for swap volumes via the rc.d script to work. Most likely, though, it's related to the order that the filesystems are mounted, and that /etc/fstab is read in relation to ZFS mount order. Never played with it much, though.

On our systems, I just add the following to /etc/rc.local, which gets run at the very end of the RC portion of the boot (for a zvol named swap):
Code:
swapon /dev/zvol/<poolname>/swap

Interesting ... just ran # zfs list -o org.freebsd:swap,name -t volume on my ZFS servers, and it seems that this property is not enabled on my swap volumes. Perhaps that's why it's not enabling it as swap at boot. I swear I enabled this way back when the servers were brought online, as the command is familiar, but maybe it didn't "stick". :)

Will have to try booting without my /etc/rc.local hack and see ...
 
Back
Top