Sunday, December 7, 2008

Booting Linux with 2048 bytes per sector USB flash devices

For some days I've been wanting to try a Linux distribution on my Nocturno computer (Pentium 4 3GHz, 1GB DDR2-667 RAM, 750GB in a RAID5 Array with an Areca ARC-1210 PCI-e RAID card), because I wanted something that is really stable and fast to make it a file server. The problem with that machine is that it doesn't have a CD/DVD-ROM drive, so my choices for installing are via Network or USB.

I've never bothered to do a full network installation (via TFTP with NFS root or such), and therefore I used the USB method. I own a Creative ZEN Stone with 1GB Flash device, that I used for this. The problem is that for some time now, some USB flash devices now use a 2048 Bytes per sector, instead of the common 512 bytes per sector; this device is one of them.

Once important issue with this layout is that GNU Grub (legacy) and ISOLINUX do not support these drives by default. For ISOLINUX it seems that the only way to make them work is to modify the source code, as specified by its Author; for GNU Grub perhaps there's a patch, but I haven't investigated enough.

Now you might be thinking, how do you boot a live system from these devices then? good question. The solution seems to come from the fact that these devices share a common detail with CD/DVD-ROM drives, they all use this layout. So simply using dd(1) to copy an ISO 9660 image directly into the device, works.

To verify this, I tried with Fedora 10, OpenSuse 11.0 and a custom NetBSD LiveCD built by my own application mklivecd(8). It's important that dd(1) reads and writes blocks of exactly 2048 bytes. In short, if you want to boot from USB on any of these drives, use something like:

$ dd if=/iso9660-image.iso of=/dev/sdd bs=2048

The image must be written into the whole device, and not a partition on it; just treat those USB flash drives as if they were CD/DVD-ROM discs.

No comments: