Skip to main content
Version: latest

trace_mount

The trace_mount gadget emits events when mount and unmount system calls are made.

Getting started

Running the gadget:

$ kubectl gadget run ghcr.io/inspektor-gadget/gadget/trace_mount:latest [flags]

Flags

--pid

Show only events generated by process with this PID

Default value: ""

Guide

First, we need to run an application that generates some events.

$ kubectl run mypod --restart=Never --image=busybox -- sh -c 'while /bin/true ; do mount /mnt /mnt ; sleep 3 ; done'
pod/mypod created

Then, let's run the gadget:

Using the trace_mount gadget, we can see which processes mount and unmount filesystems. We can simply filter for the pod mypod and omit specifying the node, thus tracing on all nodes for a pod called mypod:

$ kubectl gadget run trace_mount:latest --podname mypod
K8S.NODE K8S.NAMESPACE K8S.PODNAME K8S.CONTAINERNAME COMM PID TID DELTA FLAGS CALL ERROR
minikube-docker default mypod mypod mount 36469 36469 3318 MS_SILENT mount("/mnt", "/mnt", "ext… ENOENT
minikube-docker default mypod mypod mount 36469 36469 1321 MS_SILENT mount("/mnt", "/mnt", "ext… ENOENT
minikube-docker default mypod mypod mount 36469 36469 1187 MS_SILENT mount("/mnt", "/mnt", "ext… ENOENT
minikube-docker default mypod mypod mount 36469 36469 1655 MS_SILENT mount("/mnt", "/mnt", "squ… ENOENT
minikube-docker default mypod mypod mount 36469 36469 1257 MS_SILENT mount("/mnt", "/mnt", "vfa… ENOENT
minikube-docker default mypod mypod mount 36469 36469 1211 MS_SILENT mount("/mnt", "/mnt", "fus… ENOENT
minikube-docker default mypod mypod mount 36474 36474 3496 MS_SILENT mount("/mnt", "/mnt", "ext… ENOENT
minikube-docker default mypod mypod mount 36474 36474 1638 MS_SILENT mount("/mnt", "/mnt", "ext… ENOENT
^C

We can stop the gadget by hitting Ctrl-C.

Finally, clean the system:

$ kubectl delete pod mypod