Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 422471 - "init 2" kernel option is ignored
Summary: "init 2" kernel option is ignored
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: Bug
Depends on:
Blocks:
 
Reported: 2012-06-19 20:29 UTC by Toralf Förster
Modified: 2012-11-23 09:21 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2012-06-19 20:29:48 UTC
Since I use a kernel + initramfs (created with genkernel) the grub command line parameter "init 2" is ignored completely.
/me wonders whether this is a initrd issue or related to genkernel (3.4.24_p1)

Reproducible: Always
Comment 1 Mike Gilbert gentoo-dev 2012-06-20 04:21:50 UTC
What do you expect "init 2" on the kernel command line to actually do?
Comment 2 Toralf Förster gentoo-dev 2012-06-20 12:08:54 UTC
(In reply to comment #1)
> What do you expect "init 2" on the kernel command line to actually do?
That the runlevel "nonetwork" will be used instead of the runlevel "default"
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2012-06-20 15:46:33 UTC
On other distros, it's an init(8) script that parses the kernel command line and determines what runlevel to start, not the initrd let alone grub. /etc/inittab defines the "nonetwork" runlevel but rc(8) (from openrc) does not list it. It does list "single" which might be what you are looking for:

 "single    Stops all services except for those in the _sysinit_ runlevel."

where "sysinit" is the runlevel before boot, i.e. it does not mount physical filesystems, only the virtual ones (like /proc and /dev) needed to bring up the physical ones in the next runlevel, "boot".
Comment 4 Toralf Förster gentoo-dev 2012-06-20 19:04:22 UTC
Hhm,

I did not understood the problem (but I can see it - gah).

This grub entry boots my system into "nonetwork" runlevel :

title Linux 3.4.3 w/o initrd
root (hd0,0)
kernel /kernel-genkernel-x86-3.4.3      root=/dev/sdb3 rootfstype=ext4 reboot=pci rootdelay=5 init 2


This grub entry boots my system _not_ into the "nonetwork" runlevel, instead the "default" is used

title Linux 3.4.3
root (hd0,0)
kernel /kernel-genkernel-x86-3.4.3      real_root=/dev/sdb3 rootfstype=ext4 reboot=pci resume=/dev/sdb2 init 2
initrd /initramfs-genkernel-x86-3.4.3


I wonder why in the 2nd example the "init" is ignored completely - regardless what I do specify.


(BTW why do I need in addition the definition "resume=/dev/sdb2" for the initrd grub entry ?  If I don#t do it, then suspend2disk won't wake up correctly, but the string is already a kernel configured option - feature or bug ?)
Comment 5 Mike Gilbert gentoo-dev 2012-06-20 21:39:31 UTC
Hmm... when no initramfs is present, the kernel passes any unknown command line paramters to /sbin/init.

With an initramfs, the /init script in the initramfs is responsible for passing any arguments to /sbin/init. It looks like genkernel handles this using the init_opts kernel command line parameter.

Can you try adding init_opts=2 to your kernel command line in the grub config?
Comment 6 Toralf Förster gentoo-dev 2012-06-21 13:25:14 UTC
(In reply to comment #5)
> Can you try adding init_opts=2 to your kernel command line in the grub
> config?
yes - was fully ignored
Comment 7 Jeroen Roovers (RETIRED) gentoo-dev 2012-06-22 14:31:24 UTC
So can I assume it's a genkernel problem for now? :)
Comment 8 Mike Gilbert gentoo-dev 2012-07-15 22:12:42 UTC
I believe this will be resolved if "$@" is added on the end of the switch_root command in linuxrc.
Comment 9 Toralf Förster gentoo-dev 2012-09-21 16:41:11 UTC
(In reply to comment #8)
> I believe this will be resolved if "$@" is added on the end of the
> switch_root command in linuxrc.
yep - solved.
Comment 10 Mike Gilbert gentoo-dev 2012-09-21 17:45:25 UTC
Marking CONFIRMED. My suggestion in comment 8 should be applied to the genkerenel source.
Comment 11 Richard Yao (RETIRED) gentoo-dev 2012-11-22 21:42:13 UTC
(In reply to comment #10)
> Marking CONFIRMED. My suggestion in comment 8 should be applied to the
> genkerenel source.

I think we need to consider why init_opts=2 does not produce the desired result, but appending "$@" to the switch_root line does.  Appending "$@" should cause us to pass genkernel-specific parameters that we would not necessarily want to pass to /sbin/init, but if that works, then passing init_opts="init 2" on the kernel commandline should also work.
Comment 12 Richard Yao (RETIRED) gentoo-dev 2012-11-22 22:21:17 UTC
This is fixed in genkernel HEAD:

http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=543181ebefddbd83850d667aa422991fbe8c3735
Comment 13 Mike Gilbert gentoo-dev 2012-11-23 01:37:42 UTC
Personally, I think a better solution would be this:

1. Loop through "$@".
2. If an option is genkernel-specific, remove it.
3. Pass any remaining (unknown) arguments to init in the switch_root call.

The current "init_opts" method does not allow more than one parameter to be passed to init.
Comment 14 Toralf Förster gentoo-dev 2012-11-23 09:21:32 UTC
(In reply to comment #13)
> Personally, I think a better solution would be this:
> 
> 1. Loop through "$@".
> 2. If an option is genkernel-specific, remove it.
> 3. Pass any remaining (unknown) arguments to init in the switch_root call.
> 
> The current "init_opts" method does not allow more than one parameter to be
> passed to init.

The INIT_OPTS fix now papered out another bug. passing init_opts="init 2" (regardless, how is it quoted) - the switch_kernel staement crashes with something like "cannot found directory" - meaning a non-empty INIT_OPTS prevents a successful kernel boot.