FreeBSD 9.1 and swap on zfs

James james at hicag.org
Tue Apr 9 20:34:49 UTC 2013


On Tue, Apr 9, 2013 at 10:05 AM, Volodymyr Kostyrko <c.kworr at gmail.com> wrote:

> Be sure to use -b prefer for that as when dump is written it goes to
> the first component. Man page is a bit outdated as we currently miss
> /etc/rc.early.

    Yes. rc.early hasn't worked in ages. But here's another way to do
    it. This assumes your swap mirror is called swap.

    /etc/rc.d/gmirror_savecore_pre:

    #!/bin/sh
    #
    # $Tilted$
    #

    # PROVIDE: gmirror_savecore_pre
    # BEFORE:  savecore
    # KEYWORD: nojail

    name='gmirror_savecore_pre'
    start_cmd='gmirror_savecore_pre_start'
    start_precmd='gmirror_savecore_pre_prestart'
    stop_cmd=':'

    gmirror_savecore_pre_prestart () {
        if ! gmirror status swap >/dev/null 2>&1; then
            debug 'No gmirror swap. Skipping.'
            return 1
        fi
        return 0
    }

    gmirror_savecore_pre_start () {
        gmirror configure -b prefer swap
    }

    load_rc_config $name
    run_rc_command "$1"

    /etc/rc.d/gmirror_savecore_post:

    #!/bin/sh
    #
    # $Tilted$
    #

    # PROVIDE: gmirror_savecore_post
    # REQUIRE: savecore
    # KEYWORD: nojail

    name='gmirror_savecore_post'
    start_cmd='gmirror_savecore_post_start'
    start_precmd='gmirror_savecore_post_prestart'
    stop_cmd=':'

    gmirror_savecore_post_prestart () {
        if ! gmirror status swap >/dev/null 2>&1; then
            debug 'No gmirror swap. Skipping.'
            return 1
        fi
        return 0
    }

    gmirror_savecore_post_start () {
        gmirror configure -b load swap
    }

    load_rc_config $name
    run_rc_command "$1"

    I would prefer swap on a zvol, but it doesn't appear ready yet. At
    this time I allocate a swap partition in the gpt of every disk and
    gmirror the first two. If a disk failure happens, or looks like it
    might, I can simply add one of the spares. It works well.

--
James.


More information about the freebsd-fs mailing list