首次安装CentOS的辛酸史

几天前,打算开始学习下Linux,于是就买了一本鸟哥的Linux私房菜来学习,并准备按照书上的来安装,由于以前只是在虚拟机中安装,所以这次打算在实体机上实践一把。不得不说,在真机上安装和在虚拟机中差别还是比较大的,所以如果想印象更深刻一些,就准备一个练习机器安装把。ISO镜像,练习机器都已经准备好了,然而没有光盘,于是上网找答案了,果然ISO可以刻录到U盘,使用软件:UltraISO软碟通。完了之后就从U盘启动开始安装,在安装过程中也遇到了一些奇怪的问题,像是U盘引导问题,最开始设备老是找不到U盘,这里最后会进入到一个输入命令的地方:dracut:/#    在这里进入dev目录,并且ls列出所有盘符,一般是sda和sdb,其中有一个有很多一般是sda(1~7),另外一个sdb1,sdb4之类的较少的那个就是你的U盘了,记下它的名字,然后到选择install的界面,按下Tab键vmlinuz initrd=initrd.imginst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet 改为: vmlinuz initrd=initrd.imgrepo=hd:/dev/sdb4 quiet。然后就可以进入安装界面了。

在安装界面又遇到问题了,发现磁盘之剩下几M了,不应该阿!明明有500G的,就算里面有东西也不可能是这样阿,于是就回收磁盘(这里会格式化,注意备份!!!),就这样以默认分区的方式安装了(这里磁盘问题也只是估计是Linux不支持NTFS格式的硬盘,所以导致识别不了,但是不是很肯定,待以后研究清楚了之后再来重装)历尽千辛万苦终于安装好了,来到了久违的Linux系统。然而,发现不能无限上网,没有网卡驱动,由于找不到电脑对应的无线网卡型号,不知道如何下载linux版本的驱动,官网上都是windows版本的,然后又是一段各种搜索,网上各种方法,其中有一个方法比较直接:买一个USB版本的无线网卡,然后安装驱动就可以了,于是我就到京东上下了个单,但是明天才能到啊,向我这种强迫症如何能够忍受呢!抱着不抛弃不放弃的心态继续各种搜,baidu、google搜了个遍,终于得到了高人的指点:

其实可以查看自己网卡的芯片组型号的,然后根据芯片组去下载对应的驱动,使用命令:lspci  我的电脑信息如下:

00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4)
00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4)
00:1c.3 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 4 (rev c4)
00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation HM77 Express Chipset LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04)
01:00.0 3D controller: NVIDIA Corporation GK208M [GeForce GT 740M] (rev a1)
03:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5229 PCI Express Card Reader (rev 01)
04:00.0 Network controller: Broadcom Corporation BCM43142 802.11b/g/n (rev 01)
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 07)

注意最后两行就是网卡信息,第一个是无线网卡,第二个是有线网卡。找到了型号,就可以去找驱动了,这里给出我电脑的下载网址和对应驱动:

http://www.broadcom.com/support/802.11

hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz

下载下来之后,按照如下步骤:参照:

安装CentOS 7双系统(四)——解决博通无线网卡问题

CentOS 7本身可以支持很多常见的无线网卡,但如果你不幸使用了博通公司的BCM4311, BCM4312, BCM4313, BCM4321, BCM4322, BCM43224, BCM43225, BCM43227 and BCM43228这些型号的无线网卡,就需要进行一些配置了。

  • 步骤一:确定无线网卡型号,并安装依赖包
  • 步骤二:下载、解压博通无线网卡驱动压缩包
  • 步骤三:编译博通芯片驱动模块
  • 步骤四:将驱动载入内核
  • 步骤五:将驱动载入程序加入开机启动
[user@host ~]$ /sbin/lspci | grep Broadcom  
0b:00.0 Network controller: Broadcom Corporation BCM4312 802.11a/b/g (rev 01)

首先解压压缩文件:
tar xvfz /path/to/the/tarball/hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz  

然后使用make命令进行编译,但是这个时候必然会出错:
make: Entering directory `/usr/src/kernels/2.6.32-573.7.1.el6.x86_64'  
CFG80211 API is prefered for this kernel version  
Using CFG80211 API   
LD /usr/local/src/hybrid-wl/built-in.o   
CC [M] /usr/local/src/hybrid-wl/src/shared/linux_osl.o   
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_linux.o   
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_iw.o   
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.o  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:83: warning: ‘enum tx_power_setting’ declared inside parameter list  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:83: warning: its scope is only this definition or declaration,   
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_cfg80211_join_ibss’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:730: error: ‘struct cfg80211_ibss_params’ has no member named ‘channel’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: At top level:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1096: warning: ‘enum tx_power_setting’ declared inside parameter list  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1096: error: parameter 2 (‘type) has incomplete type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_cfg80211_set_tx_power’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1107: error: ‘TX_POWER_AUTOMATIC’ undeclared (first use in this   
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1107: error: (Each undeclared identifier is reported only once  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1107: error: for each function it appears in.)  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1109: error: ‘TX_POWER_LIMITED’ undeclared (first use in this function)  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1115: error: ‘TX_POWER_FIXED’ undeclared (first use in this function)  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: At top level:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1774: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1779: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1780: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1781: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1782: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1783: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1784: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1789: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_inform_single_bss’:/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1984: error: too few arguments to function   
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2023: warning: passing argument 1 of ‘cfg80211_put_bss’ from  include/net/cfg80211.h:3380: note: expected ‘struct wiphy *’ but argument is of type ‘struct cfg80211_bss *’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2023: error: too few arguments to function ‘cfg80211_put_bss’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_update_bss_info’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2276: error: ‘struct cfg80211_bss’ has no member named   
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2277: error: ‘struct cfg80211_bss’ has no member named   
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2283: warning: passing argument 1 of ‘cfg80211_put_bss’ from include/net/cfg80211.h:3380: note: expected ‘struct wiphy *’ but argument is of type ‘struct cfg80211_bss *’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2283: error: too few arguments to function ‘cfg80211_put_bss’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_bss_roaming_done’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: warning: passing argument 2 of ‘cfg80211_roamed’ from include/net/cfg80211.h:3726: note: expected ‘struct ieee80211_channel *’ but argument is of type ‘u8 *’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: warning: passing argument 4 of ‘cfg80211_roamed’ makes include/net/cfg80211.h:3726: note: expected ‘const u8 *’ but argument is of type ‘s32’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: warning: passing argument 5 of ‘cfg80211_roamed’ makes include/net/cfg80211.h:3726: note: expected ‘size_t’ but argument is of type ‘u8 *’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: warning: passing argument 6 of ‘cfg80211_roamed’ makes include/net/cfg80211.h:3726: note: expected ‘const u8 *’ but argument is of type ‘s32’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: error: too few arguments to function ‘cfg80211_roamed’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_update_wowl’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2791: warning: unused variable ‘wdev’  
make[1]: *** [/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.o] Error 1  
make: *** [_module_/usr/local/src/hybrid-wl] Error 2  
make: Leaving directory `/usr/src/kernels/2.6.32-573.7.1.el6.x86_64'

解决方法:改源码

[user@host hybrid-wl]$ sed -i 's/ >= KERNEL_VERSION(3,11, 0)/ >= KERNEL_VERSION(3,10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c

[user@host hybrid-wl]$ sed -i's/ >= KERNEL_VERSION(3,15, 0)/ >= KERNEL_VERSION(3,10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c

[user@host hybrid-wl]$ sed -i's/ < KERNEL_VERSION(3,18, 0)/ < KERNEL_VERSION(3,9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c

[user@host hybrid-wl]$ sed -i's/ >= KERNEL_VERSION(4,0, 0)/ >= KERNEL_VERSION(3,10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c


下载wl-kmod-fix-ioctl-handling.patch到/usr/local/src并运行

[user@host hybrid-wl]$ patch -p1 < ../wl-kmod-fix-ioctl-handling.patch  
patching file src/wl/sys/wl_cfg80211_hybrid.c  
Hunk #1 succeeded at 1467 (offset 17 lines).  
patching file src/wl/sys/wl_linux.c  
Hunk #1 succeeded at 1659 (offset 8 lines).

现在再次编译,成功,如果不成功请检查你前面的命令是否输入正确!如不正确请先  make clean以下。

之后可以去掉一些不必要的符号

[user@host hybrid-wl]$ strip --strip-debug wl.ko

首先,移除已经存在的一些不可用的无线网卡驱动,这样才能载入新的。

[root@host ~]# modprobe -r bcm43xx  
[root@host ~]# modprobe -r b43  
[root@host ~]# modprobe -r b43legacy  
[root@host ~]# modprobe -r ssb  
[root@host ~]# modprobe -r bcma  
[root@host ~]# modprobe -r brcmsmac  
[root@host ~]# modprobe -r ndiswrapper

把驱动模块放在kernel能找到的地方

[root@host hybrid-wl]# cp -vi /usr/local/src/hybrid-wl/wl.ko /lib/modules/`uname -r`/extra/

然后运行

[root@host ~]# depmod $(uname -r)  
[root@host hybrid-wl]# modprobe wl

编辑/etc/modprobe.d/blacklist.conf添加以下语句

blacklist bcm43xx  
blacklist b43  
blacklist b43legacy  
blacklist bcma  
blacklist brcmsmac  
blacklist ssb  
blacklist ndiswrapper

编辑/etc/sysconfig/modules/kmod-wl.modules写入以下内容

#!/bin/bash  
for M in lib80211 cfg80211 wl; do   
  modprobe $M &>/dev/null  
done

这样,驱动就会开机启动啦!


重启之后就可以连接wifi了!




你可能感兴趣的:(首次安装CentOS的辛酸史)