Trying to reason out a way to load my kernel from grub.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Bobbias
Posts: 14
Joined: Sun Mar 23, 2008 11:27 pm
Location: Midland, Ontario Canada

Trying to reason out a way to load my kernel from grub.

Post by Bobbias »

Ok, here's the deal: I'm following Bran's tutorial, and I've compiled a really basic kernel. I've got the kernel.bin file ready to load, and I've got VMWare running a bootable GRUB ISO. Here's where the trouble starts: I don't have a floppy drive in this computer.

(I should also point out I'm running Windows.)

I've tried creating a floppy image and setting my virtual machine to load that along with the GRUB CD, but that seemed just to crash. GRUB never loaded.

I can get GRUB to load right now, but I'm using a virtual floppy drive program, which doesn't show up as a floppy drive to my computer. It shows up as a removable drive (like a USB storage drive would). GRUB can't see it from VMWare.

does anyone have a better solution?

I also don't know how to install grub onto the otherwise empty hard drive in VMWare. I'm not very experienced with GRUB...

(Yeah, I'm a noob, but I'm doing this so I can hopefully learn a lot more.)
I've been writing miserably bad code since I was 12, and things haven't changed yet...
thomasloven
Member
Member
Posts: 89
Joined: Tue Feb 26, 2008 10:47 am
Location: Sweden

Post by thomasloven »

Hi.
I can recommend VFD for windows.

I think this is it...
http://chitchat.at.infoseek.co.jp/vmware/vfd.html
...no way of checking myself right now.

It loads a floppy image as a floppy drive, not as removable media.

It can also be controlled by command line which is very convenient if you want to make say a .bat file to update your image.

Also, I think the easiest way to do things would be installing grub on the same floppy and boot directly from it.
You should be able to find an image with GRUB installed for FAT12 somewhere I think.

There ought to be one in the wiki (if not, there realy should be IMO)
Last edited by thomasloven on Mon Mar 24, 2008 7:13 pm, edited 1 time in total.
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

That is the correct link. VFD is what I use, and it works great.
Bobbias
Posts: 14
Joined: Sun Mar 23, 2008 11:27 pm
Location: Midland, Ontario Canada

Post by Bobbias »

Ok, I uninstalled the default Floppy drivers and reinstalled/started VFD and it finally showed up as a floppy, instead of as a removable drive.

I'm following the wiki right now. I've got cygwin installed and I'm about to make the Auxiliary GRUB install.

Ok, problem: the dd commands don't work. It complains about of=/dev/fd0 not existing.
I've been writing miserably bad code since I was 12, and things haven't changed yet...
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Bobbias wrote: Ok, problem: the dd commands don't work. It complains about of=/dev/fd0 not existing.
Yeah they wouldn't - dd is unix only. You'd have to use a cygwin shell.
Bobbias
Posts: 14
Joined: Sun Mar 23, 2008 11:27 pm
Location: Midland, Ontario Canada

Post by Bobbias »

Well, I've got the cygwin shell, but I don't have much experience with this level of interaction with linux stuff, so I don't exactly know what to do from here.

Some parts of this, I can find my own way through, and other parts, I'm a complete noob with.

My experience with Linux is either basic commands through SSH, or playing around with it in one of the GUIs, so I don't have much experience under the hood.

Is there another way other than using DD to get the desired result? (well, I assume there is, but I don't know it...)
I've been writing miserably bad code since I was 12, and things haven't changed yet...
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Is there another way other than using DD to get the desired result? (well, I assume there is, but I don't know it...)
Not with unix commands -- dd is the one you need. Post the command you are using and the resulting error message.
Bobbias
Posts: 14
Joined: Sun Mar 23, 2008 11:27 pm
Location: Midland, Ontario Canada

Post by Bobbias »

I used the same lines that are supplied by the wiki page on grub:

$> dd if=<stage1> of=/dev/fd0 bs=512 count=1
$> dd if=<stage2> of=/dev/fd0 bs=512 seek=1

I don't have anything except fd sdterr stdin and stdout in /dev according to cygwin bash.

The other aspect of this problem is that I've booted VMWare with the "SuperGRUBDisk" iso I found online (because I had no way to build grub in windows/didn't want to spend a year trying to figure out how to) doesn't seem to recognize the floppy drive. Hell, I don't even know how to get it installed on the "Hard drive" in VMWare.

I'm too tired to be doing this right now, I'll be back when I'm not feeling like a total zombie. (I'll try to get on during the day time, instead of starting all this crap at 2 in the morning)
I've been writing miserably bad code since I was 12, and things haven't changed yet...
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

In cygwin, the first floppy drive is not found under /dev/fd0 - it's found under /cygdrive/a.

Cheers,
Adam
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Post by egos »

Bobbias, install GRUB on your hard drive or use emulator to boot from the floppy image. For quick making and changing a floppy image you can use fasm and special include file. For example,

Code: Select all

include "mkfloppy.inc"

file "bootcode.bin", 512

; fat1
db 0F0h, 0FFh, 0FFh, 9*512-3 dup 0

; fat2
db 0F0h, 0FFh, 0FFh, 9*512-3 dup 0

; root
dent io,        "IO      SYS", FA_RO or FA_HID or FA_SYS or FA_ARC
dent msdos,     "MSDOS   SYS", FA_RO or FA_HID or FA_SYS or FA_ARC
dent command,   "COMMAND COM", FA_ARC
dent drvspace,  "DRVSPACEBIN", FA_RO or FA_HID or FA_SYS or FA_ARC
dent autoexec,  "AUTOEXECBAT", FA_ARC
dent command2,  "COMMAND",     FA_DIR
rb 33*512-$

; data
stof io,        "content/IO.SYS"
stof msdos,     "content/MSDOS.SYS"
stof command,   "content/COMMAND.COM"
stof drvspace,  "content/DRVSPACE.BIN"
stof autoexec,  "content/AUTOEXEC.BAT"

defdir command2
{
dent fdisk,     "FDISK   EXE", FA_ARC
dent format,    "FORMAT  COM", FA_ARC
dent sys,       "SYS     COM", FA_ARC
dent defrag,    "DEFRAG  EXE", FA_ARC
dent scandisk1, "SCANDISKEXE", FA_ARC
dent scandisk2, "SCANDISKINI", FA_ARC
}

stod command2,  root
stof fdisk,     "content/COMMAND/FDISK.EXE"
stof format,    "content/COMMAND/FORMAT.COM"
stof sys,       "content/COMMAND/SYS.COM"
stof defrag,    "content/COMMAND/DEFRAG.EXE"
stof scandisk1, "content/COMMAND/SCANDISK.EXE"
stof scandisk2, "content/COMMAND/SCANDISK.INI"
rb 2*80*18*512-$
LFN not yet supported.
Bobbias
Posts: 14
Joined: Sun Mar 23, 2008 11:27 pm
Location: Midland, Ontario Canada

Post by Bobbias »

The reason I didn't want to install GRUB on my computer is because I've already seriously messed up my boot system. NTLDR on my main drive (a320 GB) refuses to find hal32.dll despite the file being right where it should, so now I have to manually supply my 80 GB with NTLDR installed and use boot.ini to point to my 320 GB. That happened after I had installed linux and stuff. I forget exactly what I was trying to do in grub when that happened, but it took a long time to get windows accessible again. (and no attempts at repairing/replacing the messed up ntldr worked.)

I tried using a new dd command:

$> dd if=<stage1> of=/cygdrive/a bs=512 count=1
$> dd if=<stage2> of=/cygdrive/a bs=512 seek=1

Still complaining that /cygdrive/a doesn't exist when I know it does...

Why is it every time I become involved with GRBU, I end up with a massive headache when I now it shouldn't be that hard?
I've been writing miserably bad code since I was 12, and things haven't changed yet...
User avatar
inx
Member
Member
Posts: 142
Joined: Wed Mar 05, 2008 12:52 am

Post by inx »

Windows recovery console could probably fix your boot problems just with "fixboot" and, if that doesn't work, "fixboot /mbr"
Bobbias
Posts: 14
Joined: Sun Mar 23, 2008 11:27 pm
Location: Midland, Ontario Canada

Post by Bobbias »

Tried it. Tried fixboot, and fixmbr, I've tried copying a different version of ntldr, I've tried installing a clean copy of windows over the old one (without formatting, because I don't back stuff up, and don't want to lose everthing). None of it worked.
I've been writing miserably bad code since I was 12, and things haven't changed yet...
kscguru
Member
Member
Posts: 27
Joined: Sat Jan 19, 2008 12:29 pm

Post by kscguru »

Bobbias wrote:I used the same lines that are supplied by the wiki page on grub:

$> dd if=<stage1> of=/dev/fd0 bs=512 count=1
$> dd if=<stage2> of=/dev/fd0 bs=512 seek=1
If you've got dd running, you're most of the way to creating a floppy image. Instead of writing to /dev/fd0, write directly to a file, e.g. myfloppy.flp. Then attach that image to your emulator of choice.

(Some emulators need the floppy image file to be exactly 1.44MB in size, but dd can do that too, dd if=/dev/zero of=<image> bs=512 seek=2 count=foo, where foo is 1.44MB / 512B and I don't have a calculator handy.)
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post by binutils »

Just out of curiosity, what kind of dd do you use? cygwin?

i doubt it works same as below dd.
http://www.chrysocome.net/dd
Post Reply