0

As we know, when we startup the system (after grub) and when we shutdown the system, many logs will be printed on screen.

I know that the kernel would write some logs of the kernel. But how about the others? Who writes them?

As I know, Ubuntu uses systemd and there are some logs from systemd. I want to know if it is possible that I could create a service of systemd, which can write some logs on screen while starting up and shutting down?

  • To me at least it is unclear what your intentions are with "creating a service of systemd. Yes, the kernel, systemd and other applications will write to the screen during the boot process. – Tommiie Jan 16 at 12:43
  • You might be looking at logs written by Plymouth, which is a boot splash manager in modern Linux distributions. – filbranden Jan 16 at 13:22
  • @Tommiie I simply want to know how to write a log message with my own service or process while startup and shutdown. – Yves Jan 17 at 1:22
  • @Yves : that is a completely different question than “who writes to the screen during startup” – Tommiie Jan 17 at 5:49
0

Can analyze the reboot system call source code, maybe the answer is there. PATH: linux-4.4.1/kernel/reboot.c

280 SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
281                 void __user *, arg)
282 {
        ....
315         switch (cmd) {
316         case LINUX_REBOOT_CMD_RESTART:
        ....
333         case LINUX_REBOOT_CMD_POWER_OFF:
334                 kernel_power_off();
335                 do_exit(0);
336                 break;
        ....


257 void kernel_power_off(void)
258 {
259         kernel_shutdown_prepare(SYSTEM_POWER_OFF);
260         if (pm_power_off_prepare)
261                 pm_power_off_prepare();
262         migrate_to_reboot_cpu();
263         syscore_shutdown();
264         pr_emerg("Power down\n");
265         kmsg_dump(KMSG_DUMP_POWEROFF);
266         machine_power_off();
267 }
  • Before kernel doing its shutdown, we can see many log have been printed on the screen. So this shouldn't have business with the kernel. – Yves Jan 17 at 8:50
  • The kernel outputs some information before the real shutdown. 265 kmsg_dump(KMSG_DUMP_POWEROFF); 266 machine_power_off(); – wzq Jan 17 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.