(cons 'geek 'culture)

Cutting edge culture for geeks...

Thursday, August 23, 2007

A Quick Hack to Convert m4a to mp3 in Linux

As I was getting ready for my eight hour car trip back to MTU, I wanted some music to ease the pain of the long trip. I do not own a portable MP3 player, so everything I wanted was going to have to be burned to an audio CD (I use GnomeBaker to do this). The only issue was, most of my Pink Floyd music was in M4A format, and GnomeBaker only handles OGG/MP3 for inclusion in an audio CD. So without further ado, here is the code for the bash script I wrote to convert M4A's to MP3:


#!/bin/bash

for i in *.m4a; do
  faad -o - "$i" lame - "${i%.m4a}.mp3"
done


After this ran, I also executed a rm *m4a. Enjoy!

Labels: , ,

Saturday, August 18, 2007

The Practical Linux Desktop Part 2: Software

So now that you have your new desktop built, the next major question is what Linux distro should you choose to install? I will cover this, as well as some of my favorite desktop software below.

Choosing a Distro

The two major distros vying for desktop domianience these days are Ubuntu and Fedora. Both have their strengths and weaknesses. Ubuntu seems to be the choice for users that are completly new to Linux (usually coming from a Windows background). It is easy to install, and Ubuntu 7.01 has a nifty script that autodetects most hardware and installs the approprate drivers (even nonfree drivers, so beware!). The other nice thing about Ubuntu is the community is aware of its stance as a "Distro for newbies", and takes pride in their motto: "Linux for Human Beings".

On the other hand, you have my personal favorite, Fedora. Fedora is sponsered by Red Hat, which gives it a unique advantage over several other Linux projects: it has strong and steady cash flow. Fedora is all about showcasing cutting edge open source software. This means that open applications will be installed by default, and as such it can pose a few issues for complete Linux newbies, even so, it is still considered by many to be "newbie friendly". I have chose Fedora to install on my desktop systems because of ease of installation and the cutting edge open source software that is always included.

The Next Step

After you've chosen a distro and installed, you will usually have some work left to do. If you have an Nvidia card, make sure you install the proper drivers (in Fedora):

yum --enable-repo=livna install kmod-nvida


After this, you can enable such things as Beryl or Compiz. I personally use VLC to view videos, Rhythembox for music playback, Firefox for web browsing, Miro for Internet TV, and Evolution for email (many people prefer Thunderbird). Many of these programs are already in the distro repositories, therefore you can just use the package manager to install them if they are not already installed.

Programming

If you are a programmer, Linux is definitely the best OS for you in terms of practicality. Many languages are included with the install (Perl, Python, bash, C, C++), and most others are trival to install. The main issue of note here is that installing Java has been an ordeal, however, the Java VM included with Fedora 8 called Iced Tea will be an OpenJDK implementation included in the main repository (hopefully). This will be a huge relief to many Java on Linux programmers.

More Multimedia

Multimedia is huge these days, and of course you should expect it to be a huge part of your desktop environmet. Many detrators of Linux try to bash its seemingly low quality support for multimedia. As a long term Linux user, I can tell you that multimedia support under Linux has improved dramitically and with increasing rapidity over the last few years. I use Fspot for my digital camera and photo management, GnomeBaker for audio CD burning, mencoder for DVD ripping (XDVDShrink works just as well, and has a GUI), dvdauthor to create DVDs, Audicity to create audio, and Cinelerra to create and edit movies. Installing all of these programs is fairly trivial in both Ubuntu and Fedora.

Final Thoughts
So that's it! The next step? Enjoy your powerful new Linux desktop!

Labels: , , ,

Wednesday, August 15, 2007

A Practical Linux Desktop Part 1: Hardware

Every year, the Linux Magazine does an article on the "Ultimate Linux Box", and they include all of the latest and greatest hardware, as well as rate how well it works with Linux. The price tags on these boxes are generally out of my price range, and I can only assume out of the price range of many a poor college student like myself.

So in my next two posts, I will show you how to build a great Linux machine for under $1000 (this includes the price for a monitor), and what distros you will want to consider along with instructions for setting up some useful applications.

Getting Started
To start out, I will list my system's specs. I purchased this box back in January 2007.


  • Processor: AMD X2 4200+ (2x2.2GHZ)
  • Motherboard: Asus M2N (Socket AM2)
  • Video Card: EVGA Nvidia 7600GS
  • RAM: 1GB PQi DDR2 800
  • HDD: WD SATA2 80GB
  • Optical Drive: LG 18x CD+-RW/DVD+-RW
  • PSU: Logisys 575W
  • Case: Cooler Master Centurion 5

This cost me ~$650 at the time. Currently, you could buy a comparable system for ~$450-$500.

Let's take a deeper look at what kinds of hardware makes the most practical Linux desktop by starting with considering some tasks you will most likely want your desktop to preform. Chances are, you will want to do video editing, word processing and other office tasks, play games, store your data, as well as play and possibly edit your music.

Processor

The first thing you will want to budget for is a processor. I chose the AMD X2 4200+ because I believe it offers me the best price/performance ratio. At under $100, this processor offers plenty of power as a mid-level dual core, not to mention that the stock heatsink and fan is great. AMD processors usually get a bad rap for being power hungry and running hot, however, I believe they still have the best mid-entry dual cores for the price (newegg.com shows the AMD X2 3800+ 2.0GHZ at $65 and the Intel Core 2 Duo E4400 2.0GHZ at $125.99). This leads me to conclude that AMD is in fact the better processor manufacturer for our practical Linux box.

Video

For several years now Linux users have been waiting with bated breath to see which of the two major video card manufacturers (ATi and Nvidia) will have better support for Linux users. Unfortunately, neither company offers an open source driver solution, although at the time of writing, Intel integrated graphics do use open drivers. For the last few years, Nvidia has won out in terms of better support for Linux users, their drivers work and are included in all major distro repositories. While ATi does have drivers that are also included in most repositories for major distros (the fglrx driver), this is always far behind the times and never seems to work on recent hardware reliably. For example, I have had my ATi Radeon Xpress 200M for over two years and just got direct rendering working a few months ago (it is broken again with a new Xorg update).

For these reasons, I chose to purchase Nvidia. For a practical desktop, we don't need the latest, most powerful GPU, so once again I opted for the mid-level 7600GS that would accomplish all the tasks I need it to. The Nvidia driver for the 7600GS is fully supported with Linux, and it is a breeze to set up (as you will see in the next part).

Storage

I chose an 80GB SATA drive for storage, however I had tight price restrictions. I would suggest at least a 250GB drive, or perhaps a 2 disk RAID1.

Conclusions

Hopefully these tips have helped you realize that a practical Linux box can be powerful as well as... practical! Not to mention easily fitting in your budget. In the next part we well look at how to set up Linux and install all the useful applications and games for you to get the most out of your new hardware.

Labels: , ,

Saturday, August 11, 2007

LVM vs. Mass Storage Device

My desktop has a 80GB hard drive. In this day and age, for most people that just doesn't cut it. I had been planning on upgrading my storage space as soon as possible, and with the advent of a new school semester I have enough extra loan money to consider this.

My first thought when I built my desktop back in January was that I would RAID four SATA 80GB disks. At the time, I only had enough money to purchase one drive. After researching RAID a little more, I came to the conclusion that it would be a little too complicated for me. I'm not worried about data redundancy and disk parity for my desktop, and a simpler RAID (such as RAID0 or RAID1) just didn't seem worth the headache of setting it up. Not to mention the cost of buying another three 80GB drives.

A more recent thought was to purchase a large drive (such as a 250GB drive) and use LVM2 to span both devices, allowing me to essentially use the larger drive as an extension to my /home. This idea seemed very appealing to me until I realized that in order to use LVM2 on the large drive I had to install an OS on it. I had decided that the primary purpose of this drive would be to store movies, music, and a backup of my /home, so doing more than formatting it with a filesystem seemed a little excessive.

I have arrived to a solution that I think works out for the best. I will purchase an this internal 250GB hard drive and this external drive enclosure. This is cheaper than purchasing an external 250GB drive, and will give me the same amount of total storage as 4x80GB disks. It also has the added plus of easy portability.

In the end, while a spanning LVM would be nice, it proved to be too much of a hassle and slightly overkill for my purposes.

Labels: , ,

Friday, August 10, 2007

Code style

A friend and I were discussing curly bracket placement for code blocks (in curly bracket languages of course), and we think it might possibly be the most flamewarred programming topic of all time.

Personally, I have always coded with the initial curly bracket on the same line as the function/method header, like so:


public static void main(String[] args) {
  System.out.prinln("Hello");
}


In Java, this seems to be a fairly common practice, although in code style guidelines for my Java classes at MTU it was not stressed. However, it is a different story when you get to C++ or C. I find that most C coders I know place each curly bracket on its own newline, like so:


int main(int argc, char **argv)
{
  printf("Hello\n");
  return 0;
}


Because I was always taught that staying consistent in my code style, I do not use that style even when coding C. I thought it was interesting; however, when I perused MTU's C++ code style guidelines (found here), they clearly state: "Brackets { }: these must always be placed on their own line."

After thinking about this for a few moments, I thought about some of the non-curly bracket languages I frequently program in (Lisp and Python), and each of them have strict code style guidelines as well. Lisp doesn't have any whitespace restraints, however, if you do not indent properly, you risk catching simple errors, and the wrath of other Lispers. For example this code follows Lisp style:


(defun foo ()
  (format t "Hello~%"))


whereas this does not:


(defun foo ()
  (format t "Hello~%")
)


even though the Lisp compiler will let you do that. Python is much more strict about whitespace and such, forcing the programmer to write clear code.

So in the end, even though a programmer may find himself/herself coding in a certain style for one language, he/she should be willing to code to the style more widely accepted for another language rather than the style he/she may be the most comfortable with (this occurs most specifically between Java and C in my opinion).

Labels: , , , ,

Tuesday, August 7, 2007

Sun Microsystems releases UltraSPARC T2 and Fedora Test 1 is out

UltraSPARC T2 Released

In December 2005, Sun released the RTL code for the UltraSPARC T1 under the GPL version 2. Soon thereafter they released the source for the IP stack. Today they continue this trend with the release of the UltraSPARC T2. The T2 is an eight core processor that with CoolThreads technology (allowing it to have up to 64 threads per CPU). It is also the world's first "System on a Chip", with 10e Gigabit ethernet, PCIe16, IO, and options for several encryption schemes with a "security coprocessor" on every core. Amazingly it takes a mere 60-123 watts to power.

The fact that Sun has taken such steps to open a technology such as this to the world needs to be commended. Sun knows where the future is, and is taking steps to make sure they are leading the way toward freedom with an open mind. Watch Johnathon Schwartz release the T2 to the world here. I am still working on the hundreds of pages of documentation that was released on http://www.opensparc.net earlier today.

For more information on the UltraSPARC T2 check out: http://www.sun.com/t2, http://www.opensparc.net, and http://www.sun.com/processors/UltraSPARC-T2.

Fedora 8 Test 1

Fedora 8 Test 1 was also released today, and I can only hope that when it hits stable it will have a better footing than Fedora 7 did. The release announcement is here. Fedora 8 will feature IcedTea (a port of OpenJDK) as the default Java (instead of GCJ), Nodoka (the new default GNOME theme), rsyslog instead of syslog for logging (there was a debate over rsyslog vs. syslog-ng, in any case whichever the user chooses to use is just a yum away), and improved security for Kernel Virtual Machines. For the complete feature list, look here. I will probably wait to use Fedora 8 until it is stable (I might try Test3). The projected release date for Fedora 8 is November 8th, 2007 (the release schedule is here). In my opinion, Fedora is still (and will continue to be) the leader for fully open cutting edge software (only a minor logo trademark issue keeps it off the GNU free Operating Systems list). I can only hope Fedora 8 will improve Fedora's track record.

Labels: , ,

Monday, August 6, 2007

How to Build and Maintain a Small Beowulf Cluster

Over the summer I have managed to get my very own three node Beowulf cluster up and running. I found that there were many so called "help" sites and mailing lists. However none of them had what I really wanted: a concise point by point guide containing workarounds for maintaince issues and set up issues I might encounter. That is what I am setting out to do here. For further reading, you will want to check out: http://www.phy.duke.edu/~rgb/Beowulf/beowulf_book.php (the Beowulf Book) as well as http://beowulf.org/ (the main Beowulf site).

One last note before we begin: I will attempt to make this guide as general as I possibly can, however, it will contain some tidbits specifically for SPARC users. With that, let's get started!

A Brief History of Beowulfery

Supercomputing seems to be all the rage these days. In the last decade the Personal Computing has soared to limits unimaginable by the fathers of computing. This is mainly due to the fact that Moore's Law still seems to be in effect with no slow down in near sight. This essentially means that building your very own supercomputer may be far cheaper than you think. Virtually all major systems on the Top 500 list (http://www.top500.com/) employ some sort of clustering. This is because it is cheaper nowadays to purchase several "commodity" computers and utilize them in a cluster to produce the compute power needed.

The Next Step

So you think you want to build your very own Beowulf eh? Be warned: this is still not a task for the timid, but help is readily available via the Internet (see the links above). My cluster currently consists of three Sun Microsystems Ultra 10s (440MHZ UltraSPARC IIi, 512MB RAM ea., 9.1GB HDD ea.). Whatever you use, keep in mind that a in a "true" Beowulf cluster all of the nodes have the same architecture (as well as same HDD size, RAM amount, etc).

The next thing to resolve is a place to put these nodes. In this guide I will assume you have a fairly small cluster (16 nodes or less). Please note that some of these techniques may not scale well to larger clusters. In my case, with only three nodes, I can keep them practically anywhere.

After you have scouted out your location, you will need to invest in a switch (the faster the better, if you can afford gigabit do it!). I use a Dlink DSH-16 10/100 Hub with Built in Switch. You may also want to purchase a UPS (I have not, mainly because of the small amount of nodes I have, and the fact that my uptime is not crucial).

If you have several nodes, you may also want to invest in a KVM. This is really only practical if you have many nodes, or can find a small KVM cheap (most small PS/2 KVMS are under $100). I do not have a KVM because the cheapest model that supports Sun DINs is $740. There is also another Sun specific issue I should mention here: if you don't have a Sun keyboard plugged in at boot, OpenBoot will dump you to a serial output. This means that in order to boot correctly into Linux, you will need to plug in a keyboard. I am still looking for a workaround to this.

Installing Linux

The next thing to do is install the OS on every node. For the Ultra 10s, Debian was my distro of choice. I chose Debian because it is an extremely stable distro, and it is trivial to set up and maintain. You will also find that on older systems Debian may be much easier to install than other distros.

I used Debian Etch's net install disk (http://www.us.debian.org/CD/netinst/). When you install, you need to make sure that each node has all the same software installed. What follows is a minimal list:

  1. GCC/G++
  2. Python
  3. All NFS packages
  4. All NTP packages

as well as anything else you might need/want. Try to make sure each HDD has the same amount of used space (this comes into play when installing and using NFS).

You will also want to make sure every node has a static IP address. In Debian, edit the /etc/hosts file and /etc/network/interfaces file with the static IP addresses you choose. I used 192.168.0.100 and up.

Installing NFS

The main point of a cluster is to use all of the nodes effectively to complete a computing task in far less time than it would take for just one of these nodes to complete on their own. The easiest way to share information over a network is with NFS. Note that this is not the best way, merely the easiest, if you are serious about clustering you should probably start using OpenAFS (http://www.openafs.org/) or Lustre (http://www.lustre.org/) after you get the hang of maintain and using your cluster with NFS.

The main issue with NFS is that it is insecure on clusters because you have to use the no_root_squash option in /etc/exports. When I set up NFS I used this (http://nfs.sourceforge.net/nfs-howto/ar01s03.html) and this (http://www.crazysquirrel.com/computing/debian/servers/nfs.jspx). It was actually much easier than I had first anticipated.

Before you continue, make sure you can ping and ssh into every node in the cluster!

I decided to share the /home and /usr/local. My /etc/exports looks like this:

/usr/local 192.168.0.101(rw,no_root_squash) 192.168.0.102(rw,no_root_squash)
/home 192.168.0.101(rw,no_root_squash) 192.168.0.102(rw,no_root_squash)

Believe it or not, you are almost done! The only thing left to do is edit the client nodes' /etc/fstab by placing a line in each for each NFS exported directory. Below is the relevent portion of /etc/fstab for one of my nodes.

192.168.0.100:/home /home nfs rw 0 0

192.168.0.100:/user/local /usr/local nfs rw 0 0

This will ensure that the NFS shared directories are mounted at boot up.

Last but not least you need to start up NFS:

/etc/init.d/portmap start
/etc/init.d/nfs-kernel-server start
/etc/init.d/nfs-common start

Make sure to do a ps -A and look for nfs (or nfsd) and portmap to be running. For added security, you many want to add rules to /etc/hosts.allow and /etc/hosts.deny that only allow mounted NFS directories on your local network (if you are isolated this is not an issue).

What's Next?

That' s it! You now have a fully functional cluster, next you will want to install clustering utilities such as OpenMPI, UPC, and MOSIX. In addition, you will want to generate a common SSH key to allow access to all the nodes without having to enter a password.

Labels: , , , ,

Sunday, August 5, 2007

The Joys of Wireless Networking and Linux

Now that I have access to my router, I wanted to set it up as a wireless AP for my laptop. Note that I am not connected to the internet with this at the moment it is merely an isolated LAN. I have an HP zv6000 (512MB RAM, AMD Athlon 3200+) with a Linksys WPC54GS wireless adapter.

In the past, I have installed the bcm43xx (Broadcom) firmware for the adapter and executed

sudo /etc/init.d/NetworkManager start

to locate and connect to wireless networks. This time I am having issues, and not just with my router.

At first I had my router (Buffalo WHR-G125) set as a wireless AP with no authentication method. I executed the above command and could not connect to the network. Look here for the results of dmesg right after I attempted to connect: http://nonlogic.org/dump/text/1186352893.html. The main concern to me was the wlan0: No IPV6 routers found line.

At this point, I noted that I could "see" the SSID with iwlist, and could set the ESSID to the router's broadcasting SSID with iwconfig. This still did not allow me to connect to the network. Also note that a wired IPV4 connection works fine across the network.

A friend suggested I use the tried and true command line applications for making a wireless connection. First I tried:

ifconfig wlan0 down
iwconfig wlan0 essid dd-wrt
iwconfig wlan0 mode managed
ifconfig wlan0 up
dhclient wlan0


This resulted in me recieving an IPV6 address from the router (fe80::218:f8ff:fe45:52b/64), but I still could not ping it, and there was no connection.

At this point, my friend suggested I enable WPA2 authentication with TKIP encryption, which I did. I then attempted to execute the following:


ifconfig wlan0 up
iwpriv wlan0 set AuthMode=WPA2PSK
iwpriv wlan0 set EncrypType=TKIP
iwpriv wlan0 set WPAPSK=""
iwconfig wlan0 essid dd-wrt
iwconfig mode managed
iwconfig wlan0 mode managed
dhclient wlan0


where my WPA2 key is left out for obvious reasons. I ran into issues with the iwpriv lines:

invalid command set

I then decided it might be a good idea to attempt to disable IPV6, but I still have not found a easy way to do this, I will continue to look into it. It was also suggested that I install wpa_supplicant and I will look into that shortly. At this point in time, this issue is unresolved, I will update here as soon as I get it to work (along with a detailed howto on how to get bcm43xx working and configuring the adapter on a wireless network).

Labels: , , , ,

Installing Linux on a Buffalo WHR-G125

I recently purchased a Buffalo WHR-G125 wireless router from a local Circut City for a mere $39.99. I was on a mission to find a router that supported dd-wrt and/or OpenWRT. This router supports both (although http://toh.openwrt.org/ still reports OpenWRT as a WIP). The WHR-G125 sports a 240MHZ processor, 4MB of flash, and 16MB RAM. It is based off of the Broadcom chipset.

Since OpenWRT was listed as a WIP, I decided I would install dd-wrt. I followed the instructions found here: http://www.dd-wrt.com/wiki/index.php/Installation. After making sure tftp was installed on my machine, I carefully reviewed the instructions and downloaded dd-wrt v24 beta. Unfortunately, the Buffalo firmware is encrypted, so it is a little tricky to flash with dd-wrt (it is a matter of good timing). I found that the one line command:

tftp 192.168.11.1 -m binary -c put dd-wrt.v23_generic.bin

worked just fine. After making sure that I could ping the router at it's new IP address (192.168.1.1), I opened Firefox and entered the dd-wrt control panel.

At this time, for some reason I am unable to manuever the control panel due to the rejection of the defualt user and password by the control panel. I am unsure what caused this problem, I plan to reflash the router with a non-beta version of dd-wrt ASAP.

All in all, this is a great little router for the price, and I am looking forward to using it as a local AP for my dorm room. The wireless signal range is not that great, however it will suit my purposes perfectly.

UPDATE: My login issue was simple to fix. I did not need to reflash the router. The Buffalo firmware has a defualt user/password combination of root/Blank. dd-wrt sets this to root/admin. The dd-wrt installation wiki does mention this for a different Buffalo router, it also applies to the WHR-G125. Thanks to Tomm Smith for pointing this out to me.

Labels: , , , ,