Bookmark this page

Guided Exercise: Preserve the System Journal

Configure the system journal to preserve its data after a reboot.

Outcomes

  • Configure the system journal to preserve its data after a reboot.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command prepares your environment and ensures that all required resources are available.

[student@workstation ~]$ lab start logs-preserve

Instructions

  1. From the workstation machine, log in to the servera machine as the student user.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$
  2. As the superuser, confirm that the /var/log/journal directory does not exist. Use the ls command to list the /var/log/journal directory contents. Use the sudo command to elevate the student user privileges. If prompted, use the student password.

    [student@servera ~]$ sudo ls /var/log/journal
    [sudo] password for student: student
    ls: cannot access '/var/log/journal': No such file or directory

    Because the /var/log/journal directory does not exist, the systemd-journald service does not preserve the log data after a reboot.

  3. Configure the systemd-journald service on the servera machine to preserve journals after a reboot.

    1. Create the /var/log/journal directory.

      [student@servera ~]$ sudo mkdir /var/log/journal
    2. Uncomment the Storage=auto line in the /etc/systemd/journald.conf file, and set the Storage parameter to the persistent value. You might use the sudo vim /etc/systemd/journald.conf command to edit the configuration file. You can type /Storage=auto in the vim editor command mode to search for the Storage=auto line.

      ...output omitted...
      [Journal]
      Storage=persistent
      ...output omitted...
    3. Restart the systemd-journald service to apply the configuration changes.

      [student@servera ~]$ sudo systemctl restart systemd-journald.service
  4. Verify that the systemd-journald service on the servera machine preserves its journals so that they persist after a reboot.

    1. Restart the servera machine.

      [student@servera ~]$ sudo systemctl reboot
      Connection to servera closed by remote host.
      Connection to servera closed.
      [student@workstation ~]$

      The SSH connection terminates as soon as you restart the servera machine.

    2. Log in to the servera machine.

      [student@workstation ~]$ ssh student@servera
      ...output omitted...
      [student@servera ~]$
    3. Verify that a subdirectory with a long hexadecimal name exists in the /var/log/journal directory. You can find the journal files in that directory. The subdirectory name on your system might be different.

      [student@servera ~]$ sudo ls /var/log/journal
      [sudo] password for student: student
      63b272eae8d5443ca7aaa5593479b25f
      [student@servera ~]$ sudo ls /var/log/journal/63b272eae8d5443ca7aaa5593479b25f
      system.journal  user-1000.journal
    4. Return to the workstation system as the student user.

      [student@servera ~]$ exit
      logout
      Connection to servera closed.

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish logs-preserve

Revision: rh134-9.3-5fd2368