Skip to content

Debugfs Guide

Posted on:December 8, 2022 at 02:30 PM

Debugfs is a simple filesystem used for debugging, that can be mounted and used to explore and modify the state of a running Linux system. This guide will walk you through how to use this debugging filesystem.

Requirements

Mounting Debugfs

To mount the debugfs you will need to use the mount command. You will then need to specify the filesystem type as debugfs and the mount point. The syntax for this command is as follows:

mount -t debugfs none /path/to/mount/point

Where /path/to/mount/point is the directory in which you want to mount the debugfs.

Examing Filesystem

Once you have mounted the debugfs, it will appear as a directory in the file system. You can use regular Linux commands to explore this directory, such as ls, cd, cat, etc.

Modifying Filesystem

Debugfs allows you to make changes to the state of the system. This can be done by writing to files in the debugfs. For example, to modify the system’s hostname, you can write to the hostname file in the debugfs.

echo "new_hostname" > /path/to/mount/point/hostname

Where /path/to/mount/point is the path to the debugfs mount point, and new_hostname is the new hostname you want to set.

Unmounting Debugfs

When you are done using the debugfs, you should unmount it. You can do this with the umount command.

umount /path/to/mount/point

Where /path/to/mount/point is the path to the debugfs mount point.

Conclusion

Debugfs is a useful tool for debugging a running Linux system. You can mount and unmount the filesystem, and use regular Linux commands to explore and modify the state of the system.