Slightly less Random Ramblings

January 11, 2009

Sharing all your music with Firefly Media Server

Filed under: DAAP, firefly, linux, mp3, songbird, ubuntu — Robert Wicks @ 12:27 am

I have a cross-platform household. My wife and daughter use Windows, I use Windows for work and Ubuntu for meaningful things ;). I have a lot of music and audiobooks, mostly in mp3 format, but a few things in ogg, flac, and mp4. Everyone likes to listen to something, but how to share all the files? There are many solutions, of course, but the most convenient one for me was the one which allowed my wife to easily access the music with iTunes. The solution was the Firefly Media Server. Installing this under Ubuntu could hardly be simpler. From a command line, as root, type:

apt-get install mt-daapd ffmpeg

This will get you the software you need. After the packages are installed, edit the /etc/mt-daapd.conf file and change the location of your media files to wherever you keep them. After saving the file, issue

/etc/init.d/mt-daapd restart

I have occasionally found cases where Ubuntu starts services immediately after installing them. Restart means it will stop the process first, if there is an active one.

Wait a couple of minutes, for Firefly to scan your media files, and they should be accessible via DAAP. iTunes will discover the new server automatically, if the computer is on the same subnet as the server. I am told that Songbird works well with Firefly as well.

July 22, 2008

Cheap solid state router using Endian Firewall

Filed under: Firewall, linux — Robert Wicks @ 2:55 am
I wanted to run Endian Firewall on compact flash, something which is not explicitly supported, apparently. I had 1.5GB of RAM, and Endian runs in 512 with no problem, so I figured I could use tmpfs to do /var and /tmp, helping prevent the card wearing out. I could not get Endian to install to a USB device, but a $12 CF-IDE adapter allowed me to install it on a 2GB flash card with no problem. It will disable swap automatically. You can either pop it out after you install, or you can boot off a Knoppix CD next so that you can make some modifications to your installation. If you are using the CF card via USB (I could not get Endian to install on a USB connected CF card, but I imagine I could get it to boot and run, once I installed it over IDE. After you perfect the installation, you can just dd the boot sector and each partition so that you can clone your install to new media), mount /dev/sdb3 to /mnt to access the root directory (/). Once you mount the / partition for editing, change the etc/fstab file on the CF card to read something like this:

/dev/hdb1 /boot ext3 nodev,nosuid,noatime 1 2
/dev/hdb3 / ext3 noatime 1 1
/dev/hdb4 /varperm ext3 noatime,mand 1 1
none /var tmpfs noatime,mand 0 0
none /tmp tmpfs defaults 0 0
none /home tmpfs defaults 0 0
none /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0

Note that I moved /var to /varperm and /home to /homeperm. You can mkdir those directories under your root partition which has been mounted to /mnt.
Next, edit the etc/rc.d/rc.sysinit file. Locate the line which reads

mount -a

Add three lines immediately below it:

######copy stuff to the tmpfs filesystems
/usr/bin/rsync -a /varperm/ /var/
/usr/bin/rsync -a /homeperm/ /home/

I also added /etc/cron.d/syncflash to /etc/rc.d/rc.halt, right after the “Shutting down” line at the top of the file so that I flush to flash whenever I shut down.

This will get the necessary directories and files on boot from the flash to RAM so that scripts start correctly. That’s all which is actually required! You can (and probably should) add a cron job (under /etc/cron.{minutely|hourly|daily} to periodically rsync stuff from /var to /varperm to keep historical logs. This is in /etc/cron.d/syncflash on my system:

/usr/bin/rsync -a /var/ /varperm/
/usr/bin/rsync -a /home/ /homeperm/

I’d probably exclude the gzipped stuff, myself, but that depends on the amount of space you have. Since tmpfs allocates half your RAM by default, we effectively have a 750MB combined /tmp and /var filesystem. This is plenty, really. We can even enable the proxy and ntop, so long as we set the limits to something reasonable. I may hack it further to keep longer logs on flash and continually flush tmpfs, but what I have works for now. I think this may be a really good solution for a dedicated router box, maybe using something like a Fit PC. Addendum: Fit PC does not have enough memory for this application. But an old laptop and a PC Card CF reader might do the trick. I also had to change the options from defaults in the /var line to enable mandatory locks. Havp would not start without this setting, which kept squid from working correctly.

April 4, 2007

beryl invisible borders

Filed under: beryl, linux, nvidia — Robert Wicks @ 5:39 pm

I use Gentoo Linux at home. It’s a pretty neat experience, and much easier than a compiled distribution might initially seem. I’m constantly updating to experimental packages on it, and one of my favorites is Beryl, a beautiful window manager. Recently, I noticed that beryl’s window edges were invisible. I could still grab the invisible window title and drag it around, but not having visible borders was frustrating. I tried changing nvidia drivers, and updating beryl components, but I finally found that I needed to come off the bleeding edge. The beryl components were versioned 9999. Once I scaled back to th 0.2.1 (the current release), things returned to normal

March 1, 2007

Converting a VMWare workstation image to Xen

Filed under: convert, linux, logical volume, lvm, migrate, migration, redhat, virtualization, vmdk, vmware, xen — Robert Wicks @ 1:43 pm

Recently I had to convert a VMWare virtual machine running Redhat Enterprise Linux 4 (vmclient running on vmhost) to it’s own box. Due to the practical limitations of remote support, I decided that Xen might be a better solution than bare metal, without sacrificing performance. Since the server had been running on VMWare Workstation on a low memory box, the move to new hardware would boost performance no matter what I did. During my conversion experience, I discovered some useful resources scattered about the Internet. One of them was in German, which I don’t speak, so I figured I would put things in one place for anyone challenged to do something like this in the future.

VMHost is a RHEL4 server with VMWare workstation running on it. First I found the directory containing the files for the server I want to clone. Looking in the /var/vmware/Virtual Machines directory, I see vmclient/vmclient.vmdk. This is the disk image. Fortunately, there is only a single image. I’m not sure what I would do if there were spanned images, which is one of the options you have with VMWare. I suppose you could append one to another, but I’d have to check into how best to do that.

I used qemu to convert from the vmware vmdk format to a raw disk image. Qemu is readily available at Convert the image by shutting down the VMWare session, then issuing the following:

qemu-img convert -f vmdk vmclient.vmdk -O raw vmclient.raw

Note that all the commands are on one line, so ignore any line breaks. This gives a disk image of vmclient in a format I can operate upon. For example do the following:

fdisk -l -u vmclient.raw

And the output will look something like this:

You must set cylinders.
You can do this from the extra functions menu.

Disk v-pt-dev1.raw: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes

Device Boot Start End Blocks Id
vmclient.raw1 * 63 208844 104391 83
vmclient.raw2 208845 8385929 4088542+ 8e
Linux LVM

This tells me that I have a disk image with two primary partitions. Knowing that the first partition is /dev/sda1 or /boot (which I could tell with the df command inside the original virtual machine), I know that the second partition is the LVM partition containing both / and swap.

I moved this raw file over to the Xen host server (xenhost), which I have already installed with a generic XenServer 3.1 install (I like XenSource’s distribution, but the concepts here should work with any Xen implementation). I create a new default RHEL 4.4 install using the Xen Client which comes with Xenserver 3.1. I had an NFS mount with all the RHEL4 CD content copied into it and pointed the install at that. But you could download a new Xen Template (XGT) for CEntOS and use that instead if you wish.

After creating the working RHEL install under Xen, I know I will need the /lib/modules/ directory in my final box, but my migration technique is going to destroy everything but /boot in the process, so I copied the modules directory to /boot temporarily. I then shut down the XenVM and ssh directly into xenhost.

Looking under /dev/mapper, I see the logical volumes (they have some absurdly long names, but end in sda, sdb, etc, depending on how many drives you set up). Since I have set up only one drive, I only have an sda logical volume. I want to save my /boot from this LV (with the modules directory already copied to it). After verifying with fdisk -l -u VG{whatever}.sda that the layout is the same, with the first 208844 blocks being /boot, I issued the following command:

dd if=VG{whatever}.sda bs=512 count=208844 of=xenclientboot.img

This pulled the /boot from the logical volume. I then overwrite the LV with my VMware image:

dd if=vmclient.raw of=VG{whatever}.sda

This will not yet boot because it does not have a paravirtualized kernel. At least on the box I am using. It may work on more recent CPUs which have hardware virtualization, in which case, saving the /boot may be unnecessary (though it may still be desirable for performance). So:

dd if=xenclientboot.img bs=512 count=208844 of=VG{whatever}.sda

This copies the correct /boot over. Boot the new Xen Client system, move the modules directory from /boot to it’s correct place in /lib/modules, run depmod -a, then netconfig and configure your network stuff. You might also want to copy the xenmond binary from /usr/sbin in any other Xen installations, along with the xenmond start script in /etc/init.d/. This will allow the XenClient to monitor the running Xen Client. Remember to do chkconfig –add xenmond after you copy the file so that it will be added to the correct runlevels. Reboot, then things should work. I’d appreciate any feedback on clarifying things, or if you see any errors or better ways to do this. I’m always looking for better methods.

« Newer Posts

Create a free website or blog at

%d bloggers like this: