Gangmax Blog

Recover the missing Windows7 boot menu entry in Grub when updating Linux kernel after installing Symantec PGP

As part of the company’s IT policy, I have to install Symantec PGP. I have dual-boot by Grub with Ubuntu and Windows7. I only encrypted the “C:”(sda1) partition by PGP. And both of my Windows and Ubuntu work fine.

But yesterday after I upgrade my Ubuntu Linux kernel and reboot, I find the Window7 boot menu entry in Grub is missing, which makes me can’t log in the Windows system.

Today After I do some investigation I find the solution to fix this problem, from “here“ and “here“.

First check the partition information. In my case, I can see that the Symantec PGP program split my original “sda1” into “sda1” and “sda2”. Or I should say: it create a new “sda1” for itself(maybe for add the booting information in the present “sda1”) and move the original “sda1” to the present “sda2”. This is important for the original Windows7 boot information is not on “sda1” now but “sda2”.(I find this is not right because the windows grub menu item works fine after the Synmantec PGP was installed, it disappears right after the Linux kernel is updated, which means the computer has “sda1” and bootable “sda2” originally.)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
user@user-ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xcec5cedc

Device Boot Start End Blocks Id System
/dev/sda1 * 1 10444 83891398+ 7 HPFS/NTFS
/dev/sda2 10445 60802 404493313 f W95 Ext'd (LBA)
/dev/sda5 10445 20643 81920000 7 HPFS/NTFS
/dev/sda6 20643 27938 58592256 83 Linux
/dev/sda7 27938 59304 251952128 83 Linux
/dev/sda8 59305 60802 12025856 82 Linux swap / Solaris
user@user-ubuntu:~$

Then what I do is to add the Windows boot entry to the “/boot/grub/grub.cfg”, and also this information should be add to the “/etc/grub.d/40_custom” as well. For after each time the Linux kernel is updated, the “/boot/grub/grub.cfg” will be refreshed. The information in “/etc/grub.d/40_custom” may be used to regenerate the “grub.cfg” file(This may also not be true, in that case I should manually add the boot entry to “/boot/grub/grub.cfg” each time after the Linux Kernel is updated).

1
2
3
4
5
cd /boot/grub
sudo chmod +w grub.cfg
sudo vi grub.cfg # Add the following text at the end of this file.
sudo chmod -w grub.cfg
sudo vi /etc/grub.d/40_custom # Add the following text at the end of this file.
1
2
3
4
5
6
menuentry "Microsoft Windows 7" {
insmod part_msdos
insmod ntfs
set root='(hd0,1)'
chainloader +1
}

Reboot.

Comments