Debug messages not being printed on the console












1















I am trying to enable printing the debug messages on the console.



#include <linux/kernel.h>
#include <linux/module.h>

MODULE_LICENSE("GPL");
static int test_hello_init(void)
{
printk(KERN_INFO"%s: In initn", __func__);
return 0;
}

static void test_hello_exit(void)
{
printk(KERN_INFO"%s: In exitn", __func__);
}

module_init(test_hello_init);
module_exit(test_hello_exit);


To get the Info messages on the console, i executed the following command: dmesg -n7



 cat /proc/sys/kernel/printk
7 4 1 7


When I load the module using insmod, i don't get any message on the terminal, while it is available when I type dmesg. What mistake i am making here.










share|improve this question



























    1















    I am trying to enable printing the debug messages on the console.



    #include <linux/kernel.h>
    #include <linux/module.h>

    MODULE_LICENSE("GPL");
    static int test_hello_init(void)
    {
    printk(KERN_INFO"%s: In initn", __func__);
    return 0;
    }

    static void test_hello_exit(void)
    {
    printk(KERN_INFO"%s: In exitn", __func__);
    }

    module_init(test_hello_init);
    module_exit(test_hello_exit);


    To get the Info messages on the console, i executed the following command: dmesg -n7



     cat /proc/sys/kernel/printk
    7 4 1 7


    When I load the module using insmod, i don't get any message on the terminal, while it is available when I type dmesg. What mistake i am making here.










    share|improve this question

























      1












      1








      1








      I am trying to enable printing the debug messages on the console.



      #include <linux/kernel.h>
      #include <linux/module.h>

      MODULE_LICENSE("GPL");
      static int test_hello_init(void)
      {
      printk(KERN_INFO"%s: In initn", __func__);
      return 0;
      }

      static void test_hello_exit(void)
      {
      printk(KERN_INFO"%s: In exitn", __func__);
      }

      module_init(test_hello_init);
      module_exit(test_hello_exit);


      To get the Info messages on the console, i executed the following command: dmesg -n7



       cat /proc/sys/kernel/printk
      7 4 1 7


      When I load the module using insmod, i don't get any message on the terminal, while it is available when I type dmesg. What mistake i am making here.










      share|improve this question














      I am trying to enable printing the debug messages on the console.



      #include <linux/kernel.h>
      #include <linux/module.h>

      MODULE_LICENSE("GPL");
      static int test_hello_init(void)
      {
      printk(KERN_INFO"%s: In initn", __func__);
      return 0;
      }

      static void test_hello_exit(void)
      {
      printk(KERN_INFO"%s: In exitn", __func__);
      }

      module_init(test_hello_init);
      module_exit(test_hello_exit);


      To get the Info messages on the console, i executed the following command: dmesg -n7



       cat /proc/sys/kernel/printk
      7 4 1 7


      When I load the module using insmod, i don't get any message on the terminal, while it is available when I type dmesg. What mistake i am making here.







      linux linux-kernel linux-device-driver






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 1 at 13:20









      md.jamalmd.jamal

      476520




      476520
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Messages from kernel are not printed on terminal (unless it's specified as console= in kernel cmdline). They are appended to kernel log, which exists in kernel. It's accessible to user space programs via device file /dev/kmsg. This file is read by dmesg command in order to print kernel log content on terminal.






          share|improve this answer
























          • what should be the value of console field in ubuntu machine running on VM

            – md.jamal
            Jan 1 at 14:35











          • If you are using serial console (e.g. virsh console) then console=ttyS0 should work fine.

            – Robert Baldyga
            Jan 1 at 14:58













          • No. I am not using serial console. I want messages to be displayed on terminal

            – md.jamal
            Jan 1 at 15:00











          • By " terminal" you mean QEMU monitor? If yes, then, as it's regular VT, so you should use console=tty0.

            – Robert Baldyga
            Jan 1 at 15:10













          • The one we use after typing CTRL+ALT+T, did not work after adding console=tty0, my command line: BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US sysrq_always_enablde nokaslr console=tty0

            – md.jamal
            Jan 1 at 15:26











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f53995773%2fdebug-messages-not-being-printed-on-the-console%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









          1














          Messages from kernel are not printed on terminal (unless it's specified as console= in kernel cmdline). They are appended to kernel log, which exists in kernel. It's accessible to user space programs via device file /dev/kmsg. This file is read by dmesg command in order to print kernel log content on terminal.






          share|improve this answer
























          • what should be the value of console field in ubuntu machine running on VM

            – md.jamal
            Jan 1 at 14:35











          • If you are using serial console (e.g. virsh console) then console=ttyS0 should work fine.

            – Robert Baldyga
            Jan 1 at 14:58













          • No. I am not using serial console. I want messages to be displayed on terminal

            – md.jamal
            Jan 1 at 15:00











          • By " terminal" you mean QEMU monitor? If yes, then, as it's regular VT, so you should use console=tty0.

            – Robert Baldyga
            Jan 1 at 15:10













          • The one we use after typing CTRL+ALT+T, did not work after adding console=tty0, my command line: BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US sysrq_always_enablde nokaslr console=tty0

            – md.jamal
            Jan 1 at 15:26
















          1














          Messages from kernel are not printed on terminal (unless it's specified as console= in kernel cmdline). They are appended to kernel log, which exists in kernel. It's accessible to user space programs via device file /dev/kmsg. This file is read by dmesg command in order to print kernel log content on terminal.






          share|improve this answer
























          • what should be the value of console field in ubuntu machine running on VM

            – md.jamal
            Jan 1 at 14:35











          • If you are using serial console (e.g. virsh console) then console=ttyS0 should work fine.

            – Robert Baldyga
            Jan 1 at 14:58













          • No. I am not using serial console. I want messages to be displayed on terminal

            – md.jamal
            Jan 1 at 15:00











          • By " terminal" you mean QEMU monitor? If yes, then, as it's regular VT, so you should use console=tty0.

            – Robert Baldyga
            Jan 1 at 15:10













          • The one we use after typing CTRL+ALT+T, did not work after adding console=tty0, my command line: BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US sysrq_always_enablde nokaslr console=tty0

            – md.jamal
            Jan 1 at 15:26














          1












          1








          1







          Messages from kernel are not printed on terminal (unless it's specified as console= in kernel cmdline). They are appended to kernel log, which exists in kernel. It's accessible to user space programs via device file /dev/kmsg. This file is read by dmesg command in order to print kernel log content on terminal.






          share|improve this answer













          Messages from kernel are not printed on terminal (unless it's specified as console= in kernel cmdline). They are appended to kernel log, which exists in kernel. It's accessible to user space programs via device file /dev/kmsg. This file is read by dmesg command in order to print kernel log content on terminal.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 1 at 13:57









          Robert BaldygaRobert Baldyga

          7715




          7715













          • what should be the value of console field in ubuntu machine running on VM

            – md.jamal
            Jan 1 at 14:35











          • If you are using serial console (e.g. virsh console) then console=ttyS0 should work fine.

            – Robert Baldyga
            Jan 1 at 14:58













          • No. I am not using serial console. I want messages to be displayed on terminal

            – md.jamal
            Jan 1 at 15:00











          • By " terminal" you mean QEMU monitor? If yes, then, as it's regular VT, so you should use console=tty0.

            – Robert Baldyga
            Jan 1 at 15:10













          • The one we use after typing CTRL+ALT+T, did not work after adding console=tty0, my command line: BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US sysrq_always_enablde nokaslr console=tty0

            – md.jamal
            Jan 1 at 15:26



















          • what should be the value of console field in ubuntu machine running on VM

            – md.jamal
            Jan 1 at 14:35











          • If you are using serial console (e.g. virsh console) then console=ttyS0 should work fine.

            – Robert Baldyga
            Jan 1 at 14:58













          • No. I am not using serial console. I want messages to be displayed on terminal

            – md.jamal
            Jan 1 at 15:00











          • By " terminal" you mean QEMU monitor? If yes, then, as it's regular VT, so you should use console=tty0.

            – Robert Baldyga
            Jan 1 at 15:10













          • The one we use after typing CTRL+ALT+T, did not work after adding console=tty0, my command line: BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US sysrq_always_enablde nokaslr console=tty0

            – md.jamal
            Jan 1 at 15:26

















          what should be the value of console field in ubuntu machine running on VM

          – md.jamal
          Jan 1 at 14:35





          what should be the value of console field in ubuntu machine running on VM

          – md.jamal
          Jan 1 at 14:35













          If you are using serial console (e.g. virsh console) then console=ttyS0 should work fine.

          – Robert Baldyga
          Jan 1 at 14:58







          If you are using serial console (e.g. virsh console) then console=ttyS0 should work fine.

          – Robert Baldyga
          Jan 1 at 14:58















          No. I am not using serial console. I want messages to be displayed on terminal

          – md.jamal
          Jan 1 at 15:00





          No. I am not using serial console. I want messages to be displayed on terminal

          – md.jamal
          Jan 1 at 15:00













          By " terminal" you mean QEMU monitor? If yes, then, as it's regular VT, so you should use console=tty0.

          – Robert Baldyga
          Jan 1 at 15:10







          By " terminal" you mean QEMU monitor? If yes, then, as it's regular VT, so you should use console=tty0.

          – Robert Baldyga
          Jan 1 at 15:10















          The one we use after typing CTRL+ALT+T, did not work after adding console=tty0, my command line: BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US sysrq_always_enablde nokaslr console=tty0

          – md.jamal
          Jan 1 at 15:26





          The one we use after typing CTRL+ALT+T, did not work after adding console=tty0, my command line: BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US sysrq_always_enablde nokaslr console=tty0

          – md.jamal
          Jan 1 at 15:26




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53995773%2fdebug-messages-not-being-printed-on-the-console%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

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]