mountsnoop(8)

๐Ÿ“ฆ version 0.36.1, in centos-stream 10, centos-stream 9, fedora 43, fedora 44

๐ŸŽ€ mountsnoop(8) ๐ŸŽ€

mountsnoop โœจ is a tracing tool that sneaks a peek at the mount() and umount() syscalls. It's a Linux eBPF/bcc tool, so it's built on the good stuff. ๐Ÿ’…

๐ŸŒธ NAME ๐ŸŒธ

mountsnoop - Trace mount() and umount() syscalls. Uses Linux eBPF/bcc.

๐Ÿ’– SYNOPSIS ๐Ÿ’–

mountsnoop

โœจ DESCRIPTION โœจ

okay so mountsnoop watches the mount() and umount() syscalls and shows you which processes are mounting and unmounting filesystems, and which mount namespaces they're doing it in. ๐Ÿงš This is seriously useful when you're troubleshooting system or container setup. ๐Ÿซถ

Under the hood, it works by tracing the kernel sys_mount() and sys_umount() functions using dynamic tracing. ๐Ÿ” The catch? If those functions ever change in the kernel, this tool will need updating to match. ๐Ÿ™ˆ

It also makes use of a Linux 4.8 feature, bpf_get_current_task(), so your kernel needs to be at least that new. ๐Ÿ’€

โš ๏ธ Since this uses BPF, only the root user can use this tool. No cap, it's a root-only situation. ๐Ÿ‘‘

๐Ÿฆ‹ REQUIREMENTS ๐Ÿฆ‹

You'll need CONFIG_BPF enabled in your kernel, plus bcc installed. ๐Ÿ’œ

๐Ÿ“ FIELDS ๐Ÿ“

Here's what shows up in the output:

  • COMM โ€” the process name ๐Ÿฃ
  • PID โ€” the process ID ๐Ÿชช
  • TID โ€” the thread ID ๐Ÿงต
  • MNT_NS โ€” the mount namespace inode number ๐ŸŒˆ
  • CALL โ€” the system call, its arguments, and its return value ๐Ÿ“ž

๐ŸŒˆ OVERHEAD ๐ŸŒˆ

Okay, the vibe check on performance: mountsnoop traces the kernel mount and umount functions and prints output for every event. Since these calls are generally expected to happen at a very low rate, the overhead is also expected to be negligible. ๐Ÿ˜Œ

Lowkey though, if your system calls mount() and umount() at a high rate, you need to test and understand the overhead before you use it. ๐Ÿšจ

๐Ÿ”— SOURCE ๐Ÿ”—

This one comes from bcc, the BPF Compiler Collection, which lives at:

https://github.com/iovisor/bcc

Also, go check the bcc distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool, and it's giving very helpful energy. ๐Ÿ“š

๐Ÿซง OS ๐Ÿซง

Linux only, bestie. ๐Ÿง

๐Ÿงช STABILITY ๐Ÿงช

Unstable - in development. ๐Ÿšง Don't be shocked if things shift around.

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Written by Omar Sandoval. Iconic. ๐Ÿ™Œ

๐Ÿ”ฎ SEE ALSO ๐Ÿ”ฎ


๐ŸŒธ Bestie, that's the whole page. This is the USER COMMANDS section, last updated 2016-10-14, and it's a manual page for mountsnoop(8). Now go trace some mounts and be obsessed with it. ๐Ÿ’…โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from