What does logind.conf `IdleAction=kexec` do exactly?












4















The logind.conf man page says:




IdleAction=



Configures the action to take when the system is idle. Takes one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate", and "lock". Defaults to "ignore".




I've not seen the kexec value explained anywhere. What exactly does kexec do here?



Is there an equivalent kexec(8) command line that it runs?



In what cases would it be useful to hot reboot into a new kernel on system idle anyway?










share|improve this question



























    4















    The logind.conf man page says:




    IdleAction=



    Configures the action to take when the system is idle. Takes one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate", and "lock". Defaults to "ignore".




    I've not seen the kexec value explained anywhere. What exactly does kexec do here?



    Is there an equivalent kexec(8) command line that it runs?



    In what cases would it be useful to hot reboot into a new kernel on system idle anyway?










    share|improve this question

























      4












      4








      4


      1






      The logind.conf man page says:




      IdleAction=



      Configures the action to take when the system is idle. Takes one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate", and "lock". Defaults to "ignore".




      I've not seen the kexec value explained anywhere. What exactly does kexec do here?



      Is there an equivalent kexec(8) command line that it runs?



      In what cases would it be useful to hot reboot into a new kernel on system idle anyway?










      share|improve this question














      The logind.conf man page says:




      IdleAction=



      Configures the action to take when the system is idle. Takes one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate", and "lock". Defaults to "ignore".




      I've not seen the kexec value explained anywhere. What exactly does kexec do here?



      Is there an equivalent kexec(8) command line that it runs?



      In what cases would it be useful to hot reboot into a new kernel on system idle anyway?







      linux systemd logind






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 22 at 9:23









      Tom HaleTom Hale

      7,255339100




      7,255339100






















          1 Answer
          1






          active

          oldest

          votes


















          3














          Yes, there is a kexec command-line tool that you can use to kexec into a new kernel.



          From an user's point of view, using kexec is about the same as using reboot, except it tends to be quicker since the current kernel loads the new one and starts executing it (bypassing BIOS, firmware, boot loader, etc.)



          The point of logind offering idle actions such as "kexec" (or "reboot") is to help with keeping your system always up-to-date, which for kernel upgrades typically needs a reboot. The idle detection helps figure out when it would be a good time to reboot your system (hopefully at a time when it won't cause too big of a disruption) and rebooting it often (assuming it's idle frequently enough) will ensure it boots into a new kernel not too long after the package manager installs an updated one.



          It's, of course, a setting not all users would agree with, so of course it's not the default setting for this option (the default is "ignore" which doesn't do anything...)





          To understand what the kexec action triggers exactly, you can start looking at systemctl kexec, which is a parallel to systemctl reboot. Its documentation says:




          Shut down and reboot the system via kexec. This is equivalent to systemctl start kexec.target --job-mode=replace-irreversibly --no-block.




          So this goes through a special kexec.target, which is typically configured to require a systemd-kexec.service, which then calls the /usr/lib/systemd/systemd-shutdown tool with a kexec argument (through a systemctl --force kexec, it turns out...).



          To go further, you need to look at the source code, and you'll see that systemd-shutdown kexec will simply try to reboot using kexec -e, with logic to fallback to a "normal" reboot if that fails.



          Looking at the kexec(8) man page, you'll see kexec -e is all that's needed to execute a kexec reboot, so that's all that systemd integrates with.



          The other part that's missing is the part that loads the booting kernel into memory, the part that executes the kexec -l so that the actual execute will work. That's another rabbit hole to follow. I suggest that as an exercise to the reader (or perhaps quite appropriate for a separate question here at U&L!)






          share|improve this answer





















          • 1





            Thanks, but which kernel is chosen when systemd takes the kexec action? What is the equivalent kexec(8) command line that it would run?

            – Tom Hale
            Feb 23 at 14:03











          • Updated the question to include the trail of events of what a kexec triggers.

            – filbranden
            Feb 24 at 12:58











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f502259%2fwhat-does-logind-conf-idleaction-kexec-do-exactly%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          Yes, there is a kexec command-line tool that you can use to kexec into a new kernel.



          From an user's point of view, using kexec is about the same as using reboot, except it tends to be quicker since the current kernel loads the new one and starts executing it (bypassing BIOS, firmware, boot loader, etc.)



          The point of logind offering idle actions such as "kexec" (or "reboot") is to help with keeping your system always up-to-date, which for kernel upgrades typically needs a reboot. The idle detection helps figure out when it would be a good time to reboot your system (hopefully at a time when it won't cause too big of a disruption) and rebooting it often (assuming it's idle frequently enough) will ensure it boots into a new kernel not too long after the package manager installs an updated one.



          It's, of course, a setting not all users would agree with, so of course it's not the default setting for this option (the default is "ignore" which doesn't do anything...)





          To understand what the kexec action triggers exactly, you can start looking at systemctl kexec, which is a parallel to systemctl reboot. Its documentation says:




          Shut down and reboot the system via kexec. This is equivalent to systemctl start kexec.target --job-mode=replace-irreversibly --no-block.




          So this goes through a special kexec.target, which is typically configured to require a systemd-kexec.service, which then calls the /usr/lib/systemd/systemd-shutdown tool with a kexec argument (through a systemctl --force kexec, it turns out...).



          To go further, you need to look at the source code, and you'll see that systemd-shutdown kexec will simply try to reboot using kexec -e, with logic to fallback to a "normal" reboot if that fails.



          Looking at the kexec(8) man page, you'll see kexec -e is all that's needed to execute a kexec reboot, so that's all that systemd integrates with.



          The other part that's missing is the part that loads the booting kernel into memory, the part that executes the kexec -l so that the actual execute will work. That's another rabbit hole to follow. I suggest that as an exercise to the reader (or perhaps quite appropriate for a separate question here at U&L!)






          share|improve this answer





















          • 1





            Thanks, but which kernel is chosen when systemd takes the kexec action? What is the equivalent kexec(8) command line that it would run?

            – Tom Hale
            Feb 23 at 14:03











          • Updated the question to include the trail of events of what a kexec triggers.

            – filbranden
            Feb 24 at 12:58
















          3














          Yes, there is a kexec command-line tool that you can use to kexec into a new kernel.



          From an user's point of view, using kexec is about the same as using reboot, except it tends to be quicker since the current kernel loads the new one and starts executing it (bypassing BIOS, firmware, boot loader, etc.)



          The point of logind offering idle actions such as "kexec" (or "reboot") is to help with keeping your system always up-to-date, which for kernel upgrades typically needs a reboot. The idle detection helps figure out when it would be a good time to reboot your system (hopefully at a time when it won't cause too big of a disruption) and rebooting it often (assuming it's idle frequently enough) will ensure it boots into a new kernel not too long after the package manager installs an updated one.



          It's, of course, a setting not all users would agree with, so of course it's not the default setting for this option (the default is "ignore" which doesn't do anything...)





          To understand what the kexec action triggers exactly, you can start looking at systemctl kexec, which is a parallel to systemctl reboot. Its documentation says:




          Shut down and reboot the system via kexec. This is equivalent to systemctl start kexec.target --job-mode=replace-irreversibly --no-block.




          So this goes through a special kexec.target, which is typically configured to require a systemd-kexec.service, which then calls the /usr/lib/systemd/systemd-shutdown tool with a kexec argument (through a systemctl --force kexec, it turns out...).



          To go further, you need to look at the source code, and you'll see that systemd-shutdown kexec will simply try to reboot using kexec -e, with logic to fallback to a "normal" reboot if that fails.



          Looking at the kexec(8) man page, you'll see kexec -e is all that's needed to execute a kexec reboot, so that's all that systemd integrates with.



          The other part that's missing is the part that loads the booting kernel into memory, the part that executes the kexec -l so that the actual execute will work. That's another rabbit hole to follow. I suggest that as an exercise to the reader (or perhaps quite appropriate for a separate question here at U&L!)






          share|improve this answer





















          • 1





            Thanks, but which kernel is chosen when systemd takes the kexec action? What is the equivalent kexec(8) command line that it would run?

            – Tom Hale
            Feb 23 at 14:03











          • Updated the question to include the trail of events of what a kexec triggers.

            – filbranden
            Feb 24 at 12:58














          3












          3








          3







          Yes, there is a kexec command-line tool that you can use to kexec into a new kernel.



          From an user's point of view, using kexec is about the same as using reboot, except it tends to be quicker since the current kernel loads the new one and starts executing it (bypassing BIOS, firmware, boot loader, etc.)



          The point of logind offering idle actions such as "kexec" (or "reboot") is to help with keeping your system always up-to-date, which for kernel upgrades typically needs a reboot. The idle detection helps figure out when it would be a good time to reboot your system (hopefully at a time when it won't cause too big of a disruption) and rebooting it often (assuming it's idle frequently enough) will ensure it boots into a new kernel not too long after the package manager installs an updated one.



          It's, of course, a setting not all users would agree with, so of course it's not the default setting for this option (the default is "ignore" which doesn't do anything...)





          To understand what the kexec action triggers exactly, you can start looking at systemctl kexec, which is a parallel to systemctl reboot. Its documentation says:




          Shut down and reboot the system via kexec. This is equivalent to systemctl start kexec.target --job-mode=replace-irreversibly --no-block.




          So this goes through a special kexec.target, which is typically configured to require a systemd-kexec.service, which then calls the /usr/lib/systemd/systemd-shutdown tool with a kexec argument (through a systemctl --force kexec, it turns out...).



          To go further, you need to look at the source code, and you'll see that systemd-shutdown kexec will simply try to reboot using kexec -e, with logic to fallback to a "normal" reboot if that fails.



          Looking at the kexec(8) man page, you'll see kexec -e is all that's needed to execute a kexec reboot, so that's all that systemd integrates with.



          The other part that's missing is the part that loads the booting kernel into memory, the part that executes the kexec -l so that the actual execute will work. That's another rabbit hole to follow. I suggest that as an exercise to the reader (or perhaps quite appropriate for a separate question here at U&L!)






          share|improve this answer















          Yes, there is a kexec command-line tool that you can use to kexec into a new kernel.



          From an user's point of view, using kexec is about the same as using reboot, except it tends to be quicker since the current kernel loads the new one and starts executing it (bypassing BIOS, firmware, boot loader, etc.)



          The point of logind offering idle actions such as "kexec" (or "reboot") is to help with keeping your system always up-to-date, which for kernel upgrades typically needs a reboot. The idle detection helps figure out when it would be a good time to reboot your system (hopefully at a time when it won't cause too big of a disruption) and rebooting it often (assuming it's idle frequently enough) will ensure it boots into a new kernel not too long after the package manager installs an updated one.



          It's, of course, a setting not all users would agree with, so of course it's not the default setting for this option (the default is "ignore" which doesn't do anything...)





          To understand what the kexec action triggers exactly, you can start looking at systemctl kexec, which is a parallel to systemctl reboot. Its documentation says:




          Shut down and reboot the system via kexec. This is equivalent to systemctl start kexec.target --job-mode=replace-irreversibly --no-block.




          So this goes through a special kexec.target, which is typically configured to require a systemd-kexec.service, which then calls the /usr/lib/systemd/systemd-shutdown tool with a kexec argument (through a systemctl --force kexec, it turns out...).



          To go further, you need to look at the source code, and you'll see that systemd-shutdown kexec will simply try to reboot using kexec -e, with logic to fallback to a "normal" reboot if that fails.



          Looking at the kexec(8) man page, you'll see kexec -e is all that's needed to execute a kexec reboot, so that's all that systemd integrates with.



          The other part that's missing is the part that loads the booting kernel into memory, the part that executes the kexec -l so that the actual execute will work. That's another rabbit hole to follow. I suggest that as an exercise to the reader (or perhaps quite appropriate for a separate question here at U&L!)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 24 at 12:57

























          answered Feb 23 at 7:04









          filbrandenfilbranden

          10.5k21646




          10.5k21646








          • 1





            Thanks, but which kernel is chosen when systemd takes the kexec action? What is the equivalent kexec(8) command line that it would run?

            – Tom Hale
            Feb 23 at 14:03











          • Updated the question to include the trail of events of what a kexec triggers.

            – filbranden
            Feb 24 at 12:58














          • 1





            Thanks, but which kernel is chosen when systemd takes the kexec action? What is the equivalent kexec(8) command line that it would run?

            – Tom Hale
            Feb 23 at 14:03











          • Updated the question to include the trail of events of what a kexec triggers.

            – filbranden
            Feb 24 at 12:58








          1




          1





          Thanks, but which kernel is chosen when systemd takes the kexec action? What is the equivalent kexec(8) command line that it would run?

          – Tom Hale
          Feb 23 at 14:03





          Thanks, but which kernel is chosen when systemd takes the kexec action? What is the equivalent kexec(8) command line that it would run?

          – Tom Hale
          Feb 23 at 14:03













          Updated the question to include the trail of events of what a kexec triggers.

          – filbranden
          Feb 24 at 12:58





          Updated the question to include the trail of events of what a kexec triggers.

          – filbranden
          Feb 24 at 12:58


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f502259%2fwhat-does-logind-conf-idleaction-kexec-do-exactly%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

          is 'sed' thread safe

          How to make a Squid Proxy server?