Monday, 18 January 2010

Booting Ubuntu/Linux Mint from ISO

Last time I prepared the USB drive to boot from ISO. That's great, but it's no good if there are no ISOs to boot into.

First off, I set up Ubuntu in GRUB. Fortunately, this was pretty easy to do. Ubuntu supports booting from ISO using the iso-scan kernel parameter. Since Linux Mint is derived from Ubuntu, it also supports this parameter. The following lines in the GRUB2 config will enable booting from a Ubuntu/Linux Mint ISO.

menuentry "Ubuntu 9.10 32bit" {
    loopback loop /ubuntu-9.10-desktop-i386.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu-9.10-desktop-i386.iso noeject noprompt --
    initrd (loop)/casper/initrd.lz
}

The loopback line loads the ISO in a way that GRUB can locate the kernel and initrd. The stuff about casper is something used for data persistence (so that the ISO remains read-only). I don't have that enabled yet. This GRUB entry works similarly for Ubuntu (32- & 64-bit), Ubuntu Netbook Remix, and Linux Mint (32- & 64-bit).

Saturday, 16 January 2010

Booting multiple live CD's from a single USB

Recently, I got a 1TB USB drive. I was planning on using this just for backups, but quite frankly, it's so big there's no need to limit it to just that. So I decided I'd put a few live CD images on it somehow to get a sort of universal test drive. I set aside about 30G which is way overkill, but in GiB, it meant the remaining was a round 900 (darn GB vs GiB thing).

First thing's first, what to put on it? I figure Ubuntu's a good choice for a beginner Linux that would probably boot anywhere (or try to). Along with that, Linux Mint seems to be a great looking option, too. Plus it's green! Also, Fedora since I'm using that on the laptop. Maybe Ubuntu Netbook Remix and something similar like Moblin. And since I'm a bit crazy, there'd have to be the 64-bit versions too. Finally, a few recovery things like GParted or similar.

Now that I have some idea what to get, I have to figure out how to get it to boot. Since I need to get a few live CD's working at the same time, I figure I can't just extract them at the root of the drive (like you would if you wanted a regular LiveUSB). So the question is how I can get them to boot straight from the ISO. First, I need a bootloader that will understand ISO files for me. I saw a few patches to GRUB to do this, but it looks like GRUB 2 proper also supports loading from an ISO, though it's still experimental. Since it's unstable in Gentoo, I had to unmask it first. I also set the multislot USE flag on GRUB so I wouldn't lose the stable version.

# Unmask GRUB 2
echo "=sys-boot/grub-1.97.1 **" >> /etc/portage/package.keywords
echo "sys-boot/grub multislot" >> /etc/portage/package.use
emerge -va =sys-boot/grub-1.97.1
# My USB drive is on /dev/sdf
# and the partition is labelled "LiveLinux"
grub2-install --no-floppy --root-directory=/media/LiveLinux /dev/sdf

Next I'll go over the results of trying to get each LiveCD to boot from ISO.

Tuesday, 12 January 2010

My first kernel patch

OK, so it's not really anything big. In fact, it's really just a copy and paste (almost).

So, way back when acerhk actually compiled, I was able to use the extra keys on the laptop. These were the volume, media, mail, etc. keys. Now with Fedora and a much newer kernel, it no longer compiles.

Every once in a while, I tried to see if I could fix the compile, but never really got anywhere. But then I found something interesting in the kernel sources. In drivers/input/serio/i8042-x86ia64io.h there was something about a Dritek quirk. I recognized the name as something the acerhk driver also supplied. So, I rebooted and tried that out using i8042.dritek=1 and voilĂ , the extra keys worked. And a quick copy and paste later and I had me a patch. Just like that:

@@ -467,6 +467,13 @@ static struct dmi_system_id __initdata i
  */
 static struct dmi_system_id __initdata i8042_dmi_dritek_table[] = {
     {
+        .ident = "Acer Aspire 5610",
+        .matches = {
+            DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+            DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
+        },
+    },
+    {
         .ident = "Acer Aspire 5630",
         .matches = {
             DMI_MATCH(DMI_SYS_VENDOR, "Acer"),

Tuesday, 29 December 2009

When the power goes out...

A little while ago, one of my friends text me because the power had gone out in her building. She was wondering whether the power was out where I was. Fortunately for me, the power was just fine.

So I thought to myself, "I've got the power of the Internet to look into these things!" Off to Google, and it turns out it's pretty hard to find out about recent power outages. What came up was lots and lots of old news about previous outages that were already fixed. Now I'm pretty good with my Google-fu, so maybe it was just a minor outage and thus less (or no) news.

However, I did manage to find this little page. It's a map with the location of power outages and repairs in regions covered by HydroOne, the power distribution company for Ontario. Now this is how important services should be run. The information is available easily, and quickly. In fact, it's got its own link right on the front page. The one problem is, if you follow the blue line, you'll see that Toronto is excluded. That's because we have our own local power supply company here, Toronto Hydro. So I can't find out about my friend's problem from HydroOne.

What can I find on Toronto Hydro's website? Absolutely nothing. Well, actually, what I found was a lot of stuff I don't want. There are many pages about things I might be interested in if I were a customer. But the most important information, the availability of the service, is not there. It would be great if the power never went out, but let's face it, even with perfect equipment, someone's going to go drive into a transformer or something that's going to disrupt service. The closest thing I could find about service reliability on Toronto Hydro's site is to "Report a Streetlight out". While a broken streetlight is unsafe in certain locations, wouldn't the power being out be even worse? I guess they just figure that if the power's out in your area, you won't be able to look up the fact that the power's out or when it's going to be fixed.

Saturday, 26 December 2009

Christmas Trees

So, I have this mini Christmas tree, with some fibre optics, that pulses red and white. A while back, it stopped working and I planned to fix it, but never got around to it. Until now!

I managed to cobble together a simple circuit based on a 555 timer. Here's a shot of the test on the breadboard. Basically, it's the 555 in astable mode, with a couple capacitors to smooth out the transitions.

The test had reds, but I put alternating red and yellow on the final circuit because yellow looked pretty good. Each side has a different size capacitor because it just pulses better that way. I managed to put this together on a little board. The wires on the right go to the LEDs.

With a little knife-work, I managed to size it up right. The wires are a little stiff, but a bit of jiggling got them in there.

Saturday, 28 November 2009

SELinux Re-labelling

So yesterday, I downgraded from ext4 to ext3. I think I forgot to set SELinux to permissive, so a couple things ended up wrong. I re-labelled everything. This is what it looked like:

Now, there are a few things wrong there. First, the text really doesn't doesn't fit in. I think this is because KMS sets up the blue background, but isn't quite connected to the virtual console nicely. There's always work going on there, but it's not quite right yet. It's always getting better though.

The second thing, you might not notice at first. But if you look between the first paragraph and the lines of stars, then you'll notice some random characters. Those were typed by me. You see, nothing happens between printing the first two lines and the first asterisk. I think I read somewhere that each one corresponds to a few thousand files, but it took so long, I almost thought something had frozen. Fortunately, I let it continue and it finished correctly. But I really think there should be a better indication of activity in between asterisks.

Friday, 27 November 2009

Downgrading ext4 to ext3

So, a little while ago, I replaced Gentoo with Fedora 11 on my laptop. The laptop is a little older and prone to overheating when compiling, so I didn't see the value in using Gentoo there. And I never quite figured out the cross-compile for my desktop since it was AMD64->x86.

I ran into one very annoying problem, and that was with ext4. Every so often, any disk I/O would just stop. I could no longer load programs, and if anything attempted to write a file, it would freeze (technically, it would enter the "uninterruptible" state and get stuck). I found a few kernel OOPS in the log, and reported those with the Fedora tool for that, but it didn't seem like it happened for many people.

In any case, the real problem is that I had to force a reboot, and ext4 would always lose something. Sometimes it was some just-created data that could be replaced, and other times, the whole file system seemed messed up. Random libraries would crash or fail to load because they were corrupted. It was quite annoying.

So, I've been looking for a way to 'downgrade' to ext3. I've used ext3 for a long time on my desktop, and also on the laptop with Gentoo, and never ran into anything quite so bad. The only problem was no-one seemed to have a guide to go to ext 3. The best I could find is to create a new partition and copy files there. Unfortunately, I didn't have enough free space to get that done. (Re-partitioning is not that hard since Fedora uses LVM.)

After much searching, I have managed to find a solution. Fsarchiver provides an easy way to back up a complete file system. Once you have that backup, you can recreate it using a different file system format without losing any of the metadata (assuming the new one supports it all). Also, because it uses compression, I was able to fit what I needed onto a USB stick, and restore from there.

I used the Fedora 11 LiveCD (on the same USB stick I used for the backup) to do all of this. Fortunately, fsarchiver is provided in a Fedora package that can be installed from the default repositories. I'm doing this from memory, but it should go something like this (I'll only show the fsarchiver bits):

yum install fsarchiver
fsarchiver savefs /media/live/rootfs.fsa /dev/mapper/lvm_name
<re-format partition>
fsarchiver restfs /media/live/rootfs.fsa id=0,dest=/dev/mapper/lvm_name,mkfs=ext3