首页 > 技术文章 > 内核编译选配(VMware篇)

sysk 2015-11-23 10:51 原文

出现这个错误的原因是相应的驱动程序没有编译进内核,所以在内核启动时,不认识分区。

 

一、磁盘驱动没编译进内核

VMware5.5.3 的磁盘有两种,一种是IDE的,一种是SCSI的;VMware 你在新建 linux 虚拟机时默认的是SCSI 。

在5.5.3的版本中使用的是SCSI类型设备中的LSI Logic设备(据网上资料,4.0以前的版本用的是BusLogic设备)。

所以我们在编译内核的时候应该把LSI Logic设备驱动程序编译进去。

 

现在分别介绍模块选择路径:

  这个是SCSI磁盘设备模块,必须选择。

  Linux Kernel Configuration
    -> Device Drivers
       -> SCSI device support
          - > SCSI disk support

  这个是BusLogic设备驱动模块。使用这个设备的的朋友需要选取。

  Linux Kernel Configuration
    -> Device Drivers
       -> SCSI device support
        -> SCSI low-level drivers
          -> BusLogic SCSI support

  这个是LSI Logic设备驱动模块。使用这个设备的的朋友需要选取。

  Linux Kernel Configuration
    -> Device Drivers
      -> Fusion MPT device support
          -> Fusion MPT (base + ScsiHost) drivers

 

2、文件系统驱动没编译进内核

linux下有ext2 和 ext3 两种文件系统,看你当前的文件系统是哪种(mount命令可以查看),并把相应的驱动编译进内核。

 

3、分区加载错误

编译完成后,一般来说就可以成功引导了。如果还提示这个错误的话,就把配置文件中的 root=LABEL=/ 改成你的 "/" 分区位置(比如: root=/dev/sda3 见下面示例)这样就可以了。新的版本是可以用 root=LABEL=/ 来自动查找引导分区的,但这个也要在内核中打开。

  在下面的位置

     filesystem   -->   
            Partition Types--->     
                  Advanced partition selection--->

                                                 PC BIOS(MSDOS partition tables)support--->

                                                         BSD disklabel(FreeBSD partition tables) support

示例:磁盘分区:

#mount

/dev/sda1    on  /boot type ext3

/dev/sda3    on / type ext3

 

 

grub.conf:

 root (hd0,6)                                            <——这里的启动(/boot)分区,也就是内核(vmlinuz)所在的位置
 kernel /vmlinuz-2.4.20 root=/dev/sda3 <——这里是根(/)分区的位置

 因为内核初始化完成后,就要启动init程序,但要启动init就要知道init的位置(默认为 /sbin/init)如果你 root=/dev/sda3 没的指对,内核当然就无法找到 init 了。

 

关于LABEL的说明:

/dev/hdc2这种属于绝对硬盘定位,hda-d分别代表两个IDE通道的4个接口,hdc2就是第二个IDE接口主盘的第二分区,这是linux最早采用的标示硬盘分区的方法,优点是简单直观。 
缺点就是不灵活,比如如果我把硬盘接到另外的ide口或者调换主从盘,则分区表示方法就会变掉,grub和fstab还按照老的标示挂盘的话就会造成无法引导。 

所以Redhat从9(好像8也有,记不清了)开始使用了新的硬盘分区表示方式-----分区Label。简单说就是给每个分区一个类似于windows磁盘卷标的特殊Label信息,grub和fstab通过查找这个Label来定位磁盘分区。即使因为某些原因hdc变成hdd或者其他hdX,但分区的label没变的话,grub还是可以通过label找到这个分区。Redhat的分区工具一般会把分区的挂接点作为分区的label,例如根分区的label就是“/”usr分区的label就是“/usr”,依次类推。 
采用了label的标示方式后就不用担心设备名字换掉的问题了,同时grub.conf和fstab都要采用label的方式来定位磁盘分区,大家可以对照自己机器的grub.conf和fstab来看就知道了。 
察看和修改分区label的工具为e2label。

 

另一个问题是关于网卡的:

  这个设备和内核版本没有关系,下面是系统信息参考:

02:00.0 Ethernet controller: Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev 10)
  
  Linux Kernel Configuration
  -> Device Drivers
    -> Networking support
       -> Ethernet (10 or 100Mbit)

             -> [*] EISA, VLB, PCI and on board controllers 
              ->   <*> AMD PCnet32 PCI support

              ->   <*> AMD 8111 (new PCI lance) support 

 

VMWare 所支持的网卡类型
它默认是虚拟的AMD PCNet AM79C970A网卡,但也可以改变网卡配置,虚拟出Intel(R) PRO/1000和VMware PCI Ethernet Adapter网卡。

如果在.vmx文件中用如下语句指定:

ethernet0.virtualDev = "e1000"

其值为e1000指定网卡类型为Intel(R) PRO/1000

其值为vlance指定网卡类型为AMD PCNet AM79C970A(默认为此项)

其值为vmxnet指定网卡类型为VMware PCI Ethernet Adapter

 

总结:

  1. 没有相应的驱动
    1. 磁盘驱动(IDE,SCSI,SATA……)
    2. 文件系统驱动(EXT2、EXT3……)
  2. 分区加载错误
    这里现在可以用LABEL来自动查找,但前提是要LABEL功能编译进内核

 

 

 


insmod used greatest stack depth: 5904 bytes left

Trying to resume from LABEL=SWAP-sda2

Unable to access resume device (LABEL=SWAP-sda2)

Creating root device.

Mounting root filesystem.

mount: could not find filesystem '/dev/root'

Setting up other filesystems.

Setting up new root fs

setuproot: moving /dev failed: No such file or directory

no fstab.sys, mounting internal defaults

setuproot: error mounting /proc: No such file or directory

setuproot: error mounting /sys: No such file or directory

Switching to new root and running init.

unmounting old /dev

unmounting old /proc

unmounting old /sys

switchroot: mount failed: No such file or directory

Kernel panic - not syncing: Attempted to kill init!

Pid: 1, comm: init Not tainted 2.6.32.8 #2

 

解决方法:

把下面选上,

general setup

              -- > enable deprecated sysfs features which may confuse old userspace tools

 

这个选项是有关内存中的sysfs文件系统的两种不同的机制,文中提到最新的linux发行版几乎已经都用了最新的那个机制!而且文中强调了这个选项的作用非常,新旧系统对于两种sysfs机制并不能完美的兼容——等于就是说新旧对于这个选项非常的不兼容。

推荐阅读