debootstrap and GRUB bootloader
I want to build a Debian system using debootstrap and install that on
a Compact Flash card for an x86 embedded system.
I have created and mounted a fresh file system on a logical volume
which I install the new Debian system into using debootstrap. That
works fine and I can chroot into the new system and install some more
package using aptitude. This is done by a simple shell script:
#!/bin/sh
mkfs /dev/vg0/cu
mount /dev/vg0/cu cu
debootstrap lenny cu
cp config/etc/hostname cu/etc
cp config/etc/fstab cu/etc
...
chroot cu <<EOF
mount /proc
mount /dev/pts
mount -t sysfs sysfs /sys
aptitude update
aptitude install -y -R iproute less wpasupplicant ferm tcpdump ppp \
pciutils openssh-{client,server} telnet ftp hdparm bridge-utils \
bzip2 file dnsutils dhcp3-server bind9 ntp ntpdate grub
umount /sys
umount /dev/pts
umount /proc
EOF
I then copy the file system image onto the Compact Flash card using dd
# umount /dev/vg0/cu
# dd if=/dev/vg0/cu of=/dev/sdb1
But then, installing the GRUB bootloader fails:
# mount /dev/sdb1 /mnt
# chroot /mnt
# mknod /dev/sdb b 8 16
# mknod /dev/sdb1 b 8 17
# ls -A /boot
# grub-install /dev/sdb
Searching for GRUB installation directory ... found: /boot/grub
The file /boot/grub/stage1 not read correctly.
# ls -AF /boot
grub/
# ls -lAF /boot/grub
total 212
-rw-r--r-- 1 root root 197 Aug 15 14:15 default
-rw-r--r-- 1 root root 15 Aug 15 14:15 device.map
-rw-r--r-- 1 root root 8704 Aug 15 14:15 e2fs_stage1_5
-rw-r--r-- 1 root root 8544 Aug 15 14:15 fat_stage1_5
-rw-r--r-- 1 root root 9568 Aug 15 14:15 jfs_stage1_5
-rw-r--r-- 1 root root 7904 Aug 15 14:15 minix_stage1_5
-rw-r--r-- 1 root root 10720 Aug 15 14:15 reiserfs_stage1_5
-rw-r--r-- 1 root root 512 Aug 15 14:15 stage1
-rw-r--r-- 1 root root 128616 Aug 15 14:15 stage2
-rw-r--r-- 1 root root 10280 Aug 15 14:15 xfs_stage1_5
# cat /boot/grub/device.map
(hd0) /dev/sdb
#
So grub-install copies all stage* to /boot/grub and correctly creates
the devices.map file, but seems to have some problem with the stage1
bootloader. I have also strace(1)ed the call to grub-install but
couldn't find out the problem.
I have also checked the MBR of /dev/sdb an there is no GRUB bootloader
installed.
So what can I do to complete the bootloader install? What does the
error message
The file /boot/grub/stage1 not read correctly.
mean? I think simply copying stage1 to /dev/sdb manually, i.e.
# dd if=/dev/stage1 of=/dev/sdb bs=446
won't work since, AFAIK, the MBR must contain the references (block
numbers) to the stage1_5 loaders.
urs
Reply to: