Wednesday, September 27, 2006

Grub2 on soekris net4801

Outline
I. Requirements
II. Compile via source
III. Installation on target device
IV. Grub configuration
V. Soekris net4801 configuration
VI. Minicom configuration
VII. Related resource - Debian/GNU Linux installation

Requirements
- Download grub2 (latest alpha! build is 1.94)
- build-essential (glibc6, gcc4, make, etc), depends on your Linux installation
- minicom for terminal emulation
- I am installing grub2 on a cf.

Installation via source
- Download grub2.
- Auto-configure with serial enabled and install root directory set to /usr/local:
./configure --prefix=/usr/local --enable-serial

- Build:
make

- Install binaries and libraries:
make install

Installation on target boot device
* grub-install - installs grub2 on your device
* grub-setup - set up images to boot from your device

- grub-install: (grub-install --help to see available options)

Example:

grub-install --root-directory=/media/usbdisk /dev/sdb1


Note 1: Make sure that you are using the binary that you just compiled and installed. Earlier, I indicated /usr/local as my prefix. In this case, the binaries can be found in /usr/local/bin and /usr/local/sbin.

Note 2: When I run the command, I get the following errors:
grub-probefs: error: Cannot get the real path of `/dev/fd0'
Auto-detection of a filesystem module failed.
Please specify the module with the option `--modules' explicitly.

The fix is to explicitly indicate the module ext2 (I am installing on an ext2 filesystem) and skip the floppy probing. I skip the floppy probing my copying a device.map without the /dev/fd0 mapping to the folder indicated in --root-directory=. This command copies the device.map to its proper location:
cp /its_dir/device.map /media/usbdisk/boot/grub

My device.map looks like this:
(hd0)   /dev/hda
(hd1) /dev/sdb

The working command is as follows:

./grub-install --modules=ext2 --root-directory=/media/usbdisk /dev/sdb1


- grub-setup:

Example:
grub-setup -d /media/usbdisk/boot/grub -v -r "(hd1,0)" \ 
-m /media/usbdisk/boot/grub/device.map "(hd1)"

Note: Grub has a different naming scheme for devices. hd1 is mapped to /dev/sdb as indicated in device.map. The 0 (zero) denotes the first partition of /dev/sdb (i.e. /dev/sdb1).

Grub configuration
Sample grub configuration file in /{root_device_dir}/boot/grub/grub.cfg
#serial --unit=0 --speed=19200 --word=8 --parity=no --stop=1
#terminal serial

# Timeout for menu
#set timeout=10

# Set default boot entry as Entry 0
set default=0

# Entry 0 - Load Linux kernel
menuentry "My Linux Kernel on (hd0,1)" {
set root=(hd0,1)
linux /vmlinuz root=/dev/hda2 console=ttyS0,9600
initrd /initrd
}

# Entry 1 - Chainload another bootloader
menuentry "Chainload my OS" {
set root=(hd0,3)
chainloader +1
}


Note: Uncomment the first two lines if you want a serial terminal for grub2. Refer to the Grub2 documentation for the available commands.

Soekris net4801 configuration
The default baud rate of grub2 is 9600. You can set the parameter in the Monitor (Ctrl+P) using the command:
set ConSpeed=9600.

Minicom configuration
This is the content of my minicom configuration file in /etc/minicom/minirc.dfl:

pu port             /dev/ttyS0
#pu baudrate 115200
#pu baudrate 19200
pu baudrate 9600
pu bits 8
pu parity N
pu stopbits 1
pu rtscts No
pu xonxoff No


NOTE: The last two lines are important to disable the software and hardware flow control in minicom.

It's now time to boot!

Related Resources
To install an OS, you can follow this documentation to install Debian GNU/Linux.

Sunday, September 10, 2006

Ubuntu network install with Intel Boot Agent

I have an IBM Thinkpad Transnote that does not have any CD drive. I am left with the network install option. This was an easy task when I was still using Mandriva (formerly Mandrake) because the installer includes the images for bootable floppy drives. With Ubuntu, you are left with an option of using your motherboard / Ethernet card's booting capability. My options are: etherboot and the on-board Intel Boot Agent that supports PXE to boot. The following steps will guide you in booting the Ubuntu installer using the Intel Boot Agent. Note that the Ubuntu installer is just a bootstrap, you will have to download the rest of the packages on the Internet. Alternatively, I think you can hack the installer to get the packages from a local host (but this is out of the scope).

Terms

* The client is the laptop that has to be installed with Ubuntu.
* The server serves the client (duh!). I am running Ubuntu Dapper (6.06).

DHCP server

We need a DHCP server to serve the client with the network settings (IP, router, DNS addresses). I used Ubuntu's dhcpd. My /etc/dhcpd.conf contains the following lines:

option subnet-mask 255.255.128.0;
default-lease-time 600;
max-lease-time 7200;
option domain-name-servers 10.32.1.7;
option routers 10.36.0.1;
allow booting;
allow bootp;

#my IBM Thinkpad
subnet 10.36.2.0 netmask 255.255.255.0 {
host premthinkpad {
hardware ethernet 00:10:A4:78:C2:D5;
fixed-address 10.36.2.90;
filename "pxelinux.0";
next-server 10.36.2.217;
}
}


DHCP-BOOT

I used another DHCP server dnsmasq which supposedly serves the purpose of the line:

filename "pxelinux.0";

in the previous configuration. I am not sure which one is working so just install these two daemons (dhcpd and dnsmasq).

TFTP server

Install a tftp server. I used tftpd-hpa, it supports the PXE protocol.

Ubuntu's netboot

Download Ubuntu's netboot tar file. I got the links from this page [1].

Ubuntu Dapper netboot archive

Place the boot files to the tftp folder:

tar -xvzf netboot.tar.gz -C /var/lib/tftpboot/
chown -R nobody:nogroup /var/lib/tftpboot


Enable the tftp server using the xinetd service. Add the ff. lines to /etc/xinet.d/tftp:

service tftp
{
disable = no
socket_type = dgram
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -v -s /var/lib/tftpboot
only_from = 10.36.2.0/23
interface = 10.36.2.217
}


If the file does not exist, create it. Restart xinetd:

killall -HUP xinetd


Intel Boot Agent

Configure the BIOS to boot using the Intel Boot Agent. You should see a DHCPD discover request sent by the client. Then, it will load the Ubuntu installer.

Good luck!

Contact

If you have questions, post them at Ubuntu Forums, then leave a comment.

Resources

* [1] https://wiki.ubuntu.com/Installation/Netboot
* Thinkpads without CD-ROM drive
* Ubuntu network install

Linux on a Compaq Presario V2000

GNU/Linux (Ubuntu 5.10) on a Compaq Presario V2000

How to make the volume keys work

Objective: Map the volume keys (Volume up/down/mute) to amixer (command-line mixer for ALSA soundcard driver).

Find the keycode of the three keys using xev. After executing xev as an ordinary user in the terminal, it creates a window and then asks the X server to send it events whenever anything happens to the window (such as it being moved, resized, typed in, clicked in, etc.).

Example: after pressing the keyboard key m, you will be see the following report:

KeyPress event, serial 27, synthetic NO, window 0x2800001,
root 0x48, subw 0x0, time 10163530, (97,69), root:(929,430),
state 0x0, ''keycode 58 (keysym 0x6d, m)'', same_screen YES,
XLookupString gives 1 bytes: (6d) "m"

KeyRelease event, serial 27, synthetic NO, window 0x2800001,
root 0x48, subw 0x0, time 10163645, (97,69), root:(929,430),
state 0x0, ''keycode 58 (keysym 0x6d, m)'', same_screen YES,
XLookupString gives 1 bytes: (6d) "m"


These two events are the pressing and de-pressing of key m. The keycode is 58 and it is symbolically mapped to character/string m.

Try pressing the three keys (volume up/down/mute), you will most likely get the following keycodes:

* 174 - volume down
* 176 - volume up
* 160 - mute

with no symbolic mapping. To map these keycodes, create the file in your home folder ~/.Xmodmap with the following mapping:

keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 160 = XF86AudioMute


Use your window manager's (e.g. Gnome metacity, mine is Xfce) key shortcut manager. This allows you to map a keyboard shortcut to a command.

Example: (applicable only in Xfce)

Settings > Xfce 4 Settings Manager > Window Manager > Keyboard (tab)

Under command shortcuts, click none to add a command, then simulate the key (i.e. pressing the volume up/down/mute key)

The commands to adjust the mixer (using amixer) are the following:

* /usr/bin/amixer sset Master toggle - toggle mute
* /usr/bin/amixer sset Master 1- unmute - decrease vol
* /usr/bin/amixer sset Master 1+ unmute - increase vol

Master is the (grand) master mixer control.

Hope that helps.

Contact

If you have questions, post them at Ubuntu Forums, then leave a comment.

Resources
* Linux (Ubuntu 5.10) on a Compaq V2000
* Ubuntu GNU/Linux on the HP Compaq nw8240