Results 1 to 6 of 6
Hi,
I'm hacking some code in the kernel, and want to pass in a custom parameter
to the kernel (either at boot time, or after startup), which my new code ...
- 09-27-2007 #1Just Joined!
- Join Date
- Jul 2006
- Posts
- 12
Passing a custom parameter to the kernel
Hi,
I'm hacking some code in the kernel, and want to pass in a custom parameter
to the kernel (either at boot time, or after startup), which my new code will
use. This parameter is a number, ranging from 40 to 800, for example.
The existing boot command line parameters do not allow the use of a user
defined custom parameter to be passed in to the kernel. Is there a way to
do this, either during or after boot?
Thanks,
John
- 09-29-2007 #2Linux Enthusiast
- Join Date
- Apr 2004
- Location
- UK
- Posts
- 658
I am certain is is possible to pass anything you like as a parameter to the kernel, but I think it depends on which boot loader you use.
Do you use grub, lilo or something else entirely? If you are not certain then tell us which distribution you use and we should be able to look it up.
Chris...To be good, you must first be bad. "Newbie" is a rank, not a slight.
- 09-30-2007 #3Just Joined!
- Join Date
- Jul 2006
- Posts
- 12
- 09-30-2007 #4Linux Enthusiast
- Join Date
- Apr 2004
- Location
- UK
- Posts
- 658
You need to edit the menu.lst file. From examples on this site:
You should be able to add your parameters to the end of the kernel line as it exists in your version of this file and have them passed to the kernel on boot.Code:title Linux root (hd0,1) kernel /boot/summer-usb ro root=/dev/hda2 hdc=ide-scsi
Let us know how you get on,
Chris...To be good, you must first be bad. "Newbie" is a rank, not a slight.
- 09-30-2007 #5Just Joined!
- Join Date
- Jul 2006
- Posts
- 12
Thanks, kakariko81280
In this case, I'd have to hack init.c, parse/collect my parameter from
/proc/cmdline, and set a global variable that my new code (located in
mm/memory.c) could use. I was going to try this, but am also interested
in passing in the parameter after kernel nitilaization is completed, if that
is possible.
John
- 09-30-2007 #6Linux Enthusiast
- Join Date
- Apr 2004
- Location
- UK
- Posts
- 658
There are ways to pass data to and from the kernel, but I'm not a kernel hacker so my advice is going to be limited.
I have been told that netlink is a decent method of passing data in and out of the kernel, or since it is a single value you plan on working with, you could look at creating an entry in the procfs filesystem, but I'm afraid I don't know the first thing about doing either of these things.
The bonus with these methods would be that you can change them as much as you want without needing to reboot your computer.
Let us know how you get on,
Chris...To be good, you must first be bad. "Newbie" is a rank, not a slight.


Reply With Quote

