Unix

Unix is the next best thing since sliced bread. I've used it for a long time now (since 1985, on a PDP-11 running BSD 2.9). I prefer Linux these days, but honestly, I really don't care that much as long as it's some reasonable flavor of Unix.

Hacking: 

Linux

I like Linux. It's not the best thing since sliced bread, but you can't beat the price, and you get very good bang for your buck.

Not all (Fedora) kernels are created equal

Hacking: 

Gnome configs

This is a list and descriptions of configurations I do for my Gnome setup. It's not a whole lot, I generally try to stick to the system defaults as much as possible.

Gnome general  shortcuts

These are the shortcuts I modify:

  • Switch to workspace [1-10]: Ctrl-[1-0]
  • Switch to workspace on the {left, right, above, below}: Ctrl-{Left, Right, Up, Down}

Gnome Terminal

For Gnome terminal, I modify the following shortcuts:

  • Switch to {Previous, Next} Tab: <Alt>-{Left, Right}
  • Switch to Tab [1-9]: <Alt>-[1-9]

 

I create a new profile, Small, which I use Monospace 9 font for. The Default font size is one size larger, Monospace 10. I make sure to enable "Run command as a login shell".
 

OCZ Vertex SSDs

This is a quick overview of changes I make to my Linux system using the OCZ Vertex SSD disks (which I really like).

Change I/O scheduler

In rc.local (or something similar) add a line like

echo deadline > /sys/block/sda/queue/scheduler
echo 0 > /sys/block/sda/queue/rotational

or perhaps even better

echo noop > /sys/block/sda/queue/scheduler
echo 0 > /sys/block/sda/queue/rotational

Turn off "atime" in all mounts

Edit /etc/fstab, and change the mount options (usually default) and add the noatime option. This will prevent excessive writes due to reading the disk.

Move "logs" to a tmpfs disk

To avoid lots of writes on the disks due to log activity (which I usually have a fair amount of), move /var/log to a tmpfs partition. For example

tmpfs			/var/log	  tmpfs	size=1024m	0 0

Swapiness

The default "swap" behavior will move inactive applications to swap, after some time. You can avoid this by something like

echo 0 > /proc/sys/vm/swappiness

 Making filesystems

This is untested (by me at least). First you must clear the partition table

fdisk -H 32 -S 32 /dev/sdc
mkfs.ext4 -E stripe-width=128 /dev/sdc1

Use the 'o' command in fdisk to setup a new empty partition table. Now create a partition, it's recommended to skip the first cylinder (I don't know why, but it gurantees the alignment). Remember "linux" is partition code 83.

 

Alternatively, if you want to use the entire disk (no partitions), there's no reason to try to align things. Just drop the partition table, and use mkfs.ext4 as above with the entire disk (e.g. /dev/sdc).

Creating an ext4 fs without journaling

mkfs.ext4 -O ^has_journal /dev/sdc1

or

tune2fs -O ^has_journal /dev/sdc1

 

Enabling TRIM on Linux

This probably only works on fairly modern Linux versions:

/dev/sda1 / ext4 discard,defaults

Some links

I've flashed my OCZ drives pretty easily to v1.5. Make sure you follow the directions properly. Since I'm on Linux, I simply made a FreeDOS boot USB, and copied over all the flash .exe's to it. I have to run the SSDCHK.EXE manually (since I'm not using the autoexec.bat etc.).

Wiper.sh

This dangerous script is available with later versions of hdparm. With the appropriate firmware support (v1.5 supports it it seems), you can TRIM unused blocks in the SSD, to restore performance. The automatic garbage collection ought to do this for you, but I have no idea if/when you actually need to run wiper.sh manually. Definitely use on your own risk (I've only tried it once).

Tweaking XFCE

This is a collection of things I've tweaked during my transition from Gnome (because Gnome 3.0 is useless) to XFCE. This is still work in progress, but comments and feedback is much appreciated.

Terminal

The default terminal with XFCE has some weird behavior, and even though most of it can be tweaked in the GUI prefs, some can not. In particular, I made the following changes to ~/.config/Terminal/terminalrc:

MiscCursorBlinks=TRUE
MiscCursorShape=TERMINAL_CURSOR_SHAPE_BLOCK
ColorCursor=#0000aaaa0000

This allows me to better see the letter that the cursor is currently over. Note that I do green text on black background on all my Terminals, it's a habit from the VT100 days at the University in '85...

Taking snapshots

I have a fairly large amount of data (source code, DB dumps, docs etc.) that I keep on either my workstations or a file servers. I use software RAID on both systems, either mirroring (RAID1) or stripes+parity (RAID5), and that obviously saves me from fatal disk errors. But this doesn't prevent me from losing data when I'm a total moron, or some application goes bad.

So a while ago, using some favorite tools ([http://search.yahoo.com/|Yahoo search] obviously, for those of you who know me) I went out to see what was out there. I found this very [http://www.mikerubel.org/computers/rsync_snapshots/|informative article] on the topic. Doing some more searches, I then found a little nugget called [http://www.rsnapshot.org/|rsnapshot]. This tool pretty much automates everything necessary to perform hourly,daily, weekly, monthly or whatever type of snapshots you wish to do.

Configuring rsnapshot is pretty straight forward, and it comes with a good template configuration file that you can tune and tweak. It's assumed you have a recent version of rsync installed, and SSH properly setup and running if you are doing snapshots over the wire. I'll describe a few of the configurations that I've used. First off, you need to provide some basic information about how snapshot should behave, where to store snapshots etc. __Note__: this is for a Linux system:

{CODE()}
snapshot_root /export/.snapshots/
cmd_cp /bin/cp
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
link_dest 1
verbose 3
loglevel 3
{CODE}

Next we need to decide what types of snapshots we want, and what sort of retention to keep. I've decided to do daily, weekly and monthly snapshots only, keeping 6 daily, 3 weekl, 3 monthly snaps, 3 quarterly and 9 yearly (yeah ...).

{CODE()}
interval daily 6
interval weekly 3
interval monthly 3
interval quarterly 3
interval yearly 9
{CODE}

Finally, we need to specify which directories to make snapshots of, possibly from a remote server. In my case, I do snapshots over the network only, to keep all snapshots on a RAID5 device.

{CODE()}
# Workstation
backup root@ws1.ogre.com:/etc/ ws1/etc/ exclude_file=/admin/etc/ws1.exclude
backup root@ws1.ogre.com:/export/ ws1/export/ exclude_file=/admin/etc/ws1.exclude

# Web/mail server
backup root@s1.ogre.com:/etc/ s1/etc/ exclude_file=/admin/etc/s1.exclude
backup root@s1.ogre.com:/data/ s1/server/ exclude_file=/admin/etc/s1.exclude
{CODE}

This part of the configuration is a bit finicky, in particular, you have to use a <TAB> character between the destination directory (e.g. ws1/etc/) and any extra options you want to pass to rsync. Any <SPACE> characters will actually be part of the directory name, which was kind of a surprise to me.

With this all configured, you're pretty much set to go, just run rsnapshot out of your crontab at the desired frequency. In my case, since I do daily snapshots (and not hourly), I just added a daily cron job, like:

{CODE()}
#!/bin/sh

rsnap='/usr/local/bin/rsnapshot'

do_weekly=0
do_monthly=0
do_quarterly=0
do_yearly=0

wday_num=`/bin/date '+%u'`
if [ $wday_num -eq 7 ]; then
do_weekly=1
day_num=`/bin/date '+%d'`
if [ $day_num -ge 25 ]; then
do_monthly=1
m_num=`/bin/date '+%m'`
if [ $m_num -eq 3 -o $m_num -eq 6 -o $m_num -eq 9 -o $m_num -eq 12 ]; then
do_quarterly=1
fi
if [ $m_num -eq 12 ]; then
do_yearly=1
fi
fi
fi

if [ $do_yearly -eq 1 ]; then
echo "Saving yearly snapshot"
$rsnap yearly
fi
if [ $do_quarterly -eq 1 ]; then
echo "Saving quarterly snapshot"
$rsnap quarterly
fi
if [ $do_monthly -eq 1 ]; then
echo "Saving monthly snapshot"
$rsnap monthly
fi
if [ $do_weekly -eq 1 ]; then
echo "Saving weekly snapshot"
$rsnap weekly
fi

echo "Doing daily snapshot"
$rsnap daily
{CODE}

This will run daily snapshots Monday - Saturday, a weekly on Sundays, except on the last Sunday of the month I perform a monthly snapshot. I also NFS export my snapshot directory (/export/.snapshots), __read-only__, so that I can easily get to it from all my machines.

Hacking: 

Disk Recovery

Hacking: 

Dell Mini-9 netbook

This is my latest toy, and I figured I need a place to collect useful tips and links. I really like this thing, although, my unit might have a heat issue. I'll know more as I progress, but definitely keep an eye on your Dell mini-9. If the performance benchmarks aren't consistent, you should probably get it replaced.

Useful links

  • The MyDellMini sites have lots of useful information about the hardware, OSes etc. 
  • To test the performance, I installed and ran GeekBench. This little gem runs on Linux, Windows and MacOS X!
  • Official Dell site for the mini.

 

Ubuntu configuration changes

First off, and to my surprise, the SSD disk is mounted with default mount options. This, I believe, implies updating access timestamp. To avoid this, I changed the /etc/fstab entry, to include a -noatime option for the relevant disk partitions / mount points.

Secondly, it's my belief that SSD drives fare better with the NoOp scheduler. I added the following to my startup script:

echo noop > /sys/block/sda/queue/scheduler 

Finally, I've had to force some WiFi setting, in order for SSH (OpenSSH server and client) to work properly. I added the following to /etc/network/if-pre-up.d/wireless-tools

/sbin/iwpriv eth1 set_vlanmode 0

 

SSD cards

I (unfortunately) got the Super Talent 32GB SSD card, and although it works just fine, I wish I hadn't bought this. Instead, spend the extra $40 and get a RunCore 32GB card instead.

HTTP

I work with HTTP, a lot. Here's a few good links to useful information related to HTTP and TCP, primarily RFCs etc.

These are not directly related to HTTP, but nevertheless useful:

 

MacOSX

Some OS X command line utilities

I found a couple of useful page showing some handy OSX command line tricks;

Hacking: