Add Swap File to Amazon EC2 Instance

I’m playing around with a free-for-a-year micro instance of Amazon’s Elastic Compute Cloud (EC2), and I noticed that while there’s around 600 MB of memory, there was no swap set up! That can grind things to a halt pretty fast. So I set one up:

[root@tauceti ~]# free
total used free shared buffers cached
Mem: 605060 596996 8064 0 68568 440104
-/+ buffers/cache: 88324 516736
Swap: 0 0 0

[root@tauceti ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvde1 6190664 1344280 4531916 23% /
tmpfs 302528 0 302528 0% /dev/shm

[root@tauceti ~]# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 14.8886 s, 36.1 MB/s

[root@tauceti ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvde1 6190664 1870116 4006080 32% /
tmpfs 302528 0 302528 0% /dev/shm

[root@tauceti ~]# mkswap /swapfile1
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=767b5917-4ff4-453e-bb3a-db644a7a7824

[root@tauceti ~]# chown root:root /swapfile1
[root@tauceti ~]# chmod 0600 /swapfile1
[root@tauceti ~]# swapon /swapfile1
[root@tauceti ~]# echo '/swapfile1 swap swap defaults 0 0' >> /etc/fstab

[root@tauceti ~]# free
total used free shared buffers cached
Mem: 605060 597368 7692 0 68576 440104
-/+ buffers/cache: 88688 516372
Swap: 524280 0 524280

Network and Server Monitoring

One of my passions is automated monitoring and correction of network and server problems. I have the most experience with SiteScope (primarily a commercial website monitoring tool that has branched out to include protocols, application stacks, and whatever custom stuf you want) and Nagios, which is free and open source, and very very configurable.

I would LOVE to form a company implementing these or similar monitoring tools. I’ve done this a lot at work, and a little bit on the side for a few friends and their companies.

I’ve been looking around, and it seems that in addition to Nagios, two other contenders are Zenoss and Cacti. I’ve heard good things about Zenoss, specifically how it is easier to set up than Nagios. I think I may check it out, though I am a fan of Nagios’s flexibility.

Neat Linux tip

Lots of times I have a need to make a backup of a file or such that I end up forgetting about and it sits around taking up disk space. Sometimes in annoyance of this, I have simply skipped making the backup, and have been burned by it. Finally I came up with this alternative:

  1. Make a directory on your desktop called DeleteIn2Weeks. In my case, the full path was /home/guytonw/Desktop/DeleteIn2Weeks
  2. Create the following cron entries:
    0 1 * * * find /home/guytonw/Desktop/DeleteIn2Weeks -mtime +14 -type f -exec echo Deleting {} \;
    1 1 * * * find /home/guytonw/Desktop/DeleteIn2Weeks -mtime +14 -type f -exec rm {} \;

This is nice because any files put in there will automatically be swept away after a sufficient amount of time. (Hopefully I won’t need the backup after 2 weeks’ time!)

Capitalism vs Open Source

I bought a scanner back in 1999, a Plustek OpticPro 9636T. It worked fine in Windows 98. Unfortunately they did not make this model when Windows XP or 2000 were released, and therefore refused to make a driver for them. I believe it’s on the premise that they would rather people buy another scanner. Geez.

My last Windows 98 machine is almost dead, so I did what any self-respecting geek would do, I hooked it up to my Linux box. It did not work out of the box with Fedora Core 2 – I had to configure some “sane” (Scanner Access Now Easy) settings first, but lo and behold, it works great! You’d better believe I will not be buying another scanner simply because Plustek wants more of my money!