Chapter 14. Using GRUB as an alternative boot loader for Bering

Revision History
Revision 0.92003-06-17JN
initial revision

Table of Contents

Create a partition on your disk
Step 2: Format your partition
Step 3: Copy the grub files on the CF
Step 4: Install grub files on the CF

This chapter assume that you have installed GRUB on a normal linux machine. I am using the latest 0.93 version. You can download it from here and install it following the instructions in the INSTALL FILE (Basically type ./configure;make;make install and you are done).

Be careful with the commands described below since they can easily wipe out the wrong disk if you are not careful. This chapter is definitively not for the newbie!

What follows describe the installation of GRUB and Bering on a CompactFlash (CF) disk that is being used to boot Bering from an openbrick machine.

Comments on this section should be addressed to its maintainer: Jacques Nilo .

Create a partition on your disk

To do that use the fdisk utility. I do it from a linux box which access the CF through a cheap 6-in-1 USB card reader. In this environnement, the CF is recognized as /dev/sda.

debian:~# fdisk /dev/sda

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1015, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1015, default 1015):
Using default value 1015

Command (m for help): p

Disk /dev/sda: 2 heads, 62 sectors, 1015 cylinders
Units = cylinders of 124 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1      1015     62899   83  Linux

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): L

 0  Empty           1c  Hidden Win95 FA 65  Novell Netware  bb  Boot Wizard hid
 1  FAT12           1e  Hidden Win95 FA 70  DiskSecure Mult c1  DRDOS/sec (FAT-
 2  XENIX root      24  NEC DOS         75  PC/IX           c4  DRDOS/sec (FAT-
 3  XENIX usr       39  Plan 9          80  Old Minix       c6  DRDOS/sec (FAT-
 4  FAT16 <32M      3c  PartitionMagic  81  Minix / old Lin c7  Syrinx
 5  Extended        40  Venix 80286     82  Linux swap      da  Non-FS data
 6  FAT16           41  PPC PReP Boot   83  Linux           db  CP/M / CTOS / .
 7  HPFS/NTFS       42  SFS             84  OS/2 hidden C:  de  Dell Utility
 8  AIX             4d  QNX4.x          85  Linux extended  df  BootIt
 9  AIX bootable    4e  QNX4.x 2nd part 86  NTFS volume set e1  DOS access
 a  OS/2 Boot Manag 4f  QNX4.x 3rd part 87  NTFS volume set e3  DOS R/O
 b  Win95 FAT32     50  OnTrack DM      8e  Linux LVM       e4  SpeedStor
 c  Win95 FAT32 (LB 51  OnTrack DM6 Aux 93  Amoeba          eb  BeOS fs
 e  Win95 FAT16 (LB 52  CP/M            94  Amoeba BBT      ee  EFI GPT
 f  Win95 Ext'd (LB 53  OnTrack DM6 Aux 9f  BSD/OS          ef  EFI (FAT-12/16/
10  OPUS            54  OnTrackDM6      a0  IBM Thinkpad hi f0  Linux/PA-RISC b
11  Hidden FAT12    55  EZ-Drive        a5  FreeBSD         f1  SpeedStor
12  Compaq diagnost 56  Golden Bow      a6  OpenBSD         f4  SpeedStor
14  Hidden FAT16 <3 5c  Priam Edisk     a7  NeXTSTEP        f2  DOS secondary
16  Hidden FAT16    61  SpeedStor       a9  NetBSD          fd  Linux raid auto
17  Hidden HPFS/NTF 63  GNU HURD or Sys b7  BSDI fs         fe  LANstep
18  AST SmartSleep  64  Novell Netware  b8  BSDI swap       ff  BBT
1b  Hidden Win95 FA
Hex code (type L to list codes): 1
Changed system type of partition 1 to 1 (FAT12)

Command (m for help): p

Disk /dev/sda: 2 heads, 62 sectors, 1015 cylinders
Units = cylinders of 124 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1      1015     62899    1  FAT12

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sda: 2 heads, 62 sectors, 1015 cylinders
Units = cylinders of 124 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1      1015     62899    1  FAT12

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
debian:~#

You could of course create several partitions (up to 4) on this disk if you want to store different versions of Bering in each of those.

Step 2: Format your partition

As root, use the mkdosfs utility of your host machine to format the partition(s) you have just created:

debian:~# mkdosfs /dev/sda1
mkdosfs 2.8 (28 Feb 2001)

Step 3: Copy the grub files on the CF

I assume that you have installed GRUB on your host machine. Then do the following:

debian:~# mount -t msdos /dev/sda1 /mnt
debian:~# cd /mnt
debian:/mnt# mkdir boot
debian:/mnt# cd boot/
debian:/mnt/boot# mkdir grub
debian:/mnt/boot# cd grub/
debian:/mnt/boot/grub# cp /home/leaf/grub-0.93/stage1/stage1 .
debian:/mnt/boot/grub# cp /home/leaf/grub-0.93/stage2/stage2 .
debian:/mnt/boot/grub# cp /root/bering-grub-ext2/boot/grub/menu.lst .
debian:/mnt/boot/grub# ls -la
total 112
drwxr-xr-x    2 root     root         2048 Mar 10 23:08 .
drwxr-xr-x    3 root     root         2048 Mar 10 23:00 ..
-rwxr-xr-x    1 root     root          490 Mar 10 23:01 menu.lst
-rwxr-xr-x    1 root     root          512 Mar 10 23:01 stage1
-rwxr-xr-x    1 root     root       106160 Mar 10 23:01 stage2

Edit the menu.lst file so that it will look like:

debian:/mnt/boot/grub# cat menu.lst
#Useful extras:
#serial --speed=9600
#terminal --timeout=2 serial console
#password --md5 $1TH$8O$%w0$d&^20R4ff&^*a2K/oUm.

root (hd0,0)
timeout 5
default 0

# For booting Linux
title LEAF Bering Version 1.1
kernel /linux init=/linuxrc rw root=/dev/ram0 boot=/dev/hda1:msdos \
  PKGPATH=/dev/hda1 initrd=initrd.lrp \
  LRP=root,etc,log,local,modules,keyboard,iptables,shorwall,dnscache,ulogd,weblet
# yes, you need the initrd.lrp line twice, once above, and once here
initrd /initrd.lrp

Your CF is declared as hda1, because it will boot as hda1 on your Bering box.

Then umount your CF:

debian:/mnt# cd /
debian:/# umount /mnt

Step 4: Install grub files on the CF

Once again I will use the grub program installed on the host machine:

debian:/# grub
Probing devices to guess BIOS drives. This may take a long time.


    GRUB  version 0.93  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]

grub> root (hd
 Possible disks are:  hd0 hd1 hd2

grub> root (hd2,0)
 Filesystem type is fat, partition type 0x1

grub> setup (hd2)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/fat_stage1_5" exists... no
 Running "install /boot/grub/stage1 (hd2) /boot/grub/stage2 p /boot/grub/menu.lst "... succeeded
Done.

grub>quit

What you have to type is what appears in front of the grub> prompt above. In the first entry "root (hd" you can type on the TAB key at the end to see the devices that are recognized. Here my /dev/sda device shows up as hd2. This is confirmed by the fact that once I have fully declared the disk, the msdos partition is recognized. Then issue the setup command and you are done. Your CF should now be able to boot from GRUB. At this stage look in the GRUB manual to refine your menu, add new options,.. I leave that to you :-)