My computer(asus N76VM 64 bit) with windows 7 (64 bit home professional) pre-installed got in a bad state while partitioning from a later installed Ubuntu environment. This had lead me to run testdisk
and copy every seperate partition onto a backup HDD.
I managed to get it al back onto the original hard drive in a state that resembles the state before things went bad.
****I was able to boot into both operating systems before all the hassle started!****
Since "repairing" the HDD the computer still doesn't want to start windows 7. It's got Grub 1.99
installed and (hoping this would help me) rEFInd
but they both don't work. I must note that Grub
does display entries for both Windows 7 and Ubuntu. Ubuntu starts like it should, but when I choose for Windows the screen tells me: Invalid EFI filepath.
Another step I tried was running a Windows 7 repair cd, enter command prompt, reassign drive letters (they were C:\ for [OS] and D:\ for [DATA]) so they fitted the original state and then the following commands:
Bootrec.exe /FixMbr
Bootrec.exe /FixBoot
Bootrec.exe /ScanOs
Bootrec.exe /RebuildBcd
Rebooted
But they did not help, so I tried the following:
bootsect /nt60 c: /force /mbr
bcdboot c:\windows /s c:
Again, no sigar. So I started looking further and ran into this website which gave advice I am a bit concerned about trying, for I don't know the possible outcomes and I don't want to be loosing anything all over again.
Running boot info script
gives me the following output (the order of the partitions might seem weird, I know that, but I don't think it is of any concern:
Boot Info Script 0.61 [1 April 2012]
============================= Boot Info Summary: ===============================
=> Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector
1880670208 of the same hard drive for core.img. core.img is at this
location and looks for (,gpt2)/boot/grub on this drive.
sda1: __________________________________________________________________________
File system: vfat
Boot sector type: FAT32
Boot sector info: According to the info in the boot sector, sda1 starts
at sector 0. But according to the info from fdisk,
sda1 starts at sector 2048.
Operating System:
Boot files: /efi/refind/refind_x64.efi /efi/ubuntu/grubx64.efi
/efi/ubuntu/shimx64.efi
sda2: __________________________________________________________________________
File system: ext4
Boot sector type: Grub2 (v1.99)
Boot sector info: Grub2 (v1.99) is installed in the boot sector of sda2
and looks at sector 1569963600 of the same hard drive
for core.img. core.img is at this location and looks
for (,gpt2)/boot/grub on this drive.
Operating System: Ubuntu 12.04.4 LTS
Boot files: /boot/grub/grub.cfg /etc/fstab
sda3: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files:
sda4: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System: Windows 7
Boot files: /NST/menu.lst /bootmgr /Boot/BCD
/Windows/System32/winload.exe
sda5: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files: /bootmgr /boot/bcd
sda6: __________________________________________________________________________
File system: swap
Boot sector type: -
Boot sector info:
sda7: __________________________________________________________________________
File system: BIOS Boot partition
Boot sector type: Grub2's core.img
Boot sector info:
============================ Drive/Partition Info: =============================
Drive: sda _____________________________________________________________________
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sda1 1 1,953,525,167 1,953,525,167 ee GPT
GUID Partition Table detected.
Partition Start Sector End Sector # of Sectors System
/dev/sda1 2,048 194,559 192,512 EFI System partition
/dev/sda2 1,556,162,560 1,864,286,207 308,123,648 EFI System partition
/dev/sda3 1,233,352,704 1,556,162,559 322,809,856 Data partition (Windows/Linux)
/dev/sda4 194,560 1,233,352,703 1,233,158,144 Data partition (Windows/Linux)
/dev/sda5 1,880,690,688 1,936,979,967 56,289,280 Windows Recovery Environment (Windows)
/dev/sda6 1,864,286,208 1,880,670,207 16,384,000 Swap partition (Linux)
/dev/sda7 1,880,670,208 1,880,690,687 20,480 BIOS Boot partition
"blkid" output: ________________________________________________________________
Device UUID TYPE LABEL
/dev/sda1 E138-2A7D vfat
/dev/sda2 598ab3d1-e1aa-4041-ba78-1de8c6762331 ext4
/dev/sda3 4DFF26211F14E609 ntfs DATA
/dev/sda4 4A814AE3556AE075 ntfs OS
/dev/sda5 1B1666970F6A4336 ntfs Recovery
/dev/sda6 03dc7be8-7682-4219-8ab0-ae5d09caa1b1 swap
================================ Mount points: =================================
Device Mount_Point Type Options
/dev/sda1 /boot/efi vfat (rw)
/dev/sda2 / ext4 (rw,errors=remount-ro)
=========================== sda2/boot/grub/grub.cfg: ===========================
--------------------------------------------------------------------------------
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
set default="0"
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 recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}
function load_video {
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
}
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 598ab3d1-e1aa-4041-ba78-1de8c6762331
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=auto
load_video
insmod gfxterm
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 598ab3d1-e1aa-4041-ba78-1de8c6762331
set locale_dir=($root)/boot/grub/locale
set lang=en_US
insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
clear
fi
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
set gfxpayload="${1}"
if [ "${1}" = "keep" ]; then
set vt_handoff=vt.handoff=7
else
set vt_handoff=
fi
}
if [ "${recordfail}" != 1 ]; then
if [ -e ${prefix}/gfxblacklist.txt ]; then
if hwmatch ${prefix}/gfxblacklist.txt 3; then
if [ ${match} = 0 ]; then
set linux_gfx_mode=keep
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=keep
fi
else
set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
menuentry 'Ubuntu, with Linux 3.8.0-35-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 598ab3d1-e1aa-4041-ba78-1de8c6762331
linux /boot/vmlinuz-3.8.0-35-generic root=UUID=598ab3d1-e1aa-4041-ba78-1de8c6762331 ro quiet splash $vt_handoff
initrd /boot/initrd.img-3.8.0-35-generic
}
menuentry 'Ubuntu, with Linux 3.8.0-35-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod gzio
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 598ab3d1-e1aa-4041-ba78-1de8c6762331
echo 'Loading Linux 3.8.0-35-generic ...'
linux /boot/vmlinuz-3.8.0-35-generic root=UUID=598ab3d1-e1aa-4041-ba78-1de8c6762331 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.8.0-35-generic
}
submenu "Previous Linux versions" {
menuentry 'Ubuntu, with Linux 3.8.0-29-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 598ab3d1-e1aa-4041-ba78-1de8c6762331
linux /boot/vmlinuz-3.8.0-29-generic root=UUID=598ab3d1-e1aa-4041-ba78-1de8c6762331 ro quiet splash $vt_handoff
initrd /boot/initrd.img-3.8.0-29-generic
}
menuentry 'Ubuntu, with Linux 3.8.0-29-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod gzio
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 598ab3d1-e1aa-4041-ba78-1de8c6762331
echo 'Loading Linux 3.8.0-29-generic ...'
linux /boot/vmlinuz-3.8.0-29-generic root=UUID=598ab3d1-e1aa-4041-ba78-1de8c6762331 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.8.0-29-generic
}
menuentry 'Ubuntu, with Linux 3.5.0-18-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 598ab3d1-e1aa-4041-ba78-1de8c6762331
linux /boot/vmlinuz-3.5.0-18-generic root=UUID=598ab3d1-e1aa-4041-ba78-1de8c6762331 ro quiet splash $vt_handoff
initrd /boot/initrd.img-3.5.0-18-generic
}
menuentry 'Ubuntu, with Linux 3.5.0-18-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod gzio
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 598ab3d1-e1aa-4041-ba78-1de8c6762331
echo 'Loading Linux 3.5.0-18-generic ...'
linux /boot/vmlinuz-3.5.0-18-generic root=UUID=598ab3d1-e1aa-4041-ba78-1de8c6762331 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.5.0-18-generic
}
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda4)" --class windows --class os {
insmod part_gpt
insmod ntfs
set root='(hd0,gpt4)'
search --no-floppy --fs-uuid --set=root 4A814AE3556AE075
chainloader +1
}
menuentry "Windows Recovery Environment (loader) (on /dev/sda5)" --class windows --class os {
insmod part_gpt
insmod ntfs
set root='(hd0,gpt5)'
search --no-floppy --fs-uuid --set=root 1B1666970F6A4336
drivemap -s (hd0) ${root}
chainloader +1
}
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
set timeout=10
fi
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###
### 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.
menuentry "Windows 7" {
insmod part_msdos
insmod ntfs
set root='(hd0,msdos4)'
search --no-floppy --fs-uuid --set=root 4A814AE3556AE075
chainloader +1
}
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
--------------------------------------------------------------------------------
=============================== sda2/etc/fstab: ================================
--------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#
proc /proc proc nodev,noexec,nosuid 0 0
tmpfs /tmp tmpfs optional,nodev,noexec,nosuid 0 0
# / was on /dev/sda2 during installation
UUID=598ab3d1-e1aa-4041-ba78-1de8c6762331 / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
#UUID=E138-2A7D /boot/efi vfat defaults 0 1
# swap was on /dev/sda3 during installation
UUID=03dc7be8-7682-4219-8ab0-ae5d09caa1b1 none swap sw 0 0
#/dev/sda7 none swap sw,noauto 0 0
#UUID=E138-2A7D /boot/efi vfat defaults 0 1
#UUID=E138-2A7D /boot/efi vfat defaults 0 1
UUID=E138-2A7D /boot/efi vfat defaults 0 1
--------------------------------------------------------------------------------
=================== sda2: Location of files loaded by Grub: ====================
GiB - GB File Fragment(s)
814.208938599 = 874.250190848 boot/grub/grub.cfg 1
765.658302307 = 822.119342080 boot/initrd.img-3.5.0-18-generic 1
743.588668823 = 798.422253568 boot/initrd.img-3.8.0-29-generic 2
769.143566132 = 825.861615616 boot/initrd.img-3.8.0-35-generic 1
765.462841034 = 821.909467136 boot/vmlinuz-3.5.0-18-generic 2
742.506031036 = 797.259780096 boot/vmlinuz-3.8.0-29-generic 2
769.006057739 = 825.713967104 boot/vmlinuz-3.8.0-35-generic 1
765.658302307 = 822.119342080 initrd.img 1
765.658302307 = 822.119342080 initrd.img.old 1
765.462841034 = 821.909467136 vmlinuz 2
765.462841034 = 821.909467136 vmlinuz.old 2
============================== sda4/NST/menu.lst: ==============================
--------------------------------------------------------------------------------
# NeoSmart NeoGrub Bootloader Configuration File
#
# This is the NeoGrub configuration file, and should be located at C:\NST\menu.lst
# Please see the EasyBCD Documentation for information on how to create/modify entries:
# http://neosmart.net/wiki/display/EBCD/
--------------------------------------------------------------------------------
=================== sda4: Location of files loaded by Grub: ====================
GiB - GB File Fragment(s)
?? = ?? NST/menu.lst 0
=============================== StdErr Messages: ===============================
xz: (stdin): Compressed data is corrupt
xz: (stdin): Compressed data is corrupt
Boot flag removed from the EXT4 partition. Now the next step is to get the windows partition that needs to be booted at C:\ instead of the EXT4 partition. I tried a couple of times with 'diskpart' on a windows live cd recovery environment within 'cmd'. However, at each reboot the drive letters get reassigned.
My setup from before everything went haywire
Edit:
Replaced the bootmgfw.efi file with a copy from the original OS partition. Now when booting windows 7 from rEFInd I get the following screen:
Windows failed to start. A recent hardware or software change might be the cause. To fix the problem:
1. Insert your Windows installation disc and restart your computer.
2. Choose your language settings, and click "Next."
3. Click "Repair your computer."
If you do not have this disc, contact your system administrator or computer manufacturer for assistance.
File: \EFI\Microsoft\Boot\BCD
Status: 0xc000000f
Info: An error occurred while attempting to read the boot configuration data.
EDIT 19 feb '14
Now I'm waiting for the repair to be done. It's taking half an hour now and I don't know when it will be done. For the sake of reference I will be adding the sources of the information when/if this operation will be done
You need to understand the differences between BIOS-mode (aka CSM or legacy-mode) booting and EFI-mode (aka UEFI-mode) booting. Windows ties these boot modes quite closely to the partition table type: Windows will boot in BIOS mode if and only if the disk uses the older Master Boot Record (MBR) partition table type, and in EFI mode if and only if the disk uses the newer GUID Partition Table (GPT) partition table type. Your question title implies you're using GPT, but it's not clear that your computer originally used GPT. (Most Windows 7 systems used BIOS and MBR, although some Windows 7 systems sold in late 2011 and later used EFI and GPT.) If your original installation used BIOS/MBR, you'll need to install an EFI-mode Windows boot loader. This process is described here.
If your computer originally used EFI/GPT, you may also need to re-install the boot loader; or it could be that you've overlooked some critical detail, such as a proper re-creation of the EFI System Partition (ESP), which holds EFI boot loaders.
If you need more help, try running the Boot Info Script in Linux. This will produce a file called RESULTS.txt
. Post it to a pastebin site and post the URL for the file here. That will give us more precise and detailed information about your current configuration, which may help in fixing it.
EDIT:
Your Boot Info Script output indicates that you don't have a Windows boot loader installed on your computer. You'll have to fix that to get Windows booting. In particular, because the disk uses GPT, you must install an EFI boot loader for Windows. Most pages that describe Windows boot repair assume a BIOS-based system, and so will be 100% useless to you. This page describes how to convert Windows from a BIOS-mode boot to EFI-mode boot, so something along those lines might work. There may be other pages that will help, too; or you can post on a Windows forum for help.
One more point, which you might want to deal with before trying to install a Windows boot loader: Your /dev/sda2
uses an ext4 filesystem, but is marked as being an EFI System Partition (ESP). This is incorrect and could cause problems down the line, so you should fix it. There are a number of ways to do this, depending on what partitioning software you use. For instance, in gdisk
, you should change the type code from EF00 to 8300 by using the t
option, then write the changes via the w
option. In parted
or GParted, you'd remove the "boot flag" (and in GParted apply the changes).
try grabbing a GPARTED liveCD and setting your windows partition to have the 'boot' flag. this will probably supersede your GRUB installation but at least you'll have a point to work from.
First, please follow Rod Smith instructions on changing the type of the EXT4 partition to not be an ESP, if you have not already done so.
Next, I suggest that you rewrite your protective MBR with one from gdisk
. Bootmgr
does not seem to like changes to the disk signature made by grub
to the MBR.
Essentially, run gdisk /dev/sda
, then:
x
n
; confirm... this will not affect any EFI bootloaders.w
If this doesn't work...
Also, booting into the Windows install disc will indeed reassign letters each time. No need to worry. Internally, each drive and partition is identified by a unique GUID (on top of the GPT GUIDs, usual Microsoft style to maintain consistency with MBR systems).
Let's regenerate an appropriate BCD
/dev/sda1
: call it S:) and the Windows Boot partition (/dev/sda3
:
call it C:)mountvol s: /s
bcdboot C:\windows /s S: /f ALL
If disk style is GPT then Windows 7 (only 64-bit version) can boot only using UEFI boot.
To repair Windows 7 booting:
1) using some disk management tool ensure you have a EFI System partition (usual size is 100 MB in FAT32 format) and a Microsoft Reserved (128 MB) partition.
EFI System partition is where boot files are placed. You can use "diskpart" on recovery console to check partitions:
C:\Windows\system32>diskpart
Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: MTNB
DISKPART> sel disk 0
Disk 0 is now the selected disk.
DISKPART> list vol
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 I DVD-ROM 0 B No Media
Volume 1 D TEMP NTFS Partition 50 GB Healthy
Volume 2 RAW Partition 18 GB Healthy
Volume 3 E DATA NTFS Partition 100 GB Healthy
Volume 4 F W8 NTFS Partition 80 GB Healthy
Volume 5 C W7 NTFS Partition 80 GB Healthy Boot
Volume 6 G VHD NTFS Partition 60 GB Healthy
Volume 7 H W81 NTFS Partition 60 GB Healthy
Volume 8 J W81_src NTFS Partition 5368 MB Healthy
Volume 9 R Recovery NTFS Partition 300 MB Healthy Hidden
Volume 10 EFI SYSTEM FAT32 Partition 100 MB Healthy System
You must ensure also there is a 128 MB Microsoft Reserved Partition on disk !
DISKPART> lis par
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Recovery 300 MB 1024 KB
Partition 2 System 100 MB 301 MB
Partition 3 Reserved 128 MB 401 MB
Partition 4 Primary 50 GB 529 MB
Partition 5 Primary 18 GB 60 GB
Partition 6 Unknown 2048 MB 78 GB
Partition 7 Primary 100 GB 80 GB
Partition 8 Primary 80 GB 180 GB
Partition 9 Primary 80 GB 260 GB
Partition 10 Primary 60 GB 340 GB
Partition 11 Primary 60 GB 400 GB
Partition 12 Primary 5368 MB 460 GB
Here Partition 3 is Microsoft Reserved partition.
If you don't have a Recovery partition in the beginning of disk EFI System partition should be first, followed by 128 MB Microsoft Reserved partition.
2) mountvol s: /s (mounts EFI System partition to drive letter s:)
3) Using bcdboot from recovery CD/USB:
bcdboot Y:\windows /s s: where Y: is Windows 7 drive.
There are NO BOOT SECTORS involved during EFI boot (no MBR, no PBR/VBR) but you could rewrite MBR using "bootsect":
bootsect /nt60 ALL /force /mbr
Link to Microsoft where you can see how to use diskpart for creating UEFI partitions.
Repair Windows BCD with explanations for UEFI.
Hope this helps.
User contributions licensed under CC BY-SA 3.0