Mount a failed system read-only at /mnt.
Read only /mnt/var/log/journal without mixing it with the current system journal.
Which command is appropriate?
journalctl --directory=DIR reads journal files from the specified directory.
Detailed explanation
journalctl --directory=/mnt/var/log/journalCorrect. --directory points journalctl at the mounted system's journal directory.
Correct. --directory points journalctl at the mounted system's journal directory.
journalctl --root=/mnt/var/log/journalIncorrect. --root expects a root directory rather than the journal-data directory itself.
Incorrect. --root expects a root directory rather than the journal-data directory itself.
journalctl --file=/mnt/var/log/journalIncorrect. --file is for a particular journal file, not a directory.
Incorrect. --file is for a particular journal file, not a directory.
journalctl --vacuum-dir=/mnt/var/log/journalIncorrect. There is no read option of this form; vacuum is for deletion.
Incorrect. There is no read option of this form; vacuum is for deletion.
Try it yourself
An example you can run in a temporary verification environment.
journalctl --help 2>&1 | grep -E -- '--directory| -D' | head -n 1Expected result
-Dまたは--directoryのhelp行Key points
- Specify journal directory
- Read-only analysis
- Separate from current journal
Notes
- Environment: journalctl helpの読取のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.