DæmonNews: News and views for the BSD community

Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

Installing BSD on IBM Netvista S40 - Part 2: FreeBSD Installation

By Micho Durdevich <micho@matem.unam.mx>

In the last article, we discussed replacement bootstrap code, which more carefully deals with the A20 issue. We also discussed some simple modifications to the FreeBSD kernel code. In this article we discuss a manual method for preparing a bootable installation CD, suitable for both Netvista and all standard configurations, is examined. Installations of DragonFly, NetBSD, OpenBSD and OS/2 will be discuss in future installations.

3. Moving Hard Drive Back and Forth

A direct, although non-elegant way of installing FreeBSD is to move the hard disk on a different machine which is able to boot fine the installation CD. Once we have the operating system up and running on this auxiliary machine, we execute Netvista specific adjustments and return back the hard disk :)

Here is one working scenario, assuming we install FreeBSD 4.11 and the auxiliary machine holds only one (the Netvista) hard drive during the installation.

Step One: Install, as usual, the operating system and full sources on the auxiliary machine.

Step Two: Patch the assembler file, /usr/src/sys/boot/i386/boot2/boot1.S

, and completely remove the existing A20 subroutine from it. From the directory /usr/src/sys/boot/i386/boot2 execute

make install

This would build the stage-1 and stage-2 bootstraps, the files /boot/boot1 and /boot/boot2 respectively.

Step Three: Update the bootstrap code on the disk, by copying the bootstraps to the appropriate init areas of the disk slice.

disklabel -B ad0s1

Step Four: Compile and install a new kernel, suitable for Netvista. The essential thing here is to comment out the following two lines from the kernel configuration file as shown:

# device atkbd0 at atkbdc? irq 1 flags 0x1
# device   psm0 at atkbdc? irq 12

It is very important not to reboot after step 3, as the system would most probably crash on an auxiliary machine (which would most probably have A20 disabled at boot time). After step 4, the disk should be ready to boot FreeBSD on the Netvista (but unusable on the auxiliary machine). A more sophisticated approach is presented in the next section.

4. Creating a Compatible Installation CD

Our objective here is to create a FreeBSD installation CD that could be used on both Netvista and other systems. This should be done on a separate computer, with full sources installed. There exists a full infrastructure for creating custom FreeBSD releases (see release(7) and /usr/src/release). However, in what follows, we shall use a simple "manual" method. We shall distinguish 3 slightly different scenarios: FreeBSD 4.11, FreeBSD 5.3 and DragonFly BSD. In all three cases, we need to create a new installation disk, by replacing the file boot/cdboot with the custom-prepared counterpart. We assume that the bootstrap files have been compiled in accordance with the previous instructions (new A20 for the CD/PXE bootstrap and complete A20 code removal for HDD stage-1 and 2 bootstraps).

Step One: Copy the contents of the entire CD to a separate directory. For example (after inserting the standard install CD)

mount /cdrom; mkdir /work/qvista
cpdup -vvv   /cdrom /work/qvista

Step Two: Place the bootstrap files in the CD directory. For FreeBSD 4.11:

cd /usr/obj/usr/src/sys/boot/i386
cp boot2/boot1 /work/qvista/boot/boot1.ns40
cp boot2/boot2 /work/qvista/boot/boot2.ns40
cp cdboot/cdboot /work/qvista/boot

In addition, we should copy our custom-prepared kernel to the CD root:

cd /usr/obj/usr/src/sys/compile/qvista
cp kernel /work/qvista/kernel.ns40

As mentioned in the previous section, we should remove the atkbd/psm devices from the kernel,

# device atkbd0 at atkbdc? irq 1 flags 0x1
# device   psm0 at atkbdc? irq 12

in order for it to boot properly. In addition, this kernel should contain

options MD_ROOT
options MFS
pseudo-device md

If we deal with FreeBSD 5.3, then we only have to copy the cdboot file. And optionally, we can also

cd /usr/obj/usr/src/sys/boot/i386
cp boot2/boot /work/qvista/boot/boot.ns40

Step Three: Create the ISO-image of the new installation CD:

mkisofs -R -no-emul-boot -b boot/cdboot -c boot/boot.catalog -o /work/diskimgs/qvista.iso /work/qvista

Step Four: Burn the ISO-image. Assuming that we have an ATAPI CD-burner attached at /dev/acd0, then

burncd -f /dev/acd0 -s max -v data /work/diskimgs/qvista.iso fixate

With this new CD, the Netvista should boot without problems. In the case of FreeBSD 5.3, we would need to escape at the loader prompt and define the following hints:

set hint.atkbd.0.disabled="1"
set   hint.psm.0.disabled="1"

After the OS installation is completed, we should define the above settings in /boot/device.hints file. Alternatively, when compiling the custom kernel for the Netvista, we can then remove the options "atkbd" and "psm" from the kernel configuration file.

When installing FreeBSD 4.11 on Netvista S40 using the prepared CD, we should escape to the loader prompt, then

unload
load kernel.ns40
load -t mfs_root /boot/mfsroot
boot

The installation should work more or less as usual. However, after the installation of the operating system completes, we have to do one more step. Move to the emergency holographic shell (Alt-F4) and execute:

cp /dist/kernel.ns40 /kernel
cd /dist/boot
/sbin/disklabel -B -b boot1.ns40 -s boot2.ns40 ad0s1

In the case of FreeBSD 5.3, there is only one final and optional step:

/sbin/disklabel -B -b boot.ns40 ad0s1

However, the existing bootstrap code of FreeBSD 5.3 already contains a cx-based timeout loop in its A20 subroutine. The above step would simply spare your Netvista from executing a bunch of useless cycles every time it boots :)

5. Concluding Remarks

We have had to overcome two obstacles, both related to the absence of the standard keyboard controller. The A20 obstacle, related to deadly loops at the very beginning of the boot process, and the kernel obstacle, related to the i8042 keyboard controller code for the FreeBSD kernel. Two kernel subroutines are "guilty": atkbdc_attach and atkbd_configure.

We shall now present additional simple solutions to deal with FreeBSD 4.11 and DragonFly, that do not require including a custom-prepared kernel for the Netvista on the CD. The main idea is to modify the kernel code, so that defining a new loader variable, say at.kbdc.disabled, would control whether or not the otherwise deadly subroutines get executed.

Here are lines of the code to include in file /sys/isa/atkbd_isa.c:

static int kbdc_disabled = 0;
TUNABLE_INT(at.kbdc.disabled, &kbdc_disabled);

...
static int
atkbdc_attach(device_t dev)
{
...
    if (kbdc_disabled == 1)
       return 0;
...
}

This allows to effectively control the execution of the routine atkbdc_attach, by setting at.kbdc.disabled=1 at the loader prompt. The above code, however, does not work for atkbd_configure (defined in /sys/dev/kbd/atkbd.c) as this function gets executed at a too early stage of the kernel initialization (in order to provide keyboard support for visual userconfig module). Instead of using the TUNABLE_INT macro, we should access directly the kernel environment variables (inherited from the loader, via the bootinfo structure).

static int
atkbd_configure(int flags)
{
...
    if (getenv("at.kbdc.disabled") != NULL)
       return 0;
...
}

Another possibility is to take advantage of kernel's user configuration files. No changes are necessary to atkbdc_isa.c, however the function atkbd_configure still has to be patched, say as above. Just prepare the install CD, along the lines of the previous section, but remove userconfig_script_load="YES" from /boot/loader.conf. Together with the single kernel, include a new file /boot/netvista.conf:

di atkbdc0
di atkbd0
di psm0

At the loader prompt, we would then execute

set at.kbdc.disabled=1
load -t userconfig_script /boot/netvista.conf

The above mentioned keyboard controller backdoor routine executes too early, so the kernel userconfig script alone would not prevent the disaster. This is why we still need to set the variable at.kbdc.disabled. An alternative is just to get rid of this early probing code, assuming we would not need interactive userconfig on any of the systems we would be dealing with.

At the end of the installation process we would then only have to update the bootstraps, as explained in the previous section. Actually, using the holographic shell, we can compile and install the appropriate Netvista kernel even before the first reboot.

It is interesting to observe that the generic kernel of NetBSD does not exhibit problems on the Netvista. In contrary, it detected correctly all the components of the hardware. The only real obstacle is A20-related (the standard installation CD does not boot at all). A procedure for installing NetBSD is presented in Appendix B.

And what about OpenBSD? Well, the answer is pretty simple: To my very pleasant surprise, OpenBSD 3.6 installed just fine, out-of-the box. As with NetBSD, all hardware components of the Netvista were correctly identified by the OpenBSD generic kernel.

Google
Web daemonnews.org

More Articles
  • Interview with Diego Petteno, Gentoo/*BSD developer
  • Installing BSD on IBM Netvista S40 - Part 1: FreeBSD Installation
  • Interview with Jan Schaumann
  • Installing BSD on IBM Netvista S40 - Part 2: FreeBSD Installation
  • Interview with Theo de Raadt
  • Book Review: Virtualization with VMware ESX Server
  • Editorial: Not Quite Dead Yet
  • The Design of OpenBGPd
  • Interview with der Mouse
  • Letter to Steve Jobs
  • Interview with Manuel Bouyer on Xen
  • Apple and Open Source
  • BSDCan 2006
  • BSD Certification Survey Results
  • Lab in a Box

  • Advertisements




    Author maintains all copyrights on this article.
    Images and layout Copyright © 1998-2006 Dæmon News. All Rights Reserved.