linux操作系统中,加载和删除内核模块的命令是什么?
modprobe命令 Linux命令:modprobe 。 功能说明:自动处理可载入模块。 语 法:modprobe 。 补充说明:modprobe可载入指定的个别模块,或是载入一组相依的模块。modprobe会根据depmod所产生的相依关系,决定要载入哪些模块。若在载入过程中发生错误,在modprobe会卸载整组的模块。 内容
1、modprobe 命令是根据depmod -a的输出/lib/modules/version/modules.dep来加载全部的所需要模块。
2、删除模块的命令是:modprobe -r filename。
3、系统启动后,正常工作的模块都在/proc/modules文件中列出。使用lsmod命令也可显示相同内容。
4、在内核中有一个“Automatic kernel module loading”功能被编译到了内核中。当用户尝试打开某类型的文件时,内核会根据需要尝试加载相应的模块。/etc/modules.conf或 /etc/modprobe.conf文件是一个自动处理内核模块的控制文件。 modprobe命令主要用于在Linux 2.6内核中加载和删除Linux内核模块。通过此命令用户可以轻松地加载和删除Linux内核模块,同时使用此命令加载Linux内核模块时,Linux内核会自动解决内核模块之间的依赖关系,将相互依赖的模块自动加载,如下所示: 1) 加载RAID1阵列级别模块: # modprobe raid1 2) 显示已加载的RAID1阵列级别模块: # lsmod |grep raid1 raid1 25153 0 3) 删除RAID1阵列级别模块: # modprobe -r raid1 4) 显示RAID1阵列级别模块: # lsmod |grep raid1 modprobe命令在加载模块时会自动解决依赖的模块。当加载的模块需依赖另一个模块时,系统会自动将此模块加载。而当用户使用insmod命令加载模块时,则不会自动解决相对应的依赖模块。 modprobe命令中的”-r”参数表示删除指定模块,”-c”参数表示显示/etc/modprobe.conf配置文件的参数,”-C”参数表示指定内核配置文件,”-f”表示覆盖,”-l”表示显示模块的绝对路径。 # modprobe -l|grep raid /lib/modules/2.6.18-8.el5/kernel/drivers/md/raid0.ko /lib/modules/2.6.18-8.el5/kernel/drivers/md/raid456.ko /lib/modules/2.6.18-8.el5/kernel/drivers/md/raid1.ko /lib/modules/2.6.18-8.el5/kernel/drivers/md/raid10.ko /lib/modules/2.6.18-8.el5/kernel/drivers/scsi/megaraid.ko /lib/modules/2.6.18-8.el5/kernel/drivers/scsi/aacraid/aacraid.ko /lib/modules/2.6.18-8.el5/kernel/drivers/scsi/megaraid/megaraid_mbox.ko /lib/modules/2.6.18-8.el5/kernel/drivers/scsi/megaraid/megaraid_mm.ko /lib/modules/2.6.18-8.el5/kernel/drivers/scsi/megaraid/megaraid_sas.ko /lib/modules/2.6.18-8.el5/kernel/drivers/scsi/raid_class.ko 以上命令表示显示系统中所有的编译模块,并过滤包含有raid字符串的模块。
linux dmesg命令详解?
linux dmesg命令参数及用法详解(linux显示开机信息命令)
功能说明:显示开机信息。
语 法:dmesg
补充说明:kernel会将开机信息存储在ring buffer中。您若是开机时来不及查看信息,可利用dmesg来查看。开机信息亦保存在/var/log目录中,名称为dmesg的文件里。
参 数:
-c 显示信息后,清除ring buffer中的内容。
-s<缓冲区大小> 预设置为8196,刚好等于ring buffer的大小。
-n 设置记录信息的层级。扩展阅读一:dmesg命令主要用途
主要应用:
dmesg用来显示内核环缓冲区(kernel-ring buffer)内容,内核将各种消息存放在这里。在系统引导时,内核将与硬件和模块初始化相关的信息填到这个缓冲区中。内核环缓冲区中的消息对于诊断系统问题 通常非常有用。在运行dmesg时,它显示大量信息。通常通过less或grep使用管道查看dmesg的输出,这样可以更容易找到待查信息。例如,如果发现硬盘性能低下,可以使用dmesg来检查它们是否运行在DMA模式:
$dmesg | grep DMA
…
ide0: BM-DMA at 0xf000-0xf007, BIOS settings: hda:DMA, hdb:DMA
ide1: BM-DMA at 0xf008-0xf00f, BIOS settings: hdc:DMA, hdd:DMA
…上面几行可以说明每个IDE设备正在什么模式下运行。如果以太网连接出现问题,那么可以在dmesg日志中搜索eth:
$dmesg | grep eth
forcedeth.c: Reverse Engineered nForce
ethernet driver. Version 0.49.
eth0: forcedeth.c: subsystem: 0147b:1c00
bound to 0000:00:04.0
eth0: no IPv6 routers present如果一切正常,那么dmesg显示每个网卡的硬件配置信息。如果某项系统服务未能得到正确的配置,dmesg日志很快就填满错误消息,这是诊断故障的良好起点。
还可以用来探测系统内核模块的加载情况,比如要检测ACPI的加载情况,使用dmesg | grep acpi
dmesg |egrep -i ”(apm|acpi)”
Kernel command line: vga=274 quiet console=ttyS3,9600acpi=no-idleoot=/dev/hda3
ACPI: Core Subsystem version
ACPI: Subsystem enabled
ACPI: System firmware supports: C2
ACPI: plvl2lat=99 plvl3lat=1001
ACPI: C2 enter=1417 C2 exit=354
ACPI: C3 enter=-1 C3 exit=-1
ACPI: Not using ACPI idle
ACPI: System firmware supports: S0 S1 S4 S5
扩展阅读二:dmesg命令使用示例
使用示例
示例一 将开机信息发邮件
man dmesg 写道
The program helps users to print out their bootup messages. Instead of copying the messages by hand, the user need only:
dmesg > boot.messages
and mail the boot.messages file to whoever can debug their problem.
# dmesg >boot.messages
# ls -l boot.messages
-rw-r–r– 1 root root 15838 12-09 12 begin_of_the_skype_highlighting
15838 12-09 12 免费 end_of_the_skype_highlighting:55 boot.messages# mail -s “Boot Log of Linux Server” public@web3q.net <boot.messages
#示例二 浏览dmesg输出的信息
# uname -a
Linux new55 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux# dmesg | less
Linux version 2.6.18-194.el5 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010
BIOS-provided physical RAM map:
BIOS-e820: 0000000000010000 – 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 – 00000000000a0000 (reserved)
BIOS-e820: 00000000000e0000 – 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 – 000000001f7d0000 (usable)
BIOS-e820: 000000001f7d0000 – 000000001f7efc00 (reserved)
BIOS-e820: 000000001f7efc00 – 000000001f7fb000 (ACPI NVS)
BIOS-e820: 000000001f7fb000 – 000000001f800000 (reserved)
BIOS-e820: 00000000e0000000 – 00000000f0000000 (reserved)
BIOS-e820: 00000000fec00000 – 00000000fec02000 (reserved)
BIOS-e820: 00000000fed20000 – 00000000fed9b000 (reserved)
BIOS-e820: 00000000feda0000 – 00000000fedc0000 (reserved)
BIOS-e820: 00000000ffb00000 – 00000000ffc00000 (reserved)
BIOS-e820: 00000000fff00000 – 0000000100000000 (reserved)
0MB HIGHMEM available.
503MB LOWMEM available.
Memory for crash kernel (0x0 to 0x0) notwithin permissible range
disabling kdump
Using x86 segment limits to approximate NX protection
On node 0 totalpages: 128976
DMA zone: 4096 pages, LIFO batch:0
Normal zone: 124880 pages, LIFO batch:31
DMI 2.3 present.
Using APIC driver default
ACPI: RSDP (v000 HP ) @ 0x000fe270
ACPI: RSDT (v001 HP 30C4 0x31100620 HP 0x00000001) @ 0x1f7efc84
ACPI: FADT (v002 HP 30C4 0x00000002 HP 0x00000001) @ 0x1f7efc00
ACPI: MADT (v001 HP 30C4 0x00000001 HP 0x00000001) @ 0x1f7efcb8
ACPI: MCFG (v001 HP 30C4 0x00000001 HP 0x00000001) @ 0x1f7efd14
ACPI: SSDT (v001 HP HPQPpc 0x00001001 MSFT 0x0100000e) @ 0x1f7f6698
ACPI: DSDT (v001 HP DAU00 0x00010000 MSFT 0x0100000e) @ 0x00000000
ACPI: PM-Timer IO Port: 0x1008
ACPI: Local APIC address 0xfec01000
ACPI: LAPIC (acpi_id lapic_id enabled)
Processor #0 6:13 APIC version 20
ACPI: LAPIC_NMI (acpi_id high edge lint)
ACPI: IOAPIC (id address gsi_base)
IOAPIC: apic_id 1, version 32, address 0xfec00000, GSI 0-23
:
示例三 查看dmesg尾部的信息
# dmesg | tail
Bluetooth: L2CAP ver 2.8
Bluetooth: L2CAP socket layer initialized
Bluetooth: RFCOMM socket layer initialized
Bluetooth: RFCOMM TTY layer initialized
Bluetooth: RFCOMM ver 1.8
Bluetooth: HIDP (Human Interface Emulation) ver 1.1
eth0: no IPv6 routers present
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory
NFSD: starting 90-second grace period
#
示例四 安装SS7卡驱动时的内核日志
# cd SS7HD_DRIVER/
# ls
bbdddlnx_iss.h bbd_hbi.h bbd_ioc.c bbd_isr.c bbd_pci.c BSD_license.txt GPL_V2-only_license.txt install_ss7hd.sh Makefile26
bbd_def.h bbd_hs.c bbd_ioc.h bbd_lnx.c bbd_pro.h build_ss7hd.sh i21555.h Makefile24
# ./build_ss7hd.sh
make: Entering directory `/usr/src/kernels/2.6.9-22.EL-i686′
CC /root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_hs.o
CC /root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_ioc.o
CC /root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_isr.o
CC /root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_pci.o
CC /root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_lnx.o
LD /root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.o
Building modules, stage 2.
MODPOST
CC /root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.mod.o
LD /root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.ko
make: Leaving directory `/usr/src/kernels/2.6.9-22.EL-i686’http://www.linuxso.com/command/dmesg.html# ./install_ss7hd.sh
# lsmod | grep ss7
ss7hddvr26 25808 0
# dmesg | tail
ACPI: PCI interrupt 0000:02:0d.0 -> GSI 9 (level, low) -> IRQ 9
BBD 64bit
SS7HD – suspend
Dialogic SS7HD Device Driver V100.00 (Source V1.21)
Copyright (C) Dialogic Corporation 2003-2010. All Rights Reserved
Using major device number 251.
ACPI: PCI interrupt 0000:02:0d.0 -> GSI 9 (level, low) -> IRQ 9
BBD 64bit
# ./install_ss7hd.sh remove
# lsmod | grep ss7
# dmesg | tail
BBD 64bit
SS7HD – suspend
Dialogic SS7HD Device Driver V100.00 (Source V1.21)
Copyright (C) Dialogic Corporation 2003-2010. All Rights Reserved
Using major device number 251.
ACPI: PCI interrupt 0000:02:0d.0 -> GSI 9 (level, low) -> IRQ 9
BBD 64bit
SS7HD – suspend
#
示例五 打印并清除内核环形缓冲区
# dmesg -c
Linux version 2.6.18-194.el5 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010
BIOS-provided physical RAM map:
BIOS-e820: 0000000000010000 – 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 – 00000000000a0000 (reserved)
BIOS-e820: 00000000000e0000 – 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 – 000000001f7d0000 (usable)
BIOS-e820: 000000001f7d0000 – 000000001f7efc00 (reserved)
BIOS-e820: 000000001f7efc00 – 000000001f7fb000 (ACPI NVS)
BIOS-e820: 000000001f7fb000 – 000000001f800000 (reserved)
BIOS-e820: 00000000e0000000 – 00000000f0000000 (reserved)
BIOS-e820: 00000000fec00000 – 00000000fec02000 (reserved)
BIOS-e820: 00000000fed20000 – 00000000fed9b000 (reserved)
BIOS-e820: 00000000feda0000 – 00000000fedc0000 (reserved)
BIOS-e820: 00000000ffb00000 – 00000000ffc00000 (reserved)
BIOS-e820: 00000000fff00000 – 0000000100000000 (reserved)
0MB HIGHMEM available.
503MB LOWMEM available.
Memory for crash kernel (0x0 to 0x0) notwithin permissible range
disabling kdump
Using x86 segment limits to approximate NX protection
On node 0 totalpages: 128976
DMA zone: 4096 pages, LIFO batch:0
Normal zone: 124880 pages, LIFO batch:31
DMI 2.3 present.省略输出
Bluetooth: HIDP (Human Interface Emulation) ver 1.1
eth0: no IPv6 routers present
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory
NFSD: starting 90-second grace period
# dmesg# less /var/log/dmesg
Linux version 2.6.18-194.el5 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010
BIOS-provided physical RAM map:
BIOS-e820: 0000000000010000 – 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 – 00000000000a0000 (reserved)
BIOS-e820: 00000000000e0000 – 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 – 000000001f7d0000 (usable)
BIOS-e820: 000000001f7d0000 – 000000001f7efc00 (reserved)
BIOS-e820: 000000001f7efc00 – 000000001f7fb000 (ACPI NVS)
BIOS-e820: 000000001f7fb000 – 000000001f800000 (reserved)
BIOS-e820: 00000000e0000000 – 00000000f0000000 (reserved)
BIOS-e820: 00000000fec00000 – 00000000fec02000 (reserved)
BIOS-e820: 00000000fed20000 – 00000000fed9b000 (reserved)
BIOS-e820: 00000000feda0000 – 00000000fedc0000 (reserved)
BIOS-e820: 00000000ffb00000 – 00000000ffc00000 (reserved)
BIOS-e820: 00000000fff00000 – 0000000100000000 (reserved)
0MB HIGHMEM available.
503MB LOWMEM available.
Memory for crash kernel (0x0 to 0x0) notwithin permissible range
disabling kdump
Using x86 segment limits to approximate NX protection
On node 0 totalpages: 128976
DMA zone: 4096 pages, LIFO batch:0
Normal zone: 124880 pages, LIFO batch:31
DMI 2.3 present.
Using APIC driver default
ACPI: RSDP (v000 HP ) @ 0x000fe270
ACPI: RSDT (v001 HP 30C4 0x31100620 HP 0x00000001) @ 0x1f7efc84
ACPI: FADT (v002 HP 30C4 0x00000002 HP 0x00000001) @ 0x1f7efc00
ACPI: MADT (v001 HP 30C4 0x00000001 HP 0x00000001) @ 0x1f7efcb8
ACPI: MCFG (v001 HP 30C4 0x00000001 HP 0x00000001) @ 0x1f7efd14
ACPI: SSDT (v001 HP HPQPpc 0x00001001 MSFT 0x0100000e) @ 0x1f7f6698
ACPI: DSDT (v001 HP DAU00 0x00010000 MSFT 0x0100000e) @ 0x00000000
ACPI: PM-Timer IO Port: 0x1008
ACPI: Local APIC address 0xfec01000
ACPI: LAPIC (acpi_id lapic_id enabled)
Processor #0 6:13 APIC version 20
ACPI: LAPIC_NMI (acpi_id high edge lint)
ACPI: IOAPIC (id address gsi_base)
IOAPIC: apic_id 1, version 32, address 0xfec00000, GSI 0-23
#
linux系统下如何关闭USB接口?
有几个办法1)直接把驱动去掉 1.进入内核目录 cd /lib/modules//kernel/drivers/usb/storage 2.删除或更名驱动文件 usb-storage.ko(建议换个文件名,以后还能找回来)
3.重启系统后就不能使用了2)写个检测脚本,每秒钟运行一次 用mount命令的输出,检测是否有U盘插入 如果有U盘插入,用eject命令,强制把U版弹出去
LINUX的XEN和KVM到底区别在什么地方?
Xen是Linux下的一个虚拟化解决方案,但由于被Citrix收购后,变成了和红帽企业版一样了,卖服务收取费用,Redhat从rhel6.0开始已经从内核中把XEN踢出去了,全心投入开发免费的KVM,虽然市场上老用户还在用Xen,但相信kvm会逐步占领大面积的市场,必竟有redhat做为强大支持源。
Xen的实现方法是运行支持Xen功能的kernel,这个kernel是工作在Xen的控制之下,叫做Domain0,使用这个kernel启动机器后,你可以在这个机器上使用qemu软件,虚拟出多个系统。Xen的缺点是如果你需要更新Xen的版本,你需要重新编译整个内核,而且,稍有设置不慎,系统就无法启动。
相比较,KVM就简化的多了。它不需要重新编译内核,也不需要对当前kernel做任何修改,它只是几个可以动态加载的.ko模块。它结构更加精简、代码量更小。所以,出错的可能性更小。并且在某些方面,性能比Xen更胜一筹。
如何在Linux下安装IPMITOOL?
下载ipmitool:
http://ipmitool.sourceforge.net/
确定gcc工具已经安装好
在Linux系统上加载启用IPMI驱动:
insmod /lib/modules/2.6.32-220.el6.x86_64/kernel/drivers/char/ipmi/ipmi_msghandler.ko
insmod /lib/modules/2.6.32-220.el6.x86_64/kernel/drivers/char/ipmi/ipmi_devintf.ko
insmod /lib/modules/2.6.32-220.el6.x86_64/kernel/drivers/char/ipmi/ipmi_si.ko
检查你的/dev目录下出现了ipmi0这个设备:
ls -l /dev/ipmi*
解压缩ipmitool-1.8.11.tar.gz
tar zxvf ipmitool-1.8.11.tar.gz
cd ipmitool-1.8.11
开始安装ipmitool:
./configure
make
make install
ipmitool命令将被安装到/usr/local/bin/ipmitool
现在你就可以用了