Solved

freebsd loader chain loading through grub2. how to tell the loader where the kernel is

Posted on 2014-03-15
3
819 Views
Last Modified: 2016-02-11
hi guys

i have a pretty specific setup : i load the same freebsd system both physically and virtually, and when virtually the disk where freebsd is installed is not always the first one

for now, i have a grub config that does a good job with this by booting the kernel directly and setting vfs.root.mountfrom appropriately (actually it autodetects freebsd systems and boots them wherever they are)

my goal is the following : i want the above to be compatible with systems that have settings in loader.conf, and this is where things get complicated

problem

if i boot the loader instead of the kernel, the currdev and bootdev are both set to wherever the grub config file resides, so the loader cannot load the kernel. booting the proper kernel from the loader's command line works fine.

i'm not interested in solutions involving to set stuff in loader.rc or loader.conf because this does not fit the autodetect goal, and it would not work anyway since the loader cannot find either of those files fior the same reason it cannot find the kernel

i naively tried to set kFreeBSD.currdev to no avail (boots but currdev is not changed)
i tried to chainload boot2 and ended up with "Invalid signature" (grub2 message when it cannot chainload something... no idea what it actually means)

i did not try chain.b (yet) because for some reason it does not happen to exist in my /boot (regular freebsd 10 install using the new installer)... ideas welcome while i'm looking for a copy, but i'd rather not rely on something that may or may not be there
i tried to chainload boot0 but (at least in qemu, it only displays "F1" with no system facing it and F6 for pxe boot. whatever key i press just prints a '#'. anyway i did not really expected it to do anything useful, i just though it might give a useful hint)

as a side note (or perhaps side question), i'd like to find a way to tell the loader where the root partiton is so it in turn can tell the kernel

any ideas ?

thanks for your input
0
Comment
Question by:skullnobrains
  • 3
3 Comments
 
LVL 27

Author Comment

by:skullnobrains
ID: 39931266
sorry all, this is idiotic : i figured it out the second i posted the question : the currdev is set to wherever root is set in grub

basically if $file contains the location of the loader

menuentry "freebsd loader $file" "$file"{
                  regexp -s root '^([^)][^)]*\))' "$file"
                  kfreebsd "$2"
            }

does the trick

i missed the regexp line
0
 
LVL 27

Accepted Solution

by:
skullnobrains earned 0 total points
ID: 39931278
i'm leaving the question open in case anyone has a hint about the side question :

is there a way to instruct the loader the location of the root partition ?

my test system does not have a separate partition for /boot

if i set kFreeBSD.vfs.root.mountfrom=disk1p45 (which does not exist), freebsd still boots fine so i assume the option is ignored

if i boot from the second drive, with the root properly detected and set, the loader finds the kernel, but the kernel does not find the root filesystem any more.

setting mountfrom does not help

hacking loader.rc would likely be feasible but would only work assuming there was a proper initial freebsd install, on the same drive, and the emulated hardware controller was the same which does not really fit my need.

---

if i script something that reads loader.conf in grub-shell and set all those variables as kfreebsd.varnam=varval (assuming i manage to do it), does anybody know if that would work for some or all variables that may be set in loader ?
0
 
LVL 27

Author Closing Comment

by:skullnobrains
ID: 39980322
no real solution
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AIX 5.x set up arrow to recall 11 58
Oracle Finace 3 86
Changing names of Physical Servers 1 52
How to choose a USB to Serial Device that has preloaded drivers on the OS. 1 61
Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question