Chaining a new kernel using kexec fails as /usr/sbin/shutdown is missing. creating a link in the skeleton, or overlay file system from /usr/sbin/shutdown to /sbin/shutdown fixes the problem.
Hmm, looking at the kexec source code I see: static int my_shutdown(void) { char *args[] = { "shutdown", "-r", "now", NULL }; execv("/sbin/shutdown", args); execv("/etc/shutdown", args); execv("/bin/shutdown", args); perror("shutdown"); return -1; } So having shutdown in /sbin seems fine? Can you please provide more info about your config and what goes wrong?
(In reply to comment #1) > Hmm, looking at the kexec source code I see: > > static int my_shutdown(void) > { > char *args[] = { > "shutdown", > "-r", > "now", > NULL > }; > > execv("/sbin/shutdown", args); > execv("/etc/shutdown", args); > execv("/bin/shutdown", args); > > perror("shutdown"); > return -1; > } > > So having shutdown in /sbin seems fine? > > Can you please provide more info about your config and what goes wrong? The problem is that there is no shutdown in /sbin, shutdown is in /usr/sbin. I had to create a link in /sbin to /usr/sbin/shutdown.
(In reply to comment #2) > (In reply to comment #1) > > Hmm, looking at the kexec source code I see: > > > > static int my_shutdown(void) > > { > > char *args[] = { > > "shutdown", > > "-r", > > "now", > > NULL > > }; > > > > execv("/sbin/shutdown", args); > > execv("/etc/shutdown", args); > > execv("/bin/shutdown", args); > > > > perror("shutdown"); > > return -1; > > } > > > > So having shutdown in /sbin seems fine? > > > > Can you please provide more info about your config and what goes wrong? > > The problem is that there is no shutdown in /sbin, shutdown is in /usr/sbin. I > had to create a link in /sbin to /usr/sbin/shutdown. I also raised a similay bug report 8336, to which I had a responce citing http://patchwork.ozlabs.org/patch/514750/ as a fix. That patch should also fix this bug.
(In reply to comment #2) > > Can you please provide more info about your config and what goes wrong? > > The problem is that there is no shutdown in /sbin, shutdown is in /usr/sbin. I > had to create a link in /sbin to /usr/sbin/shutdown. Ok, what package do you have providing /usr/sbin/shutdown? I see that busybox doesn't provide a shutdown applet at all (it does provide halt/poweroff/reboot though).
(In reply to comment #4) > (In reply to comment #2) > > > Can you please provide more info about your config and what goes wrong? > > > > The problem is that there is no shutdown in /sbin, shutdown is in /usr/sbin. I > > had to create a link in /sbin to /usr/sbin/shutdown. > > Ok, what package do you have providing /usr/sbin/shutdown? I see that busybox > doesn't provide a shutdown applet at all (it does provide halt/poweroff/reboot > though). Systemd is providing /usr/sbin/shutdown
(In reply to comment #0) > Chaining a new kernel using kexec fails as /usr/sbin/shutdown is missing. That's not correct. /usr/sbin/shutdown does exists. The problem is that kexec is trying to find it at /sbin instead of /usr/sbin. (In reply to comment #3) > I also raised a similay bug report 8336, to which I had a responce citing > http://patchwork.ozlabs.org/patch/514750/ as a fix. That patch should also fix > this bug. Currently in Buildroot there are two ways to have shutdown installed in your target. The first one is using sysvinit as you init system, which will install shutdown in /sbin. The second one is using systemd as your init system, which will install shutdown in /usr/sbin. Once we get the patch from Yann merged, kexec will be able to find shutdown because /sbin will be a symlink to /usr/sbin if you use systemd as your init system. So, yes, that patches fixes your problem. The thing is that here we have highlighted a different problem. Busybox doesn't install shutdown, so kexec will never be able to find it, either if you have /sbin as a real directory or being a symlink to /usr/sbin. It simply doesn't exist.
(In reply to comment #5) > Systemd is providing /usr/sbin/shutdown Ok, so there's two issues: - Not all of our init implementations provide shutdown (busybox doesn't, sysvinit has /sbin/shutdown, systemd has /usr/sbin/shutdown - Systemd doesn't install it where kexec looks for it I see that kexec-lite doesn't have such code. I've never used kexec, but looking at the kexec code I'm not sure what the shutdown code is for, it seems to just be a wrapper around shutting down that isn't normally used (as it gets checked before do_exec). What is your use case for needing it?
By the way, is this helpful for you? http://unix.stackexchange.com/questions/37323/kexec-from-within-initramfs From the kexec man page: -e (--exec) Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8).
(In reply to comment #7) > What is your use case for needing it? I think he is loading a new kernel image using "kexec --load", and then he wants to reboot the board in order to boot with that kernel image, which should be able to do it with "kexec --exec", without calling shutdown. Dr I J Ormshaw, please confirm.
I was trying /usr/sbin/kexec --command-line="@kernelCommandLine@" "${mountPoint}"/boot/@kernelName@ Using kexec -l followed bu kexec -e will not shut down services correctly. but I think I should be able to use: kexec -l followed by systemctl isolate kexec.target to achieve what I want, as I think systemd should kexec the loaded kernel once services are shutdown.
(In reply to comment #10) > Using kexec -l followed bu kexec -e will not shut down services correctly. Well, but that's because you are using systemd, right? That would work with busybox. > but I think I should be able to use: > > kexec -l > > followed by > > systemctl isolate kexec.target > > to achieve what I want, as I think systemd should kexec the loaded kernel once > services are shutdown. Or, in the meantime, you can create the symlink to workaround the problem until the patch from Yann gets applied. You could also send a patch to kexec upstream in order to add... execv("/usr/sbin/shutdown", args); ...to the my_shutdown() function, so it would also work on systemd although you don't have the /bin, /sbin and /lib symlinks stuff. So, to summarize and make progress on this issue: - systemd: symlink workaround until Yann's patch OR fix kexec upstream - sysvinit: already works - busybox: use "kexec -e" Should we mark this bug as RESOLVED DUPLICATE (of #8336), Peter? For busybox you can use the "-e (--exec)" option
(In reply to comment #11) > For busybox you can use the "-e (--exec)" option Ignore that line (the last one of my previous comment). I forgot to remove it before sending my message.
*** This bug has been marked as a duplicate of bug 8336 ***