阐述备份Linux内核步骤

运维 系统运维
随着学习Suse的深入,面临的问题也是越来越多,Suse编译内核是非常头疼的,今天编译Suse 10.2内核直接导致Suse面临重装,要是备份Linux内核就好了,本文就是介绍备份Linux内核的简单步骤。

随着学习Suse的深入,面临的问题也是越来越多,Suse编译内核是非常头疼的,今天编译Suse 10.2内核直接导致Suse面临重装,要是备份Linux内核就好了,备份Linux内核相当的简单,下面就是步骤,英文也很简单,相信准备对内核有所动作的人都能轻易看懂。虽然是针对Suse写的,其它Linux发行版本也大同小异,下面就是备份Linux内核的简单步骤:

 

  1. 1) open terminal  
  2.  
  3. 2) su to root  
  4.  
  5. 3) change directory to /boot  
  6. #cd /boot  
  7.  
  8. 4) see what are the names of running kernels  
  9. #ls  
  10.  
  11. 5) make backup copy of your kernel and System.map  
  12. #cp vmlinuz-2.6.18.8-0.1-default vmlinuz-2.6.18.8-0.1-bak  
  13. #cp System.map-2.6.18.8-0.1-default System.map-2.6.18.8-0.1-bak  
  14. #cp -R /lib/modules/2.6.18.8-0.1-default /lib/modules/2.6.18.8-0.1-bak  
  15.  
  16. 6) create initrd  
  17. #mkinitrd -s 1024×768  
  18.  
  19. 7) check if new initrd was created:  
  20. #ls  
  21. and look for initrd-2.6.18.8-0.1-bak  
  22.  
  23. 8) make backup of your current GRUB menu (in the case that you may screw up editing)  
  24. #cp /boot/grub/menu.lst /boot/grub/menu.lst_bak  
  25.  
  26. 9) edit grub menu whatever editor (I use vi, but you may use kedit.gedit, joe, pico and so on as long as you run editor with root privileges)  
  27. boot/grub/menu.lst  
  28.  
  29. 10) add new entry at the end of the file (copy original entry for Suse Linux 10.2):  
  30. title Suse Linux 10.2 kernel backup  
  31. root (hd0,0)  
  32. kernel /vmlinuz-2.6.18.8-0.1-bak root=/dev/sda2 vga=0×317 vga=normal video=vesa:1024×768@60 resume=/dev/sda3 elevator=deadline splash=silent showopts  
  33. initrd /initrd-2.6.18.8-0.1-bak  
  34. important changes are marked bold. You may not have the other stuff or it may be different. Simply keep the rest of the file exactly the same as in the original entry for Suse Linux 10.2  
  35.  
  36. 11) save the file  
  37.  
  38. 12) restart computer and select from GRUB menu “Suse Linux 10.2 kernel backup”  
  39. if system boots successfully you have working kernel backup, now if Suse updates kernel next time and new kernel will not boot properly, you can always boot to Suse Linux 10.2 kernel backup which will never be modified (and safe from screwed updates)  
  40.  
  41. 举一反三的令一种方法:  
  42. ideally would be do something different:  
  43. 1) install kernel sources  
  44.  
  45. 2) su to root  
  46.  
  47. 3) copy kernel sources to the new direcory:  
  48. #cp -R /usr/src/Linux-2.6.18.8-0.1 /usr/src/Linux-2.6.18.8-0.1-bak  
  49.  
  50. 4) change directory to /usr/src/Linux-2.6.18.8-0.1-bak  
  51. #cd /usr/src/Linux-2.6.18.8-0.1-bak  
  52.  
  53. 5) create config file  
  54. #make oldconfig  
  55.  
  56. 6) change kernel name (super important!!!)  
  57. by editing .config file (in /usr/src/Linux-2.6.18.8-0.1-bak) Tehre is a dot before “config”  
  58. scroll down to the line:  
  59. #  
  60. # General setup  
  61. #  
  62. CONFIG_LOCALVERSION=”"  
  63. and change local kernel name version by adding:  
  64. CONFIG_LOCALVERSION=”-bak”  
  65. if there is anything already written in the line  
  66. CONFIG_LOCALVERSION=”"  
  67. delete old name remember that new name must have quotation marks.  
  68.  
  69. 7) save file  
  70.  
  71. 8) compile kernel  
  72. #make bzImage && make modules && make modules_install && make install  
  73. You just created a new kernel! Exactly the same as the running one but the name will have “-bak” at the end  
  74. there is nothing more required. in your GRUB menu will appear a new entry pointing to the new kernel. Old kernel will not be affected (if you did exactly as I suggested)  
  75. new kernel is invisible to Yast and will never be changed.  
  76. Because the latest kernel upgrade is a real disaster I would make backup copy of grub menu (as root):  
  77. #cp /boot/grub/menu.lst /boot/grub/menu.lst_bak  
  78. now you can boot to the new kernel  
  79. you will get to command line (when booting to the new kernel) if you installed nvidia/ati drivers,  
  80. That is easy to fix of course. what is important, you have working Suse setup in spite of all Suse devs efforts to screw you up  

通过我的介绍,这篇简单的备份Linux内核的文章会对你有帮助。其实我的主要目的就是提醒各位应用Linux的朋友,记得要备份Linux内核。

【编辑推荐】

  1. SUSE Linux 10的虚拟化:Xen
  2. 实操Suse防火墙配置
  3. Suse Linux整理大全:快捷键
  4. 学习手札:加强Suse Linux操作系统安全
  5. 详解Suse Postfix配置解法
责任编辑:小霞 来源: eNet硅谷动力
相关推荐

2009-12-17 14:24:39

Linux内核

2009-01-30 21:56:00

2009-12-09 14:15:39

2009-12-02 14:09:52

2009-12-14 10:47:34

Linux makef

2010-03-10 14:48:24

2009-11-30 10:54:59

solaris命令

2009-12-21 14:33:11

2009-12-10 10:25:12

Linux触摸屏驱动

2009-12-14 13:14:57

2009-12-22 15:12:33

Linux扩展文件系统

2009-12-01 18:41:08

SUSE Linux

2009-12-23 10:50:57

Linux chmod

2009-12-25 17:15:03

Linux内存

2009-12-17 09:56:26

Linux添加驱动模块

2010-01-07 14:39:37

Linux配置远程桌面

2010-01-07 13:27:22

Linux驱动程序

2009-12-16 15:59:13

Linux设备文件管理

2009-12-11 10:02:46

Linux内存管理

2021-02-20 06:08:07

LinuxWindows内核
点赞
收藏

51CTO技术栈公众号