I said I'd never blog

DeforaOS, NetBSD, reverse-engineering and stuff

Older stuff...

A replacement for DPI: DPI 3D
Sat Jan 17 16:55:06 CET 2009

Still today, I often find that the notion of DPI does not work (for screens at least). The first example that comes to my mind is whenever I plug a new screen for, say, a multi-head setup.

Let's assume that all is well: we have both LCD screens, the native screen resolution is detected upon new connections, as is the actual physical size. This is unfortunately not good enough: it could very well be that the two screens are not seen from the same distance, or even by the same person in the first place.

It's not really that the concept is flawed, it's more like it misses at least another factor. Enforcing a fixed value will not cure the problem, since your second screen may as well be very big these days: while fonts may be good on your laptop at 96 DPI, you may want your assistance to be able to read from 10 meters away on your beamer...

Therefore, I suggest that we also define DPI with the notion of depth from now on. I have no idea if this idea is new, or already patented or whatever. I'm pretty sure it isn't (new). I will refer to it as « DPI 3D » (tm)(Copyright © 2009 Me) in the future. Who knows, maybe you will too :)

Seriously: I'll welcome comments and suggestions about how to solve this, and whether my idea is worth propagating. Have fun!

Installing NetBSD 5.0 on a Netbook
Mon Jan 5 03:30:07 CET 2009

First, I wish you all a happy new year, and I thank you for reading me :)

But let's get to this topic. Supposing you want to install NetBSD 5.0 onto your newly acquired Netbook (which has no CD-ROM drive), here's how you can create a bootable USB key with the necessary installation content.

Getting started

My other system is a NetBSD amd64 workstation, whereas the Netbook is i386. Once you have downloaded NetBSD sources to /usr/src:

# cd /usr
# cvs -d:anoncvs@anoncvs3.de.NetBSD.org:/cvsroot co -r netbsd-5 src

you are free to bootstrap a compilation environment, in /home/i386 for example:

# mkdir -p /home/i386/obj /home/i386/tools
# cd /usr/src
# ./build.sh -m i386 -O /home/i386/obj -T /home/i386/tools -u tools

Congratulations, you now have a cross-compiler for i386 on your system. What is usually a tedious task took only one command with the wrapper.

Compiling a kernel

It is easier to use NetBSD's build.sh wrapper again:

# cd /usr/src
# ./build.sh -m i386 -O /home/i386/obj -T /home/i386/tools -u kernel=INSTALL_FLOPPY

You should now have a kernel in /home/i386/obj/sys/arch/i386/compile/INSTALL_FLOPPY/netbsd. Let's make a copy in a more convenient location:

$ mkdir -p /tmp/netbook
$ cp /home/i386/obj/sys/arch/i386/compile/INSTALL_FLOPPY/netbsd /tmp/netbook/

This kernel is not yet usable as an installation kernel though: it is configured to run in RAM, but does not embed any such filesystem yet.

Creating a RAM disk

Again, this is quite straightforward:

# cd /usr/src/distrib/i386/ramdisks/ramdisk-big
# /home/i386/tools/bin/nbmake-i386

If all went well, you now have a ramdisk file in /home/i386/obj/distrib/i386/ramdisks/ramdisk-big/ramdisk-big.fs. If something went wrong, such as compiling restore (like for me), simply edit the list file and comment out this line as so:

#PROG	sbin/restore	sbin/rrestore

Let's make it more convenient again:

$ cp /home/i386/obj/distrib/i386/ramdisks/ramdisk-big/ramdisk-big.fs /tmp/netbook/

Preparing the kernel

We can now embed the ramdisk inside the kernel. It only takes this:

$ cd /tmp/netbook/
$ mdsetimage -v -s netbsd ramdisk-big.fs
$ gzip -9 netbsd && mv netbsd.gz netbsd-INSTALL.gz

This kernel is now able to start the installer. By booting it, we could already download and install a system, if the sets were available. Unfortunately, we may have to compile them ourselves at the moment.

Generating the sets

This should just work:

# cd /usr/src
# ./build.sh -m i386 -O /home/i386/obj -T /home/i386/tools -u sets

It will also help for the following step to copy the sets over:

$ cp -R /home/i386/obj/releasedir/i386/binary/sets /tmp/netbook/

We will also need a kernel, for which the GENERIC configuration should be safe:

# cd /usr/src
# ./build.sh -m i386 -O /home/i386/obj -T /home/i386/tools -u kernel=GENERIC

Creating the kernel set should be as simple as this:

$ cd /tmp/netbook/
$ cp /home/i386/obj/sys/arch/i386/compile/GENERIC/netbsd .
$ gzip -9 netbsd && mv netbsd.gz netbsd
$ tar -czvf kern-GENERIC.tgz ./netbsd

Make a bootable USB key

Now comes the tricky part. First, identify how your USB key is seen by the system. A good way to do so is to run:

$ tail -f /var/log/messages

and to read what the kernel has to say. It should print something like this:

/netbsd: sd0 at scsibus0 target 0 lun 0: <, , > disk removable
/netbsd: sd0: fabricating a geometry

which means, in my case, that the key is seen as sd0. If it is already formatted as a FAT volume, you should be able to mount it like this:

# mkdir -p /mnt/usb
# mount /dev/sd0e /mnt/usb

You can make sure that it is the case through the disklabel command:

# disklabel sd0
[...]
5 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 d:   2023424         0     unused      0     0        # (Cyl.      0 -    987)
 e:   2021634        62      MSDOS                     # (Cyl.      0*-    987*)

(the d partition is virtual and represents the whole disk)

Starting with the obvious, it is time to copy the installation kernel and associated sets onto the USB key:

# cp /tmp/netbook/* /mnt/usb
# mv /mnt/usb/netbsd-INSTALL.gz /mnt/usb/netbsd

Booting will also require this file on the key:

# cp /usr/mdec/boot /mnt/usb

It is time to unmount the media:

# umount /mnt/usb

And finally, the following command will make the key bootable:

# installboot -v -o timeout=5 /dev/rsd0e /usr/mdec/bootxx_msdos

Troubleshooting

If the key does not boot, it can be that:

  • there is already a bootloader in the Master Boot Record (MBR)
  • the partition needs to be active
  • the partition is incorrectly formatted

You may refer to the manual page of installboot(8) for more details. Alternatively, it is also possible to use grub to boot the key.

Come back...
Creative Commons License