[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem installing grub in a hard disk image

From: Nick Brown
Subject: problem installing grub in a hard disk image
Date: Wed, 26 Jan 2005 23:51:24 +0000
User-agent: KMail/1.7.1


I'm trying to install grub into a hard disk image, however I'm encountering a 
Below are the steps I've taken to create the disk image, partition it, create 
the file system, and copy the grub images into it. At the end are the grub 
commands I use to attempt to install grub into the image.
There should be enough info to reproduce what I did.
All of this was done on Mandrake 10.1 (important detail; kernel, 
grub 0.95)
The error message I get from grub is shown below the last command I use.

Can anyone offer any help or suggestion?


# Building a raw disk image

# bytes per sector
# sectors per track
# heads per track
# bytes per cylinder is bytes*sectors*head
bpc=$(( bytes*sectors*heads ))
# number of cylinders
# For a image of $size MB, cylinders = (($size*1024*1024)/$bpc)
cylinders=$(( ($size*1024*1024) / $bpc ))

# Path to disk image
# Path to location to mount image

# Create raw disk image
dd if=/dev/zero of=$image bs=$bpc count=$cylinders

# Attach image as raw device and partition it
losetup /dev/loop0 $image
fdisk -u -C$cylinders -S$sectors -H$heads /dev/loop0
# Create a ext2 partition
# With commands like these;
# o n p 1 <return> <return> a 1 p w
# Note the start sector and block count of partition
# start=63
# count=204592
losetup -d /dev/loop0

# Mount a specfic parition
offset=$(( start*bytes ))
losetup -o$offset /dev/loop0 $image

# Format the partition
mke2fs -o hurd -b1024 /dev/loop0 $count

# Mount the partition
mount -tauto /dev/loop0 $mount

# Unmount the partition
umount /dev/loop0
losetup -d /dev/loop0

# Installing GRUB into the raw disk image

# Easy mounting
mount -tauto -oloop=/dev/loop0,offset=$offset $image $mount

# Copy across needed grub images
cd $mount
mkdir -p boot/grub
cd /boot/grub
cp stage1 stage2 e2fs_stage1_5 $mount/boot/grub
umount -d $mount

# Install grub
losetup /dev/loop0 $image
# Commands like this;
# device (hd0) /dev/loop0
# geometry (hd0) $cylinders $heads $sectors
# root (hd0,0)
# setup (hd0)

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  22 sectors are embedded.
 Running "install /boot/grub/stage1 (hd0) (hd0)1+22 p (hd0,0)/boot/grub/stage2
/boot/grub/menu.lst"... failed

Error 22: No such partition

reply via email to

[Prev in Thread] Current Thread [Next in Thread]