repair MBR

Hi :slight_smile:
I have a desktop machine that dual booted w7 and opensuse 13.2. I have little experience in linux (or windows) and when I tried to upgrade to Leap, naively formatted the mbr partition to install the grub :shame:. Opensuse Leap starts well and i’ve used it for several months now.
But, I need to use w7 to run some adobe programs (photoshop etc). Is it possible to “repair” the mbr?
This is my windows partition: https://drive.google.com/open?id=0BzBoLoUQva9aNWdVa1QxU3Vhemc and this my mbr, where i installed the grub: https://drive.google.com/open?id=0BzBoLoUQva9aRUFDLTRtZ2loRFk
Can you help me fix my mess?
My machine has an AMD processor with two cores (hope this helps…)

   
     *-cpu
          description: CPU
          product: AMD E-350 Processor
          vendor: Advanced Micro Devices [AMD]
          physical id: 4
          bus info: cpu@0
          version: AMD E-350 Processor
          slot: CPU 1
          size: 1280MHz
          capacity: 1600MHz
          width: 64 bits
          clock: 100MHz
          capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt arat hw_pstate npt lbrv svm_lock nrip_save pausefilter vmmcall cpufreq
          configuration: cores=2 enabledcores=2


Thanks lol!

Should have picked up Windows. BTW MBR is not a partition it is the first block on the drive.

Show us the output of **sudo fdisk -l ** (note that is a lower case L not a one)

please paste output using code tags so that the text is not reformatted, # in the too bar

I still do not understand the problem. You said you had dual boot system that worked. What does not work now? Please describe what you expect and what you get.

Thank you very much for your quick replies :slight_smile:

This is the output:

Disco /dev/sda: 465,8 GiB, 500107862016 bytes, 976773168 sectores
Unidades: sectores de 1 * 512 = 512 bytes
Tamaño de sector (lógico/físico): 512 bytes / 4096 bytes
Tamaño de E/S (mínimo/óptimo): 4096 bytes / 4096 bytes
Tipo de etiqueta de disco: gpt
Identificador del disco: ED4F673F-129C-478B-8701-B73A528C2AA0

Device         Start       End   Sectors   Size Type
/dev/sda1       2048    321535    319488   156M EFI System
/dev/sda2     321536   4530175   4208640     2G Microsoft basic data
/dev/sda3    4530176 214243327 209713152   100G Microsoft basic data
/dev/sda4  214243328 976773119 762529792 363,6G Microsoft basic data

Thanks for your reply. Before time when I started the machine I could choose between w7 and opensuse 13.2. Now the machine starts “directly” to opensuse Leap. It doesn’t show the menu where you can select the operating system.
Thanks for your support and hope this information helps lol!

I suspect that the main issue here is that you have a UEFI system. But you may have installed 13.2 for legacy MBR booting. That’s a mistake. Mixing legacy booting and UEFI booting can cause the problems that you are seeing (such as not able to boot Windows from the grub menu).

Try hitting F12 during boot (or F9 if this is an HP computer). Does the BIOS provide a boot menu, and can you select Windows from that menu?

Unless you have another drive you are not showing I don’t see a Windows partition. What you seem to have is a EFI booting Linux only system.

So you installed EFI not MBR boot which is OK but seems to have over written Windows :open_mouth:

Show sudo gdisk /dev/sda

It will better report partition type on a GPT partitioned drive

Always pay careful attention to the partition scheme before accepting and committing to it when installing Remember the installer can not read you mind and uses the best guess at what you intend. You can always override it’s choices. Installing an OS is a lot more serious then installing an app.

Hi again :wink:

I see I committed a mistake in the fdisk -l command. I repeated it:

$ sudo fdisk -l

Disco /dev/sda: 465,8 GiB, 500107862016 bytes, 976773168 sectores
Unidades: sectores de 1 * 512 = 512 bytes
Tamaño de sector (lógico/físico): 512 bytes / 512 bytes
Tamaño de E/S (mínimo/óptimo): 512 bytes / 512 bytes
Tipo de etiqueta de disco: dos
Identificador del disco: 0x4f59320e

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1          206848    411647    204800   100M 83 Linux
/dev/sda2  *       411648 205006847 204595200  97,6G  7 HPFS/NTFS/exFAT
/dev/sda3       205006848 707106815 502099968 239,4G  7 HPFS/NTFS/exFAT
/dev/sda4       707106816 976769023 269662208 128,6G  5 Extended
/dev/sda5       967063552 976769023   9705472   4,6G 82 Linux swap / Solaris
/dev/sda6       707108864 882401279 175292416  83,6G 83 Linux
/dev/sda7       883156992 967049215  83892224    40G 83 Linux


$ sudo gdisk /dev/sda
root's password:
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Command (? for help): q

BIOS shows: UEFI, and Legacy: cd-rom, hard-disk. And no w7 options. The system starts with UEFI.

Thank you very much for your answers and support lol!

Guessing that sda1 is supposed to be the efi boot partition yes you messed up it has to be a FAT formatted partition not a Linux format

So looks like you installed openSUSE in MBR mode since it would not boot like this if installed in EFI mode. You can not chain between OS’s if they boot in different modes

Don’t know how to fix this but to start EFI boot partition has to be FAT. You must first reformat it then you could in Yast -bootloader change to EFI boot for openSUSE but yo u still have to repair Windows and I have not a clue how you will need some sort of Windows rescue

Please show your /boot/grub2/grub.cfg and output of “grub2-editenv - list” (there are spaces around “-”).

Hi, lol!
I greatly thank you for your advice and support
Yours jazmiel :wink:

Hello, again :wink:

This is the output:

 # grub2-editenv - list
env_block=512+1
saved_entry=openSUSE Leap 42.1

I hope this helps lol!

So once more - you do not see GRUB menu on boot or you see GRUB menu but it does not offer Windows?

P.S. and you ignored my question about grub.cfg.

Hello :wink:

I see the grub menu and the next screen is of opensuse options. Nothing about windows.

P.S. and you ignored my question about grub.cfg.

Oh, excuse me. Here is my grub.cfg

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set btrfs_relative_path="y"
export btrfs_relative_path
if  -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif  -s $prefix/grubenv ]; then
  load_env
fi

if  "${env_block}" ] ; then
  load_env -f "${env_block}"
fi

if  "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   if  "${env_block}" ] ; then
     save_env -f "${env_block}" next_entry
   fi
   set boot_once=true
else
   set default="${saved_entry}"
fi

if  x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if  "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if  -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if  x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if  x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos 
insmod btrfs
set root='hd0,msdos6'
if  x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  3d3008bf-4718-49f7-af20-2380a2b6ce63
else
  search --no-floppy --fs-uuid --set=root 3d3008bf-4718-49f7-af20-2380a2b6ce63
fi
    font="/usr/share/grub2/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
fi
terminal_output gfxterm
insmod part_msdos 
insmod btrfs
set root='hd0,msdos6'
if  x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  3d3008bf-4718-49f7-af20-2380a2b6ce63
else
  search --no-floppy --fs-uuid --set=root 3d3008bf-4718-49f7-af20-2380a2b6ce63
fi
insmod gfxmenu
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans-Bold14.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans10.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans12.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/ascii.pf2
insmod png
set theme=($root)/boot/grub2/themes/openSUSE/theme.txt
export theme
if  x${boot_once} = xtrue ]; then
  set timeout=0
elif  x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=3
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=3
fi
if  -n "$extra_cmdline" ]; then
  submenu "Bootable snapshot #$snapshot_num" {
    menuentry "If OK, run 'snapper rollback' and reboot." { true; }
  }
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
### END /etc/grub.d/00_tuned ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'openSUSE Leap 42.1'  --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-3d3008bf-4718-49f7-af20-2380a2b6ce63' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos 
    insmod btrfs
    set root='hd0,msdos6'
    if  x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  3d3008bf-4718-49f7-af20-2380a2b6ce63
    else
      search --no-floppy --fs-uuid --set=root 3d3008bf-4718-49f7-af20-2380a2b6ce63
    fi
    echo    'Loading Linux 4.1.27-27-default ...'
    linux    /boot/vmlinuz-4.1.27-27-default root=UUID=3d3008bf-4718-49f7-af20-2380a2b6ce63  ${extra_cmdline} resume=/dev/disk/by-uuid/87ad283b-c799-4b71-8814-1f45e77ae0c6 splash=silent quiet showopts
    echo    'Loading initial ramdisk ...'
    initrd    /boot/initrd-4.1.27-27-default
}
submenu 'Advanced options for openSUSE Leap 42.1' --hotkey=1 $menuentry_id_option 'gnulinux-advanced-3d3008bf-4718-49f7-af20-2380a2b6ce63' {
    menuentry 'openSUSE Leap 42.1, with Linux 4.1.27-27-default' --hotkey=2 --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.27-27-default-advanced-3d3008bf-4718-49f7-af20-2380a2b6ce63' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos 
        insmod btrfs
        set root='hd0,msdos6'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  3d3008bf-4718-49f7-af20-2380a2b6ce63
        else
          search --no-floppy --fs-uuid --set=root 3d3008bf-4718-49f7-af20-2380a2b6ce63
        fi
        echo    'Loading Linux 4.1.27-27-default ...'
        linux    /boot/vmlinuz-4.1.27-27-default root=UUID=3d3008bf-4718-49f7-af20-2380a2b6ce63  ${extra_cmdline} resume=/dev/disk/by-uuid/87ad283b-c799-4b71-8814-1f45e77ae0c6 splash=silent quiet showopts
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initrd-4.1.27-27-default
    }
    menuentry 'openSUSE Leap 42.1, with Linux 4.1.27-24-default'  --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.27-24-default-advanced-3d3008bf-4718-49f7-af20-2380a2b6ce63' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos 
        insmod btrfs
        set root='hd0,msdos6'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  3d3008bf-4718-49f7-af20-2380a2b6ce63
        else
          search --no-floppy --fs-uuid --set=root 3d3008bf-4718-49f7-af20-2380a2b6ce63
        fi
        echo    'Loading Linux 4.1.27-24-default ...'
        linux    /boot/vmlinuz-4.1.27-24-default root=UUID=3d3008bf-4718-49f7-af20-2380a2b6ce63  ${extra_cmdline} resume=/dev/disk/by-uuid/87ad283b-c799-4b71-8814-1f45e77ae0c6 splash=silent quiet showopts
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initrd-4.1.27-24-default
    }
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if  -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif  -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/80_suse_btrfs_snapshot ###
if  -f "/.snapshots/grub-snapshot.cfg" ]; then
  source "/.snapshots/grub-snapshot.cfg"
fi
### END /etc/grub.d/80_suse_btrfs_snapshot ###

### BEGIN /etc/grub.d/90_persistent ###
### END /etc/grub.d/90_persistent ###

I hope this helps. Thank you lol!

Help anyone? Please :’(

If you run as root “os-prober” - does it find Windows? Your “fdisk” output shows 100M partition 1 with type “Linux”; your grub.cfg output shows that GRUB files are on partition 6. So partition 1 is not /boot. What is on this partition? Please show output of “df -h” in Linux.

Hi lol!

“os-prober” shows nothing. And

# df -h
S.ficheros     Tamaño Usados  Disp Uso% Montado en
devtmpfs         1,8G   8,0K  1,8G   1% /dev
tmpfs            1,8G   180K  1,8G   1% /dev/shm
tmpfs            1,8G   2,2M  1,8G   1% /run
tmpfs            1,8G      0  1,8G   0% /sys/fs/cgroup
/dev/sda6         84G    23G   60G  28% /
/dev/sda6         84G    23G   60G  28% /.snapshots
/dev/sda6         84G    23G   60G  28% /var/lib/pgsql
/dev/sda6         84G    23G   60G  28% /var/lib/mariadb
/dev/sda6         84G    23G   60G  28% /var/lib/named
/dev/sda6         84G    23G   60G  28% /var/lib/mysql
/dev/sda6         84G    23G   60G  28% /var/lib/mailman
/dev/sda6         84G    23G   60G  28% /var/lib/libvirt/images
/dev/sda6         84G    23G   60G  28% /usr/local
/dev/sda6         84G    23G   60G  28% /var/spool
/dev/sda6         84G    23G   60G  28% /tmp
/dev/sda6         84G    23G   60G  28% /var/opt
/dev/sda6         84G    23G   60G  28% /opt
/dev/sda6         84G    23G   60G  28% /var/tmp
/dev/sda6         84G    23G   60G  28% /srv
/dev/sda6         84G    23G   60G  28% /boot/grub2/x86_64-efi
/dev/sda6         84G    23G   60G  28% /boot/grub2/i386-pc
/dev/sda6         84G    23G   60G  28% /var/crash
/dev/sda6         84G    23G   60G  28% /var/log
/dev/sda7         40G   2,4G   38G   6% /home

Does this mean that w7 partition is lost?
Thank you very much for your answer rotfl!

It is confusing since you first showed a EFI boot disk then an MBR boot disk with a small Linux partition that looks as it should be formatted FAT for tan EFI boot. If one OS is installed MBR and the other EFI they won’t see one another and without a proper EFI boot partition the EFI OS will not boot at all. Not at all sure how to fix the problem. W7 is probably still there just unbootable . You can recover any data

What is lost is most likely Windows System partition that contains Windows bootloader. This partition is not mandatory (if you update from earlier versions this partition is not created). So you should be able to recover Windows bootloader either on System partition or on Windows Boot partition (which contains Windows folder). But that is really topic for Windows forum. :slight_smile:

Hi lol!

According to https://drive.google.com/file/d/0BzBoLoUQva9aNWdVa1QxU3Vhemc w7 is there.

I tried to correct it through windows but, my linux partition was erased (and had to reinstall everything…). I good hope that I can fix it from linux. Is it possible? Can you tell me how, or where to look for a solution?
Thanks rotfl!

So you have 2 drives??

OK you still must use the same boot method. both must be MBR or both must be EFI in order for one OS to see the other. Multiple drive is not a real issue either EFI or MBR will work but you can not mix.

In future show ALL output from commands you showed only one drive. fdisk -l will show all drives. Don’t edit the output