Saturday, 30 January 2010

Booting recovery images from USB

So, I'm still trying to figure out the Fedora boot, but in the meantime, I tried to figure out how to boot from a few recovery systems.

First off, let's try Parted Magic. This one is pretty simple since they provide a "USB" version. If you extract that, you'll find a boot and a pmagic folder. Copy the pmagic folder to the USB drive. In boot/grub/grub.lst, you'll find a whole bunch of boot options. I only chose the default and failsafe versions for my USB, but some of the others might be useful for you. For GRUB2, however, it'll look a little different:

menuentry "Parted Magic (Default)" {
    linux /pmagic/bzImage edd=off noapic load_ramdisk=1 prompt_ramdisk=0 \
        rw vga=791 loglevel=0 max_loop=256 keymap=us
    initrd /pmagic/initramfs
}

menuentry "Parted Magic (Failsafe)" {
    linux /pmagic/bzImage edd=off acpi=off noapic load_ramdisk=1 \
        prompt_ramdisk=0 rw vga=normal nolapic nopcmcia noscsi nogpm \
        consoleboot nosmart keymap=us nosshd nosound max_loop=256
    initrd /pmagic/initramfs
}

Second, you'll probably want memtest. The memtest page has a "Pre-Compiled Bootable Binary" which works just fine. You can also find memtest in the PartedMagic package. Whichever one you choose, it can just be placed directly on the USB drive. The line in GRUB2 is not exactly the same for memtest since it's 16-bit:

menuentry "Memory test (memtest86+)" {
    linux16 /memtest86+.bin
}

Sunday, 24 January 2010

Trying to boot Fedora from ISO

Last time I managed to boot Ubuntu and Linux Mint from ISO pretty easily. Unfortunately, Fedora does not work so simply. There is no iso-scan parameter that can be used for it.

Fedora uses Dracut to create its initramfs infrastructure. From that page, I found the rdshell parameter that could be added to the kernel command line to get into a shell before switching to the real root and init. Once there, I was able to mount the USB drive, then the ISO, and finally the actual live image. So I knew that it should be possible to boot from ISO, but the initramfs doesn't have any parameter to look for it. And useful for later, I found the the version of dracut was 002-13.4.git8f397a9b.fc12.

I went looking at the Dracut pages a little more, and it turns out that support for booting off an ISO was added, and is in dracut-004. Which is great, except of course, it means it's not on the existing image. The commit was easy to find, and seemed self-contained, so I figured I might be able to patch the existing initramfs myself. It would probably be better to just build it from scratch, but I don't think I have everything installed for it and it didn't look like too big of a change to do manually. Modifying the initramfs was simple:

mount -o loop Fedora-12-i686-Live.iso /mnt/cdrom
zcat /mnt/cdrom/isolinux/initrd0.img | cpio -iV
# Modify files here
find . | cpio -oVH newc | gzip > /media/LiveLinux/boot/F12-i686-initrd.img

Now for that modify step, you need to look at the install script of the 90dmsquash-live module to see where dracut would be installing the modified files. Anyway, that seemed to work up until getting past dracut. I saw plymouth start up, but then the kernel complained about the invalid root. Obviously, the ISO was not actually mounted in the end. I even booted to the dracut shell and found no trace of the USB drive. I'm waiting to see if the comments on bug 557426 will help explain something.

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"),