×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Using swap files located outside of / and /usr (Solaris 10)

    Solaris 10 upto and including Sol10u3 (and possibly later) don't mount swap files at boot that are located outside of the / and /usr filesystems if nfs/client is disabled.

    It's not always desirable to start nfs/client so we use an additional SMF service.

    Put this in /var/svc/manifest/system/filesystem/RKswap.xml (chmod it 444):-

    <?xml version="1.0"?>
    <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
    <!--
         Service to add additional swap files located outside of / and /usr at boot
    -->
    
    <service_bundle type='manifest' name='RKswap'>
    
    <service
            name='system/filesystem/RKswap'
            type='service'
            version='1'>
    
            <create_default_instance enabled='true' />
    
            <single_instance/>
    
            <dependency
                    name='single-user'
                    grouping='require_all'
                    restart_on='none'
                    type='service'>
                    <service_fmri value='svc:/milestone/single-user' />
            </dependency>
    
            <dependency
                    name='root'
                    grouping='require_all'
                    restart_on='none'
                    type='service'>
                    <service_fmri value='svc:/system/filesystem/local' />
            </dependency>
    
            <!--
              Start method timeout is infinite to handle potentially unbounded
              fsck times.
            -->
            <exec_method
                    type='method'
                    name='start'
                    exec='/lib/svc/method/RKswap'
                    timeout_seconds='30' />
    
            <exec_method
                    type='method'
                    name='stop'
                    exec=':true'
                    timeout_seconds='0' />
    
            <property_group name='startd' type='framework'>
                    <propval name='duration' type='astring' value='transient' />
            </property_group>
    
            <stability value='Unstable' />
    
            <template>
                    <common_name>
                            <loctext xml:lang='C'>
                                    Add additional swap outside of / and /usr filesystems
                            </loctext>
                    </common_name>
            </template>
    </service>
    
    </service_bundle>

    Then put the following at /lib/svc/method/RKswap (chmod it 555):-

    #!/sbin/sh
    #
    # Add additional 'swap files' located on filesystems other than / and /usr
    #
    # Gordon Johnston - 16/07/2007
    #
    
    . /lib/svc/share/smf_include.sh
    
    # swapadd -2 adds swap files that were not mounted by the call to swapadd in filesystem/fs-usr
    
    /sbin/swapadd -2
    
    exit $SMF_EXIT_OK
    

    Then import the service:-

    svccfg -v import /var/svc/manifest/system/filesystem/RKswap.xml
    

    Then you can enable and start the service with:-

    svcadm enable RKswap
    

    To remove the swap again use 'swap -d' using svcadm disable will not umount the swap, it will however prevent it from being used at the next boot.

    Don't forget to exclude the swap file from NetBackup!

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.