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!