Get dual boot back after a windows image re-install

Hi Folks,

I have a backup disk that was dual boot windows 7 and OS 13.2. I had to do a windows image restore from my main disk as windows got broken.
I have further done a upgrade to windows 10 (seemed a good idea to try that out). So I have a disk that still has all the OS 13.2 partitions but with windows 10. As the 13.2 was originally installed straight from the install DVD, it boots from /dev/sda1 (shown from working dual boot master disk)

inux-bdyp:~ # fdisk -l

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 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
Disklabel type: dos
Disk identifier: 0xc6ba34c2

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1  *         2048     821247     819200   400M 27 Hidden NTFS WinRE
/dev/sda2          821248  420337663  419516416   200G  7 HPFS/NTFS/exFAT
/dev/sda3       420337664  420950015     612352   299M 83 Linux
/dev/sda4       420952064 1953523711 1532571648 730.8G  5 Extended
/dev/sda5       420954112  686782463  265828352 126.8G 83 Linux
/dev/sda6       686786560 1953521663 1266735104   604G 83 Linux


(for information sda3 is /boot, sda5 is / and sda6 is /home)

The same is for the non dual booting drive, where windows image has obvious removed the dual boot capacity on sda1.

So my question is how do I get dual boot back please?

Thanks Robert

You are using the older MBR/legacy boot so the boot goes to the boot flag which is currently set to sda1 change it to sda3 note you don’t have any swap partition so if you should use all the memory while in Linux then it will crash unless you set up a swap file or are just loaded down with memory.

I tried that and it just caused a “missing operating system” on boot. The working disk has boot flag on sda1 so I expect the MBR has been replaced by the image replacement. I tried to re-write that using YAST from the 13.2 repair disk but that gave an error (I think the scripts are not there) How do I replace the MBR correctly?

Robert

The Windows MBR code is generic and if installed as legacy then it uses the boot flag. AFAIK that has not changed in Win10 How ever it is known the Win 10 conversions with dual boot systems can be bad. :open_mouth:

It is known that Win10 likes more then one partition and may mess with partitioning to get what it desires. Just like MS.

are you certain the sda3 partition is the boot? Maybe try setting flag on sda4

mount and look at the sda3 partition from a live boot and see what it contains should be boot if you can’t mount then you probably need to reinstall. Maybe do an upgrade install from full DVD/USB and be double sure all the partitions are mounted at the right spot.

Yes sda3 is /boot and all files seem correct, contents of /boot (part3) drive with Win10 (non dual booting):

linux-bdyp:~ # ls -l /run/media/xxxx/_boot/
total 48882
-rw-r--r-- 1 root root      65 Apr 14  2015 .vmlinuz-3.16.7-21-desktop.hmac
-rw-r--r-- 1 root root      65 Aug  7 17:39 .vmlinuz-3.16.7-24-desktop.hmac
-rw-r--r-- 1 root root 3003004 Apr 14  2015 System.map-3.16.7-21-desktop
-rw-r--r-- 1 root root 3003177 Aug  7 15:11 System.map-3.16.7-24-desktop
-rw-r--r-- 1 root root     512 Nov  9  2014 backup_mbr
lrwxrwxrwx 1 root root       1 Nov  9  2014 boot -> .
-rw-r--r-- 1 root root    1484 Oct 22  2014 boot.readme
-rw-r--r-- 1 root root  148309 Apr 14  2015 config-3.16.7-21-desktop
-rw-r--r-- 1 root root  148309 Aug  7 13:18 config-3.16.7-24-desktop
drwxr-xr-x 2 root root    1024 Oct 14 15:32 dracut
drwxr-xr-x 2 root root    1024 Nov  9  2014 grub
drwxr-xr-x 7 root root    1024 Aug 17 14:46 grub2
lrwxrwxrwx 1 root root      24 Aug 16 17:59 initrd -> initrd-3.16.7-24-desktop
-rw-r--r-- 1 root root 9002092 Apr 23  2015 initrd-3.16.7-21-desktop
-rw-r--r-- 1 root root 8975252 Aug 16 17:59 initrd-3.16.7-24-desktop
drwx------ 2 root root   12288 Nov  9  2014 lost+found
-rw-r--r-- 1 root root  424448 Oct 26  2014 message
-rw-r--r-- 1 root root  309437 Apr 14  2015 symvers-3.16.7-21-desktop.gz
-rw-r--r-- 1 root root  309437 Aug  7 15:35 symvers-3.16.7-24-desktop.gz
-rw-r--r-- 1 root root     516 Apr 14  2015 sysctl.conf-3.16.7-21-desktop
-rw-r--r-- 1 root root     516 Aug  7 15:35 sysctl.conf-3.16.7-24-desktop
-rw-r--r-- 1 root root 6665656 Apr 14  2015 vmlinux-3.16.7-21-desktop.gz
-rw-r--r-- 1 root root 6668759 Aug  7 15:46 vmlinux-3.16.7-24-desktop.gz
lrwxrwxrwx 1 root root      25 Aug 16 17:59 vmlinuz -> vmlinuz-3.16.7-24-desktop
-rw-r--r-- 1 root root 5682344 Apr 14  2015 vmlinuz-3.16.7-21-desktop
-rw-r--r-- 1 root root 5685608 Aug  7 17:39 vmlinuz-3.16.7-24-desktop


There must have been some change to the MBR when 13.2 was installed as it still has the boot flag set to sda1 and (in the good drive) it gets to a opensuse grub2 page with selections for opensuse and windows.

My guess would be that you had Grub installed to the MBR. This will often give you problems on a dual-boot system, especially with Windows.

Whenever you run a Windows fix, or as in your case, re-install Windows, it will write the Windows preference of an MBR. This will also occasionally happen with certain Windows online updates. When that happens, Windows overwrites Grub, if it is installed in the MBR.

Your best bet would be to install Grub to (in your case) sda3, then set the boot flag Active on sda3.

So, put your 13.2 install disk in and boot with it.

But, do not click on Install.

Instead, 3rd item down should be “Rescue System”. Click on that and wait for it to load.

It will stop with the line

Rescue login:

Type (without the quotes) “root” then press Enter.

You will now see the prompt, probably in a red font:

Rescue:~#

Do:

parted

You will now have a prompt
(parted)
Do:

select /dev/sda

You should get a confirmation message that the device is now selected.

Do:

set 1 boot

That is to set/reset the 1st partition’s boot flag.

It will prompt you with the line New state?

Do:

off

That should clear the Active flag from sda1.

Now, do:

set 3 boot

Again, it will prompt you with the line New state?

Do:

on

That will set the Active flag to sda3. When it is confirmed, do:

quit

You will be back at the Rescue:~# prompt.

Now, we need to mount root. Do:

mount /dev/sda3 /mnt

Mount the other devices next, do:

mount --bind /dev /mnt/dev

Then chroot:

chroot /mnt
mount -t proc proc /proc
mount -t sysfs sysfs /sys

Now, do:

grub2-mkconfig -o /boot/grub2/grub.cfg

Next, install Grub to your root partition:

grub2-install /dev/sda3

Now:

exit
reboot

You should now be back in business. If this solves your problems, then you should boot the other drive, as well, and install Grub to the root partition there, as well. When you do that, also make certain you change the Active flag to the root partition on that drive.

Good luck, let us know.:wink:

Hi Fraser_Bell,

I got as far as
mount --bind /dev /mnt/dev

/mnt/dev does not exist – so I mkdir /mnt/dev and repeated the was then OK

Then,

chroot /mnt

chroot: failed to run command ‘/bin/bash’: No such file or directory

even through ls -l /mnt worked ok, So not sure what to do to correct that

Robert

Ok I think I know where this is going


mount --bind /dev /run/media/linux/_/dev                      ---bind the rescue disk /dev to the harddrive /dev
mount --bind /run/media/linux/_boot/ /run/media/linux/_/boot  ---bind the boot partition to the harddrive /boot
chroot /run/media/linux/_/                                    ---set root to hardrive /
mount -t proc proc /proc
mount -t sysfs sysfs /sys

grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found theme: /boot/grub2/themes/openSUSE/theme.txt
Found linux image: /boot/vmlinuz-3.16.7-24-desktop
Found initrd image: /boot/initrd-3.16.7-24-desktop
Found linux image: /boot/vmlinuz-3.16.7-21-desktop
Found initrd image: /boot/initrd-3.16.7-21-desktop
  No volume groups found
Found Windows Recovery Environment (loader) on /dev/sda1
done


Almost worked!!!
for some reason mkconfig has found the recovery partition (sda1) and not the windows 10 partition (sda2)

That seems to be the next problem to solve…any help please

Robert

After some thought I wondered if it was correct for the windows boot to go to sda1 as that is where the boot would have gone before grub. So I continued


grub2-install /dev/sda3
Installing for i386-pc platform.
grub2-install: warning: File system `ext2' doesn't support embedding.
grub2-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub2-install: error: will not proceed with blocklists.


Not good!!! especially as sda3 (and all linux partitions) are ext4

Now I am stuck and going to bed (5:30am)

Robert

If you really want to do it: grub2-install --force /dev/sda3.

I am confused now about this. I have done some reading and it seems that its to do with grub 1.5 stage and sectors used by grub to incease the boot code space. These sectors must not be moved but installing grub in anything other than in the MBR and blocks after causes this issue. As it has been recommended to not use the MBR how can this be over come?

My /boot is in its own partition so block moving is not that likely but could be an issue when cloning?

What is the usual place for grub and what filesystem should be used?

Is it safe to force grub on my system?

Robert

Assuming the rest of the partition is OK you could just reinstall grub

note instruction here are to reinstall to MBR

https://forums.opensuse.org/content.php/128-Re-install-Grub2-from-DVD-Rescue

This is ok but Windows may mess with things in the future better to install to the boot partition (BTW why do you have one?) and use generic MBR and boot flag because Windows is just nasty about any other OS

The only filesystem that supports embedding is btrfs. Either you install on btrfs or you install in MBR. Otherwise you have to bite the bullet.

Is it safe to force grub on my system?

It depends on your definition of “safe”. YaST does it by default without even asking you. As long as this is the only bootloader location configured in YaST it is acceptable.

I have bitten the bullet and installed grub on sda3 and it works. My thoughts are it should continue working for some time/ever. If it fails to boot I just reinstall grub again

Thanks for all the help
Robert

Yes but it should be ok Windows should not mess with thing as you have them configured. the upgrade to 10 is flaky. You may have had grub in the MBR and Windows upgrades will overwrite then

Just a guess, but this would suggest to me that you used a device (DVD/USB or?) with a different version of openSUSE than the version that is installed on the machine. If so, this would be a typical error.

This really needed to be done using an install or rescue disk with the same version of openSUSE to work properly.

However, end result is that you finally did get it to work, and that is ultimately what is important. Good to see.