Re: Install Grub to a HDD image?
- From: Douglas Mayne <doug@xxxxxxxxxxxxxxxxx>
- Date: Sun, 05 Nov 2006 11:33:16 -0700
On Sat, 04 Nov 2006 12:52:15 -0800, Tim wrote:
Hey Douglas,You have to completely model the disk's layout. This can be difficult, and
sorry for my late answer. Thank you for your detailed description of
installing grub onto a virtual disk. Unfortunately, I get the following
error during your install method:
grub> root (fd0)Unknown partition table signature
grub> device (fd0) /mnt/test
grub> setup (fd0)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... no
Error 16: Inconsistent file system structure
I'm using the following commands to create the hdd image:
dd if=/dev/zero of=test.img bs=1000 count=10000
losetup /dev/loop0 test.img
mkfs -t ext3 /dev/loop0
mount -t ext3 /dev/loop0 test.img
grub --no-floppy
I have no idea, why the file system should be inconsistent or why the
partition table signature is unknown. Have you any suggestions how I
can solve this problem? Thank you for any advice.
Best regards,
Tim
is why my initial description focused on modelling floppy disks (which
have a simpler layout than hard disks.) The response by Robert Nichols
explains this correctly.
VMWare...
Really, the easiest way to model entire virtual hard disks is to use
virtualization. Do you have any interest in using VMWare as your test
platform? VMWare makes these nitty-gritty details disappear. Basically,
VMWare allows building both the development and test platform on the same
physical computer. The final step is to verify your hdd image is usable as
intended by testing with VMWare.
Manually...
There are quite a few hurdles to modelling disks manually (without
VMWare.) Understanding what you're modelling is key. I did some tests to
attempt installing grub to a complete hdd image. I came close, but no
cigar. There may be a way through the minefield, but I couldn't find it-
even though I tried hard. VMWare solves the same problem in two seconds,
because it is not constrained to using the "device" statements within the
grub shell.
Some details of my _unsucessful_ test...
Steps that I followed:
1. Allocated some file space to use as the hdd image (600M).
dd if=/dev/zero of=master.img bs=512 count=$val
2. Setup a loopback pointing at the entire disk.
losetup /dev/loop0 master.img
3. Setup partition tables (start fdisk using -H and -S switches)
example: fdisk /dev/loop0 -H 16 -S 63 -H 1220
I created partition entries for a boot and and swap partition. Use of
fdisk not shown.
4. Create separate files which match the size of the boot and swap
partitions. (450M for root, 150M for swap). This step is necessary
because simple loopbacks use all of the space available in the file; we
need a separate file which matches the partition size only. The file
master.img will contain copies of these duplications when finished. This
command is useful for getting the size of partitions:
fdisk -lu -H 16 -S 63 /dev/loop0
Use this output to allocate duplicate partitions (and compute values for
$c and $d, below).
dd if=/dev/zero of=vp1 bs=512 count=$c
dd if=/dev/zero of=vp2 bs=512 count=$d
5. Setup loopbacks to duplicate partitions.
losetup /dev/loop1 vp1
losetup /dev/loop2 vp2
6. Format copies of virtual partitions
mke2fs /dev/loop1
mkswap /dev/loop2
7. Mount and install root filesystem to /dev/loop1 (not shown). Include
the grub loader. Unmount when finished:
umount /dev/loop1
8. Copy virtual partition images to "master" disk image; master was
assigned to /dev/loop0 in step 2.
dd if=/dev/loop1 of=/dev/loop0 bs=512 seek=63
Similarly for the virtual swap:
dd if=/dev/loop2 of=/dev/loop0 bs=512 seek=$offset
9. Setup the grub loader using the grub loader. I tried using device
statements which specied the loopback, but failed.
grub>device (hd0) /dev/loop0
grub>geometry (hd0) 1220 16 63
grub>
I'll omit various tricks I tried without success, for now. I could not
produce a bootable virtual hd image using this method.
10. Clean up by removing all loopbacks.
losetup -d /dev/loop0
losetup -d /dev/loop1
losetup -d /dev/loop2
Close, but no cigar.
--
Douglas Mayne
.
- References:
- Re: Install Grub to a HDD image?
- From: Tim
- Re: Install Grub to a HDD image?
- Prev by Date: Re: MySQL Proble on Linux
- Next by Date: Windows 3.x app under Linux
- Previous by thread: Re: Install Grub to a HDD image?
- Next by thread: LINUX SYSLOG SERVER
- Index(es):
Relevant Pages
|