Jump to content











Photo
- - - - -

Problem: map (rd) (fd0) -> Error 65: RD_BASE must be sector-aligned


  • Please log in to reply
13 replies to this topic

#1 enaut

enaut
  • Members
  • 8 posts
  •  
    Germany

Posted 08 February 2012 - 02:32 PM

Hey Guys,

I have a network boot setup using kexec and initramdisks... The setup is perfectly able to boot grub4dos however I really dont get the ramdisk stuff right. It is described in the section "Direct transition to DOS/Win9x from within Linux" of the README (http://code.google.c...ME_GRUB4DOS.txt)

According to the readme the following command should work:
kexec -l grub.exe --initrd=WIN98.IMG --command-line="--config-file=map (rd) (hd0); map --hook; chainloader (hd0)+1; rootnoverify (hd0)"

I divided the process into several steps...

1. a running Linux

2. execute kexec -l grub4dos.exe --initrd=Disk.IMG

3. kexec -e

in Grub commandline execute:

4a. map (rd) (fd0)
or
4b. map (rd)+1 (fd0)
or both of them with (hd0)

after a map --hook I should be able to have access to the files in the RD but I allways get only:

In case of 4a:
Error 65: RD_BASE must be sector-aligned and non-zero for mapping at a fixed location

In case of 4b:
Error 28: Selected item cannot fit into memory

The programm versions I'm using:
Linux kernel 3.0.8

Kexec-Tools 2.0.1

grub4dos-0.4.5c-2012-02-01.7z


I think actually it should work if the stuff from the README is correct. However I never get to the point where I can actually see the content of the Initramdisk that was loaded by kexec.
I tried several different Images. One simply a file containing a filesystem(fat32) and the files (without any compression) another being a cpio initramdisk like the linux-kernel uses and last I downloaded a file similar to the DOS.IMG but neither of them showed any desired result.

One thing to remark though if I use 4b. map (rd)+2 (fd0) I only get warnings but I can hook the rd in with map --hook. I cannot access any files though (Error 17: Cannot mount selected partition)

The Thing I actually want to do is: I have a setting which can manage and boot kernels using kexec but I want to use exactly this setting to boot arbitrary systems. I have given up to make it work on any System wich is why I do all the stuff in a virtual machine.
In this setting kernels and initrds are provided via network.
My goal is that you can use grub4dos as kernel and put a payload into a ramdisk and load this payload using grub4dos.
An example of such a payload would be memtestx86+.

What are the Requirements for a Ramdisk and how do I use it from Kexec in Grub4Dos?
Maybe I have to set the boundaries? - But which ones? where does Kexec load the initrd to?

#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 8,789 posts
  • Location:The Outside of the Asylum
  •  
    Italy

Posted 08 February 2012 - 06:57 PM

Seemingly - and at first sight - the issue is the actual WIN98.IMG.
Can you detail how exactly did you create the image, how big it is, etc., etc.?

:cheers:
Wonko

#3 enaut

enaut
  • Members
  • 8 posts
  •  
    Germany

Posted 08 February 2012 - 07:51 PM

Well as I wrote I never found any real "what does it expect" document. In the README they use a WIN98.IMG image... I just Googled it and found some file called WIN98c.IMG and tried that one... I'm not so sure if its legal to download wich is why I don't post any Links.

But
$ file Downloads/WIN98.IMG

WIN98.IMG: DOS floppy 1440k, x86 hard disk boot sector

$ sudo mount WIN98.IMG /mnt

$ ls /mnt

ASPI2DOS.SYS  ASPI8DOS.SYS  ASPICD.SYS	BTCDROM.SYS  COMMAND.COM  COUNTRY.SYS  DRVSPACE.BIN  EBD.SYS   EXTRACT.EXE  FINDRAMD.EXE  HIMEM.SYS  KEYB.COM	 MODE.COM   OAKCDROM.SYS  README.TXT

ASPI4DOS.SYS  ASPI8U2.SYS   AUTOEXEC.BAT  BTDOSM.SYS   CONFIG.SYS   DISPLAY.SYS  EBD.CAB	   EGA3.CPI  FDISK.EXE	FLASHPT.SYS   IO.SYS	 KEYBRD3.SYS  MSDOS.SYS  RAMDRIVE.SYS  SETRAMD.BAT

$ mount

...

WIN98.IMG on /mnt type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=ascii,shortname=mixed,errors=remount-ro)

$ ls -l WIN98.IMG

-rw-rw-r--. 1 enaut enaut 1474560  8. Feb 20:19 WIN98.IMG


as for the ramdisk that I created on my own I tried several approaches. One of these is pretty good documented with a script:

# Ramdisk Constants

RDSIZE=4000

BLKSIZE=1024



# Create an empty image

dd if=/dev/zero of=/tmp/grub-rd.img bs=$BLKSIZE count=$RDSIZE



# Make it an ext2 mountable file system

/sbin/mke2fs -F -m 0 -b $BLKSIZE /tmp/grub-rd.img $RDSIZE



mkdir -pv /tmp/grub-rd-dir



# Mount it so that we can populate

mount -v /tmp/grub-rd.img /tmp/grub-rd-dir -t ext2 -o loop=/dev/loop0



# Copy the files that are needed by grub4dos

cp -v contrib/ipxe/ipxe.krn /tmp/grub-rd-dir/



# Finish up...

umount -v /tmp/grub-rd-dir

rmdir -v /tmp/grub-rd-dir

This results in an Image:
$ file grub-rd.img

grub-rd.img: Linux rev 1.0 ext2 filesystem data, UUID=8c65e11a-b816-480f-b6a4-da4bd9b3f24b

$ sudo mount grub-rd.img /mnt

$ ls /mnt

ipxe.krn  lost+found

$ mount

grub-rd.img on /mnt type ext2 (rw,relatime,seclabel,user_xattr,acl,barrier=1)

$ ls -l grub-rd.img

-rw-r--r--. 1 root root 4096000  8. Feb 20:45 grub-rd.img


I also tried that one as gz archive.

I tried to do some magic with cpio too and got a Image as a result but I have no Idea wether that was right unfortunately I didn't write a cute script like the above and I don't know the exact steps. If you want these I would have to redo it while documenting which takes some time... so first I post only the quick version ;)

Edited by enaut, 08 February 2012 - 07:54 PM.


#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 8,789 posts
  • Location:The Outside of the Asylum
  •  
    Italy

Posted 08 February 2012 - 09:06 PM

Can you set aside - for the moment - the "whole" kexec thingy and just do a couple of tests?
From what I understand you should NOT create any ramdisk at all, it's the initrd that creates it.

Please try the following before anything else.

Boot to grub.exe (i presume that with your setup should be simply):
kexec -l grub.exe
you should be at the grub> prompt.
If not, find *any* way to load grub.exe (if you have syslinux use kernel grub.exe, if you have GRUB2 use linux grub.exe, etc.)

At the grub prompt type (giving [ENTER] after each line:
find --set-root /win98c.img

map --mem /win98c.img (fd0)

map --hook

root (fd0)

chainloader /io.sys

boot

(that is assuming that your image is named win98c.img, pay attentrion to CaSe SeNsItIvEnEsS - it may apply depending on the used "base" filesystem)

Describe what happens.
Please post also the EXACT version of grub4dos you are using.

:cheers:
Wonko

#5 tinybit

tinybit

    Silver Member

  • Developer
  • 795 posts
  •  
    China

Posted 09 February 2012 - 03:28 AM

>>> RD_BASE must be sector-aligned
kexec had not aligned properly its INITRD image.

Try these commands before the map command to gain needed info:

map --status <-------------- this will tell the rd_base and size
displaymem <-------------- this will show memory layout
cat --hex (rd)+1 <-------------- this will show the first sector of the initrd image.

#6 enaut

enaut
  • Members
  • 8 posts
  •  
    Germany

Posted 09 February 2012 - 10:16 AM

Ok the numbers seem wrong I guess:
grub> map --status





flop_orig=0, hd_orig=1, flop_curr=0, hd_curr=1

Number of ATAPI CD-ROMs: 0

ram_drive=0x7F, rd_base=0x0, rd_size=0x100000000

The int13 hook is off. The drive ma table is currently empty.


grub> displaymem



EISO Memory BIOS Interface is present

Addess Map BIOS Interface is present

Lower memory: 639K, Upper memory to first chipset hole: 709568K

[Address Range Descriptor entries immediately follow (values are 64-bit)]

  Usable RAM: Base: 0x0, Length: 0x9FC00

  Reserved: Base: 0x9FC00, Lenght: 0x400

  Reserved: Base: 0xF0000, Length:0x10000

  Usable RAM: Base: 0x100000, Length: 0x2B4F0000

  Reserved: Base: 0x2B5F0000, Lenght: 0x10000

  Reserved: Base: 0xFFFC0000, Length:0x40000

As I typed these from screen the original might differ though I pretty much copied them.

From the hex you get a screenshot (good thing its running in VM)
Posted Image

Is there Any possibility to get the rd_base and length from kexec? - Length is probably the filesize but the rd_base?

#7 tinybit

tinybit

    Silver Member

  • Developer
  • 795 posts
  •  
    China

Posted 09 February 2012 - 11:34 AM

Sorry I didn't describe it clearly.

You just started a new/clean grub4dos, and it did not have its rd linked to your INITRD image.

Do it this way:
kexec -l grub.exe --initrd=YOUR.IMG --command-line="--config-file=commandline"
kexec -e

Now grub.exe should prompt you with "grub> " and you can enter commands there.

And then issue commands in post #5.

#8 enaut

enaut
  • Members
  • 8 posts
  •  
    Germany

Posted 09 February 2012 - 11:43 AM

Ouch I didn't see your post at first...

At the grub prompt type (giving [ENTER] after each line:

find --set-root /win98c.img

map --mem /win98c.img (fd0)

map --hook

root (fd0)

chainloader /io.sys

boot

(that is assuming that your image is named win98c.img, pay attentrion to CaSe SeNsItIvEnEsS - it may apply depending on the used "base" filesystem)

Describe what happens.


Well I guess the description "it just works is quite good." ;)

I Added a real file (the WIN98c.IMG) to a filesystem accessible from grub4dos and loaded it exactly as you described and the map command worked as did the hook command as did the chainloader... The DOS-Tools never succeded to start fully but that is a totally different chapter andnot of interest right here...

Please post also the EXACT version of grub4dos you are using.

Mhm the exact version? I already wrote all I know maybe a link helps? http://code.google.c...-01.7z&can=2&q=

#9 enaut

enaut
  • Members
  • 8 posts
  •  
    Germany

Posted 09 February 2012 - 01:20 PM

You just started a new/clean grub4dos, and it did not have its rd linked to your INITRD image.

Do it this way:

kexec -l grub.exe --initrd=YOUR.IMG --command-line="--config-file=commandline"

kexec -e


Actually this is exactly what I did... except that I didn't use the --command-line option since can type that interactively and get error messages...

But I tried it with both (--initrd= and --ramdisk=) options it doesn't seem to make any difference.

I think the main problem here is that kexec somehow fails to hand over the initrd.

#10 tinybit

tinybit

    Silver Member

  • Developer
  • 795 posts
  •  
    China

Posted 09 February 2012 - 04:24 PM

You seem to have found a big problem, I mean, a bug. Wait some time and see if it be solved.

EDIT:

I just completed a test and confirm no problem with grub4dos. Here are my steps:

Step 1.

kexec -l grub.exe --initrd=grub.exe --command-line="--config-file=commandline"

Note: I just use grub.exe as the IMAGE for simplicity.

Step 2.

kexec -e

Note: This will enter grub4dos. The prompt "grub> " will occur.

Step 3.

map --status

Note: This will show rd_base = 0x1FFxxxxx and rd_size=0x48xxx which is the size of grub.exe (the IMAGE file).

Step 4.

cat --hex (rd)+1

Note: This will show the contents of grub.exe(it is our IMAGE file).

Conclusion: Test was successful. No problems were found.

#11 enaut

enaut
  • Members
  • 8 posts
  •  
    Germany

Posted 12 February 2012 - 05:12 PM

Oh there I found something, that I didn't do even though you told me to.

I just left out the --command-line="--config-file=commandline" option because I thought it will bring me automatically to the commandline... but apparently this option is needed for the ramdisk to work why is that? and what does this option do?

I mean the problem I now have is:

I start grub4dos using kexec (sidenote in my diskimage is one file ipxe.krn wich is a zImage):

kexec -l grub.exe --initrd=diskimage.IMG --command-line="--config-file=kernel (rd)/ipxe.krn; boot;"

Lucky thing is, this actually works!

But if I do not add the --command-line="--config-file=commandline" command I am dropped to a commandline automatically but in this automatic commandline there is noramdisk.

enaut

#12 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 8,789 posts
  • Location:The Outside of the Asylum
  •  
    Italy

Posted 12 February 2012 - 07:23 PM

Lucky thing is, this actually works!

But if I do not add the --command-line="--config-file=commandline" command I am dropped to a commandline automatically but in this automatic commandline there is noramdisk.

Good, we have found the problem and also solved it. :yahoo:

My guess is that when you load grub.exe with just:
--initrd=diskimage.IMG

the grub.exe is loaded as a Linux kernel, BUT without the:
--command-line="--config-file=commandline"
once loaded grub.exe defaults to "interactive command mode" and thus "loses" the previous parameter. :dubbio:

What happens if, on the grub4dos prompt you do:

find --set-root /diskimage.IMG

initrd /diskimage.IMG

kernel (rd)/ipxe.krn

boot


:unsure:

:cheers:
Wonko

#13 tinybit

tinybit

    Silver Member

  • Developer
  • 795 posts
  •  
    China

Posted 13 February 2012 - 04:16 AM

try this build please:

http://bbs.znpc.net/...ad.php?tid=6197

#14 enaut

enaut
  • Members
  • 8 posts
  •  
    Germany

Posted 13 February 2012 - 09:08 AM

Yes this fixed the issue I can now launch grub4dos by

kexec -l grub.exe --initrd=image.img

this will drop me automatically to a commandline in which (rd) contains the desired data.

Thank you so much!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users