Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
77401d6a
Commit
77401d6a
authored
Jul 11, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system: add optional swap file for SSD; closes #1554
parent
286bbf65
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
5 deletions
+70
-5
plist
plist
+1
-0
rc
src/etc/rc
+1
-1
rc.swapon
src/etc/rc.swapon
+49
-0
system_advanced_misc.php
src/www/system_advanced_misc.php
+19
-4
No files found.
plist
View file @
77401d6a
...
...
@@ -126,6 +126,7 @@
/usr/local/etc/rc.restart_webgui
/usr/local/etc/rc.shutdown
/usr/local/etc/rc.sshd
/usr/local/etc/rc.swapon
/usr/local/etc/rc.syshook
/usr/local/etc/rc.syshook.d/05-beep.stop
/usr/local/etc/rc.syshook.d/05-update.early
...
...
src/etc/rc
View file @
77401d6a
...
...
@@ -203,7 +203,7 @@ rm -f /var/run/nologin
# set up and recover a crash dump before activating swap
/usr/local/etc/rc.crashdump
swapon
-a
/usr/local/etc/rc.swapon
# write /var/run/dmesg.boot
/etc/rc.d/dmesg onestart
...
...
src/etc/rc.swapon
0 → 100755
View file @
77401d6a
#!/bin/sh
# Copyright (c) 2017 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
SWAPUSE
=
$(
grep
-c
use_swap_file /conf/config.xml
)
SWAPFILE
=
/usr/swap0
SWAPSIZE
=
2048
SWAPDEV
=
md98
# auto-configured fstab entries:
swapon
-a
# swap file option for SSDs:
if
[
"
${
SWAPUSE
}
"
!=
"0"
]
;
then
if
[
!
-f
${
SWAPFILE
}
]
;
then
dd
if
=
/dev/zero
of
=
${
SWAPFILE
}
bs
=
1m
count
=
${
SWAPSIZE
}
chmod
0600
${
SWAPFILE
}
fi
if
mdconfig
-a
-t
vnode
-f
${
SWAPFILE
}
-u
${
SWAPDEV
}
;
then
swapon /dev/
${
SWAPDEV
}
fi
else
rm
-f
${
SWAPFILE
}
fi
src/www/system_advanced_misc.php
View file @
77401d6a
...
...
@@ -82,6 +82,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
/* if the old use_mfs_tmpvar is found, set these flags, too */
$pconfig
[
'use_mfs_var'
]
=
isset
(
$config
[
'system'
][
'use_mfs_tmpvar'
])
||
isset
(
$config
[
'system'
][
'use_mfs_var'
]);
$pconfig
[
'use_mfs_tmp'
]
=
isset
(
$config
[
'system'
][
'use_mfs_tmpvar'
])
||
isset
(
$config
[
'system'
][
'use_mfs_tmp'
]);
$pconfig
[
'use_swap_file'
]
=
isset
(
$config
[
'system'
][
'use_swap_file'
]);
$pconfig
[
'rrdbackup'
]
=
!
empty
(
$config
[
'system'
][
'rrdbackup'
])
?
$config
[
'system'
][
'rrdbackup'
]
:
null
;
$pconfig
[
'dhcpbackup'
]
=
!
empty
(
$config
[
'system'
][
'dhcpbackup'
])
?
$config
[
'system'
][
'dhcpbackup'
]
:
null
;
$pconfig
[
'netflowbackup'
]
=
!
empty
(
$config
[
'system'
][
'netflowbackup'
])
?
$config
[
'system'
][
'netflowbackup'
]
:
null
;
...
...
@@ -157,6 +158,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset
(
$config
[
'system'
][
'use_mfs_tmp'
]);
}
if
(
!
empty
(
$pconfig
[
'use_swap_file'
]))
{
/* set explicit value here in case we want to make it flexible */
$config
[
'system'
][
'use_swap_file'
]
=
2048
;
}
elseif
(
isset
(
$config
[
'system'
][
'use_swap_file'
]))
{
unset
(
$config
[
'system'
][
'use_swap_file'
]);
}
if
(
!
empty
(
$pconfig
[
'rrdbackup'
]))
{
$config
[
'system'
][
'rrdbackup'
]
=
$pconfig
[
'rrdbackup'
];
}
elseif
(
isset
(
$config
[
'system'
][
'rrdbackup'
]))
{
...
...
@@ -449,7 +457,14 @@ include("head.inc");
</td>
</tr>
<tr>
<th
colspan=
"2"
valign=
"top"
class=
"listtopic"
>
<?=
gettext
(
"RAM Disk Settings (Reboot to Apply Changes)"
);
?>
</th>
<th
colspan=
"2"
valign=
"top"
class=
"listtopic"
>
<?=
gettext
(
"Disk / Memory Settings (reboot to apply changes)"
);
?>
</th>
</tr>
<tr>
<td><i
class=
"fa fa-info-circle text-muted"
></i>
<?=
gettext
(
'Swap file'
);
?>
</td>
<td>
<input
name=
"use_swap_file"
type=
"checkbox"
id=
"use_swap_file"
value=
"yes"
<?=
!
empty
(
$pconfig
[
'use_swap_file'
])
?
'checked="checked"'
:
''
;
?>
/>
<strong>
<?=
gettext
(
'Add a 2 GB swap file to the system'
)
?>
</strong>
</td>
</tr>
<tr>
<td><a
id=
"help_for_use_mfs_var"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
'/var RAM disk'
);
?>
</td>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment