Wednesday, December 2, 2009

Glorious LXF126 Contest

Linux Format #126 Cover Image
If you are the winner in my glorious Linux Format 2009 Christmas Issue giveaway, here's what you have to look forward to:




  • Ultimate eye candy

    - a pretty interesting article on how to get the most dazzling display, whether you use Compiz, KDE, or GNOME. Despite my general disdain for eye candy, I would try the Compiz/Emerald 3d window manager if it worked on dual monitors, but last I looked it didn't support them.

  • KDE distributions

    - coincidentally enough, just as I'm looking to move on up from my OpenSUSE 11.0 install, along comes LXF with their KDE distro Roundup. I wouldn't have to go too far afield if I stayed with their winner, which is OpenSUSE 11.2, but I'm trying out a couple of other ones they regard highly, like Sabayon and Sidux. I'm a KDE man, so it works out well.

  • Get to grips with /proc and /sysfs

    - this is an excellent overview of the virtual filesystems /proc and /sysfs.

  • DVD Coverdisc

    - the DVD coverdisc includes live previews of the latest versions of KDE and GNOME, which is pretty cool. It also includes Ubuntu Netbook Remix (which I think I'll try on my Dell Mini), Moblin 2.0 and Puppy Linux 4.3.



To enter my little contest, where I will mail you a pristine copy of LXF #126, along with the DVD coverdisc, just drop me an email at jdarnold@buddydog.org. On Monday, Dec. 7th, probably in the evening, I will randomly select one entry and email you back asking for your mailing address and soon it will show up on your doorstep. Open to both of my international readers too :)



Oh, and I also heartily endorse subscribing to the magazine. Yeah, it's pretty expensive, but if you do it via the TuxRadar web page, you can cut it down to US$99 for 13 issues. And, as a subscriber, you get access to all the back issues in PDF format and they really have gotten their act together with it. The PDFs look great and they have a nice HTML page linking it all together. You won't be disappointed.




Monday, November 30, 2009

Contest and Projects

Due to a mix-up, I ended up with two copies of Linux Format #126, the Christmas 2009 issue. I figure I'll run my first ever contest here at Daemon Dancing - after over 6 years of writing on this blog, why not? Let's make it a simple one - just drop me an email at jdarnold@buddydog.org and next Monday, when I get back from my work trip, I'll randomly select one entry to mail it out to. No strings attached and, believe you me, I won't be keeping your emails around! And heck, I'll even make it open internationally, just to make it even more likely I'll get at least one email entry:)



So I get a 1.5 out of 4 for my holiday projects. I did get the girls' computer up and running. The new power supply took a bit of forcing to get it to fit into the old case, but then it was up and running just fine. I was bit stumped as to what to install for an OS on it. For obvious reasons, the old Windows XP installed on the hard drive failed to boot. Really, all they do is play flash games on it at this point, save for R10.4 playing some Day of Defeat with me and my clan buddies. So I moved her onto the Windows machine and had to pick a Linux for the new box. I went with OpenSUSE 11.2, as I'm most familiar with that and so it would require the least amount of thought. So far, so good.



I get a half a project because I did try to install a new Linux on my own box, but wasn't really happy with it. I installed the latest Sabayon (v5.0), after being pretty impressed with how well the Live CD ran. But I immediately ran into a problem after the installation - GRUB refused to boot it up.



Because I run my own boot manager (TerraByte's BootIt NG), I always install the GRUB boot loader onto the first block of the OS's boot partition. One test of an installer is just how hard this is to do, and I'm happy to report it wasn't too hard for the Sabayon installer - just select the Advanced Options and it was one of the choices. But on boot, I just saw "GRUB " and I knew immediately what the problem was. My machine is a homebrew one, with both old fashioned IDE drives and newfangled SATA drives and this isn't the first time an installer or LiveCD called the drives something different than what a full boot calls them.



Unfortunately, I had formatted the partition as an 'ext4' drive, so I couldn't get at it with my OpenSUSE 11.0 boot. And it may also have had something to do with why GRUB didn't work either. So I redid the install using 'ext3' and still had the problem. After rebooting the Sabayon Live CD, the usual GRUB steps to fix a broken GRUB install didn't quite work:



# grub
grub> find /boot/grub/stage1
(hd0,0)
(hd0,3)
grub> root (hd0)
grub> setup (hd0,3)
....
grub> quit


I do the ",3" part to (hd0,3) so that it installs in the root block of partition 3 and not the root block of that whole hard drive, to not overwrite my own boot manager. But I knew this was still wrong, because after a "normal" boot, the boot drive is hd1, not hd0. I think there is a way to tell grub this using another parameter to the setup command, but I had a better idea - I just booted into my OpenSUSE boot and changed all 'hd0's to be 'hd1'. After booting, things got a little further, until I realized that the setup command doesn't seem to fix the /boot/grub/menu.lst file, so I had the make the same s/hd0/hd1/g change there too.



Now I was able to boot into Sabayon. And because they aren't afraid to install binary drivers, I got the nVidia drivers and was quickly able to turn on my second display, which was nice. But the update process left me a little mystified. I couldn't really figure out how to get it to select packages and install the updates. And even when it was downloading, it was incredibly slow and, in the end, didn't seem to do anything.



So in this age of instant gratification, I sort of gave up. I think I'll try the Sidux distro next, although I should just stop wasting time and install OpenSUSE 11.2, as that is the one I like and use.




Friday, November 27, 2009

Holiday Projects

So on this long weekend in the US, I have a few technology projects I hope to work on:



Fix Girls' Computer



Their computer finally gave up the ghost a few weeks ago and they've been using one of my work computers while I figured out what to do. I picked up an AMD motherboard for cheap (US$120) from AscendTech.us, that included an AMD 6000+ cpu and 1gb of RAM. What it did not include was any kind of manual, which kind of upset me. I think it is an ECS MCP61SM-AM motherboard, which isn't even listed on the ECS web site. But I did figure it out enough to get it put into the case, only to find out the power supply only has a 20 pin plug, and the new ones require a 24 pin plug. So I ordered a new power supply and now it awaits final assembly. Not sure what OS I'l put on it. Maybe I'll go back to Qimo For Kids again.



Install New Linux



My current openSUSE installation is pretty old at this point. I did upgrade from 10.3 to 11.0 about a year ago, but since then I've managed to break it. An update was going too slow and eventually had to be abandoned, leaving it in a state where even the updater won't run. But it was time to start fresh anyway. Good timing, as Linux Format #126 reviewed the "best" KDE4 distros. Not surprisingly to me, their #1 pick was OpenSUSE 11.2. But I also thought the Sidux and Sabayon distros sounded interesting, so I wanted to spend some time with those before picking one.



Continue Linux From Scratch



I also need to get back on the Linux From Scratch project. I have the toolchain all built and backed up, and am ready to begin Chapter Six and actually build the real copy. I have gotten a little sidetracked in the whole package manager discussion, but I think I'll just ignore it for now and try an install. If I want to go further, then I'll think more on a package manager. But I have really been enjoying the heck out of getting into the real guts of a Linux install.



Work On Android



One new toy I haven't talked about is my G1 (Google) phone from T-Mobile. I have actually had it about 8 months now. I really like it and one reason I bought it was for its open source development model. I have a couple of interesting little projects for it ready to go, but just haven't found the time to pursue. I'm not a huge fan of Java programming, but I think I know enough to get something running.



So who knows how many, if any of the above projects I'll get to. Well, I have to do the first one so I can get my test computer back, and it promises to be a cold rainy day here in the US Northeast, so I think I can definitely get that done. As for the rest....?





Friday, November 13, 2009

Scratching the Linux Itch, pt. II

Finally, we get started building the system in Chapter 5. As mentioned in the last important point here, for every package done in Chapter 5, you need to do the following commands, as the 'lfs' user:



$ cd $LFS/sources
lfs:/mnt/lfs/sources$ tar xjvf binutils-2.20.tar.bz2
lfs:/mnt/lfs/sources$ cd binutils-2.20


If the downloaded package is a .gz file, then instead of 'xjvf', you do use 'xzvf' to untar it. 'j' uncompresses bz2 files while 'z' uncompresses .gz files. The untarring command is implied before you start each sub-chapter. I also finally figured out how to time multiple commands using the GNU time command (which has a nicer, seconds-only format) rather than the builtin bash 'time' command:



$ \time -f "\\n================\\nTotal time: %e seconds\\n================" bash -c "../binutils-2.20/configure \
--target=$LFS_TGT --prefix=/tools \
--disable-nls --disable-werror && make && make install"

[.... many many commands later ....]

================
Total time: 146.24 seconds
================
$ \time -f "\\n================\\nTotal time: %e seconds\\n================" bash -c " ../gcc-4.4.2/configure \
--target=$LFS_TGT --prefix=/tools \
--disable-nls --disable-shared --disable-multilib \
--disable-decimal-float --disable-threads \
--disable-libmudflap --disable-libssp \
--disable-libgomp --enable-languages=c && make && make install"

[....]
================
Total time: 678.12 seconds
================


I use \time to make sure I'm not using any builtin or alias command - this picks up GNUs /usr/bin/time (read more about finding the correct time in an earlier post). The -f option lets you specify a printf-like statement for formatting the output, so in this case I want it to just show seconds (%e). The real tricky part was how to get the multiple commands to run as one command, as time just times one single command. By invoking bash with its -c option, and quoting the entire rest of the line, we get it all together as one.



Oh, I also forgot to remove the source and build directories as specified in the book, so I needed to go back and do that for gcc and the binutils. And for the API headers, I understood it to mean that I needed to untar the linux-2.6.31.5.tar.bz2 file. And actually, that's one of the gotchas mentioned in the Linux Format's article:



Kernel API headers


A common mistake is to expect the kernel API headers to be in their own package. This is not the case - you will need to extract the kernel source package (usually of the form linux-2.6.x.tar.bz2) and then move into the extracted directory to follow the steps in the ebook.



For the binutils Pass 2 build, I needed to tweak the line a bit because of quoting problems:



 $ \time -f "\\n================\\nTotal time: %e seconds\\n================" bash -c "CC=\"$LFS_TGT-gcc -B/tools/lib/\" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../binutils-2.20/configure --prefix=/tools \
--disable-nls --with-lib-path=/tools/lib && make && make install"

[.....]
================
Total time: 135.00 seconds
================


Note the \" ...\" for the CC= line. This is so that it gets passed along correctly to the bash shell that gets run. I do wonder if the SBU time used should include the last 2 make commands specified on the binutils, Pass 2 page though. To get the current status of the SBUs for my system, you can see it here.



And I do know what LXF means when one of their caveats says to be careful with getting lulled into feeling it is always ./configure --prefix=/tools! I have changed my sample timing command to be:



\time -f "\\n================\\nTotal time: %e seconds\\n================" bash -c "./configure --prefix=/tools && make && make install"


I have this in a file and I just copy / paste while running it in an Emacs shell. But every now and then, a configure slips in that wants just a little more...



I finished up with Chapter 5: Constructing a Temporary System without too many problems. I've really been enjoying the in depth exploration of exactly what gets built and why. I do wonder about some of the unapplied patches though. Perhaps because it is just the "bootstrap" system, they aren't important at this point. I also thought it very quaint that the book worries about disk space and gives advice on how to save a whole 95mb by stripping the apps and removing some doc files:)



Edit: turns out the manual, not surprisingly, does talk about the unapplied patches here::

Several of the packages are patched before compilation, but only when the patch is needed to circumvent a problem. A patch is often needed in both this and the next chapter, but sometimes in only one or the other. Therefore, do not be concerned if instructions for a downloaded patch seem to be missing



The series so far:



  1. Scratching the Linux Itch, pt. I

  2. Scratching the Linux Itch, pt. II




Thursday, November 12, 2009

Scratching the Linux Itch, pt. I

So I'm going to try a Linux From Scratch build and installation, just because I need another pointless project to write about :)



Here is the result of my version-check.sh script on my openSUSE 11.0 system:




bash, version 3.2.39(1)-release
/bin/sh -> /bin/bash
Binutils: (GNU Binutils; openSUSE 11.0) 2.18.50.20080409-11.1
bison (GNU Bison) 2.3
/usr/bin/yacc -> /usr/bin/yacc
bzip2, Version 1.0.5, 10-Dec-2007.
Coreutils: 6.11
diff (GNU diffutils) 2.8.7-cvs
find (GNU findutils) 4.4.0
GNU Awk 3.1.5h
/usr/bin/awk -> /bin/gawk
gcc (SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]
GNU C Library stable release version 2.8
GNU grep 2.5.2
gzip 1.3.12
Linux version 2.6.25.20-0.5-pae (geeko@buildhost) (gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision
135036] (SUSE Linux) ) #1 SMP 2009-08-14 01:48:11 +0200
m4 (GNU M4) 1.4.11
GNU Make 3.81
patch 2.5.9
Perl version='5.10.0';
GNU sed version 4.1.5
tar (GNU tar) 1.19
makeinfo (GNU texinfo) 4.11
Compilation OK


So it looks pretty good so far. It's always scary when reformatting an existing partition. I have 3 primary 50gb partitions on a 250gb hard drive used to play with Linux distros. The fourth partition is an extended one with 2 logical partitions, a 90gb /home partition and a 2gb Swap. One of the primary partitions houses my regular distro, openSUSE 11.0, while the other 2 currently have an openSUSE 11.1 and an Ubuntu 9.04, neither of which I've used recently. So I'll just use the Ubuntu one, which is /dev/sdb3, and already created, so I just need to reformat it:



# mke2fs -jv /dev/sdb3
mke2fs 1.40.8 (13-Mar-2008)
Warning: 256-byte inodes not usable on older systems
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2883584 inodes, 11520613 blocks
576030 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
352 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.


So far so good. Mount it on /mnt/lfs and we're good to go. On to chapter 3.



One small confusion about getting the matching packages is that while the manual says that an easy way to download all the packages is "by using wget-list as an input to wget", only they don't explain what that means. So here's what I did:



# cd $LFS/sources
# wget -i wget-list

[... 77 downloads later ...]

FINISHED --2009-11-12 09:22:42--
Downloaded: 77 files, 257M in 39m 57s (110 KB/s)


Actually, it turns out there is a slight clarification in the FAQ here, although they still don't clearly mention that you should cd into the $LFS/sources folder before doing the wget command. Maybe getting a little too anal but I think every little bit helps. So it took about 40 minutes to download all 77 packages. Now, onto Chapter 4, Final Preparations.



My next bit of anal retentiveness comes in the section 4.4, Setting Up the Environment. The book suggests a way to create a .bash_profile that restarts the bash shell in a "good" (ie, clean) working environment. But it doesn't really help in my openSUSE distro, because there is a system wide /etc/bash.bashrc that gets executed, "cluttering" up the environment even when the system wide /etc/profile isn't executed. So I modified the .bash_profile to be:



exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash --norc ./bash-startup


The --norc prevents both the system and the user .bashrc file from executing. And I copied the .bashrc file they say to create to bash-startup, and appended a couple of lines, leaving me with:



set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH

# my added lines to create a brand new, empty shell:
export PS1='\u:\w\$ '
exec bash --norc --noprofile


So I added the PS1 export and then re-exec bash, this time with neither the rc files or the profile files getting executed, just to be safe. Even then, there are a bunch of environment variables, but I think they are just ones that bash sets up for itself:



$ su - lfs
Password:
lfs:~$ set
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="39" [3]="1" [4]="release" [5]="i586-suse-linux-gnu")
BASH_VERSION='3.2.39(1)-release'
COLUMNS=80
DIRSTACK=()
EUID=1003
GROUPS=()
HISTFILE=/home/lfs/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/home/lfs
HOSTNAME=touch
HOSTTYPE=i586
IFS=$' \t\n'
LC_ALL=POSIX
LFS=/mnt/lfs
LFS_TGT=i686-lfs-linux-gnu
LINES=24
MACHTYPE=i586-suse-linux-gnu
MAILCHECK=60
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/tools/bin:/bin:/usr/bin
PPID=16656
PS1='\u:\w\$ '
PS2='> '
PS4='+ '
PWD=/home/lfs
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
TERM=vt100
UID=1003
_=bash
lfs:~$


Now that the environment is set, time to move on to Chapter 5.



The series so far:



  1. Scratching the Linux Itch, pt. I

  2. Scratching the Linux Itch, pt. II




Tuesday, November 10, 2009

Linux Format 125

Linux Format Dec 2009 Cover

My favorite Linux magazine, by far, is Linux Format, a UK based magazine that is just chock-a-block full of great Linux info. They also run the informative Tux Radar blog. So I thought I would just give a rundown each month of the highlights from the most recent issue.


In issue 125, dated December 2009, the cover story is Remix Linux and there's some great stuff in there about creating your own personal distro. They start with apps that let you create your own mix, working from the Ubuntu Customization Kit (or UCK for short), thru SUSE Studio, and include quick shoutouts for Revisor (the Fedora UCK equivalent) and InstalLinux.com, a cool web site for building a distro.


The next step is to build your own Arch Linux version. Looks involved but you get pretty much complete control. And speaking of hard core, the final step is a project I've always had on my back burner - Linux From Scratch. Here you build it all from sources, beginning with GCC. Follow along with the ebook and see what happens! Better than a video game, even.


My favorite sections, being the "app-aholic" I am, are the Reviews and the Hotpicks, along with the Roundup, where they examine a bunch of apps dedicated to one purpose. This month, they looked at collection managers, and, being the packrat I am, I'm hoping to give this month's winner, GCStar a whirl, esp. after finding it in the openSUSE 11.0 KDE4 repository. I also tried to compile Choqok, a Twitter client, directly from the development snapshot, but my current installation as KDE3 just doesn't seem to like compiling this KDE4 app. Other interesting apps this month include Bilbo (a blogging client now called Blogilo), Booh (generate static web albums ready to upload straight to your website), Jampa (Yet Another music player), Rednotebook (a diary, journal and notebook), and KMyMoney (a personal finance package). I played a bit with KMyMoney (again) but got stumped when I couldn't figure out how to import .OXF files. Also disappointing there's no kind of web connect, but maybe I'll get back to it.


There's also several great tutorials, including writing a Python script to get Google data and getting your backups straightened out using Backup PC (although I've always leaned towards Bacula myself).


All in all, a great deal, even for US$99 (go here for that deal). You get 13 issues a year, plus a jam packed DVD in each issue, plus access to all the back issues in PDF form. The best deal in Linux!



Thursday, July 23, 2009

Mysterious Icewind Port

This doesn't really have anything to do with Linux, but I needed to put this down somewhere so maybe it would help someone else. My friend and I like to play "hardcore" computer RPG games, cooperative style, across the Internet. We have a weekly session, playing for a couple of hours. It's the only way, really, that I would ever complete a game, as I just don't have the persistence to do it myself. I play a bit, and pretty much irregardless of how good or bad the game is, I'm always flying off, checking the next game.



Anyway, we finished Neverwinter Nights (we don't mind playing lagging edge games) and went on to play Sacred, which we picked up for cheap at the wonderful GoG (Grand Old Games) site. It was fun for the first few weeks, but then there started to be problems with the lobby server, as it isn't a direct connect game. It had become a bit of a grind, anyway, so we started looking about for a new game to play.



Unfortunately, classic, hard-core, cooperative RPG games are few and far between these days. The definitive site for all thing co-op, Co-optimus has almost no entries at all for even an action RPG to play co-op. Not sure why the well has dried up. So we decided to go really olde school and try the classic Baldur's Gate. Many years ago, in a galaxy far far away, I actually played this a bit across the 'net, but I've never really played it all that much. As I had two copies of it, I gave one to my buddy and we sat down to play it.



But we played the "Figure Out The Router/Firewall" game instead. For the next 2 hours, we tried to figure out why I couldn't connect to his server. This worked fine for both NWN and Sacred, but whenever I would type in his IP address, BG would just pause for a long time, and the come back with "Cannot Connect To Game Session". As my router is a virtually impossible to configure Juniper Netscreen router, he was hosting the games on his side. He made sure all the ports mentioned were opened, all to no avail. As well as the "official" ports (2300-2400 & 6073), someone also mentioned ports 1470, 15000, and, most importantly, ports 47624-49672. Not sure about those, but port 47624 is the DirectPlay port, so I'm not sure why this doesn't show up in the official docs.



But despite all these efforts, we just couldn't get our Baldur's Gate games to connect. So last night, we tried Icewind Dale. Still a wonderful RPG (in fact, I like it more than Baldur's Gate, despite, or perhaps because of, its more linear and hack-n-slash nature), but a slightly newer engine, esp. when updated with the Heart of Winter expansion and its Trials of Luremaster patch/expansion. So we were hoping the updated engine would be more cooperative.



But, alas, we were wrong. I still got the dreaded "Cannot Connect" error. So we then tried Hamachi, a free VPN software. Still no go. As he's a network wonk, I was sure the firewall and router was correct on his end. And I don't run a firewall at all (don't really need one if you are behind a NAT router), so it had to be my "user unfriendly pain in the butt to configure" Juniper Netgear NS5GT router. I fired up Wireshark (nee Ethereal) and began sniffing packets.



I hosted the game on another internal computer and sniffed the traffic, comparing it to the packets I was sending and receiving to my friend's machine. It was then I noticed something odd - my machine would send out a DirectPlay packet on port 47624, but it would get back the response on port 2300 on my internal connection but, of course, it wouldn't get it back from my friend's computer, because routers will allow a response on the same port but not a different one.



So I rolled up my sleeves, used some Black Belt Google Fu and found this page that describes the dozen or so steps(!) you need to go through to get it to work. I added 2300 & 47624 to my "Infinity Engine" Custom Service Object, and set the policy to forward it to my game playing machine. This got me connected but not for long. Turns out, I needed to add 2350 as well. I tried to add 2300-2400, as recommended somewhere, but the Juniper Netgear complained about not enough ports in the pool, whatever the hell that means.



And now it works. So, the basic fix is to make sure that both players port forward UDP and TCP traffic for the ports mentioned here (2300-2400, 6073) and 47624 (the DirectPlay port). I'm not sure what 6073 is for, as I don't think either of us have it set up - maybe that's an old DirectPlay service port? Yup, it is according to this (DirectPlay 8), while it say 47624 is "directplaysrvr". Not sure what the difference is, unless one is a fallback for the other. At the very least, forward ports 2300 & 2350 - I think it uses the second one by default and will only use a different one if it finds that port is busy.



Thursday, July 2, 2009

Creator and emacsclient

Some notes on using emacsclient on KDE, as I'm trying to integrate it with Qt Creator, because Qt Creator doesn't have Emacs key bindings (so far, my biggest gripe). There's an albeit painful keystroke to pass the current file off to an external editor, so I'm trying to get it to work with emacsclient. So far, here's my external editor command:



emacsclient -n +%l:%c %f



The -n tells it to not wait for the server to relinquish control of the file - I just want to edit it. +%l:%c says set the cursor at the line,column specified. The Info and Man pages for emacsclient don't specify this correctly, as they are both missing the colon.



Now I'm trying to figure out how to bring it to the front. Burying Emacs behind a bunch of windows isn't much help. I did come across a pretty cool KDE keyboard shortcut - Ctrl-Alt-A - which brings to the front the window "demanding attention", but that's not all that much help. Unfortunately, it doesn't look like a problem that has been solved for these window managers that don't allow "focus stealing".





Tuesday, June 23, 2009

Information Please

An article on Lifehacker featured an interesting utility called iotop, which gives a birds eye view of what your hard drive is up to. The commentors mentioned a couple of other interesting tools, although many seemed to be confused as to what iotop is measuring as opposed to some of the other utilities. I thought I'd do a quick write up about a few of these command line machine status reporters.



The most basic status tool is, of course, ps. In number of options, it competes with ls for most in the Linux manual! This is because it has 3 different command "modes" - UNIX, BSD and GNU versions, and all are usually mutually incompatible. ps gives you a basic snapshot of what programs are being run.



While ps is always around, the rest of these usually need special installation, although the next one, top, is almost always around. top adds more information but, most importantly, runs in a curses display, so it stays around and updates itself, giving you a constant view of what your CPU is up to. You can see it change dynamically as programs work your CPU harder. Use the 'h' key to display a help screen, giving you more sorting and display options.



View top in action


The most flexible version of ps is htop. This gives you even more information, more sorting options and an even better curses display. Again, use the 'h' command to get a full help display. I especially like htop for how it displays the complete command line.



View htop in action


iftop uses a top-like display to show you what is going on in your network (your interface). It displays the various network requests, who is making them and how much is coming and going on each. This is an especially useful command on a server, as you can see what your web server is working on, and keep useful totals.


View iftop in action



iotop again uses a top-like display to give you a real time, in-depth view of disk I/O. This is an especially useful diagnostic tool if you notice your hard disk is "thrashing" - ie, the red access light is doing a disco-like strobe effect and you're wondering who is doing all that hard drive dancing.



View iotop in action


saidar is another monitoring tool that shows a nice overview of everything going on in your computer. Useful information like CPU load, swap usage, disk space, and network traffic. Good quick clean overview.


View saidar in action


Next time, perhaps I'll take a look at some of the graphical system monitoring tools available for KDE and GNOME. If you have any other favorite terminal-based monitors, please mention them in the comments.




Wednesday, June 10, 2009

Screencasting the Creator

I'm trying out Nokia's fancy new Qt Creator IDE for developing Qt 4.5 applications. Looks pretty nice, even if Qt itself is a little fugly, given all the weird macros it uses to get its work done. Maybe this IDE will shield me from the worst of it?



Anyway, I'm going through the recommended book (C++ GUI Programming with Qt 4, Second Edition) on Safari and am finding it a bit of a chore. It is working with the older GUI design tool, Qt Designer, and not Qt Creator. As far as I can tell, there isn't much introduction material for Qt Creator. So I'll try and puzzle out the answer to some of the oddities and document them here.


So what I've done is create my very first screencast! I am using recordMyDesktop via its GUI interface qt-recordmydesktop, which works pretty well. I had the usual audio hassles, trying to figure out how to set up the mic for recording. I could never get it to use my USB headset, but luckily this lovely Plantronics USB headset comes with regular 3.5mm jacks that plug into a USB adapter, so by plugging the jacks into the back of the audio board, I could get it to record after trying various options in KMixer.


Coincidentally enough, the most recent issue of Linux Format magazine has a Roundup of screencasting tools. Their pick is the closed source DemoRecorder but it doesn't seem to offer anything that the free recordMyDesktop offers besides the ablity to save in multiple formats. recordMyDesktop only does Ogg Vorbis video, but all the upload sites convert it to Flash video anyway, so I don't really care.



I had a few problems getting the screencast to work. First off is a bug in Qt Creator, where if you rename the main widget, the compiler gets all weirded out. Took me a while to figure that one out. The workaround is to rename it from the Project creation dialog.



Then I was having problems getting the post-recording conversion to work. It would only do some of it, or not a complete audio track. Not sure what the work around was for that. I either got lucky finally or, by just leaving the computer alone until the process was done made it work. Finally, I got the 6 minute screencast to work.



I am using blip.tv to host the video. I've heard it does the best job at conversion and has the fewest restrictions on formats, as well as giving the most options for display. So, without further ado, is my very first screencast:







Wednesday, April 29, 2009

Pick The Best

The latest issue of Linux Format magazine has a very nice article on how to pick the best distro. This is a subject rife with controversy, but they do a very nice job of remaining bias free and objective. By listing a wide variety of user types, you can pick your area and see what they recommend.


I do have a couple of nits to pick with it though:



  • While Ubuntu has its strengths (the biggest of which is the vast and active user community), I think its choice of GNOME as its default desktop is a mistake. GNOME is quirky and quite different from Windows and offers up too many gratuitous changes from the "norm" for it to be a newbie friend face. KDE is much more "normal" in that respect.

  • I also disagree with the admittedly tepid recommendation to use the 64bit version of a distro. Again, just enough annoyances with not enough payback to discourage a newbie.



That being said, I enjoyed reading it and am itching to try a new distro. Still perfectly happy with my openSUSE, but I have a free 40gb partition just begging for some play time:) I did use their recommendation for Qimo as a "family friendly" distro and installed it on my daughters' computers, as WinXP was behaving very badly. They have really enjoyed the pre-installed games and creativity software. I just wish there was better support for it besides comments on a blog post. And I think it should pre-install Flash support, as that is the other big destination for the girls, Flash web games.



Now maybe try Fedora 10, which was included on a recent Linux Format DVD? Or Mandriva? or....



How to choose the best Linux distro for you | TuxRadar



Wednesday, March 11, 2009

import this


$ python
Python 2.5.2 (r252:60911, Dec 1 2008, 17:47:46)
[GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>>



Tuesday, March 10, 2009

Magazine Heaven

My favorite Linux magazine, Linux Format (out of the UK) has some interesting news:




  • A very nice podcast, which can be found at Tux Radar. Three editors talk about a wide range of Linux subjects. I have been finding it very entertaining, even if they don't have their RSS feed tags quite set up correctly.

  • They offered up a free download of their issue 116, the KDE issue. The zip file with the 3 torrents (hires, lowres, and ISO) for it is here. Very nice job!

  • And most excitingly, as they announced at the end of their latest podcast, a deal on the subscription! It's hard to justify the US$130 in these tough economic times, even if it is the best Linux magazine going. But if you follow this link, you can subscribe for "only" US$95, which is a pretty good deal for 13 issues. Linux Format sub deal



Every issue is just jammed packed with great info, from news to in depth technical tutorials. I love the mix of articles, and I love the layout. Very clean look, well edited and good stories. I highly recommend it!



Linux Journal also recently had a special ($12 for 12 issues) but I'm pretty sure that was just a day long one. However, they do have a contest to give out some free subscriptions to the digital version. You can get more details here.




Thursday, February 26, 2009

Stale Lock

I did a bad thing the other day and have just barely lived to tell about it. I turned of my Linux box without shutting down. All you Linux & Unix veterans know my horror when I realized what I had just done. I hit the shutdown button and, when the screen briefly blanked out before going into the shutdown graphic, I hit the power button on my power strip to turn it all off. Oh oh, says I...



Now, I never used to shut off my machine(s). The only time I have ever had a hardware problem (he says, knocking on wood), is when I was turning on a machine. Given that, and some daemons that like to run in the background at night, I usually left my computers turned on.



But I have started to get more worried about power consumption, including 'zombie' electronic devices, I have started to power down all the computers in the house before I head to bed. It makes me feel all virtuous and green. But the other night I nearly paid dearly for my greeness.



When I turn the computer on the next morning, it booted to a text screen. Somehow, I just wasn't surprised. But I couldn't figure out why. dmesg told me nothing, nor did /var/log/messages. But when I tried to 'startx', I got a complaint about .X0.lock and a "stale NFS handle". How odd, as I don't use NFS at all.



Well, this file proved to be very difficult to get rid of. See, when your X server starts up, it creates this file to prevent X from running twice. So at startup, it checks to see if /tmp/.X0.lock exists. If it doesn't, X will create it and carry on its merry way. If it does, it assumes X is already running and will complain, albeit in a very obscure fashion. The usual solution, if you're sure there isn't a X server already running, is to just delete it. But 'stale NFS handle' files are a real pain to delete, especially if they aren't really NFS handles!



I had an inkling that I needed to run fsck on the partition, but that's a problem on the root partition. Luckily, I have several other Linux partitions I can boot into, so I just booted up my openSUSE 11.1 and tried fsck from there. Haven't made the jump to 11.1 yet, as too many of my packages don't quite work right, or I don't like the newer versions (I'm talking to you, Eclipse Ganymede and Amarok 2). But fsck didn't find anything wrong either, so I was stuck for ideas.



But then I read about the force option for e2fsck, so I ran that. Voila! A few odd errors, but most especially an odd error with .X0.lock. So I mounted the filesystem while still in 11.1 and was finally able to delete the .X0.lock file. And the reboot back into my 11.0 openSUSE went swimmingly!



So the lessons learned:




  1. If X won't start, try removing the lock file found at /tmp/.X0.lock

  2. If you can't remove a file because there is a bogus 'stale NFS handle' error (and believe me, it doesn't let you do anything with it), try forcing an fsck on the partition





Wednesday, February 25, 2009

Big Bad SATA


So Best Buy had the much maligned Seagate 7200.11 Barracuda 1.5 terabyte hard drive on sale for a mere US$130. Given a couple of Best Buy rebates, I just couldn't resist picking it up for just a little of US$120 - incredible! I immediately went to the Seagate page to see if my drive had a firmware update, but luckily(?) it didn't so I was all set to install it.



Man, I just love the SATA connectors! Gone are the days of bending one of the gazillion little pins, or, even worse, getting it plugged in backwards. And no more slave/master settings either. Slid it into my tower, plugged two small cables into it and fired up the machine. It was immediately noticed and so now I needed to figure out how to partition it.



I created one 650gb partition for backups. I really truly am going to get a backup strategy implemented, especially now that my wife has her own laptop and is working from home. I'm going to run a Bacula server on my machine and Bacula clients on my box, my work box (WinXP) and my wife's Vista laptop. So I want to have plenty of room for storing select backups. I created this as an ext3 partition, with no access time tracking (for performance reasons), using YasT2's very easy Partitioner.



The other partition was a little more problematic. I want it to be the home for all our media - songs, movies, pictures. And I'll run a media server here. I have had real good luck with Mediatomb but Andrew Wafaa convinced me to try Coherence, a true DLNA/UPnP framework. It looks pretty neat - great, just what I need another project!



I wanted my media partition to be readable by WinXP as well as my openSUSE (and, in general, Linux) boots. I just checked so I know differently now, but I also thought that sharing a volume via Samba would require it to be a Windows partition as well. Turns out, that is a by now obvious bad conclusion, as Samba will share Linux partitions just fine. But as I wanted to use it natively as well, I still needed a Windows partition.



I was shying away from an NTFS partition, as I just wasn't sure how stable the NTFS-3G implementation was, so I started with a FAT32 partition. The biggest drawback with FAT32 is its 4gb max file size. It is also, I think, less efficient than NTFS in its structure, so it would use more space for such a large (nearly 750gb) partition. Once again, the Yast Partitioner worked great and was nearly instantaneous for FAT32 (or vfat) partition.



Now I wanted to move my ripped music CDs over to the new "mediax" partition (I couldn't use /media, as KDE uses that). As I wanted to preserve the time information, I used rsync:



$ rsync -auv Music /mediax
[lots and lots of]
/bin/cp: preserving times for `/mediax/Music/podcasts': Operation not permitted


That was odd. So without thinking about it too much, I decided to take the plunge and try out NTFS, as openSUSE 11 comes with read/write support "out of the box". So I reformatted it as NTFS (after rebooting into Windows, as Partitioner doesn't format NTFS) and tried again.



This time, it worked pretty well. openSUSE uses the "standard" NTFS-3G driver. There is an odd caveat about a slowdown with Amarok, my prefer music player, but it seems to have to do with writing, not reading, which I don't do much, so no big deal.



But I ran into a problem because of my change of heart. Because I had originally formated it with FAT32 (vfat) using the Partioner in YaST (openSUSE's graphical admin tool), and because Partioner doesn't support NTFS formating, I forgot to change the /etc/fstab file, so on reboot, it didn't work correctly. I then compounded errors by changing the 3rd column to being merely 'ntfs', which meant I was still getting the weird cp "Operation not permitted" error, which had me really confused. But I checked out swerdna's page on using NTFS on Linux and finally the light dawned on Marblehead. I changed the filetype to 'ntfs-3g' and now all is good and I can use my music collection whether I'm in Linux or (shudder) have to reboot into Windows.






Monday, January 26, 2009

Feeding The Monster

I have many different Web 2.0 personas and I'd love to pull together all the various postings and updates I do into one stream and display that. Of course, this all has a name and it is Lifestreaming. Personally, I think it is a dumb name. I like the web, and do a lot of things on the web, but trust me, it ain't my life. I prefer to call it "Webstreaming".


For the most part, Webstreaming is based on RSS feeds. But it's a complicated thing to do, as nearly every feed has some customization required to get it to display correctly. There are links, text, microblogs, audio, video, etc. There are s few sites that try to do it for you, but of course for us geeks, it has to be self hosted.


So I downloaded and installed Sweetcron, a PHP-based blog software. There are some really interesting implementations of this, most especially Tom Beardshaw, who does a lot of work on it. Unfortunately, it does require a lot of customization, done all in PHP, which is no longer a favorite language of mine. I used to like it, but now find it too idiosyncratic and prone to code breakage. I do have a rough version of it running on my new domain, IHieronym.us (I use the nom de plume Hieronymus on a few Web 2.0 sites).


As I really would rather do something in Python or, even better, Django, I went on a quest. As I said, most social media sites will report activity via an RSS stream, so I needed to find a python-based RSS parser and the most common one seems to be the Universal Feed Parser, which can deal with nearly any kind of RSS / Atom feed.


But on top of that I found Feedjack, a full blown feed "aggregator" built using both Django and Feedparser! Pretty cool stuff, although installation is a very strange thing. I'm not intimately familiar with python or Django installation issues, and found it weird how the feedjack page talks about "your Django", as Django is a library, not an installation. But what they really mean is "your Django project". So, after getting Feedparser and Feedjack installed (for openSUSE, I installed Feedparser via YaST & Feedjack via the python setup.py install process, while I on my FreeBSD box I was able to find both of them in the ports), I did the following basic steps to get a Feedjack site up and running:


$ django-admin.py startproject ihieronymus
$ cd ihieronymus
$ ls
__init__.py manage.py settings.py urls.py
__init__.pyo manage.pyo settings.pyo urls.pyo

[ after editing setting.py and urls.py as suggested here to add the admin site ]

$ python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'jdarnold'):
E-mail address: jdarnold@buddydog.org
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model
Installing index for admin.LogEntry model
$ sudo python manage.py runserver 207.22.41.217:80
Password:
Validating models...
0 errors found

Django version 1.1 pre-alpha, using settings 'ihieronymus.settings'
Development server is running at http://207.22.41.217:80/
Quit the server with CONTROL-C.
[26/Jan/2009 13:05:31] "GET / HTTP/1.1" 404 1921
^C
$


So at this point, we have a very basic djano site with the admin part all setup. Now we need to add in the Feedjack values into the settings.py file:



MEDIA_ROOT = '/www/data/'
MEDIA_URL = 'http://www.myserver.com'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'feedjack',
)


Now I need to create a link to Feedjack's static images on my 'regular' web server. Remember, the builtin Django debug server doesn't serve up static images and pages, so you need host them somewhere else. Also, on many Apache sites, it won't allow serving up pages outside of the Apache folders, so you may have to copy the folder into the Apache data folder rather than just using a symbolic link.



 $ sudo ln -s /usr/local/lib/python2.5/site-packages/Feedjack-0.9.16-py2.5.egg/feedjack/static/feedjack /www/data/feedjack


Now we should be able to run syncdb to add in Feedjacks db files:



$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in
execute_manager(settings)
File "/usr/local/lib/python2.5/site-packages/django/core/management/__init__.py", line 340, in execute_manager
utility.execute()
File "/usr/local/lib/python2.5/site-packages/django/core/management/__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.5/site-packages/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.5/site-packages/django/core/management/base.py", line 221, in execute
self.validate()
File "/usr/local/lib/python2.5/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.5/site-packages/django/core/management/validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.5/site-packages/django/db/models/loading.py", line 128, in get_app_errors
self._populate()
File "/usr/local/lib/python2.5/site-packages/django/db/models/loading.py", line 57, in _populate
self.load_app(app_name, True)
File "/usr/local/lib/python2.5/site-packages/django/db/models/loading.py", line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
File "/usr/local/lib/python2.5/site-packages/Feedjack-0.9.7-py2.5.egg/feedjack/models.py", line 19, in
class Link(models.Model):
File "/usr/local/lib/python2.5/site-packages/Feedjack-0.9.7-py2.5.egg/feedjack/models.py", line 20, in Link
name = models.CharField(maxlength=100, unique=True)
TypeError: __init__() got an unexpected keyword argument 'maxlength'
$


Darn, not quite there. This 'maxlength' problem is usually indicative of some kind of Django version mismatch. And yup, the Freebsd ports version of Feedjack is 0.9.7, while the Django version is 1.1 pre-alpha. So I grabbed and installed Feedjack v0.9.16 and now:



$ python manage.py syncdb
Creating table feedjack_link
Creating table feedjack_site
Creating table feedjack_feed
Creating table feedjack_tag
Creating table feedjack_post
Creating table feedjack_subscriber
Installing index for feedjack.Post model
Installing index for feedjack.Subscriber model
$


Spot on! Now when I run the server and go to the admin web page, I see Feedjacks new entries. Next is to try and decipher the obscure references for how to grab new feeds, as Feedjack is pretty tied to its paradigm of grabbing feeds from other People. First you add a "Site", which basically defines what your site is going to look like. Then you add some feeds, giving it the RSS url. Unfortunately, it isn't nearly as good at figuring out the correct RSS URL as is Sweetcron and many Web 2.0 sites make it far too hard to track it down. Then you need to add a "Subscriber", which links the Site to the Feed. All of this is because you can have multiple "Planets" hosted with a single Feedjack installation, but it seems to me to be overkill, as most sites, including all the ones I looked at in their links, only have one.



Now that you have a few sites, you run the feedjack_update.py script to go get the RSS feeds and drag them in. This requires a little bit of environment dancing around, as otherwise it can't find the Django info it needs:



$ pwd
/home/jdarnold/django/ihieronymus
$ export PYTHONPATH=/home/jdarnold/django
$ export DJANGO_SETTINGS_MODULE=ihieronymus.settings
$ feedjack_update.py
* BEGIN: 2009-01-26 14:43:49.014353
[2] Processing feed http://anaze.tumblr.com/rss
[2] Processed http://anaze.tumblr.com/rss in 0:00:00.341290 [ok] [new=0 updated=0 same=20 error=0]
[1] Processing feed http://linuxlove.tumblr.com/rss
[1] Processed http://linuxlove.tumblr.com/rss in 0:00:00.528515 [ok] [new=0 updated=0 same=20 error=0]
* END: 2009-01-26 14:43:49.941449 (no threadpool module available, no parallel fetching)


Oh, and you should probably get memcached running, as it really helps speed the database access. feedjack does a good job of using the cache. You can also install threadpool, as discussed on the web site, but I haven't tried that yet.



Next, of course, is the never ending customization battle. First though, I need to decide if this is the path I want to go down. Feedjack comes with two "themes", neither of which is as expressive as I want, especially for my music feeds like blip.fm and last.fm. And especially after I came across soup.io, which looks like it might already do all I need. Check out my page here: hieronymus.soup.io.