I’ve just released the first version of netaman. A very simplistic script that automatically configures a Ubuntu Server 9.10 system as a Mac OS X 10.4+ compatible AFP server. Read more about it at http://blog.dustinrue.com/netaman.
Category Archives: Linux
75% of Linux Code Written by Paid Developers
This doesn’t surprise me too much but I’m curious how this number would change if you included all open source software.
Western Digital WD TV Live
I’ve been trying for a while now to find a reasonably priced way to play video files that live on my computers on our TV or projector with acceptable quality while still being easy to use. Finding a solution has proven more difficult than I initially thought. I could never really find anything that gave me everything I wanted without some major compromise and didn’t cost a lot in terms of price or time spent configuring. I simply want to be able to take a file from the computer and play it on my TV or projector on a device that feels integrated with the rest of my setup.
Enter Western Digital’s WD TV Live. The WD TV Live does exactly what I want and does it in a tiny and silent, remote controlled package. It is able to stream virtually every common video or audio format in use today from a network share or from a locally attached USB drive. As an added bonus, it can also access YouTube, Pandora, Flickr as well as a couple of other online services. You can read more about the WD TV Live at http://www.wdtvlive.com/products/wdtv_live#highlights.
There are some isues with the device right now that are supposed to be cleared up in a soon to be released firmware update. It will play DVDs ripped to .iso format but doesn’t support menus, or even chapters, at all. This makes it nearly impossible to watch a TV series on DVD. The other issue the player currently has is with h264 files but oddly enough it is all in the name. A file with the extension .m4v will most likely have audio sync issues. Renaming the file to .mp4 will resolve the audio sync issue but will do nothing with the stuttering playback for all but the most basic of h264 encoded files. Incredibly, taking the same h264 file and putting it into mkv format will fix all of the issues and the file will play perfectly.
Despite these very easily fixed issues, this is the best device I’ve come across for playing videos at this price point. Yes, there are probably more capable devices available and there is certainly more capable software available (XBMC for one) but for the money, it’s hard to beat the WD TV Live. My next few blog posts will focus on how I’ve integrated the WDTV into my home network including how I’m encoding files for it using HandBrake, Linux and Automator in OS X.
Encoding episodic DVDs to h264
My wife and I don’t watch a ton of TV but we do have a few TV series on DVD. Lately I’ve been taking the time to rip the DVDs to hard drive so we can travel with them more easily.
The problem of course is they take up a lot of space after awhile so I’ve started to compress some of them to the h264 format. I picked h264 because I like the quality and because newer Macs are able to decode h264 using hardware acceleration. One problem with the h264 format is that by itself it has no support chapter markers unlike say, the mkv container. To get around this, I wrote a couple of scripts. One of them determines how many chapters (episodes) are available on a disc and the other one does the encoding.
In order to put all of this to use you’ll need to have the HandBrakeCLI program installed on your computer. The HandBrake is site (http://handbrake.fr/) has information about how to get everything installed for your OS. This post assumes you are using Linux, Mac OS X or other UNIX like system.
Here is the script that retrieves the number of chapters on from a DVD that has been ripped to a hard drive. You’ll need to modify it for your environment. I called mine getchapters.sh but the name is arbitrary.
#!/bin/bash
HandBrakeCLI -i $1 -t 0 2>&1| grep "title 1 has" | grep chapters | awk '{print $
6}'
This script is called within another script that I called h264encode_episodic and looks like this
#!/bin/bash
chapters=`getchapters.sh $1`
if [ "$2" != "" ]; then
title=$2
else
title=$1
fifor I in `seq 1 $chapters`
do
HandBrakeCLI -Z "High Profile" -i $1 -o ${title}E${I}.mp4 -c $I
done
Running this script in the same directory as the DVD iso or VIDEO_TS directory you will end up individual video files, one for each chapter or episode of your show. Here’s how it is called
h264encode_episodic Scrubs_S1D2.iso Scrubs_S1D2
Scrubs_S1D2.iso is the iso of the DVD I want to convert and Scrubs_S1D2 is part of how the resulting files will be named. The first episode will be named Scrubs_S1D2E1.mp4.
Overheard on Facebook regarding the latest Ubuntu release
Linux is such a love/hate relationship for me and this post from Facebook about sums up the reason why. There is so much it can do and yet so much it can’t.
“I’ve been having this hankering to just run flat out Ubuntu on my laptop again. However, I have iTunes thanks to a bunch of free music I got from a Pepsi promo so many years ago, and I don’t exactly have money to get cd-r’s to burn it all to re-rip it. I’ve found some new toys for Ubuntu that I wasn’t aware of and they make me crave it more. Maybe I’ll just end up running Windows in a VM. I still need to have something that can print photos relatively easy.”
Ubuntu, Netatalk and OS X
Recently I removed Fedora 10 from my Linux server at home and installed Ubuntu 9.10 Server. I did this partly because I was tired of finding packages that weren’t available on Fedora but were available in Ubuntu. Ironically I ended up trading one mess for another. Under Fedora I was compiling software that simply wasn’t available, but under Ubuntu I need to recompile the provided netatalk package in order to enable support for newer versions of OS X.
Netatalk is the Linux package for providing the native file sharing protocol to Macs and also provides better performance than Samba under most conditions. The missing feature in this case seems like quite the over site considering it makes the software virtually useless on networks with modern Macs as it prevents them from authenticating. Lucky for me, someone else has gone through the work of figuring out what it takes to get things working again.
The information is Debian/Ubuntu centric but you should be able to apply the same fix on other distributions. Here’s the link http://www.kremalicious.com/2008/06/ubuntu-as-mac-file-server-and-time-machine-volume/
Rescuing your Linux system from a failed grub install
It is bound to happen at some point. You’ve installed the latest kernel or you’re attempting an upgrade and now your system just won’t boot. The screen shows nothing more than GRUB. If your system isn’t able to get past the GRUB prompt and it isn’t because of a hard drive failure then chances are very good that you can rescue your system. This routine will work best if you created a non LVM boot partition or if your rescue cd includes the LVM tools.
This post assumes you are running a RedHat or Fedora based system but the concepts apply to all systems that use grub to boot. It also assumes you have a relatively recent install cd.
To get started, insert your install cd. In my rescue scenario I used a CentOS install cd. When the install has loaded to the initial screen enter ‘linux rescue’ and press enter. The cd will boot like normal and ask about your preferred language and keyboard layout. Continue until you are asked if the rescue routine should find any installed systems. If your root directory exists in LVM you should say no, unless you the rescue cd you using includes LVM tools. It isn’t important to mount root anyway, just your boot partition.
When you are at a prompt, create a boot directory at / and mount your boot partition there. In a typical RedHat/Fedora setup it will be on /dev/[h|s]da1. Next, rename the current device.map files to some other name. We’re now ready to reinstall grub.
Type grub and press enter. You’ll now be in the grub interface. Type ‘root (hd0,0)’ and press enter. Next, type ‘setup (hd0)’ and press enter. Some text will flash by with, hopefully a success message. If you see success you should now be able to reboot into your Linux system.
iPhone Linux, Linux now booting on the iPhone/iPod Touch
Linux now booting on the iPhone/iPod Touch, with video.
VIM editor tip of the day
If you’ve spent any time at all on this site then you know that VIM is my preferred text editor. Even though I’ve been using it for years I still learn something new about the editor from time to time. Here is something that I just figured out a couple of weeks ago. It turns out VIM provides a simple way to repeat exactly what you last did. By simply pressing the period key, VIM will repeat whatever command -or- text you last entered.
For example, lets say you’re editing an HTML file that has a list of links. Before each link you want to add a generic image. You could do this a few ways; type in the text each time, use a search and replace or copy and paste. Using period is just one more method to add to your toolbox. To use this trick, enter INSERT mode by pressing i. Enter in the text you want to enter before each link (or whatever it is you need to repeat a few times) and when you’re done press ESC. Move to the next line and press the period key. Whatever you typed previously will be inserted to the right of the cursor. You can do this as often as you like but as soon as you delete a letter, line, insert different text or whatever the “period key” shortcut will begin to do that action instead.
Another way to use this is if you’re deleting lines of text over and over. Say you want to delete 10 rows of text at a time until you’ve deleted what ever it is you need to delete. You could press d 10 down arrow and then each time you press the period key you’ll repeat the same action.
Adding high speed storage to that Macbook lacking firewire
Here is a copy/paste of a post I did on a forum. It describes in very light detail how to add iSCSI based storage to a Mac. With the new Macbook lacking firewire, this might actually become a more popular method.
In the last couple of weeks I’ve been playing around with a few different bits of technology, one of them being iSCSI. iSCSI is a relatively cheap and efficient method of adding storage to a computer that uses your existing network infrastructure. If you have a gigabit network and a Linux server (I haven’t tested other solutions) you can add as much storage to your Mac as you can fit in your Linux system.
You might be thinking, “I have a 2TB USB/FW drive why would I want iSCSI?” USB and FireWire drives are a fine thing but lets look at some of their disadvantages.
* USB2 is actually slower than many FW400 devices
* If you have a mac with just one FW port and your external drive doesn’t include a FW port, you can’t attach anything else to that FW port AND use your drive
* External drives add noise
* External drives must be located close to the computer, not ideal in a HTPC setup
Here a really quick overview of how it is done, I can certainly provide more detailed information however. Here is a list of what you need to get the job done.
1. Linux server with gigabit ethernet
2. A hard drive or RAID set that you want to share to your Mac
3. gigabit switch
4. Mac with gigabit, the more recent the better
5. GlobalSAN iSCSI initiator for Mac
6. iSCSI Enterprise Target for Linux
Setup your Linux system and install IET. If you’re using Ubuntu, IET might be available in apt. I use Fedora so I compiled IET from source. Edit the /etc/ietd.conf file to point to your disk or RAID set (or even a file that was made using dd if=/dev/zero of=filename bs=1024 count=1 seek=n where n is the size of file you want in bytes). Start the ietd service, /etc/init.d/iscsi-target under Fedora.
Install the GlobalSAN iSCSI initiator on your Mac. Enter System Preferences and click the new GlobalSAN button. Add your Linux server’s IP address to the Discovery screen. Click on the target tab and your disk should be shown, click it and logon to it without a username or password UNLESS you configured one in IET. Be sure to check the persistent tab if you want this drive to appear each time you boot your Mac.
Open Disk Utility and format the iSCSI disk. Your Mac will format the new drive and it’ll soon appear on your desktop. You can use it like any other disk you’ve ever used. You can partition it, copy/delete files, whatever. As far as the Mac is concerned it is a normal hard drive.
In my setup I have an Intel Mac mini, 1.83Ghz C2D and a Linux server built in late January, 2.2Ghz C2D. The disk being shared to my mini is a single 120GB PATA drive. I am able to copy files to the drive with a top speed of 44MB/s. Reading is actually slow but I attribute that to a limitation with the mini’s internal drive. I haven’t been able to test using OpenSolaris as the iSCSI target though OpenSolaris would be a fantastic choice as a storage server.
To be fair, there are some negatives to this setup. The biggest one being you can’t have multiple Macs using the same disk at the same time. You can unmount the disk on one mac and mount it with another one, but having two macs connected at the same time risks your data.