A script to start and stop ramdisks in the Solaris OS

Version 4 by kperkins
on Nov 24, 2008 07:16.

compared with
Current by bnsmb
on Nov 08, 2009 05:30.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (43)

View page history

by Bernd Schemmer, November 2008

Homepage: [http://www.bnsmb.de/]

*Table of contents*
{toc}
*Note:*
Although the script provides a function to backup the data from the ramdisk to another filesystem you should not rely
on this feature for important data\! In case of a machine crash or after executing the _halt_ command no stop scripts
will be executed and all data on the ramdisks are lost\!
h2. Scope
This article only describes the script and the usage of the script - it does not discuss the concept of a ramdisk in general.
For a more indepth article about the various ramdisk types in the Solaris OS see the article [Talking about /tmp and RAM disks in the Solaris OS|http://wikis.sun.com/display/BigAdmin/Talking+about+RAM+disks+in+the+Solaris+OS].
disks in the Solaris|http://wikis.sun.com/display/BigAdmin/Talking+about+RAM+disks+in+the+Solaris+OS].

h2. Prerequisites
h2. The script
{code}#!/bin/sh
#!/bin/sh
## --------------------------------------------------------------------------------
##
h3. Script Usage
{code}
{code}bash-3.00# /usr/bin/startstop_ramdisk
startstop_ramdisk: Usage: startstop_ramdisk [help|start|stop|status|viewconfig|backup {backupdir}]
{code}
{code}{*}Note:* To get a verbose help text use the parameter *help*. 

h2. The config file for the script

Examples:
|| Scriptname \\ || Config file \\ ||
| /etc/rcS.d/S99ramdisk1 | /etc/ramdisk1.conf |
| /etc/rc3.d/K01ramdisk1 | /etc/ramdisk1.conf |
| /etc/rcS.d/S99ramdisk2 | /etc/ramdisk2.conf \\ |
| /usr/bin/ramdisk1 | /etc/ramdisk1.conf |
| /usr/sbin/startstop_ramdisk \\ | /etc/startstop_ramdisk.conf |
h3. Sample config file for the script
{code}
{code}#               --- configuration starts ----

# name of the ramdisk (see ramdiskadm(1m) for valid names)
h2. Usage example 1 - manually creating and destroying a ramdisk
{noformat}
# {noformat}# the ramdisk is not yet defined:
#
bash-3.00# /usr/sbin/startstop_ramdisk status

First create the necessary links in the /etc/rc\* directories:
{code}
{code}ln -s /etc/rc3.d/S02ramdisk1 /usr/sbin/startstop_ramdisk
ln -s /etc/rc3.d/S02ramdisk2 /usr/sbin/startstop_ramdisk
ln -s /etc/rc2.d/K01ramdisk2 /usr/sbin/startstop_ramdisk
{code}
{code}Next create the config files for the ramdisks, e.g.:
{noformat}
{noformat}bash-3.00# cat /etc/ramdisk1.conf
RAMDISK_NAME="ramdisk1"
RAMDISK_SIZE="40m"
BACKUP_LOGFILE="/var/log/${BASENAME}.backup.log"
 
{noformat}
{noformat}That's all. Now two ramdisks, ramdisk1 and ramdisk2, will be created after each reboot:
{noformat}
{noformat}bash-3.00#  ramdiskadm
Block Device                                                  Size  Removable
/dev/ramdisk/ramdisk1                                     41943040    Yes
/ramdisk2 on /dev/ramdisk/ramdisk2 read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=1180002 on Fri Nov 21 19:36:41 2008
{noformat}
{noformat}In Solaris 10 you can view the log of the startup scripts in the approbate log file for the milestone; for the scripts in /etc/rc3.d this is the file /var/svc/log/milestone-multi-user-server:default.log:
{noformat}
{noformat}bash-3.00# cat /var/svc/log/milestone-multi-user-server:default.log

...

In case of an unexpected behaviour of the script, execute the script in verbose mode, e.g.:
{code}VERBOSE=0 /usr/bin/startstop_ramdisk start
{code}
VERBOSE=0 /usr/bin/startstop_ramdisk start
{code}

h2. How to check if the backup of the ramdisk was successfull

Check the logfile for the backup of the ramdisk. The logfile is created in the directory */var/log*; the name of the log file  is:
{code}{scriptname}.backup.log
{code}
{scriptname}.backup.log
{code}

h2. How to view the configuration for a ramdisk

Call the script with the parameter *viewconfig*, e.g:
{noformat}
{noformat}bash-3.00# /etc/rcS.d/K01ramdisk2 viewconfig
K01ramdisk2: Config file "/etc/ramdisk2.conf" found - now reading it ...
K01ramdisk2: The configuration of the ramdisk "ramdisk2" is:

Call the script with the parameter  *backup \{backup_directory\}*, where \{backup_directory} is the name of the directory for the files from the ramdisk, e.g.:
{code}
{code}bash-3.00# /etc/rcS.d/K01ramdisk2 backup /var/tmp/ramdisk2_tempbackup
K01ramdisk2: Config file "/etc/ramdisk2.conf" found - now reading it ...
K01ramdisk2: Backing up the data from the ramdisk "ramdisk2" ...

Call the script with the parameter *backup*, e.g.:
{code}
{code}bash-3.00# /etc/rcS.d/K01ramdisk2 backup
K01ramdisk2: Config file "/etc/ramdisk2.conf" found - now reading it ...
K01ramdisk2: Backing up the data from the ramdisk "ramdisk2" ...

{code}
 
\\
{column}

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact