Support Support Downloads Knowledge Base Apex Support Portal Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

How to collect /var/log files from MX150 device



Article ID: KB32660 KB Last Updated: 07 Oct 2020Version: 2.0

This article explains how to collect log files for both Junos OS and Linux based host OS from MX150 device.


The following procedure describes the collecting of log files. Log files in the /var/log directory are required when analyzing an incident in a JTAC Service Request.

MX150 is based on a virtualized architecture. Junos OS runs as vMX virtual machine on Linux host OS KVM Hypervisor. The log directories are created individually on an OS basis and log files should be collected from both OS.

Note: You will need ftp, SSH, HTTP (JWEB) or USB access to copy the logs from MX150 box.

Junos OS (vMX)

  1. Compress all log files in the /var/log directories the same was as you would in Junos boxes. Please refer the documentation on Compressing Troubleshooting Logs from /var/logs to Send to Juniper Networks Technical Support

    user@mx150> file archive compress source /var/log/* destination /var/tmp/junos_varlog.tgz

Linux host OS

  1. Move to Linux host prompt. "" is the fixed address for Linux host via internal connection.

    user@mx150> ssh routing-instance __juniper_private4__ root@
    root@mx150-node:~#    <-- "-node" indicates you're in Linux host shell

    Note: From 17.4R1, you can use "hypervisor" as name resolution for Linux host instead of private IP address. Also from this revision, you need to input password every time.

    user@mx150> ssh routing-instance __juniper_private4__ root@hypervisor
    root@hypervisor's password:
  2. Archive and compress all log files and put them in /var/tmp.

    root@mx150-node:~# tar czf /var/tmp/linuxhost_varlog.tar.gz /var/log/
    tar: Removing leading `/' from member names
    root@mx150-node:~# ls -l /var/tmp | grep varlog
    -rw-r--r-- 1 root root 958867 Apr 20 06:35 linuxhost_varlog.tar.gz

    NOTE:  In later release, /var/log directory is symbolic linked. It is not followed target directory by default, needs additional "-h"(–dereference) option if following output is seen.

    root@mx150-node:~# ls -l /var/log
    lrwxrwxrwx 1 root root 17 Sep 21 06:01 /var/log -> /var/volatile/log
    root@mx150-node:~# ls -l /var/tmp/linuxhost_varlog.tar.gz
    -rw------- 1 root root   119 Oct  5 02:51 linuxhost_varlog.tar.gz  <-- shows quite small size.
    root@mx150-node:~# tar tvf /var/tmp/linuxhost_varlog.tar.gz
    lrwxrwxrwx root/root         0 2020-09-21 06:01 var/log -> /var/volatile/log  <-- only archived block information.
    root@mx150-node:~# tar czfh /var/tmp/linuxhost_varlog.tar.gz /var/log/  <-- add h option. (Using wildcard works as well.)
    tar: Removing leading `/' from member names
    root@mx150-node:~# ls -l /var/tmp/linuxhost_varlog.tar.gz
    -rw------- 1 root root 1712110 Oct  5 02:54 linuxhost_varlog.tar.gz
  3. Copy the archived file from Linux host to Junos OS VM. "" is fixed address for Junos VM via internal connection.

    root@mx150-node:~# scp /var/tmp/linuxhost_varlog.tar.gz <username>@
    linuxhost_varlog.tar.gz                                    100%  936KB 936.4KB/s   00:00

    Note: Unless you enable configuration for SSH login from root user by "set system services ssh root-login allow", you cannot login to Junos as "root".

  4. You can see both logs in /var/tmp on Junos OS. These files can be transferred via FTP, SCP, JWEB, or mounted USB.

    user@mx150> file list /var/tmp | match varlog
Modification History:
2020-10-05: Added note lines for recursive collection with symbolic link.

Related Links

Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search