Solved

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

Posted on 2014-03-15
3
814 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 26

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 26

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 26

Author Closing Comment

by:skullnobrains
ID: 39980322
no real solution
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now