On Tue, Dec 18, 2001 at 12:32:55PM +0100, Christoph Plattner mentioned: > Interesting topic ! > > I play armound with this, with the further problem to have a cross > build from Sparc (Solaris) to i386. > > One quite simple way is, you create a stage1 + stage1_5 on a device of > your choise with an normal (online) install. The dd the MBR+nr_of_blocks > of stage1.5 into a file, let's call it bootldr.img.
Ok, I did most of this. I plugged my flash card into my IDE reader, on /dev/sda, with my workstations root disk as /dev/hda, and did; # grub grub> root (hd1,0) Filesystem type is ext2fs, partition type 0x83 grub> find /boot/grub/stage1 (hd0,3) (hd1,0) grub> setup (hd1) 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 (hd1)"... 22 sectors are embedded. succeeded Running "install /boot/grub/stage1 d (hd1) (hd1)1+22 p (hd1,0)/boot/grub/stage 2 /boot/grub/grub.conf"... succeeded Done. grub> quit # cat /mnt/rescue/boot/grub/grub.conf default=0 timeout=10 title Test Kernel root (hd0,1) kernel /boot/bzImage # Looks good. But, on booting a box with this flash chip, I got a grub "hard disk error" of some description. I think it could be that grub is telling init that the root filesystem is on hd1 (which it no longer is, on the target system). This was just to test did the grub install work. On the "dd" bit; for an ext2 filesystem, that'll be; round_up(10848/512) + 1 = 23 blocks yes ? Will this always be there ? Basically, I would really like to be able to dd off those 23 blocks, and know that even if I write new files into that partition, and move (non-grub) ones around, I won't have to re-run grub. > Now you must know something about the geometry of the disk. Example: > 4 heads, 20 sectors (only to have round values), 300 cylinders and > ofcourse every sector has 512 bytes. > > The layout is: The MBR is in the frist sector on the first cylinder > on the first head. The rest of this track is kept empty and used > for the stage1.5. So the first partition starts at lba sector 20, > as 0..19 are reserved (MBR = stage1, stage1_5 13 to 16 sectors, > rest is padding). So you need a padding file, to have fullfill > the structure and you can create a disk image like > > fdisk bootldr.img to create partitions ... > cat bootldr.img padding.img part1.img part2.img ... > fulldisk.img > Important, the 2nd, 3rd, etc.., partition then starts on 80 sector > boundaries, always on complete cylinders. Hmm. Slightly different approach to mine; I was dding in the partitions directly like; # Make partition tables /root/make_partition_tables $IMAGE_FILE hda2_offset_bytes="2359296" hda1_offset_bytes="16384" hda1_offset_blocks="32" hda2_offset_blocks="4608" # Make, format & tune files to be used as templates for the image dd if=/dev/zero of=/tmp/hda2 bs=512 count=121768 dd if=/dev/zero of=/tmp/hda1 bs=512 count=4526 mkfs -F -m0 /tmp/hda1 mkfs -F -m0 /tmp/hda2 tune2fs -c 0 /tmp/hda1 tune2fs -c 0 /tmp/hda2 # Put the two images into the IMAGE file, and mount them dd if=/tmp/hda1 of=$IMAGE_FILE seek=$hda1_offset_blocks bs=512 dd if=/tmp/hda2 of=$IMAGE_FILE seek=$hda2_offset_blocks bs=512 But, I assume this will work - "padding" will just be empty, as long as I have the partition tables calculated properly. > With giving the geometry to GRUB, it should also be possible to > use GRUB directly for installing itself on the diskimage, but > I have not tried it. Hmm. I do have all the geometry worked out, but I've no idea how to even start at this. Are there grub config file examples anywhere ? Thanks for taking an interest in my private pain! John -- _______________________________________ John Looney Chief Scientist a n t e f a c t o t: +353 1 8586004 www.antefacto.com f: +353 1 8586014
msg04905/pgp00000.pgp
Description: PGP signature