我有两块硬盘,分别安装Windows和Linux。之前先安装的win7 64位,然后安装的Fedora22,开机引导没啥问题,后来感觉系统带不动win7,又重装了个XP,结果就是XP能进了,Fedora不能进入了。
(说明:其实我还是可以进入Fedora,因为我是两块硬盘,只是得每次开机时,进BIOS选择从第二个硬盘(Fedara系统盘)启动就可以了)
就是觉得不爽要修修!
一 修复grub2过程:
1,用LiveCD制作好的U盘启动,进入fedora系统。
2,打开terminal,找到以前安装fedora系统的硬盘(分区),用下面命令查找:
[liveuser@MiWiFi-R1CM ~]$ sudo -i
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[root@MiWiFi-R1CM ~]# fdisk -l
Disk /dev/sda: 149.1 GiB, 160041885696 bytes, 312581808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf0b1ebb0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 102764543 102762496 49G 7 HPFS/NTFS/exFAT
/dev/sda2 102764544 207624191 104859648 50G 7 HPFS/NTFS/exFAT
/dev/sda3 207624192 312580095 104955904 50G 7 HPFS/NTFS/exFAT
Disk /dev/sdb: 149.1 GiB, 160041885696 bytes, 312581808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x648faaa3
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 1026047 1024000 500M 83 Linux
/dev/sdb2 1026048 312580095 311554048 148.6G 8e Linux LVM
Disk /dev/mapper/fedora_miwifi--r1cm-home: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora_miwifi--r1cm-tmp: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora_miwifi--r1cm-var: 15 GiB, 16106127360 bytes, 31457280 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora_miwifi--r1cm-swap: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora_miwifi--r1cm-root: 26.6 GiB, 28512878592 bytes, 55689216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
4,上面找到了fedora系统盘:/dev/sdb
fedora系统的根分区:/dev/mapper/fedora_miwifi–r1cm-root
fedora系统的boot分区:/dev/sdb1
5,挂载以前的分区(boot分区,根分区)
[root@MiWiFi-R1CM ~]# mount /dev/mapper/fedora_miwifi--r1cm-root /mnt/
[root@MiWiFi-R1CM ~]# ls /mnt/
bin/ etc/ lib64/ mnt/ root/ srv/ usr/
boot/ home/ lost+found/ opt/ run/ sys/ var/
dev/ lib/ media/ proc/ sbin/ tmp/
[root@MiWiFi-R1CM ~]# ls /mnt/boot/
[root@MiWiFi-R1CM ~]# ls /mnt/dev/
[root@MiWiFi-R1CM ~]# mount /dev/sdb1 /mnt/boot/
6,转到chroot环境,修复grub2系统引导
[root@MiWiFi-R1CM ~]# mount --bind /dev /mnt/dev/
[root@MiWiFi-R1CM ~]# chroot /mnt
[root@MiWiFi-R1CM /]# grub2-install /dev/sda (或者sdb,看后面的:后记)
Installing for i386-pc platform.
......(忽略)
Installation finished. No error reported.
7,上述命令结束,恢复成功,重启系统即可。
二 更新grub2过程(更新grub2的配置文件):
8,上面的做完,开机硬盘启动后,是没有XP菜单可以进入的,先进入Fedora系统,然后执行下面命令:
[chenxl@MiWiFi-R1CM ~]$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
[sudo] xxxxx 的密码:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.3-200.fc22.x86_64
Found initrd image: /boot/initramfs-4.2.3-200.fc22.x86_64.img
Found linux image: /boot/vmlinuz-4.0.4-301.fc22.x86_64
Found initrd image: /boot/initramfs-4.0.4-301.fc22.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-4373ef76102146ad9b4d7093d0e590a9
Found initrd image: /boot/initramfs-0-rescue-4373ef76102146ad9b4d7093d0e590a9.img
Found Microsoft Windows XP Professional on /dev/sda1
done
9,用grub2-mkconfig命令可以生成新的配置文件,里面包含能找到的磁盘上的所有系统引导记录。
10,现在重启电脑就可以了,fedora和XP都有进入的菜单了。
后记:
修改完后发现的:其实我觉得我以前的grub2没有坏掉,通过这么改,我觉得坏掉了(因为安装到sda上了,单独启动fedora系统盘,倒是找不到grub了,哈哈),想再改回去也行,就是重新修复,在上面的6中运行grub2-install /dev/sdb,这样就又可以单独启动fedora系统盘了。
搞了半天现在是用grub2引导XP系统,可能我搞麻烦了,我认为刚开始就不要修复,直接进入我的fedora进行更新grub2就行了。
grub2设置引导fedora22 Workstation Live:http://www.linuxdiyf.com/linux/12422.html
Ubuntu系统grub修复的方法:http://www.linuxdiyf.com/linux/12961.html
重装Windows系统后Ubuntu Grub2的恢复:http://www.linuxdiyf.com/linux/11820.html
恢复Ubuntu GRUB引导的方法:http://www.linuxdiyf.com/linux/11271.html
Ubuntu修复Grub2笔记:http://www.linuxdiyf.com/linux/11796.html