1 | #!/bin/bash
|
---|
2 | # Output lines suitable for sysctl configuration based
|
---|
3 | # on total amount of RAM on the system. The output
|
---|
4 | # will allow up to 50% of physical memory to be allocated
|
---|
5 | # into shared memory.
|
---|
6 |
|
---|
7 | # On Linux, you can use it as follows (as root):
|
---|
8 | #
|
---|
9 | # ./shmsetup >> /etc/sysctl.conf
|
---|
10 | # sysctl -p
|
---|
11 |
|
---|
12 | # Early FreeBSD versions do not support the sysconf interface
|
---|
13 | # used here. The exact version where this works hasn't
|
---|
14 | # been confirmed yet.
|
---|
15 |
|
---|
16 | page_size=`getconf PAGE_SIZE`
|
---|
17 | phys_pages=`getconf _PHYS_PAGES`
|
---|
18 |
|
---|
19 | if [ -z "$page_size" ]; then
|
---|
20 | echo Error: cannot determine page size
|
---|
21 | exit 1
|
---|
22 | fi
|
---|
23 |
|
---|
24 | if [ -z "$phys_pages" ]; then
|
---|
25 | echo Error: cannot determine number of memory pages
|
---|
26 | exit 2
|
---|
27 | fi
|
---|
28 |
|
---|
29 | shmall=`expr $phys_pages / 2`
|
---|
30 | shmmax=`expr $shmall \* $page_size`
|
---|
31 |
|
---|
32 | echo \# Maximum shared segment size in bytes
|
---|
33 | echo kernel.shmmax = $shmmax
|
---|
34 | echo \# Maximum number of shared memory segments in pages
|
---|
35 | echo kernel.shmall = $shmall
|
---|
36 |
|
---|