Chapter 11. Using Bering-uClibc with an IDE harddisk or CD-ROM drive

Revision History
Revision 0.12003-10-30kp
Initial version
Revision 0.22003-11-06kp
Additional inks for CD building
Revision 0.32003-11-19et
PXEBoot chapter
Revision 0.42004-05-27kp
added IDE chapter (from Bering Guide)
Revision 0.52004-06-24kp
reworked IDE chapter
Revision 0.62004-09-06kp
added IDE-CF chapter written by Peter Mueller

Table of Contents

initrd.lrp
Create a bootable CD-ROM
Create a bootable HD
Using pxeinstall.tgz
Create a bootable IDE-CF
Links

initrd.lrp

To boot from a IDE-based medium you need to add the ide-related modules and hd/cd-rom modules to initrd.lrp (/boot/lib/modules) and to modify /boot/etc/modules. For your convenience the Bering-uClibc team provides an already enhanced initrd.lrp with all modules needed to boot from an IDE harddisk or IDE CD-ROM drive for Bering-uClibc version 2.0 and above.

You can download the file initrd_ide_cd.lrp from CVS.

Please rename initrd_ide_cd.lrp to initrd.lrp and use this initrd.lrp while following the instructions below.

Create a bootable CD-ROM

Introduction

To create a bootable CD-ROM you may follow the instructions in the Bering User's Guide Chapter 10, with the exception that you don't have to build a new initrd if you use initrd_ide_cd.lrp renamed to initrd.lrp.

The approach described in the Bering User's Guide has the disadvantage that due to bad BIOS implementations, the CD may not boot in older computers.

We will describe the more general approach the Dachstein versions used to create a bootable CD-ROM, which allows to boot from CD on every computer that is able to boot from CD.

Main trick is to provide a bootable 1,44Mb floppy diskimage on the CD-ROM.

Step1 Create a bootable 1,44MB floppy

Format a floppy disk, add a msdos filesystem and make it bootable with syslinux:

# fdformat /dev/fd0 
# mkfs.msdos /dev/fd0 
# syslinux -sf /dev/fd0

Now mount the floppy and copy the kernel (linux), syslinux.cfg and syslinux.dpy from the Bering-uClibc diskimage onto the floppy. Copy initrd_ide_cd.lrp renamed to initrd.lrp onto the floppy.

Before umounting the floppy edit syslinux.cfg on the floppy disk.

syslinux.cfg for Bering-uClibc 2.1 and earlier versions

Edit syslinux.cfg and make shure the PKGPATH points to the CD-ROM device and floppy as well (that's the place where you store your configuration settings).

display syslinux.dpy
timeout 0
default linux initrd=initrd.lrp init=/linuxrc rw root=/dev/ram0 boot=/dev/fd0:msdos PKG
PATH=/dev/cdrom:iso9660,/dev/fd0:msdos LRP=root,etc,loca.....

Now you have a bootable floppy for your CD.

syslinuxcfg for Bering-uClibc 2.2 and later versions

Edit syslinux.cfg and change the LEAFCFG variable to point to your floppy device (so you can easily add or remove packages to load without buring a new ISO-image:

display syslinux.dpy
timeout 0
default linux initrd=initrd.lrp init=/linuxrc rw root=/dev/ram0 LEAFCFG=/dev/fd0:msdos

This will be your bootable the floppy for the CD creation.

The floppy device will be used to store your configuration settings.

Step 2: Create the CD

Now you are ready to build your CD-ROM. Create a new directory and put all packages you like to have available on your CD into it.

Next dump your boot floppy build above into the same directory.

# dd if=/dev/fd0 of=bootdisk.ima bs=8k

Create an ISO-Image from that directory and burn it.

# mkisofs -v -b bootdisk.ima -c boot.catalog -r -J -f -o Bering-uClibc-CD.iso 
# cdrecord -v dev=[target] Bering-uClibc-CD.iso

Step 3: Adding packages and backup configuration

Packages can be added or removed in a flexibel way by declaring/undeclaring them in lrpkg.cfg (Bering-uClibc <= 2.1) or leaf.cfg (Bering-uClibc >= 2.2) on a new formatted floppy.

Additionally your configuration settings for all packages can be stored on the same floppy.

Declaring packages for Bering-uClibc 2.1 and earlier versions

To add or remove packages just edit lrpkg.cfg on a blank formatted floppy disk - all entries on one line. It looks like:

root,etc,local,modules,pump,keyboard,shorwall,dnscache,webconf

Declaring packages for Bering-uClibc 2.2 and later versions

Edit leaf.cfg on a blank formatted floppy disk, add your packages to LRP and change PKGPATH to point to your CDROM and the floppy device.

LRP="root config etc local modules iptables dnsmasq keyboard shorwall ulogd libz mawk libssl libm ezipupd dropbear webconf ppp pppoe libpcap"
PKGPATH=/dev/fd0:msdos,/dev/cdrom:iso9660
syst_size=8M
log_size=2M

Note

The order in PKGPATH is important!

The leftmost entry will be loaded last - so your packages will be load first from CDROM and then from /dev/fd0. This will overwrite the configuration with the settings you stored on the floppy.

Backing up your configuration

You can backup your configuration changes onto the floppy, you have declared leaf.cfg/lrpkg.cfg.

To only backup the changes in configuration and not the complete packages, which may be too big to fit onto a floppy, choose "partial backup" and /dev/fd0 as destination for the packages.

Important

Partial backup does not work for etc.lrp.

Create a bootable HD

To install Bering-uClibc on an IDE device, proceed as follows:

You have to make sure your IDE device has a first bootable partition and is DOS formatted.

Warning

Be careful: you will be destroying any pre-existing data !

Replace initrd.lrp on your Bering-uClibc floppy with initrd_ide_cd.lrp and boot from that floppy.

Keep a second floppy with the hdsupp.lrp package around and insert this floppy after boot.

After login mount the new floppy with hdsupp.lrp, install hdsupp.lrp, partition and format your IDE disk:

mount /dev/fd0 /mnt
cp /mnt/hdsupp.lrp /
cd /
lrpkg -i hdsupp
fdisk /dev/hda

Create an empty DOS partition table (using the 'o' command), create a primary partition and make that bootable (using the 'a' command). Save your changes with 'w'.

Format the IDE device:

mkfs.msdos /dev/hda1

and create a Master Boot Record:

dd if=/usr/bin/mbr.bin of=/dev/hda bs=512 count=1

Now you can install syslinux; issue the following command:

syslinux [-s] /dev/hda1

The -s flag might be required for syslinux to work with old buggy BIOSes. See the syslinux web site for more instructions.

Umount the floppy with hdsupp.lrp, reinsert your boot floppy and mount it:

mount /dev/fd0u1680 /mnt

Once this is done, the steps for Bering-uClibc 2.1 and previous versions and Bering-uClibc 2.2 and later versions are different.

Bering-uClibc 2.1 and earlier versions

For Bering-uClibc 2.1 and earlier versions edit the syslinux.cfg file in /mnt and change the "boot" and "PKGPATH" entries to point to your harddisk. It will look like:

display syslinux.dpy
timeout 0
default linux initrd=initrd.lrp init=/linuxrc rw root=/dev/ram0 boot=/dev/hda1:msdos PKGPATH=/dev/hda1
   LRP=root,etc,loc

Once you have finished with your floppy preparation, copy all the files from it except ldlinux.sys (which is created by syslinux) to the IDE device that you prepared earlier. You should now be able to boot from the IDE device. Once again be careful not to copy ldlinux.sys from the floppy otherwise your disk won't be bootable and you will have to go over the installation of syslinux on your hard disk again.

An alternative methode is to prepare and load the packages onto your disk with pxeinstall.tgz described in the next chapter. Besides it's pretty fast, once you've setup the environment, it is especially useful if your router has no floppy drive.

Bering-uClibc 2.2 and later versions

For Bering-uClibc 2.2 and later versions edit syslinux.cfg and change the LEAFCFG variable to point to your harddisk:

display syslinux.dpy
timeout 0
default linux initrd=initrd.lrp init=/linuxrc rw root=/dev/ram0 LEAFCFG=/dev/hda1:msdos

Edit leaf.cfg and add your packages to LRP and change PKGPATH to point to your harddisk.

LRP="root config etc local modules iptables dnsmasq keyboard shorwall ulogd libz mawk libssl libm ezipupd dropbear webconf ppp pppoe libpcap"
PKGPATH=/dev/hda1:msdos
syst_size=8M
log_size=2M

If you have declared two partitions on your harddisk, and intend to use the second partition for backups, you have to add the second partition in the PKGPATH variable:

LRP="root config etc local modules iptables dnsmasq keyboard shorwall ulogd libz mawk libssl libm ezipupd dropbear webconf ppp pppoe libpcap"
PKGPATH=/dev/hda2:msdos,/dev/hda1:msdos
syst_size=8M
log_size=2M

Note

The order in PKGPATH is important!

Your second partition has to be the first entry to load the stored configuration, or partial backup, after the original (unconfigured) package.

Once you have finished with your floppy preparation, copy all the files from it EXCEPT ldlinux.sys (which is created by syslinux) to the IDE device that you prepared earlier. You should now be able to boot from the IDE device. Once again be careful not to copy ldlinux.sys from the floppy otherwise your disk won't be bootable and you will have to go over the installation of syslinux on your hard disk again.

An alternative methode is to prepare and load the packages onto your disk with pxeinstall.tgz described in the next chapter. Besides it's pretty fast, once you've setup the environment, it is useful if your router has no floppy drive.

Using pxeinstall.tgz

Introduction

This section describes how to setup an environment in which you can use PXE to boot systems like a Soekris net4501 or a LexSystem (tested with a CV860A version). A lot of information on this issue is already available on the internet. A lot of these pages describe how to get a system with complete functionality up and running this way. The main focus of this chapter is to get the system up and running with PXE boot so that you can format the CF card, put an msdos file system and syslinux on the CF card and finally copy all files necessary for a Bering(-uClibc) system on the CF card.

With the functionality of pxeinstall.tgz you can:

  • boot the system via the network,

  • put a number of different file systems on the CF card (minix, ext2, swap, msdos),

  • make the CF card bootable (syslinux) and

  • download files onto the card via http or ftp (wget)

  • download files onto the card via Windows networking (smbmount and cp)

If you need more functionality than this, you'll need to search further .....

Caution

The PXE boot functionality can only be used to get a system up and running, it is not intended to be used for regular use. For example, you cannot backup any files because the backup function does not exist.

Requirements

  • A system up and running with a DHCP and a TFTP server. I used a RedHat 9.0 system with standard dhcp and tftp servers (not the pxeboot server that comes with RH 9.0).

    Caution

    • The DHCP and the TFTP server must be running on the same ip address to get PXE boot working !!

    • The TFTP server MUST support the tsize option. The LexSystem is known to reboot without proper error messages if a TFTP server is used that doesn't support the tsize option.

  • The pxeinstall.tgz tarball which contains the files that must be put on the TFTP server.

  • Systems that do not have a keyboard and videocard (such as the Soekris) also need a system connected to the serial port so that you can control the system.

General description of the PXE boot sequence

The pxeboot sequence goes as follows:

  1. BIOS starts

    • The necessary IP addresses are acquired via DHCP. (IP address and the IP address of the TFTP server).

    • The pxelinux.0 file is downloaded from server via TFTP. (pxelinux.0 is a network boot loader).

    • The pxeconfig file is downloaded from server via TFTP. The pxeconfig file looks very much like the syslinux.conf file for normal LEAF booting. One of the additions is that some information is passed to the kernel command line for IP autoconfiguration at kernel load time (see step 3)

  2. PXELinux starts

    • The kernel is downloaded from server via TFTP from the location specified in the pxeconfig file

    • The initrd file is downloaded from server via TFTP from the location specified in the pxeconfig file

  3. Kernel starts

    • The network interface is initialized and autoconfigured using the parameters in pxelinux config file

  4. Initrd starts

    • The initrd image contains TFTP client which is used to download the packages from the TFTP server.

    • A modified linuxrc downloads the packages supplied in the LRP variable from the TFTP server address mentioned in the "boot" variable

  5. Normal leaf boot sequence continues from here. Packages are uncompressed and untarred and the system starts.

Configuration

DHCP server

To configure the DHCP server you need to find out the MAC address of the interface on which the PXE boot will take place. In most cases the MAC address is shown when the PXE client in the BIOS starts.

See the system specific sections on Soekris and LexSystem how to find out the right MAC address on your system.

When you have the address, edit the file /etc/dhcpd.conf:

#
subnet 192.168.1.0 netmask 255.255.255.0 {

    default-lease-time 600;
    max-lease-time 7200;

    host pxe {
        hardware ethernet  00:00:c3:2f:63:80;
        fixed-address 192.168.1.254;
        option host-name "pxe";
        filename "pxelinux.0";
    }
}

Restart the dhcp daemon.

TFTP server

Unzip and untar the pxeinstall.tgz file in the root directory of the TFTP server. On my system this is /tftpboot.

The directory /tftpboot/pxelinux.cfg contains three files: default, lexsystem and net4501. The file default is the one being used by the PXE boot functionality and is right after unzipping and untarring a copy of the lexsystem file.

This file has pretty much the same layout as any other syslinux.cfg file and defines where the kernel and the initial file system image can be found. Like any other LEAF distribution it also contains the packages to be installed. In this specific case the packages will be downloaded with TFTP prior to installation.

Depending on the system that you want to boot via PXE you should copy either the lexsystem file or the net4501 file to default. The lexsystem file can be used for systems with a keyboard and video card. The net4501 file should be used for systems with only a serial console.

Now that the needed servers are configured it is time to go to your specific system. In the following sections, the PXE boot sequence for the Soekris system is described, the one for LexSystem is similar.

Booting via PXE

Soekris

Connect a terminal to the serial port and fire-up your Soekris system. You should see something like this:

OS ver. 1.10  20020603  Copyright (C) 2000-2002 Soekris Engineering.

Soekris Engineering net4501               CPU 80486 134 Mhz 

0064 Mbyte Memory

PXE-M00: BootManage UNDI, PXE-2.0 (build 082)

Slot   Vend Dev  ClassRev Cmd  Stat CL LT HT  Base1    Base2   Int 
-------------------------------------------------------------------
0:00:0 1022 3000 06000000 0006 2280 00 00 00 00000000 00000000 00
0:18:0 100B 0020 02000000 0107 0290 00 3F 00 0000E001 A0000000 10
0:19:0 100B 0020 02000000 0107 0290 00 3F 00 0000E101 A0001000 11
0:20:0 100B 0020 02000000 0107 0290 00 3F 00 0000E201 A0002000 05

 5 Seconds to automatic boot.   Press Ctrl-P for entering Monitor.

Caution

The Soekris only supports PXE boot via the NET0 interface. So make sure that your NET0 interface and the DHCP/TFTP server are connected to the same network !!

Now press <Ctrl-P> and give the command boot f0.

comBIOS Monitor.   Press ? for help.

> boot F0

BootManage UNDI, PXE-2.0 (build 082)
BootManage PXE-2.0 PROM 1.0, NATSEC 1.0, SDK 3.0/082 (OEM52)
Copyright (C) 1989,2000 bootix Technology GmbH, D-41466 Neuss.
PXE Software Copyright (C) 1997, 1998, 1999, 2000 Intel Corporation.
Licensed to National Semiconductor

CLIENT MAC ADDR: 00 00 C3 2F 63 80

Here you have the MAC address that you need to configure your DHCP server. If your DHCP and TFTP server were correctly setup and are connected to the right interface of the Soekris, the boot sequence should continue with:

DHCP /

CLIENT IP: 192.168.1.254  MASK: 255.255.255.0  DHCP IP: 192.168.1.200

TFTP /

PXELINUX 1.76 2002-08-27  Copyright (C) 1994-2002 H. Peter Anvin

Linux version 2.4.18 ..............
..
<snip> Linux kernel loading
..
Kernel command line: console=ttyS0,19200 BOOT_IMAGE=pxe/linux ip=192.168.1.254:::255.255.255.0:pxe:eth0 rw initrd=pxe/initrd.lrp init=/linuxrc root=/dev/ram0 boot=/tftp/192.168.1.200 LRP=etc,inittabc,hdsupp,wget,smbmount 
..
eth0: link up.
IP-Config: Complete:
      device=eth0, addr=192.168.1.254, mask=255.255.255.0, gw=255.255.255.255,
     host=pxe, domain=, nis-domain=(none),
     bootserver=255.255.255.255, rootserver=255.255.255.255, rootpath=
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
..
<snip> kernel loading continues
..

As you see, during kernel loading the ip configuration is set based upon the parameters passed on the kernel command line.

The whole sequence should end with a login prompt. You what to do next ;-)

LexSystem

The LexSystem we have tested is based on the so-called CV860A board with a VIA C3 533A processor. The board supports up to 512MB PC133 SDRAM and is delivered with two or optional three network interfaces (usually Realtek with rtl8139too driver). Mass storage devices supported are IDE HD, CF and DOM.

It is a good idea to have LAN as third boot device in the "Advanced BIOS Features". The network interfaces can be configured by pressing <Shift-F10> to enter the NIC BIOS setup. The options that must be set here are:

  • Network Boot Protocol: PXE

  • Boot Order: Int 18h (boot the devices ordered in Bios Setup)

  • show config message and show message time do not really matter...

One of the problems of the LexSystem is, that you do can not recognize which NIC you are configuring as it is not really shown if you don't have all 3 messages enabled (3 NIC boot agent configuration roms out there). Also the order in the BIOS is not the order of the interfaces set by the linux kernel...

We had to provide an separate configuration file, because the board behaves somewhat wierd during setup/installation with pxeinstall. During pxe part of booting it uses eth0 and after getting a dhcp address and changing to TFTP to load kernel, basic cfg and basic applications it uses eth1. Additionally it is important that eth0 and eth1 connect the same LAN segment during install, because DHCP server and TFTP server has to be accessible on the same IP address.

Setting up the new system

If all went well, you should now be looking at a login prompt on your system. Login as "root", no password is required. The CF card can be formatted and installed with syslinux with the following commands:

pxe: -root-
# mkfs.msdos /dev/hda1

pxe: -root-
# syslinux /dev/hda1

pxe: -root - 
# dd if=/usr/sbin/mbr.bin of=/dev/hda bs=512 count=1

The last command installs a master boot record on to your IDE disk.

Now you can use the wget command to download all the files you need to the CF card. Another option is to use smbmount to mount a Windows share to /mnt and copy all necessary files.

Supported network cards

The pxeinstall.tgz requires that all supported network cards have to be compiled into the kernel, kernel modules for network cards are not supported. To allow you to make use of pxeinstall we added at least all modules provided with LEAF Bering-uClibc 2.0 to this special kernel . Please let us know, if you have success with hardware and network interface cards other than tested and described in this document.

Currently supported/compiled into the kernel are:

  • 3c590/3c900 series (592/595/597) "Vortex/Boomerang"

  • AT1700/1720

  • AMD PCnet32 PCI

  • DECchip Tulip (dc21x4x) PCI

  • EtherExpressPro/100

  • National Semiconductor DP8381x series PCI Ethernet

  • PCI NE2000 and clones

  • RealTek RTL-8139 PCI Fast Ethernet Adapter

  • SMC EtherPower II

  • VIA Rhine

  • Winbond W89c840 EthernetI

Create a bootable IDE-CF

This section is a contribution by Peter Mueller and describes how create a bootable IDE-CF device.

Booting from an onboard IDE-CF system

You can purchase CF-IDE adapters for very cheap. Both parts can be purchased for $30 US or less. The setup is simple. 1.) Setup the CF flash in the system. Note that you will want to configure the IDE CF card manually instead of letting IDE auto-detect the settings. To find the setting for your CF card, use IDEINFO. If you auto-configure the CF you might have big problems!!

2.) Create a dos bootdisk floppy from bootdisk.com. I have used http://csislabs.palomar.edu/Student/Utilities/boot622.exe succesfully.

3.) Install syslinux.com onto the floppy. The file is available from http://www.kernel.org/pub/linux/utils/boot/syslinux/. Grab the .zip file and extract syslinux.com onto the floppy that you just made.

Note

If you run into problems with latest version you may want to use syslinux 2.07, which has been proofed to work.

4.) Boot from the floppy on the IDE-CF system. Fdisk the drive. If there are any partitions on the drive, delete them and reboot before proceeding further. Setup a primary DOS partition,and make it active. Reboot.

5.) Boot from the floppy again. Format the CF card with "format c:".

Note

If you have other IDE devices in the system, the CF card might not be C:. Be careful here!

6.) After the format is complete, run "syslinux -s c:".

7.) Download the latest Bering-uClibc image.

8.) Using a CD-R, sneakernet (floppy), "CF on another machine", or whatever means you feel comfortable with, transfer the Bering-uClibc LRP & txt files to the floppy. Do NOT transfer ldlinux.sys or you will have to start over.

9.) Change the syslinux.cfg part "LEAFCFG=/dev/fd0:msdos" to "LEAFCFG=/dev/hda1:msdos".

10.) Change the leaf.cfg part 'PKGPATH="/dev/fd0:msdos"' to 'PKGPATH="/dev/hda1:msdos"'

11.) Install initrd.lrp with IDE support instead of standard initrd.lrp Currently this package is http://leaf.sourceforge.net/packages/uclibc-0.9/20/initrd_ide_cd.lrp Rename the package to initrd.lrp and install on the CF card.

12.) Reboot & configure your happy IDE-CF system.

Booting from a PCI-IDE CF system

Most of the steps are the same. You will need to ask the Bering-uClibc team for a kernel that supports your add-on card. Additionally, you must turn off DMA support on your device or it will work erratically. Here is how I did it in syslinux,cfg:

serial 0 19200
display syslinux.dpy
timeout 0
default bzimage initrd=initrd.lrp init=/linuxrc rw root=/dev/ram0 syst_size=20M
 log_size=20M tmpfs_size=256M LEAFCFG=/dev/hda1:msdos
append console=ttyS0,19200 nodma=hda ide=nodma

Change hda to whatever your device is. Note the syst_size, log_size, etc. options that you normally see in leaf.cfg. These can be ignored, you can put these in leaf.cfg. I have tried 10 different cards. The only card I have had any success with is the SIIG Ultra-ATA 100. The SIIG Ultra-ATA 133 is a different chipset. Here is the product - http://www.siig.com/product.asp?pid=429. If the link is broken, it is chipset CMD0649 in linux. If you have any choice at all, use onboard IDE. The add-on cards are not worth the pain.

Credits

Thanks to the Bering-uClibc & LEAF teams for a great product! Thanks Nicholas Fong! Your page @ http://chinese-watercolor.com/LRP/hd/ is very nice!

Links

Building a LEAF CD-ROM

Other sources how to build a CD-ROM are: