debian5 内核升级与模块加载

         最近有台服务器需要安装ssd卡,因为安装驱动需要内核2.6.32,而debian5机器默认还是2.6.18,所有首先需要升级内核.

1.安装2.6.32内核需要debian6的源

root@10.1.1.200:~# uname -a
Linux 10.1.1.200 2.6.18-6-amd64
root@10.1.1.200:~# vim /etc/apt/sources.list
deb http://mirrors.163.com/debian squeeze main non-free contrib   
deb http://mirrors.163.com/debian-security squeeze/updates main contrib non-free
2.安装2.6.32头文件和镜像
root@10.1.1.200:~# apt-get install linux-headers-2.6.32-5-amd64 linux-image-2.6.32-5-amd64
升完内核默认会将/boot/grub/menu.lst,/etc/fstab文件里磁盘位置更换为UUID,记得手动加入 console=tty0 console=ttyS1,115200 已供ipmi查看重启过程界面状态.
root@192.168.2.197:grub# cat menu.lst | egrep -v '^#|^$' 
default		0
timeout		5
color cyan/blue white/blue
title		Debian GNU/Linux, kernel 2.6.32-5-amd64
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.32-5-amd64 root=UUID=4f343e7c-3c29-4ce6-9bf6-0ee46c07ee28 ro console=tty0 console=ttyS1,115200
initrd		/boot/initrd.img-2.6.32-5-amd64
title		Debian GNU/Linux, kernel 2.6.32-5-amd64 (single-user mode)
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.32-5-amd64 root=UUID=4f343e7c-3c29-4ce6-9bf6-0ee46c07ee28 ro single console=tty0 console=ttyS1,115200
initrd		/boot/initrd.img-2.6.32-5-amd64
title		Debian GNU/Linux, kernel 2.6.26-2-amd64
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.26-2-amd64 root=UUID=4f343e7c-3c29-4ce6-9bf6-0ee46c07ee28 ro console=tty0 console=ttyS1,115200
initrd		/boot/initrd.img-2.6.26-2-amd64
title		Debian GNU/Linux, kernel 2.6.26-2-amd64 (single-user mode)
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.26-2-amd64 root=UUID=4f343e7c-3c29-4ce6-9bf6-0ee46c07ee28 ro single console=tty0 console=ttyS1,115200
initrd		/boot/initrd.img-2.6.26-2-amd64
title		Debian GNU/Linux, kernel 2.6.18-6-amd64
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.18-6-amd64 root=UUID=4f343e7c-3c29-4ce6-9bf6-0ee46c07ee28 ro console=tty0 console=ttyS1,115200
initrd		/boot/initrd.img-2.6.18-6-amd64
title		Debian GNU/Linux, kernel 2.6.18-6-amd64 (single-user mode)
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.18-6-amd64 root=UUID=4f343e7c-3c29-4ce6-9bf6-0ee46c07ee28 ro single console=tty0 console=ttyS1,115200
initrd		/boot/initrd.img-2.6.18-6-amd64
 

root@10.1.1.200:grub# cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# /dev/sda1       /               ext3    noatime,commit=15,errors=remount-ro 0       1
UUID=4f343e7c-3c29-4ce6-9bf6-0ee46c07ee28       /               ext3    noatime,commit=15,errors=remount-ro 0       1
# /dev/sda5       none            swap    sw              0       0
UUID=bd42e7e0-1f64-4d31-9e16-842a920b7162       none            swap    sw              0       0
# /dev/sda6       /opt            ext3    noatime,commit=15,errors=remount-ro	0       0
UUID=670e1dbf-8848-4a25-b200-4483f95adcc1       /opt            ext3    noatime,commit=15,errors=remount-ro	0       0
# /dev/sda7       /db_bak          ext3    noatime,commit=15,errors=remount-ro     0       0
UUID=7f4f1207-d74e-4048-9e76-c4cd1081513b       /db_bak          ext3    noatime,commit=15,errors=remount-ro     0       0
# /dev/sda8       /export         ext3    noatime,commit=15,errors=remount-ro     0       0
UUID=3500e14f-e89b-42c9-a4f2-0da4db8843ff       /export         ext3    noatime,commit=15,errors=remount-ro     0       0

这里一定要核对系统分区的UUID值和以上文件里是否一致,可用blkid查询

root@10.1.1.200:grub# blkid 
/dev/sda1: UUID="4f343e7c-3c29-4ce6-9bf6-0ee46c07ee28" TYPE="ext3" 
/dev/sda5: TYPE="swap" UUID="bd42e7e0-1f64-4d31-9e16-842a920b7162" 
/dev/sda6: UUID="670e1dbf-8848-4a25-b200-4483f95adcc1" TYPE="ext3" SEC_TYPE="ext2" 
/dev/sda7: UUID="7f4f1207-d74e-4048-9e76-c4cd1081513b" TYPE="ext3" SEC_TYPE="ext2" 
/dev/sda8: UUID="3500e14f-e89b-42c9-a4f2-0da4db8843ff" TYPE="ext3" SEC_TYPE="ext2" 
root@10.1.1.200:grub# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              28G  1.9G   25G   8% /
tmpfs                  16G     0   16G   0% /lib/init/rw
udev                   10M   76K   10M   1% /dev
tmpfs                  16G     0   16G   0% /dev/shm
/dev/sda6             917G  1.8G  869G   1% /opt
/dev/sda7             459G  199M  435G   1% /db_bak
/dev/sda8             238G  188M  225G   1% /export

重启机器,内核升级完成

root@10.1.1.2:grub# uname -a
Linux 10.1.1.2 2.6.32-5-amd64


模块加载

这里先讲解下内核是如何载入模块的.

1.查看现在内核加载的模块

lsmod #可以查看现在内核加载的模块,是通过读取/proc/modules/中的内容来查看的

root@10.1.1.200:~# lsmod 
Module                  Size  Used by
hio                    29631  0 
ipmi_si                30960  1 
ipmi_devintf            6587  0 
ipmi_poweroff           6705  0 
ipmi_watchdog          12737  0 
ipmi_msghandler        26634  4 ipmi_si,ipmi_devintf,ipmi_poweroff,ipmi_watchdog
loop                   11799  0 
.........
crc_t10dif              1276  1 sd_mod
raid1                  18431  0 
md_mod                 73872  1 raid1

2.内核是如何载入模块的

当内核所需要的扩展功能不存在时,内核模块管理守护进程kmod执行modprobe去加载内核模块,两种类型的参数可以传给modprobe

a.模块的名字,如md

b.通用识别符,如block-major-9-*

   当传给modprobe的参数是通用识别符时,modprobe首先在modprobe -c 或/etc/modprobe.d/aliases中查找该字符串,如果它发现有一行像alias block-major-9-*  md说明要加载的是md模块,然后遍历/lib/modules/2.6.32-5-amd64/modules.dep 来判断是否有其他内核模块需要在加载此模块前加载.该文件由depmod  -a来创建, 保存着内核模块的依赖关系.

root@10.1.1.200:~# modprobe -c | grep "md_mod"
alias block-major-9-* md_mod
alias md md_mod
root@10.1.1.200:~# cat /etc/modprobe.d/aliases | egrep -v '^#|^$' | grep 'md'
alias block-major-9-*  md

  最终modprobe调用inmod来先加载需要依赖的模块,然后加载此模块inmod将指向/lib/modules/2.6.32-5-amd64/kernel/....为模块的专门存放的目录.

   载入一个模块有2种方法:

1)#insmod 后面必须要写明全部的路径

#insmod /lib/modules/2.6.32-5-amd64/kernel/drivers/md/md-mod.ko
2) modprobe会调用insmod来加载模块
#modprobe md

  modeprobe和insmod都可以安装模块,但是,modeprobe会依靠分析模块之间的依赖关系,然后又先后顺序的加载必需的模块,然后再加载当前的模块,而insmod就只会加载你所制定的这个模块,一旦它有一些依赖关系,容易出错的.

   卸载模块:

#rmmod md 
或#modprode -r md


modules常用参数

-c 查看modules的配置文件

root@10.1.1.200:~# modprobe -c | grep md_mod
alias block-major-9-* md_mod
alias md md_mod
-l 列出内核中所有已经或者未挂载的所有模块
root@10.1.1.200:~# modprobe -l | grep md-mod
/lib/modules/2.6.32-5-amd64/kernel/drivers/md/md-mod.ko
-r移除模块
root@10.1.1.200:~# modprobe -r md

     

      上面了解了模块加载的过程,由于ssd的驱动已经编译好,这里直接dpgk安装即可

root@10.1.1.200:~# dpkg -i hio-1.0-0.7.amd64.deb 
Selecting previously deselected package hio.
(Reading database ... 46823 files and directories currently installed.)
Unpacking hio (from hio-1.0-0.7.amd64.deb) ...
Setting up hio (1.0-0.7) ...
root@10.1.1.200:~# modprobe -l | grep hio
/lib/modules/2.6.32-5-amd64/kernel/drivers/hio/hio.ko
root@10.1.1.200:~# lsmod | grep hio
hio                    29631  0 
root@10.1.1.200:~# modprobe -c | grep hio
alias pci:v000010EEd00000007sv*sd*bc*sc*i* hio
再次查看ssd卡结果已识别/dev/hioa
root@10.1.1.200:~# fdisk -l

Disk /dev/sda: 730.8 GB, 730815528960 bytes
255 heads, 63 sectors/track, 88849 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000e801e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        3706    29768413+  83  Linux
/dev/sda2            3707       88849   683911147+   f  W95 Ext'd (LBA)
/dev/sda5            3707        4694     7936078+  82  Linux swap / Solaris
/dev/sda6            4695       41168   292977373+  83  Linux
/dev/sda7           41169       65484   195318238+  83  Linux
/dev/sda8           65485       88849   187679331   83  Linux

Disk /dev/hioa: 642.8 GB, 642835808256 bytes
4 heads, 16 sectors/track, 19617792 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0x00000000

Disk /dev/hioa doesn't contain a valid partition table


转载于:https://my.oschina.net/davehe/blog/104933

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值