Reparaing grub after WIndows 10 install

Hi,

some days ago I upgrade my windows to windows 10. But i’m dual-booting with my openSUSE 13.2 and when I restarted GRUB disapeared, directly booting on windows 10.

Can you tell me a safe way to fix that ?

Thanks

Is this a UEFI system, or a traditional (legacy MBR) system?

Legacy BIOS, Windows on a MBR Partition

Best would be for you to provide us with the output from:

# fdisk -l /dev/sda

Use CODE tags around the output (easier to read). You can generate code tags by clicking the “#” near the top of the edit box, then paste the output there.

You will probably need to boot from live media or boot your install media in rescue mode, to run that command. You can maybe mount a Windows drive or a USB and save the output of the command to there for later posting.

It will also be useful to know:

Are you using grub2? (that’s the 13.2 default, but if you upgraded from an earlier system you might be using legacy grub).

Where did you tell the system to boot from: (could be the root partition or the MBR or “/boot” if you have a separate “/boot”).

Since MBR it may be that Windows changed the boot flag. Check the boot flag (fdisk -l will show it) If it is on the Windows boot change it to the partition that holds your Linux boot

And out of curiosity, what would the procedure be for those that had a UEFI system?

I have not tried Win 10, so I don’t have personal experience with this.

The first thing that I would do, would be to hit F12 during boot. That should bring up the firmware boot menu. If opensuse is there, I would try to boot it. If it is not there, I would boot the live rescue CD, and see if I can add the boot entry with the “efibootmgr” command.

If the boot entry is there, but it doesn’t boot, then there’s a different problem. It is known that Win10 installs can add partitions and change the partition numbering. That might require editing “/etc/fstab” to fix. Also edit “/etc/crypttab” if an encrypted partition is needed. Then one might need to go into rescue mode to rebuild the “initrd” and the boot menu.

Most of this is similar to what can happen with MBR boots. The difference is with the actual boot selection – depends on an NVRAM entry for UEFI and on the active partition flag for legacy booting.

From what I have seen on the net, a Windows 10 install does not do major damage to linux, but might require the kind of repairs mentioned above, and perhaps also a reinstall of grub2 (or grub2-efi).

No boot flags in a UEFI GPT system the problem would be in the BIOS boot default or Windows had wiped out the entries in the EFI boot partition. If the former fix in the BIOS the later then it is much more complicated. in essence you need to rebuild the opnesuse directory in the EFI boot partition.

I installed openSUSE 13.1 and upgraded 13.2, I think I let default boot option but don’t know where I tell the system to boot from and if I have grub legacy or grub2.

When I upgraded my win7 to win10 I tagged/flagged my win7 partition as active (maybe it can help).

Here are partitioning infos :

lubuntu@lubuntu:/$ sudo fdisk -l /dev/sda

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00004f0b


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2   *      206848   308027391   153910272    7  HPFS/NTFS/exFAT
/dev/sda3       308027392  1465147391   578560000    f  W95 Ext'd (LBA)
/dev/sda5       308029440   324802559     8386560   82  Linux swap / Solaris
/dev/sda6       324804608   429658111    52426752   83  Linux
/dev/sda7       429660160   953143295   261741568    7  HPFS/NTFS/exFAT
/dev/sda8       953145344  1465147391   256001024    7  HPFS/NTFS/exFAT

lubuntu@lubuntu:/$ sudo fdisk -lu /dev/sda

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00004f0b


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2   *      206848   308027391   153910272    7  HPFS/NTFS/exFAT
/dev/sda3       308027392  1465147391   578560000    f  W95 Ext'd (LBA)
/dev/sda5       308029440   324802559     8386560   82  Linux swap / Solaris
/dev/sda6       324804608   429658111    52426752   83  Linux
/dev/sda7       429660160   953143295   261741568    7  HPFS/NTFS/exFAT

lubuntu@lubuntu:/$ lsblkNAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 698,7G  0 disk 
├─sda1   8:1    0   100M  0 part /media/lubuntu/Réservé au système
├─sda2   8:2    0 146,8G  0 part /media/lubuntu/8C687FAA687F91A6
├─sda3   8:3    0     1K  0 part 
├─sda5   8:5    0     8G  0 part [SWAP]
├─sda6   8:6    0    50G  0 part /media/lubuntu/214174d0-4744-4fc1-a9e7-e1c6c4846dbb
├─sda7   8:7    0 249,6G  0 part 
└─sda8   8:8    0 244,1G  0 part /media/lubuntu/Media

lubuntu@lubuntu:/$  sudo parted -lModel: ATA Hitachi HTS54757 (scsi)
Disk /dev/sda: 750GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos


Number  Start   End    Size    Type      File system     Flags
 1      1049kB  106MB  105MB   primary   ntfs
 2      106MB   158GB  158GB   primary   ntfs            boot
 3      158GB   750GB  592GB   extended                  lba
 5      158GB   166GB  8588MB  logical   linux-swap(v1)
 6      166GB   220GB  53,7GB  logical   ext4
 7      220GB   488GB  268GB   logical   ntfs
 8      488GB   750GB  262GB   logical   ntfs

There is boot-info (post will expire in dec 2015) : http://paste.opensuse.org/8426534

That’s useful information. Not just the “bootinfo” but also the other info in your latest posts.

I can see that you are using grub2, and that it is installed in “/dev/sda6”.

The official way to fix this is to go into rescue mode and reinstall grub2. However, I think the following will work and be a lot easier.

You need to be booted to linux (can be a live CD or live USB), and have a root command line.


cd /tmp  ## just to have somewhere
dd if=/dev/sda6 of=bootsect bs=440 count=1
dd if=bootsect of=/dev/sda3 bs=440 count=1

I’ll explain that part first.

The first “dd” command copies the boot code from your linux partition to a file “bootsect”, and limits it to 440 bytes.
The second “dd” command now copies that same boot code to the boot sector of your extended partition. It limits the copy to 440 bytes, which is redundant but there for safety.

After doing this, you should now have bootable code in the extended partition. It’s possible that there is already bootable code there, but Windows has possibly overwritten that so the above commands play it safe.

Now you need to use “fdisk” and

  1. turn off the active flag for “/dev/sda2” (the Windows partition) and
  2. turn on the active flag for “/dev/sda3” the extended partition.

I think you already know how to do that, since you said that you switched the active flag to Windows before the upgrade.

Final step – reboot and see what works.

A very simple way is to create a CD/USB with Super Grub2, allowing you to boot any kernel on the sda6,

http://www.supergrubdisk.org/

I used boot-repair disk there I just what I need : gParted, a terminal and leafpad.

No :frowning:

I go on my live cd.
I did just what you tell first :

lubuntu@lubuntu:~$ cd /tmplubuntu@lubuntu:/tmp$ sudo dd if=/dev/sda6 of=bootsect bs=440 count=1
1+0 records in
1+0 records out
440 bytes (440 B) copied, 0,0331543 s, 13,3 kB/s
lubuntu@lubuntu:/tmp$ sudo dd if=bootsect of=/dev/sda3 bs=440 count=1
1+0 records inlq
440 bytes (440 B) copied, 0,0348815 s, 12,6 kB/s

I rebooted, and directly booted on win10 (that’s normal).

So I go back on my live cd and on gparted I managed boot-flag :
flag “boot” turn off /dev/sda2
flag “boot” turn on /dev/sda3

checked :

lubuntu@lubuntu:~$ sudo fdisk -l /dev/sda


Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00004f0b


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2          206848   308027391   153910272    7  HPFS/NTFS/exFAT
/dev/sda3   *   308027392  1465147391   578560000    f  W95 Ext'd (LBA)
/dev/sda5       308029440   324802559     8386560   82  Linux swap / Solaris
/dev/sda6       324804608   429658111    52426752   83  Linux
/dev/sda7       429660160   953143295   261741568    7  HPFS/NTFS/exFAT
/dev/sda8       953145344  1465147391   256001024    7  HPFS/NTFS/exFAT

And when I booted => just a simple black screen with nothing else.

Live cd and gparted again :

flag boot off /dev/sda3
flag boot on /dev/sda6

checked :

lubuntu@lubuntu:~$ sudo fdisk -l /dev/sda


Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00004f0b


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2          206848   308027391   153910272    7  HPFS/NTFS/exFAT
/dev/sda3       308027392  1465147391   578560000    f  W95 Ext'd (LBA)
/dev/sda5       308029440   324802559     8386560   82  Linux swap / Solaris
/dev/sda6   *   324804608   429658111    52426752   83  Linux
/dev/sda7       429660160   953143295   261741568    7  HPFS/NTFS/exFAT
/dev/sda8       953145344  1465147391   256001024    7  HPFS/NTFS/exFAT

When I boot error message :
“Missing operating system - Reboot ans select proper boot device”

live cd :
flag boot /dev/sda6 was disepeared !!!
flag boot on /dev/sda2

checked :

lubuntu@lubuntu:~$ sudo fdisk -l /dev/sda


Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00004f0b


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2   *      206848   308027391   153910272    7  HPFS/NTFS/exFAT
/dev/sda3       308027392  1465147391   578560000    f  W95 Ext'd (LBA)
/dev/sda5       308029440   324802559     8386560   82  Linux swap / Solaris
/dev/sda6       324804608   429658111    52426752   83  Linux
/dev/sda7       429660160   953143295   261741568    7  HPFS/NTFS/exFAT
/dev/sda8       953145344  1465147391   256001024    7  HPFS/NTFS/exFAT

When I booted, go on win10 directly (that’s normal) but ouf I’m save I’ve an OS working :slight_smile:

May be I have to re-install a full grub and configure it, not just copy the old one.

PS : before everything, before I post the thread I do something first (just after win10 upgrade) : the auto-repair option on the boot-repair disk and just after I generated the boot-info (SUSE Paste) because that didn’t work.

What do you think about doing this :
http://www.dedoimedo.com/computers/grub.html#mozTocId856030

find /boot/grub/stage1
root (hd0,5) (for /dev/sda6 am I right ??)
setup (hd0)
quit

and after configure what appear in the boot menu ?

You may have installed grub to the extended. put flag there.

If you used a generic MBR boot code then you can not boot direct to a logical partition you need to boot to the extended. That is most probably where grub was put

On /dev/sda6 ? already try it (see my previous coms)

Generic MBR code will not boot to a logical partition only primary ones. So either install grub to extended and set boot flag on it or install grub to mbr which can handle logical boot partition booting. Installing grub to mbr is a problem since Windows likes to over write it with it’s own generic boot code. This may be what happened when you installed Win10.

This one of the many reasons I only run Windows in VMs rotfl!

So what are the code to install grub to extended ?

The best is not run windows at all but for some games …