USB Stick GNU/Linux mini howto with Fix for "Boot error" Buggy BIOSes
I was reading some articles around the web about how building your persistent GNU/Linux system on usb stick, I found many howtos but I had problems with my BIOS.
It seems that certain versions of Award BIOS, one of the major BIOS vendor, are Buggy and misbehave with syslinux, to fix this you should give a USB-ZIP drive compatible geometry to the USB Stick. I found this useful info into the documentation inside the syslinux tarball (doc/usbkey.doc).
At this time and on this setup persistency does not work, but the diskless usb stick is still a useful tool also without persitency and if you really need it you can use another usb stick for the persistent filesystem, for doing that you need to patch initrd.gz and to create another filesystem on another device to be flagged casper-rw ... if interested take a look here to patch initrd.gz, here to customize your image and here to flag your casper-rw filesystem.
So let's come back to our project leaving persistency away for now ...
What you need to do is determine your USB Stick head and sectors needed for dealing with the mkdiskimage tool, and you can do this using fdisk, for example on my 2GB USB Stick:
NOTE: Substitute X with your letter, for example mine is "b"; if you don't know, try using something like:
# dmesg |grep -A 3 -B 3 -i usb
Once determined your USB disk device, you can go on with fdisk but be very careful, as you can loose all your data, you've been warned.
# fdisk /dev/sdX
Command (m for help): p
Disk /dev/sdb: 2029 MB, 2029518848 bytes
63 heads, 62 sectors/track, 1014 cylinders
Units = cylinders of 3906 * 512 = 1999872 bytes
Disk identifier: 0x00000000
So my USB Stick has 63 heads and 62 sectors.
After that, run the command mkdiskimage to make the Stick USB-ZIP drive geometry compliant:
mkdiskimage -4 /dev/sdX 0 63 62
"0" is for cylinders auto detection and "-4" is for create /dev/sdb4 as in USB-ZIP disks.
Wait a while as mkdiskimage will FAT16 format your device, on my 2GB it took several minutes.
Then use the loopback device to mount your ISO image, for example /home/fabio/ubuntu-7.10-desktop-i386.iso, so:
# mkdir /mnt/live_cd
# mount -o loop /home/fabio/ubuntu-7.10-desktop-i386.iso /mnt/live_cd
Mount your USB device too:
# mkdir /mnt/usb_disk
# mount /dev/sdb4 /mnt/usb_disk
Copy the files there:
# cd /mnt/live_cd
# cp -rf casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines ubuntu.ico casper/vmlinuz casper/initrd.gz install/mt86plus /mnt/usb_disk/
Move isolinux.cfg in syslinux.cfg
# cd /mnt/usb_disk
# mv isolinux.cfg syslinux.cfg
Edit syslinux.cfg to have something like this:
DEFAULT vmlinuz
GFXBOOT bootlogo
GFXBOOT-BACKGROUND 0xB6875A
APPEND file=/preseed/ubuntu.seed boot=casper initrd=initrd.gz quiet splash --
LABEL persistent
menu label ^Start Ubuntu in USB persistent mode (saves changes)
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper persistent initrd=initrd.gz quiet splash --
LABEL live
menu label ^Start Ubuntu in Live mode
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper initrd=initrd.gz quiet splash --
LABEL xforcevesa
menu label Start Ubuntu in safe ^graphics mode
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper xforcevesa initrd=initrd.gz quiet splash --
LABEL driverupdates
menu label Install with driver ^update CD
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true initrd=initrd.gz quiet splash --
LABEL oem
menu label ^OEM install (for manufacturers)
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper oem-config/enable=true initrd=initrd.gz quiet splash --
LABEL check
menu label ^Check CD for defects
kernel vmlinuz
append boot=casper integrity-check initrd=initrd.gz quiet splash --
LABEL memtest
menu label ^Memory test
kernel /install/mt86plus
append -
LABEL hd
menu label ^Boot from first hard disk
localboot 0x80
append -
DISPLAY isolinux.txt
TIMEOUT 300
PROMPT 1
F1 f1.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt
F5 f5.txt
F6 f6.txt
F7 f7.txt
F8 f8.txt
F9 f9.txt
F0 f10.txt
Umount and unplug your usb stick, than plug in again, in this way, the kernel will get the right partition id.
Run syslinux on your USB device:
# syslinux -f /dev/sdX4
To try things without reboots you can:
# apt-get install qemu
# qemu /dev/sdb
Probably with qemu things as Xorg will not work, but here it is useful to quickly check the initial boot process without rebooting ... enjoy your USB Stick GNU/Linux! ;)
- admin's blog
- Login to post comments

