在线修改
- 启用:
# sysctl -q -w dev.scsi.logging_level=[N]
或者
# echo [N] > /proc/sys/dev/scsi/logging_level
其中 N 指定要启用的字段以及详细级别。
- 禁用:
# sysctl -q -w dev.scsi.logging_level=0
或者
# echo 0 > /proc/sys/dev/scsi/logging_level
开机时修改
启用 (CentOS/RHEL 5)
使用“options scsi_mod scsi_logging_level=N”修改/etc/modprobe.conf。
重建 initrd 镜像文件以获取新的 /etc/modprobe.conf 文件。
查看我们的教程:如何在CentOS/RHEL中重建初始 Ramdisk 镜像
编辑 /boot/grub/grub.conf 中的引导行,删除“quiet”(如果存在),添加“debug”或者“loglevel=10”(它们都做同样的事情)。
还要添加 'log_buf_len=8M ' 以增加内核的日志 fifo 大小,因为另外的日志记录将创建更多的消息。重新启动并捕获消息输出。
# shutdown -r now
启用 (CentOS/RHEL 6)
编辑 /boot/grub/grub.conf 中的引导行并添加“scsi_logging_level=N”。
编辑引导行并删除“quiet”(如果存在),添加“debug”或者“loglevel=10”(它们都做同样的事情)。
还要添加 'log_buf_len=8M ' 以增加内核的日志 fifo 大小,因为另外的日志记录将创建更多的消息。重新启动并捕获消息输出:
# shutdown -r now
启用 (CentOS/RHEL 7 & 8)
编辑 /etc/default/grub 中的“GRUB_CMDLINE_LINUX”行并添加“scsi_logging_level=N”。
编辑“GRUB_CMDLINE_LINUX”行并删除“quiet”(如果存在),添加“debug”或者“loglevel=10”(它们都做同样的事情)。
还要添加 'log_buf_len=8M ' 以增加内核的日志 fifo 大小,因为另外的日志记录将创建更多的消息。对 /etc/default/grub 的更改需要重建 grub.cfg 文件。
# grub2-mkconfig -o /boot/grub2/grub.cfg
- 重新启动并捕获消息输出。
# shutdown -r now
上述标志的作用是提高 scsi 扩展日志记录级别,以包含有关错误和超时以及扫描处理期间以及任何 io 完成高级队列的信息。
要手动创建掩码值,请参阅 scsi_logging.h 并选择要启用的字段。
/* * This defines the scsi logging feature. It is a means by which the user * can select how much information they get about various goings on, and it * can be really useful for fault tracing. The logging word is divided into * 8 nibbles, each of which describes a loglevel. The division of things is * somewhat arbitrary, and the division of the word could be changed if it * were really needed for any reason. The numbers below are the only place * where these are specified. For a first go-around, 3 bits is more than * enough, since this gives 8 levels of logging (really 7, since 0 is always * off). */ #define SCSI_LOG_ERROR_SHIFT 0 #define SCSI_LOG_TIMEOUT_SHIFT 3 #define SCSI_LOG_SCAN_SHIFT 6 #define SCSI_LOG_MLQUEUE_SHIFT 9 #define SCSI_LOG_MLCOMPLETE_SHIFT 12 #define SCSI_LOG_LLQUEUE_SHIFT 15 #define SCSI_LOG_LLCOMPLETE_SHIFT 18 #define SCSI_LOG_HLQUEUE_SHIFT 21 #define SCSI_LOG_HLCOMPLETE_SHIFT 24 #define SCSI_LOG_IOCTL_SHIFT 27 #define SCSI_LOG_ERROR_BITS 3 /* additional logging associated with errors and recovery */ #define SCSI_LOG_TIMEOUT_BITS 3 /* additional logging associated with command timeouts */ #define SCSI_LOG_SCAN_BITS 3 /* additional logging associated with device scans and discovery */ #define SCSI_LOG_MLQUEUE_BITS 3 /* additional logging associated with mid-level command queueing */ #define SCSI_LOG_MLCOMPLETE_BITS 3 /* additional logging associated with mid-level command completions */ #define SCSI_LOG_LLQUEUE_BITS 3 /* additional logging associated with low-level command queueing */ #define SCSI_LOG_LLCOMPLETE_BITS 3 /* additional logging associated with low-level command completions */ #define SCSI_LOG_HLQUEUE_BITS 3 /* additional logging associated with hi-level command queueing */ #define SCSI_LOG_HLCOMPLETE_BITS 3 /* additional logging associated with hi-level command completions */ #define SCSI_LOG_IOCTL_BITS 3 /* additional logging associated with ioctl (typ: non-data commands) */ extern unsigned int scsi_logging_level;
例如,要打开与 ioctl 和错误相关的最大日志记录,将通过“sysctl -q -w dev.scsi.logging_level=0x38000007”设置八进制值 7000000007 (0x38000007)。
反之,如果使用'sysctl -q dev.scsi.logging_level'查询当前设置值,返回402653425(0x180000F1或者八进制3000000361),则当前字段掩码有ioctl=3,scan=3,timeout=6,和 error=1 值设置。
问题
如何打开 scsi 扩展调试消息?
scsi_logging_level 的字段/标志定义是什么?
解决方法
可以通过使用 echo 或者最好使用 sysctl 命令写入 /proc/sys/dev/scsi/logging_level 来启用其他 scsi 日志记录消息。
内核参数由十个压缩字段组成,每个字段的长度为 3 位。
每个字段的值可以是 0 到 7.
字段的值越高,与该字段类型关联的消息的日志记录就越详细。
注意:打开高级别的扩展日志记录和/或者多种类型的扩展日志记录会降低系统性能,尤其是在启动和关闭期间。
除非需要,请避免在启动期间打开 scsi 日志记录。