我的博客已迁移到xdoujiang.com请去那边和我交流
======================grub2文件修复======================
一、grub2文件修复
1、内核
cat /etc/debian_version 
7.8

2、版本
uname -r
3.2.0-4-amd64

3、先模拟破坏mv /boot/grub/grub.cfg /boot/grub/grub.cfg.bak
这样的话系统会找不到配置文件 直接进入grub命令行

wKioL1XnBFLyl9tvAADRbgsmv7w372.jpg

4、先查看下有哪些命令可以使用
help

wKiom1XnAkaw4h04AAH65acVaHE188.jpg

wKioL1XnBGjQ5t1CAAGBxu9-sk8397.jpg

wKiom1XnAkbj5goMAAHnpVYG05M093.jpg

wKioL1XnBGnCt06nAAGRLPfmmks620.jpg

5、可以看到相关赋值
ls

wKiom1XnAnvC68YyAABcRtvWLn4007.jpg

6、也可以不用打这条命令,默认系统已经赋值     
set root=(hd0,msdos1)

7、查看内核和initrd映像系统
ls -l /boot

wKioL1XnBK_ynsPgAADp7_DWLIM050.jpg

8、linux命令
linux /boot/vmlinuz-3.2.0-4-amd64 root=/dev/sda1

wKioL1XnBL7xQdbAAABAh7OB6lE256.jpg

9、initrd命令
initrd /boot/initrd.img-3.2.0-4-amd64

wKiom1XnAqmTu0SxAABEycXAYT8607.jpg

10、使用boot命令进入系统
boot

11、进入系统后使用update-grub命令来检测内核、启动文件,并添加所有的操作系统,自动生成你的启动菜单。
cd /boot/grub && update-grub
Generating grub.cfg ...
Found linux p_w_picpath: /boot/vmlinuz-3.2.0-4-amd64
Found initrd p_w_picpath: /boot/initrd.img-3.2.0-4-amd64
done

12、确认下文件是否已生成
ls /boot/grub/grub.cfg
/boot/grub/grub.cfg

13、最后使用grub-install命令对/dev/sda
grub-install /dev/sda
Installation finished. No error reported.
======================grub1文件修复======================
二、grub1文件修复
1、内核
cat /etc/debian_version 
5.0.10

2、版本
uname -r
2.6.26-2-amd64

3、先模拟破坏mv /boot/grub/menu.lst /boot/grub/menu.lst.bak
这样的话系统会找不到配置文件 直接进入grub命令行

wKioL1XnBN_BOxXmAACzYMjfA-Y886.jpg

4、先查看下有哪些命令可以使用
help

wKiom1XnAszARY8DAAK4g-L2hJ8100.jpg

5、使用root命令查看赋值并赋值     
root (hd0,0)

wKioL1XnBPyQ9Q6KAAHPLh0KCc8147.jpg

wKiom1XnAtrRNP5UAAEICa9FmuY495.jpg

6、kernel命令
kernel /boot/vmlinuz-2.6.26-2-amd64 root=/dev/sda1

wKiom1XnAujCu-a3AABzIjjgNc4537.jpg

7、initrd命令
initrd /boot/initrd.img-2.6.26-2-amd64

wKiom1XnAwGDoVxlAABpVUah_rU829.jpg

8、使用boot命令进入系统
boot

9、进入系统后使用update-grub命令来检测内核、启动文件,并添加所有的操作系统,自动生成你的启动菜单。
cd /boot/grub && update-grub
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... 
Generating /boot/grub/menu.lst
Searching for splash p_w_picpath ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.26-2-amd64
Updating /boot/grub/menu.lst ... done

10、确认下文件是否已生成
ls /boot/grub/menu.lst
/boot/grub/menu.lst

11、最后使用grub-install命令对/dev/sda
Searching for GRUB installation directory ... found: /boot/grub
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script grub-install.
(hd0)    /dev/sda

三、参考文章
http://www.gnu.org/software/grub/manual/grub.html