Saturday, November 10, 2012

Linux Swap Create Init Script

I use an SSD as my primary drive.  I used to have a swap partition on it (I know, bad idea on SSD) and it had probs w/ data corruption and the swap randomly being disabled.  Linux supports trim for SSDs, but trim won't do anything for swap that's always on a specific set of blocks in the SSD...

If we need swap space, but don't want it to always hit the same part of the SSD, we should be able to use a swap file in /tmp, allocating 2GB at boot. At least in Ubuntu, /tmp is cleaned up each boot, so when we create our swap file, trim has the opportunity to put the file on some fresh SSD sectors.

Here's the init script for this:


#!/bin/sh
#
# setup swap file init script
#

### BEGIN INIT INFO
# Provides:          atop
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Should-Start:      $local_fs
# Should-Stop:       $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Monitor for system resources and process activity
# Description:       Atop is an ASCII full-screen performance monitor,
#                    similar to the top command, but atop only shows
#                    the active system-resources and processes, and
#                    only shows the deviations since the previous
#                    interval.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
SWAPFILE=/tmp/swapfile
NAME=init_swap.sh
DESC="tmp swapfile creator"

case "$1" in
        start)
                echo -n "Starting $DESC: "
                if $0 status >/dev/null
                then
                        echo "    Already Running."
                        exit 0
                fi

                test -f ${SWAPFILE} && rm ${SWAPFILE}
                dd if=/dev/zero of=${SWAPFILE} bs=1M count=2048
                mkswap ${SWAPFILE}
                swapon ${SWAPFILE}
                echo "        Done."
                ;;
        stop)
                echo -n "Stopping $DESC: "
                $0 status >/dev/null && swapoff ${SWAPFILE}
                test -f ${SWAPFILE} && rm ${SWAPFILE}
                echo "        Done."
                exit 0
                ;;
        status)
                if swapon -s | grep -q ^/tmp/swapfile
                then
                        echo "Swap is enabled"
                        exit 0
                else
                        echo "Swap is not enabled"
                        exit 1
                fi
                ;;
        *)
                N=/etc/init.d/$NAME
                echo "Usage: $N {start|status}" >&2
                exit 1
                ;;
esac

exit 0



Thursday, October 25, 2012

Way cool dream about freedom of information...

I've had a few remarkable, vivid, dreams over the years.  This is one of them.

I find myself sitting in a college lecture hall, much like the old ones at Shasta College. There are two people up front, a man and a woman; I’m not sure which of them was actually the instructor. They seem more interested in each other than teaching and put on some music, using an iPod, that they want the class to listen to. It’s hard to hear and the class gets restless.

People in class start suggesting better things to listen to. I’m tired and slump down in my chair, half asleep. My friend Jon, sitting diagonally behind me says we should listen to something. I say lethargically that I can’t even hear him. He starts the song playing on his laptop.

As I glance over, I see the album cover on the screen and I’m pulled into the music!

I find myself on a floating airship, totally steam-punk style. It’s an elongated oval hewn from yellow wood, with two great propellers spinning underneath, one at each end, and the ship is probably fifteen feet long. Offset from the perimeter of the craft by a small walkway is a bookshelf that wraps most of the way around and is loaded with books facing outward. All of the ship’s wood paneling is carved with intricate symbols.

Listening to the music, I look into a gap between a couple of the books, and it seems that the shelf is forever deep, despite the ship only being a few feet across.

Glancing around, I see that there are four well dressed and well mannered fantasy creatures, each a different species having a variety of ears and humanoid/animal faces.

As the music plays, the creatures chatter about how the Marxists, the Librists, and the Serialists are no longer being persecuted and that they can finally return to society.


INTERPRETATION:

The school scene is symbolic of the poor state of our educational systems, or perhaps any social program that’s in place that perpetuates the state of our society. The teachers work to satisfy their flesh while they do a crappy job of feeding the class whatever the system has given them to teach.

The students represent society. They are fed so much BS through the schools and the media that, although they know that there’s a problem, most can’t figure out what to do about it.

The magnificence of the airship stands for a golden age that will come when information flows freely. The truth speaks for itself, and dysfunction cannot be hidden by bureaucracy. The books are the wealth of information that is unavailable to us.

The persecution is our world’s corporate and political attacks on free speech, whistle blowing (reform), and on file sharing.

The Marxists bring social change or reform. The Librists are keepers and sharers of knowledge. The Serialists are those who digitize and preserve information.

That the persecution is over gives me great hope!