Radio Tron
2008-Nov-01 19:12 UTC
[syslinux] Patching your own boot-disk from first principles
Hi, I'm trying to build a bootable MSDOS disk and put it on a ISO with floppy and hard disk emulation. I want to use commonly available Linux tools like dd, losetup, mkdosfs, memdisk etc. I have done the following: 1. dd if=/dev/zero of=myImage bs=1M count=50 [ Builds a 52MB image ] 2. losetup /dev/loop0 myImage [Links /dev/loop0 to myImage file ] 3. vi /grub/stage1; %!xxd; [ NULL the partion tablei within stage1 ]; %!xxd -r; 4. cat /grub/stage1 /grub/fat_stage1_5 > /dev/loop0 [ Puts the GRUB boot loader into the MBR of the image and stage1_5 after that ] 5. fdisk /dev/loop0 [ I use this to create a new single partition ] I now have a hard disk image of 52MB with a single partition on it, and a MBR with GRUB?? Unfortunately I know of no way to format that partition as a MSDOS file system, and populate it with the DOS files and the DOS partition boot loader. Could someone point me to docs that explain: 1. When I fdisk /dev/hda and print the partition table - how Cylinder values (Start/End) can be used to identify the start of a partition in bytes. 2. Where a MBR starts, what follows that, what is at the start of a partition, how a MSDOS boot loader loads a DOS system file, what system file is loaded (MSDOS)? 3. How I might install GRUB to a file which is acting as a block device (/dev/loop0) [The reason I'm doing all this is because I've been playing with Symantec Ghost 2.55. They have some app to generate bootable images (PXE, CD boot). The bootable images don't load, apparently due to some problem with the way the images are being built! I dumped out the FAT16 file system that they were using, and want to stitch it back together.] Could someone advice and help. I'm pretty much a noob and didn't know what my MBR contained until two days back. I'm trying to understand, solidly and clearly, how ISO's, floppy's, HD's and PXE's boot with MSDOS and with Linux. What offsets contain what.. stuff like that..
Michael McConnell
2008-Nov-01 20:45 UTC
[syslinux] Patching your own boot-disk from first principles
On Sat, 1 Nov 2008, Radio Tron wrote:> Hi, > I'm trying to build a bootable MSDOS disk and put it on a ISO with floppy and hard disk emulation. I want to use commonly available Linux tools like dd, losetup, mkdosfs, memdisk etc. > > I have done the following: > 1. dd if=/dev/zero of=myImage bs=1M count=50 [ Builds a 52MB image ] > 2. losetup /dev/loop0 myImage [Links /dev/loop0 to myImage file ] > 3. vi /grub/stage1; %!xxd; [ NULL the partion tablei within stage1 ]; > %!xxd -r; > 4. cat /grub/stage1 /grub/fat_stage1_5 > /dev/loop0 [ Puts > the GRUB boot loader into the MBR of the image and stage1_5 after > that ] > 5. fdisk /dev/loop0 [ I use this to create a new single partition ]Do you have qemu installed, and do you have a Knoppix disc or ISO? If so, try: 1. qemu-img create -f raw myImage 50M 2. qemu -boot d -hda myImage -cdrom /path/to/knoppix.iso (or /dev/cdrom) The Knoppix session within QEMU will see your hard disc image as an IDE hard disc, so you can partition it with fdisk, run mkdosfs on it, and install grub as if you were working with a real hard disc. QEMU will also take care of the disc geometry for you. Hope that helps. -- Michael "Soruk" McConnell Eridani Star System MailStripper - http://www.MailStripper.eu/ - SMTP spam filter
H. Peter Anvin
2008-Nov-01 20:49 UTC
[syslinux] Patching your own boot-disk from first principles
Radio Tron wrote:> I'm trying to build a bootable MSDOS disk and put it on a ISO with floppy and hard disk emulation. I want to use commonly available Linux tools like dd, losetup, mkdosfs, memdisk etc.Okay, I'm sorry, but this is a discussion of tools that are completely outside the scope of Syslinux. Quite frankly, discussion of how to set up Grub on the Syslinux mailing list is really well beyond reasonable. If you want to use Grub, find a Grub forum. This is not one. -hpa