Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Error when reboot with kexec
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
fingolfin0
n00b
n00b


Joined: 02 Dec 2022
Posts: 3

PostPosted: Fri Dec 02, 2022 5:06 pm    Post subject: Error when reboot with kexec Reply with quote

Hello, I want to set up rebooting via kexec. I've compiled the kernel width kexec support and installed kexec-tools. When I use reboot -k, it throws the error:
Code:
ERROR: using -k at this runlevel requires also -f
  (You probably want instead to reboot normally and let your reboot
   script, usually /etc/init.d/reboot, specify -k)

Output of command runlevel: "N 3".
I read mans -- "reboot", "runlevel", sysvinit wiki page and initscripts chapter from handbook, but I still can’t understand what I am doing wrong.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Fri Dec 02, 2022 5:18 pm    Post subject: Reply with quote

Welcome to Gentoo.
Why dont you follow your system's advice
Code:

reboot -kf

?
_________________
:)
Back to top
View user's profile Send private message
fingolfin0
n00b
n00b


Joined: 02 Dec 2022
Posts: 3

PostPosted: Fri Dec 02, 2022 5:53 pm    Post subject: Reply with quote

Thanks, alamahant :)

Because with "-k" option reboot does not proper unmounting, stopping services, etc. I want a normal reboot, but via kexec. In addition, in my case, for some reason reboot -fk does usual reboot through the BIOS.
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1522
Location: South America

PostPosted: Fri Dec 02, 2022 7:21 pm    Post subject: Reply with quote

fingolfin0 wrote:
Because with "-k" option reboot does not proper unmounting, stopping services, etc. I want a normal reboot, but via kexec.

In that case, just use reboot without -k. From runlevel 3, the reboot will then go through /etc/inittab, and Gentoo's inittab should trigger a kexec reboot if the kernel supports it.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
sublogic
Apprentice
Apprentice


Joined: 21 Mar 2022
Posts: 222
Location: Pennsylvania, USA

PostPosted: Sat Dec 03, 2022 3:57 am    Post subject: Reply with quote

fingolfin0, did you run the appropriate "kexec -l" to preload a kernel before rebooting ?

Edited 2022-12-03: Okay, I just tested this on the laptop on which I had to use kexec before. (See topic 1147842)
Back then I did everything from single-user mode, but this time I tried from runlevel 3 (aka default). Something like this:
Code:
# mount -o ro /boot
# kexec -l /boot/vmlinuz-5.15.75-gentoo-x86 --initrd=/boot/initramfs-5.15.75-gentoo-x86.img \
> --append="root=/dev/vg0/root ro dolvm crypt_root=/dev/sda3 hpet=force"
# reboot

... and, it worked. Orderly shutdown to runlevel S, then normal boot without going through the power-on self test.

The above, especially the "--append", is of course idiosyncratic to my laptop. Also, my kernels now have the final video driver built-in, with the required firmware embedded (see the topic linked above). Otherwise the video hardware wouldn't re-initialize properly, the screen would be all garbled during early userspace, and I would have to guess when cryptsetup was waiting for a passphrase and enter it blind.

YMMV. Anyway, the proper sequence is "kexec -l", then "reboot". Practice from single-user mode first. Good luck.
Back to top
View user's profile Send private message
sublogic
Apprentice
Apprentice


Joined: 21 Mar 2022
Posts: 222
Location: Pennsylvania, USA

PostPosted: Sun Dec 04, 2022 7:51 pm    Post subject: Reply with quote

Okay, I see what @GDH-gentoo was saying. sys-apps/kexec-tools installs a "kexec" service that will run the "kexec -l" command for you during the shutdown phase. The Gentoo wiki says to start the service, then reboot. (It also says to use "reboot -k", but the "-k" is not necessary, the /etc/inittab does a "/sbin/shutdown -dkn" at runlevel 6.)

Hm. Would it make sense to add the kexec service to runlevel 3 ?
Back to top
View user's profile Send private message
fingolfin0
n00b
n00b


Joined: 02 Dec 2022
Posts: 3

PostPosted: Mon Dec 05, 2022 1:03 pm    Post subject: Reply with quote

Thans @GDH-gentoo, @sublogic! The gentoo community is very friendly :)

My problem solved. As @GDH-gentoo said, I can to use reboot without -k. I emphasize that we need to use it without a "-k" option. It turned out that while the reboot -k gives an error, just reboot works correctly.

sublogic wrote:
Hm. Would it make sense to add the kexec service to runlevel 3 ?

I do not think. The use of a kexec can lead to errors with video divers, so it should not be turned on by default.

Now I see two problems:
1. The wiki page tells to use reboot -k while we need use it without "-k". Do I need to start discussion on that page about this, or maybe I should edit the wiki myself?
2. I don't know why the option is really needed. But it seems to me that it works incorrectly, or an error message is confusing and does not tell the actual reason for the error. Should I create a bugreport?

I like gentoo and want to make it better.
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1522
Location: South America

PostPosted: Mon Dec 05, 2022 4:45 pm    Post subject: Reply with quote

fingolfin0 wrote:
1. The wiki page tells to use reboot -k while we need use it without "-k". Do I need to start discussion on that page about this, or maybe I should edit the wiki myself?

If you have a Wiki account, just edit the article. Correcting wrong information does not require a permission.

fingolfin0 wrote:
2. I don't know why the option is really needed. But it seems to me that it works incorrectly, or an error message is confusing and does not tell the actual reason for the error. Should I create a bugreport?

The -k option is needed to request a kexec reboot, if possible, instead of a 'normal' reboot, but it can only be used either in sysvinit runlevel 6, or with -f (i. e. when bypassing the init system). When you run reboot from an interactive shell, you are usually in sysvinit runlevel 3, so you can't use it.

In any runlevel that is not 6, reboot with no options is equivalent to shutdown -r now, which, among other things, asks init to switch to runlevel 6. And then, Gentoo's /etc/inittab specifies that, in runlevel 6, reboot -k be called.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum