Slackware 9.0 USB Floppy Boot Mini HOWTO

Version 0.01 - July, 19th 2003

  1. Introduction

    This document intends to be a guide on how to boot a USB diskette. Maybe it is also possible to boot other USB devices but I have none available at this time for testing.

    It was written from the necessity of making a Panasonic CF-L1XA notebook boot Slackware 9.0 from its external USB disk drive. This paper is focused in this arrengment but I think it is not difficult to apply the concepts exposed here to other distributions.

  2. Background

    You will need the following pieces to make it happen:

    a) the Slackware 9.0 kernel source tree (tested 2.4.21) with the '.config' that has generated the running vmlinuz which recognizes your USB hardware and lets you mount your floppy disks under /dev/sda ;

    b) the Slackware 3 disc set: bare.i, install.1 and install.2

    c) the development tools for compiling the kernel (gcc, ld, as, etc.)

    d) two brand new formatted diskettes (one of them with ms-dos file system)

  3. Hands on it

    The way Linux kernel is written make it impossible to completely boot and load the disc set sequence from any device that is not under /dev/fd*.

    Thus it is necessary to patch the kernel to "fix" this. It is also necessary to patch "rc.S" on "install.1" disk.

    (As I said above it is necessary that you already have linux recognizing your USB floppy disk - normally as /dev/sda - with this support hardwired. If you don't know how to do this read this document)

    Lets walk thru the five steps necessary to make it work

    a) Preparing the kernel

    Make a backup copy of the current '.config'. Make shure your new '.config' has the following options hardwired (marked '*' and not modularized marked as 'M'). Use make menuconfig or whatever method you are used to.

    WARNING: these options *must* be turned on even if you don't have the corresponding hardware

    CONFIG_BLK_DEV_FD under Block devices ---> <*> Normal floppy disk support

    CONFIG_BLK_DEV_RAM under Block devices ---> <*> RAM disk support

    Patch the kernel

    Save init/do_mount.c as you wish and edit line 877 from

        int is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
        int is_floppy = (MAJOR(ROOT_DEV) == FLOPPY_MAJOR ||
                         (MAJOR(ROOT_DEV) == SCSI_DISK0_MAJOR &&
                          MINOR(ROOT_DEV) == 0));

    (Remember this is not an ultimate solution. That's why you saved do_mount.c.

    This may also collide with any SCSI device you may have but since I do not know about any notebooks with those, maybe it is not a issue!)

    Compile the kernel with "make bzImage" (don't use 'make bzlilo' since it will overwite your current linux image at the boot directory).

    b) Preparing the boot disk

    Copy the original boot disk from Slackware bare.i to the harddisk (Slackware 9.0 uses Syslinux scheme which, in turn, uses a MS-DOS formatted boot diskette)

        # mkdir /tmp/mybare.i
        # cd mybare.i
        # mount /dev/sda /mnt/floppy
        # cp /mnt/floppy/* .
        # umount /mnt/floppy
        # rm vmlinuz ldlinux.sys config
        # cp /usr/src/linux/arch/i386/boot/bzImage vmlinuz
        # cp /usr/src/linux/.config config

    Don't worry about the

    Prepare the kernel image to ask for disk change and load RamDisk (read Documentation/ramdisk.txt about this magic number)

        # rdev -r vmlinux 49152
    Now edit 'syslinux.cfg' and change the 'default' line parameters from

    Insert the new ms-dos formatted floppy into drive, execute syslinux and copy the files to this disk

        # syslinux /dev/sda
        # mount /dev/sda /mnt/floppy -t msdos
        # cp /tmp/mybare.i/* /mnt/floppy

    Your disk should look like this:

        # ls /mnt/floppy/
        config* ldlinux.sys* syslinux.cfg* vmlinuz*
        f1.txt* message.txt*

    Unmount the disk

        # umount /mnt/floppy

    The boot disk is now ready. Remove it from the driver and label it

    "Customized USB Boot Disk" (or whatever you prefer!)

    c) Preparing the install.1 disk

    Insert the original install.1 disk on the drive and create a file with its contents

        # mkdir /tmp/myinstall.1
        # cd /tmp/myinstall.1
        # gunzip < /dev/sda > install.1.fs

    This created a 6.6MBytes install.1.fs file at you hard drive.

    Now mount the file and edit rc.S inside it (loopback device support is required for this to work - "modprobe loop" may help if it is not hardwired inside kernel):

        # mount install.1.fs /mnt/floppy -o loop
        # vi /mnt/floppy/etc/rc.d/rc.S

    Since your new kernel now has support for SCSI devices and USB is simulated as one, you must copy by hand the SCSI '/dev' entries to install.1 'dev' directory

        # cp -dpR /dev/sda* /mnt/floppy/dev

    do the trick for you (/dev/sda is just what you need. we copy sda* just in case).

    At this point you may choose between:

    change '/dev/fd0' (about line 96)

       echo -n "Loading install.${NEWDISK} floppy into RAM disk... "
       ( cd / ; cat /dev/fd0 | zcat 2> /dev/null | tar xf - )
    to '/dev/sda'
       echo -n "Loading install.${NEWDISK} floppy into RAM disk... "
       ( cd / ; cat /dev/sda | zcat 2> /dev/null | tar xf - )
    and save the rc.S and remove any backup your editor may have created,


    create a link from /dev/fd0 to /dev/sda with

        # mv /dev/fd0 /dev/fd0.old
        # ln /dev/sda /dev/fd0

    With this last approach it will be possible to copy the kernel from the boot disk to harddisk during installation.

    To generate the new install.1 disk, insert the new diskette into driver and

        # umount /mnt/floppy
        # gzip -v9 < install.1.fs > /dev/sda

    (the -v9 option is imperative. It is the only compression scheme recognized by the kernel at boot time)

    The install.1 disk is now ready. Remove it from driver and label it "USB Install.1 disk".

    install.2 disk needs no modification.

    d) Preparing to boot

    You must make the target machine boot from USB even with a bootable harddisk installed. This means you have to make your USB driver the first boot device. Try booting a MS-DOS disk for example. If it doesn't, you'll have to play with you BIOS to do so.

    Some BIOS do not have an USB option on Boot menu. It is common in these machines to select a floppy disk as the first boot device and, in another menu, enable boot from USB legacy device. You must figure it out. I can't help you on this subject. A good place to start is your BIOS documentation.

    e) Reboot

    Have the disks you just created in hand, reboot you machine and Good Luck!

  4. Epilogue

    This mini HOWTO was written on a winter's saturday sunny afternoon with the beautiful mountains of Aiuruoca [I-u-roo-oh-ka] (a tiny country city at Minas Gerais-Brazil) landscaped thru my window (I said window and not Windows!)

    If you have any suggestions that may contribute to this document and would like to share, I can be reached thru ethy at inexo dot com dot br.