DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 31st July 2020
shachter shachter is offline
New User
 
Join Date: Jul 2020
Posts: 2
Default How Do You Pass Information To OpenBSD From The Boot Loader?

Esteemed Colleagues:

I have an OpenBSD question that i cannot find answered in the online documentation, so I sought an OpenBSD forum, and this is the only one I found. I hope one of you can answer my question. I do not use OpenBSD for serious work, because it does not support ZFS, but I still hope you can answer my question, because it has been giving me no rest.

How do I pass information from the Grub bootloader to my OpenBSD system?

The context of my question is that I want to boot OpenBSD in such a way that the xenodm display manager will mirror my two displays, whereas on other occasions I want xenodm not to mirror my displays. Yes, I know that after I log it, I can invoke "xrandr" with the appropriate arguments either to mirror or unmirror my displays; but if I mirror my displays, it is because I want my students to see what is happening from the very beginning.

The context of my question is, of course, irrelevant, but I thought you might want to know it.

I have two different Grub menu items for booting FreeBSD. One of them does "set kFreeBSD.mdisplay=1" before booting, the other one does not. Then, once the system is running, the display manager, in the appropriate Xsetup* script, examines the output of "kenv mdisplay", which tells the display manager whether or not to mirror the displays with xrandr. But OpenBSD does not have a "kenv" command, so I cannot use that strategy on OpenBSD.

I also have three different Linux distributions on my laptop (LinuxMint, OpenSuSE, and a Red Hat clone). When I boot Linux, I can add "mdisplay" to the kernel arguments, in the "linux" line that specifies the kernel and its arguments. Then, once the system is running, the display manager, in the appropriate Xsetup* script, examines the contents of "/proc/cmdline", and, if it contains "mdisplay", uses "xrandr" to mirror the displays. But OpenBSD dropped the /proc filesystem several years ago (parenthetical question: aren't later releases supposed to be better than earlier releases, and not inferior to them?), and, even when it had a /proc filesystem, never supported "/proc/cmdline".

The funny thing is that Grub does pass arguments to the kernel -- it says "kopenbsd /bsd -r sd0a" -- but I cannot find, anywhere in the documentation, a technique for a user-level program to access those arguments.

Thank you in advance for any and all replies.

jay at m5 dot chicago dot il dot us
Reply With Quote
  #2   (View Single Post)  
Old 1st August 2020
e1-531g e1-531g is offline
ISO Quartermaster
 
Join Date: Mar 2014
Posts: 628
Default

Quote:
Originally Posted by shachter View Post
The funny thing is that Grub does pass arguments to the kernel -- it says "kopenbsd /bsd -r sd0a" -- but I cannot find, anywhere in the documentation, a technique for a user-level program to access those arguments.
I don't have OpenBSD installed, so I can't check my wild guess. I wonder whether dmesg(8) shows args passed to the kernel by boot(8) typed in interactive command line or read from boot.conf file.
https://man.openbsd.org/boot.conf.8#set
https://man.openbsd.org/dmesg
__________________
Signature: Furthermore, I consider that systemd must be destroyed.
Based on Latin oratorical phrase

Last edited by e1-531g; 1st August 2020 at 11:20 AM. Reason: add second link
Reply With Quote
  #3   (View Single Post)  
Old 1st August 2020
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Hello, and welcome!

This isn't the only OpenBSD forum, and it's entirely unofficial. Other unofficial forums include the BSD forum at linuxquestions.org and the r/openbsd subreddit at reddit.com. The official communication path is the OpenBSD project's misc@ mailing list.

The following is only to the best of my knowledge. OpenBSD Developers who are active on the misc@ mailing list may be able to provide more information if this explanation does not suffice:
OpenBSD can be booted only through its own 2-stage bootloader, biosboot(8) / boot(8). Grub can initiate this 2-stage boot through its "chain loader" facility, but there is no way to to pass any Grub option strings to OpenBSD's bootloader through it. Not only because chain loading is merely a MBR/PBR-like function, but also because OpenBSD's bootloader has no Grub integration.
Reply With Quote
  #4   (View Single Post)  
Old 1st August 2020
Head_on_a_Stick's Avatar
Head_on_a_Stick Head_on_a_Stick is offline
Real Name: Matthew
Bitchy Nerd Elitist
 
Join Date: Dec 2015
Location: London
Posts: 456
Default

Quote:
Originally Posted by shachter View Post
OpenBSD dropped the /proc filesystem several years ago (parenthetical question: aren't later releases supposed to be better than earlier releases, and not inferior to them?)
AFAIUI the OpenBSD developers considered procfs to be a potential attack surface rather than a "feature", hence the removal — it was listed under "security improvements" in the 5.7 release notes.

EDIT: to set your monitors up as desired perhaps add a scripted mechanism to ~/.xsession.
__________________
Are you infected with Wetiko?
Reply With Quote
  #5   (View Single Post)  
Old 1st August 2020
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Quote:
Originally Posted by Head_on_a_Stick View Post
AFAIUI the OpenBSD developers considered procfs to be a potential attack surface rather than a "feature", hence the removal — it was listed under "security improvements" in the 5.7 release notes....
It was more than a potential. There was a vulnerability found and corrected in 2004 (Release 3.5 era).
Reply With Quote
  #6   (View Single Post)  
Old 3rd August 2020
shachter shachter is offline
New User
 
Join Date: Jul 2020
Posts: 2
Default

Quote:
Originally Posted by jggimi View Post
OpenBSD can be booted only through its own 2-stage bootloader, biosboot(8) / boot(8). Grub can initiate this 2-stage boot through its "chain loader" facility, but there is no way to to pass any Grub option strings to OpenBSD's bootloader through it. Not only because chain loading is merely a MBR/PBR-like function, but also because OpenBSD's bootloader has no Grub integration.
As soon as I read the above, I rebooted to test whether it was true. It is not. First, I replaced "kopenbsd /bsd -r sd0a" with "chainloader +1" in the grub menuitem; the boot failed. Second, I booted without "-r sd0a", and the computer asked me for the name of the root disk. So both parts of the quoted text are untrue: grub is not chainloading when it boots, and the arguments in the "kopenbsd" command line are being passed to the operating system.

Here's how I, for now, solved my problem, but it is inelegant: I copied /bsd to /bsd_m and edited the latter file with emacs, changing the place where "uname" finds the name of the OS, from "OpenBSD" to "OpemBSD". I have two grub menuitems for booting OpenBSD, one that boots /bsd and one that boots /bsd_m and is otherwise identical. The "xenodm" command, in the appropriate XSetup_* file, checks whether the output of "uname -s" is equal to "OpemBSD" and if it is (i.e., if the bootloader booted /bsd_m rather than /bsd), it tells xrandr to mirror the two displays. This is a highly undesirable solution -- one has to have a separate copy of the operating system for every variation of the boot options one might want to pass! -- and I welcome a better solution if anyone reading this can come up with one.

jay at m5 dot chicago dot il dot us
Reply With Quote
  #7   (View Single Post)  
Old 4th August 2020
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Thank you for the correction; my knowledge was based on Grub v1.

OpenBSD's second stage bootloader can pass a string to the OpenBSD kernel, see the set option "howto" in the boot(8) man page. But looking through kernel source code, this string appears (to me) to be a way to indicate only the various boot options -a -c -d and -s.
Reply With Quote
  #8   (View Single Post)  
Old 4th August 2020
e1-531g e1-531g is offline
ISO Quartermaster
 
Join Date: Mar 2014
Posts: 628
Default

Quote:
Originally Posted by shachter View Post
As soon as I read the above, I rebooted to test whether it was true. It is not. First, I replaced "kopenbsd /bsd -r sd0a" with "chainloader +1" in the grub menuitem; the boot failed.
I chainloaded OpenBSD bootloader from Grub somehow in the past, but I can't provide details how I done this.
__________________
Signature: Furthermore, I consider that systemd must be destroyed.
Based on Latin oratorical phrase
Reply With Quote
  #9   (View Single Post)  
Old 4th August 2020
Head_on_a_Stick's Avatar
Head_on_a_Stick Head_on_a_Stick is offline
Real Name: Matthew
Bitchy Nerd Elitist
 
Join Date: Dec 2015
Location: London
Posts: 456
Default

I use this to chainload OpenBSD's EFI loader from GRUB v2:
Code:
menuentry 'OpenBSD' {
   search --fs-uuid --set=root $uuid
   chainloader /EFI/BOOT/BOOTX64.EFI
}
$uuid is the UUID for the EFI system partition.
__________________
Are you infected with Wetiko?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loader, MBR and the boot process Jago FreeBSD Installation and Upgrading 1 22nd January 2010 04:52 AM
How to boot from a CD with the FreeBSD BTX Loader? Turquoise88 FreeBSD General 6 25th August 2009 04:16 PM
How to disable FreeBSD boot loader? Turquoise88 FreeBSD General 2 17th July 2009 03:11 PM
Deleted my /boot/loader enpey FreeBSD General 16 10th June 2008 10:02 PM
How to modify the boot loader? Sunsawe FreeBSD General 5 29th May 2008 05:13 AM


All times are GMT. The time now is 11:56 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick