
Solutions:
- Specify custom block device mapping during instance launch.
- Rebuild Ubuntu AMI (with automation).
Various ramblings of sysadmin, programmer, dancer, coffee snob, food lover and Winnipegger.

Most Linux distributions come with several (usually six) virtual consoles enabled by default. Think of it as having six terminal windows you can flip through using (CTRL)+ALT+F[1-6] keys. Sometimes you don't need or want to have that many TTYs. Let's say you have very little RAM, or want to shave a fraction of a second from your boot time, or simply want to strip all that isn't necessary from your installation. Here's how you do it in Ubuntu 10.04 Lucid Lynx.
Let's say you want to leave only two virtual consoles, tty1 and tty2. simply go to /etc/init/ directory and delete, or better yet move to safe location, files tty3.conf, tty4.conf, tty5.conf and tty6.conf
$ cd /etc/init/ $ sudo rm tty[3-6].conf
Next time you boot, only first two TTYs will be present. Note, that this will also shift your X session to where tty3 would normally be, so you can access it by typing ALT+F3 instead of ALT+F7.
There are many ways to achieve this, but this is probably the simplest since you most likely already have all the necessary components installed.
On Ubuntu it's the "shuf" command from "coreutils" package. It's original purpose is to shuffle the lines passed to it, or as its description says: "write a random permutation of the input lines to standard output". However, with one of the arguments you can limit the number of lines it returns, so if all you need is a single line from a given text file, juts run:
$ shuf –n 1 list.txt
where argument –n tells shuf to print only one random line from file list.txt
There are a lot of recipes out there on how to automatically login into a given Linux user's account on start up, but most of them rely on some sort of graphical environment or display manager to be present. It took me quite a bit of digging to find a way to auto login in Ubuntu with nothing but CLI. I'm sure others will find this tip useful.
To auto login user "bob" on first console terminal (tty1) edit file /etc/init/tty1.conf and replace last line:
exec /sbin/getty -8 38400 tty1
with this:
exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1
and Robert's your father's brother, next time you boot your machine bob will automatically log into his account on tty1.
If you ever tried to make Nagios web interface look a little nicer by adding some custom host or service icons, you have probably came across collections of icon packs at Nagios Exchange. You have also noticed an unusual .gd2 extension on some of the images and realized that without this format icons don't display properly on Status Map. I was doing exactly that the other day and couldn't find the icons I needed, so I ended up creating some myself. Here's how to convert a PNG image into .gd2 (GD Graphics Library format).
On Ubuntu install libgd-tools package, it will contain a pngtogd2 app. To convert file.png to file.gd2 use:
$ pngtogd2 file.png file.gd2 0 1
Once you have your .png or .gif and .gd2 images, I tend to use 40x40x8bit images with transparent background, place them in your /usr/local/nagios/share/images/logos/ directory (if you installed Nagios from source) and add these properties to your host or service definition:
define host{
...
icon_image ubuntu.png
statusmap_image ubuntu.gd2
...
}
There are three Munin plug-ins for Apache monitoring bundled with Ubuntu's munin-node package:
apache_accesses - monitors the number of accesses to Apache servers apache_processes - monitors the number of apache-processes running on the machine, and (in addition to a simple process count), separate then into "busy" or "idle" servers apache_volume - monitors the volume of data sent from Apache servers First of all, make sure that the libwww-perl package is installed on your system, or you might notice an error like this when you're executing these plug-ins directly from /usr/share/munin/plugins:
Can't locate object method "new" via package "LWP::UserAgent" at ./apache_volume line 127
In addition, apache_accesses and apache_volume require ExtendedStatus support to be enabled as well as mod_status module.
Status module can be enabled by running:
$ sudo a2enmod status $ sudo /etc/init.d/apache2 restart
To enable ExtendedStatus support create a /etc/apache2/conf.d/extendedstatus file containing the following directives:
<IfModule mod_status.c> ExtendedStatus On </IfModule>
Now create symbolic links to plug-ins in /etc/munin/plugins directory:
$ cd /etc/munin/plugins $ sudo ln -s /usr/share/munin/plugins/apache_accesses $ sudo ln -s /usr/share/munin/plugins/apache_processes $ sudo ln -s /usr/share/munin/plugins/apache_volume
Reload Apache and restart munin-node:
$ sudo /etc/init.d/apache2 reload $ sudo /etc/init.d/munin-node restart
My current favourite (and it seems almost everyone else's) Linux distro is Ubuntu. I use it on my home server, on virtual machines at work, I even carry it on my USB stick. I find that the easiest, and probably the fastest, way to download Ubuntu is via BitTorrent. Using BitTorrent to download Open Source software is also a nice way to show your appreciation - you reduce project's bandwidth costs and help creators to distribute their product. This is especially true during the stable release time, when everyone rushes to get the latest release and direct downloads slow down to a crawl. This is the perfect time to use P2P, since hundreds of people already have the file you want and are willing to share it with you.
BitTorrent is not a silver bullet, however. It's only good when the file you want is a popular one. For example here's a some tracker stats for two Ubuntu releases, 10.04 is a stable release from a couple months back and maverick is the latest alpha:
| File | Seeders | Leechers |
| ubuntu-10.04-dvd-i386.iso | 1391 | 123 |
| ubuntu-10.04-server-i386.iso | 968 | 20 |
| maverick-dvd-i386.iso | 8 | 5 |
| maverick-server-i386.iso | 10 | 0 |
Not a lot of people care about the alpha release, so there are very few seeders and leechers. Since number of peers is low, P2P download will be slow and you might be better off just downloading the file directly. In Ubuntu's case there is a better solution - zsync.
My little daughter loves to press buttons. Some of her favourite toys are my spare mouse and keyboard. I think she's going to be a computer geek, like her daddy. Unfortunately, my small headless Ubuntu server (and its glowing green power button) is also within her reach. Couple times during this week I've received a message from Monit that it was going down, a rare event, unless your kid just shutdown your entire server, again…
Fortunately, this problem is quite easy to fix. On Ubuntu and other Debians all you have to do is edit /etc/acpi/powerbtn.sh script (part of the acpid package) and comment out one line, like so:
#/sbin/shutdown -h now "Power button pressed"
This would prevent the triggered ACPI power button event from calling shutdown command.
Recently I had to create a video DVD iso image from a bunch .VOB files using Linux command line. I found this extensive tutorial on both how to create and burn an image file using command line. Here is a quick summary.
First, create VIDEO_TS and AUDIO_TS folders, if you don't already have them. Apparently some DVD players will not play a DVD if it doesn't have this particular directory structure.
In my case I had just .VOB, .IFO and .BUP files with no directory structure, so I copied all files to VIDEO_TS folder and left AUDIO_TS empty.
To create ISO I used a mkisofs command like so:
$ mkisofs -dvd-video -o mydvd.iso -udf /path/to/filedir/
Where "mydvd.iso" is the name of my future ISO file and "/path/to/filedir/" is the directory containing my VIDEO_TS and AUDIO_TS folders.
Just a little while later my ISO image file was ready. Just in case I checked to make sure that VIDEO_TS.IFO file had the lowest sector number like so:
$ isoinfo -i mydvd.iso -l
Now burn!
My choice BitTorrent client for headless Linux NAS server - Transmission has recently got a nice feature upgrade. Transmission already had most features you want from a BitTorrent client: encryption, a web interface, peer exchange, DHT, UPnP and NAT-PMP port forwarding, web seed support, watch directories, tracker editing, global and per-torrent speed limits, and more. Now it finally supports magnet links, and for users switching from Mac desktop client - the dearly missed "turtle mode" in Web UI!
These are my prettified notes on installing multi-site Drupal setup, using swiss army knife for all things Drupal - drush (DRUpal SHell) on Ubuntu 9.04 (Jaunty). This post will cover quick LAMP, CVS and phpMyAdmin installation and then show how easy it is to get latest stable Drupal, plus over a dozen of modules, up and running with drush. If you care, just follow along.
In my earlier post I have compared several BitTorrent clients for Linux and decided that Transmission was the best option for me.
In this series of posts I'll try to document installation and configuration of Transmission on my headless Ubuntu 9.04 NAS.
Transmission is already included in Ubuntu repository, in fact it's the default BT client for this distro, unfortunately the version in Jaunty (1.61) is a bit old and lacks a few useful new features such as DHT. Luckily, there was an up to date package (1.74) at Launchpad, and that's what I'm going to use.