centos启动过程可能报错

无法启动

Warning: /dev/centos/root does not exist
Warning: /dev/centos/swap does not exist
Warning: /dev/mapper/centos-root does not exist

解决方法:救援内核启动

重新引导虚拟机,在boot页面,选择CentOS Linx(0-rescue-xxx) 7 (Core)启动。

  1. 列出镜像:

    ls -ltrh /boot/initramfs-*
    
  2. Rebuild the kernel image for that specific kernel

    dracut -f  /boot/initramfs-3.10.0-1062.el7.x86_64.img 3.10.0-1062.el7.x86_64
    
  3. Generate a GRUB configuration file

    grub2-mkconfig
    
  4. Reboot

  5. Done

找不到内核

[root@bogon unittest-KM_B0_UNITTEST_MASTER]# ./env_setup.sh
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c  *.mod.c.tmp_versions
rm -f Module.symvers modules.order
rm -rf .cache.mk .tmp_versions unittestk.o.ur-safe
make -C /lib/modules/3.10.0-1160.95.1.el7.x86_64/build M=/home/hcsw/unittest-KM_B0_UNITTEST_MASTER/hal/core/driver modules
make: *** /lib/modules/3.10.0-1160.95.1.el7.x86_64/build: No such file or directory.  Stop.
make: *** [all] Error 2
insmod: ERROR: could not load module ./unittestk-mod.ko: No such file or directory
rm -f *.so *~ *.pyc *.o
g++ -g -O3 -Wall -fPIC -m64 -DMAJOR_VERSION=1 -DMINOR_VERSION=0  -DPYTHON_3=1 -I/usr/local/include `python3-config --cflags | sed -e 's/-Wstrict-prototypes//g'` -I../driver "-I../include" -c unittest_C_interface.cpp -o unittest_C_interface.o
g++ -g -O3 -Wall -fPIC -m64 -DMAJOR_VERSION=1 -DMINOR_VERSION=0  -DPYTHON_3=1 -I/usr/local/include `python3-config --cflags | sed -e 's/-Wstrict-prototypes//g'` -I../driver "-I../include" -c unittestpymodule.c -o unittestpymodule.o
g++ -shared unittest_C_interface.o unittestpymodule.o -o unittestpy.so

[root@bogon unittest-KM_B0_UNITTEST_MASTER]# uname -r
3.10.0-1160.95.1.el7.x86_64

[root@bogon unittest-KM_B0_UNITTEST_MASTER]# ll /lib/modules/3.10.0-1160.95.1.el7.x86_64/
total 3292
lrwxrwxrwx.  1 root root     44 Aug 17 11:11 build -> /usr/src/kernels/3.10.0-1160.95.1.el7.x86_64[一闪一闪,说明这个文件夹其实不存在,这时候需要你去装对应的kernel了]
drwxr-xr-x.  2 root root      6 Jul 24 22:04 extra
drwxr-xr-x. 12 root root    128 Aug 17 11:11 kernel
-rw-r--r--.  1 root root 860346 Aug 17 11:12 modules.alias
-rw-r--r--.  1 root root 819751 Aug 17 11:12 modules.alias.bin
-rw-r--r--.  1 root root   1333 Jul 24 22:04 modules.block
-rw-r--r--.  1 root root   7426 Jul 24 22:03 modules.builtin
-rw-r--r--.  1 root root   9458 Aug 17 11:12 modules.builtin.bin
-rw-r--r--.  1 root root 270763 Aug 17 11:12 modules.dep
-rw-r--r--.  1 root root 379632 Aug 17 11:12 modules.dep.bin
-rw-r--r--.  1 root root    361 Aug 17 11:12 modules.devname
-rw-r--r--.  1 root root    140 Jul 24 22:04 modules.drm
-rw-r--r--.  1 root root     69 Jul 24 22:04 modules.modesetting
-rw-r--r--.  1 root root   1810 Jul 24 22:04 modules.networking
-rw-r--r--.  1 root root  97866 Jul 24 22:03 modules.order
-rw-r--r--.  1 root root    569 Aug 17 11:12 modules.softdep
-rw-r--r--.  1 root root 397297 Aug 17 11:12 modules.symbols
-rw-r--r--.  1 root root 485928 Aug 17 11:12 modules.symbols.bin
lrwxrwxrwx.  1 root root      5 Aug 17 11:11 source -> build
drwxr-xr-x.  2 root root      6 Jul 24 22:04 updates
drwxr-xr-x.  2 root root     95 Aug 17 11:11 vdso
drwxr-xr-x.  2 root root      6 Aug 17 11:12 weak-updates
[root@bogon unittest-KM_B0_UNITTEST_MASTER]# ll /usr/src/kernels/
total 0 【这里确实没有kernel】
[root@bogon unittest-KM_B0_UNITTEST_MASTER]# yum install kernel-devel-3.10.0-1160.95.1.el7.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:3.10.0-1160.95.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================
 Package                               Arch                            Version                                       Repository                        Size
============================================================================================================================================================
Installing:
 kernel-devel                          x86_64                          3.10.0-1160.95.1.el7                          updates                           18 M

Transaction Summary
============================================================================================================================================================
Install  1 Package

Total download size: 18 M
Installed size: 38 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
kernel-devel-3.10.0-1160.95.1.el7.x86_64.rpm                                                                                         |  18 MB  00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-devel-3.10.0-1160.95.1.el7.x86_64                                                                                                 1/1
  Verifying  : kernel-devel-3.10.0-1160.95.1.el7.x86_64                                                                                                 1/1

Installed:
  kernel-devel.x86_64 0:3.10.0-1160.95.1.el7

Complete!

[root@bogon unittest-KM_B0_UNITTEST_MASTER]# ./env_setup.sh
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c  *.mod.c.tmp_versions
rm -f Module.symvers modules.order
rm -rf .cache.mk .tmp_versions unittestk.o.ur-safe
make -C /lib/modules/3.10.0-1160.95.1.el7.x86_64/build M=/home/hcsw/unittest-KM_B0_UNITTEST_MASTER/hal/core/driver modules
make[1]: Entering directory `/usr/src/kernels/3.10.0-1160.95.1.el7.x86_64'
  CC [M]  /home/hcsw/unittest-KM_B0_UNITTEST_MASTER/hal/core/driver/unittestk.o
/home/hcsw/unittest-KM_B0_UNITTEST_MASTER/hal/core/driver/unittestk.c: In function ‘ih_interrupt_init’:
/home/hcsw/unittest-KM_B0_UNITTEST_MASTER/hal/core/driver/unittestk.c:1113:16: warning: ignoring return value of ‘request_irq’, declared with attribute warn_unused_result [-Wunused-result]
     request_irq(pdev->irq,ih_interrupt_handler,IRQF_SHARED,"IH_irq",pdev);
                ^
  LD [M]  /home/hcsw/unittest-KM_B0_UNITTEST_MASTER/hal/core/driver/unittestk-mod.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/hcsw/unittest-KM_B0_UNITTEST_MASTER/hal/core/driver/unittestk-mod.mod.o
  LD [M]  /home/hcsw/unittest-KM_B0_UNITTEST_MASTER/hal/core/driver/unittestk-mod.ko
make[1]: Leaving directory `/usr/src/kernels/3.10.0-1160.95.1.el7.x86_64'
major is 242
rm -f *.so *~ *.pyc *.o
g++ -g -O3 -Wall -fPIC -m64 -DMAJOR_VERSION=1 -DMINOR_VERSION=0  -DPYTHON_3=1 -I/usr/local/include `python3-config --cflags | sed -e 's/-Wstrict-prototypes//g'` -I../driver "-I../include" -c unittest_C_interface.cpp -o unittest_C_interface.o
g++ -g -O3 -Wall -fPIC -m64 -DMAJOR_VERSION=1 -DMINOR_VERSION=0  -DPYTHON_3=1 -I/usr/local/include `python3-config --cflags | sed -e 's/-Wstrict-prototypes//g'` -I../driver "-I../include" -c unittestpymodule.c -o unittestpymodule.o
g++ -shared unittest_C_interface.o unittestpymodule.o -o unittestpy.so

[root@bogon unittest-KM_B0_UNITTEST_MASTER]# lsmod | grep unittest
unittestk_mod          26015  0
全部评论

相关推荐

头像
10-22 19:18
上海大学 后端
jopajhhdjwnqk:水印都叠杀人书了
点赞 评论 收藏
分享
有工作后先养猫:太好了,是超时空战警,我们有救了😋
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务