# Tracing the loop device kernel module The loop device kernel module can be traced with the *ftrace* framework of the Linux kernel. Therefore, *ftrace* must be compiled into the Linux kernel and the user space module *trace-cmd* is necessary. ## Creating the trace file Each loop device specific operation can be traced with the following command ```bash trace-cmd record -p function_graph --module loop -o [trace file] [cmd] ``` where `[trace file]` is the created trace file and `[cmd]` is one of the following loop device operation: * add loop device: `losetup -f test.img` * read from loop device: `dd if=/dev/loop0 bs=512 count=1 of=tmp.img` * write to loop device: `dd of=/dev/loop0 bs=512 count=1 if=tmp.img` * remove loop device: `losetup -D` ## Viewing the trace file The created trace file can be viewed on the command line with the following command: ```bash trace-cmd report -i [trace file] ``` where `[trace file]` is the already created trace file.