How do I repair my grub file (dual boot)?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
arebek
Level 1
Level 1
Posts: 15
Joined: Thu Feb 19, 2015 5:46 pm

How do I repair my grub file (dual boot)?

Postby arebek » Wed Nov 08, 2017 1:44 pm

I have a dual boot with Windows 8.1 and Linux Mint 17.

However, I did some kind of "special fresh update reset" in Windows (mistake!) and it wrote over my grub file, so now when I turn on my computer, it goes automatically into Windows.

I plugged a live linux mint USB stick into my computer, and was relieved to see all my linux files are still there in the partition. However, is there a way to repair the grub file so that I can go into my linux partition without using the USB stick?

User avatar
WharfRat
Level 19
Level 19
Posts: 9956
Joined: Thu Apr 07, 2011 8:15 pm

Re: How do I repair my grub file (dual boot)?

Postby WharfRat » Wed Nov 08, 2017 2:09 pm

arebek,

Good instructions can be found here by a forum member.

Good luck :wink:
Image ImageImage

arebek
Level 1
Level 1
Posts: 15
Joined: Thu Feb 19, 2015 5:46 pm

Re: How do I repair my grub file (dual boot)?

Postby arebek » Wed Nov 08, 2017 8:18 pm

I looked at my partitions in gparted and guessed that my "efi" partition was (just like the tutorial's) "sda2". However, when I tried to mount it with the command "sudo mount /dev/sda2 /mnt/boot/efi"

It wouldn't work. It kept saying that there was no location "/mnt/boot/efi"

So I guess that even though I got my laptop with Windows 8 back in 2014, it was the super cheapest bottom of the line, so probably I had a traditional BIOS. So I tried his other tutorial here: https://sites.google.com/site/easylinux ... TOC-How-to

I had to mount the linux sda partition, unfortunately, I had 3 partitions (sda6, sda7, sda9) that were all EXT4. They were 477 mb, 55.88 gb, and 153 gb respectively. None of them had flags (there was a partition called 'sda8 linux swap' but I left that one alone).

So I mounted the biggest one first (sda9) and that command was fine, but when I tried "sudo grub-install /dev/sda --root-directory=/mnt" it kept spitting out the error:

grub-probe error: failed to get canonical path of '/cow'.
installing for i386 platform.
grub-install.real: warning: this GPT partition label contains no BIOS boot partition; embedding won't be possible.
grub-install.real: 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..
grub-install.real: error: will not proceed with blocklists.

So I figured that maybe I had picked the wrong EXT4 partition. I tried this method (both mounting and running the sudo grub install command) with sda7 and sda9 as well. I got the exact same error every time:


grub-probe error: failed to get canonical path of '/cow'.
installing for i386 platform.
grub-install.real: warning: this GPT partition label contains no BIOS boot partition; embedding won't be possible.
grub-install.real: 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..
grub-install.real: error: will not proceed with blocklists.

It mounted the Linux sda partition just fine
but it kept spitting out the error

I rebooted it and removed my live usb, and sure enough, it just went directly to windows as usual.

is it not bios? Should try the EFI method again---is there something i am missing there?

User avatar
WharfRat
Level 19
Level 19
Posts: 9956
Joined: Thu Apr 07, 2011 8:15 pm

Re: How do I repair my grub file (dual boot)?

Postby WharfRat » Wed Nov 08, 2017 9:09 pm

Your situation seems eerily similar to this one viewtopic.php?f=46&t=256013

Unfortunately it was never resolved :?

Can you paste back sudo gdisk -l /dev/sda and sudo blkid
Image ImageImage

lmintnewb2

Re: How do I repair my grub file (dual boot)?

Postby lmintnewb2 » Thu Nov 09, 2017 1:04 am

NOTE: Read the whole post before taking any action: AND the whole thread linked too.

Could check that out. Note: It covers grub2 uefi/gpt and for bios/mbr too. Though do pay attention to which applies to your system. You've indicated it is uefi/gpt with an ESP = Efi system partition on it. So follow that one up. Some distro's have a boot from disk option built right into the iso. Which I believe is a dang good and handy. As I go on to say in that thread. Username over thataway is BLizgreat!

If you want to be extra cautious you can go ahead and post a screen-shot of how your hard drive and partitions are laid out. Even the simple output of "df -h" could give folks a clue about which Nix partitions and mounted where.

It wouldn't work. It kept saying that there was no location "/mnt/boot/efi"


Just a for-your-info thing, reason it was saying that is there is no mount point of such a name. You'd have to create it, to mount stuff there. ie: "sudo mkdir /mnt/boot/efi". Don't do it, just know it kay ?

Finally absolutely window$ (many versions) are known to do this type of thing to grub when it's updated. Micro$oft says it's for security. Oh yeah ... we have our bootloader wipe out any other OS's bootloader so we can be sure nothing nefarious is going on, on that users system ... wink, wink. ;)

What I think they really mean is, ahhhhh ... someone else trying to use an alternative ( and better open source operating system) has been detected. Thus we design our's to check for this occasionally and if find any encroaching on our pc monopoly we make sure it borks their bootloader and then they have to reinstall it !

Also you may not even have to reinstall grub, it's likely still in the ESP, where it's supposed to be. You could use boot from disk, as per that link and while in Mint use efibootmgr (should come with Mint out-of-box) to wrestle control of which bootloader you want to use back from M$'s boot-manager. Window$ probably just took back control of the ESP and decided ah grub2, how you doing ... I won't be recognizing or booting Linux Mint ! :D

lmintnewb2

Re: How do I repair my grub file (dual boot)?

Postby lmintnewb2 » Thu Nov 09, 2017 1:51 am

Warning M$ rant follows: But hey do feel it's relevant ...

This type of thing is but one of gazillion sleazetastic and scumbaggy ways M$ hassles and tries to discourage people from enjoying/using Mint( everything gnu/Linux) Personally feel they should be sued for it, xyz-computer owner decides to install Mint, wants grub2 to handle the boot process, to be the systems bootloader. Grub2 happily detects and boots window$ no problem. However M$ designs there's to not return the favor and often wipe grub2 out and take back control of the boot.

In doing this, they override the pc owners choice and cost them however much time and headache's fixing this situation that M$ maliciously has imposed on them. If you added up how many HOURS per year nixers waste having to deal with this, esp people new to gnu/Linux, someone who doesn't bother learning what they're doing and does something ignorant possibly messing up one or more OS's on their pc and having to reinstall etc. Possibly losing data that's important to them in the process or whatever too.

I mean put a monetary value on something like someone's only video of their kid or grandkids 1st steps ? They shouldn't lose it if they use their head but if someone were to jump the gun and make an easily repairable situation into a nightmare (and didn't have the common sense to keep a backup of important stuff), they could. They shouldn't be in that situation and m$ intentionally put them there. So imo ... M$ should have to compensate them for damages.

Yet again ... one of a gazillion sleazy ways M$ is using to protect their profit margin$ and keep the world safe from better free operating systems. As mentioned, unfortunately they can't be sued for this. Because their lawyers will immediately say it's a security measure or whatever to make sure consumers systems haven't been compromised blahblahblah.

In any event, learning to use efibootmgr or reinstall grub is something that's good to know. Once you learn about it, it doesn't take very much time anyway. Every nixer will bork grub and need to reinstall or fix it @ some point. So may as well get learning it out of the way, so you'll be ready the next time window$ decides LM doesn't exist and shall not be booted on that pc.

arebek
Level 1
Level 1
Posts: 15
Joined: Thu Feb 19, 2015 5:46 pm

Re: How do I repair my grub file (dual boot)?

Postby arebek » Thu Nov 09, 2017 10:04 am

I am not sure if it is EFI or BIOS. I was just guessing. Attached is the screenshot of what the GPARTED gave me.

arebek
Level 1
Level 1
Posts: 15
Joined: Thu Feb 19, 2015 5:46 pm

Re: How do I repair my grub file (dual boot)?

Postby arebek » Thu Nov 09, 2017 10:26 am

this command

Code: Select all

sudo gdisk -l /dev/sda

yields this:

GPT fdisk (gdisk) version 1.0.1

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D1015097-00ED-48A1-B1A8-D2A9E8433948
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 3669 sectors (1.8 MiB)

Number Start (sector) End (sector) Size Code Name
1 2048 2099199 1024.0 MiB 2700 Basic data partition
2 2099200 2303999 100.0 MiB EF00 Basic data partition
3 2304000 2566143 128.0 MiB 0C01 Basic data partition
4 2566144 495513599 235.1 GiB 0700 Basic data partition
5 959287296 976771479 8.3 GiB 2700 Basic data partition
6 495513600 496490495 477.0 MiB 8300
7 496490496 613677055 55.9 GiB 8300
8 613677056 637114367 11.2 GiB 8200
9 637114368 959287295 153.6 GiB 8300

arebek
Level 1
Level 1
Posts: 15
Joined: Thu Feb 19, 2015 5:46 pm

Re: How do I repair my grub file (dual boot)?

Postby arebek » Thu Nov 09, 2017 10:27 am

and this command:

Code: Select all

sudo blkid


gives this:

/dev/sda1: LABEL="System" UUID="4C4451DD4451C9FA" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="6ba48ce0-7255-11e3-95f3-a1ed737751aa"
/dev/sda2: UUID="4653-1E2D" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="6ba48ce8-7255-11e3-95f3-a1ed737751aa"
/dev/sda3: UUID="FEFE54CDFE547FB7" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="6ba48cea-7255-11e3-95f3-a1ed737751aa"
/dev/sda4: LABEL="Windows" UUID="E2AC56D9AC56A7B5" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="6ba48cf2-7255-11e3-95f3-a1ed737751aa"
/dev/sda5: LABEL="Recovery" UUID="487696377696262A" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="a5b0b306-ca01-11e3-9fa9-008cfa9f5e41"
/dev/sda6: UUID="52399af1-e080-4555-b682-b220bd242f04" TYPE="ext4" PARTUUID="e69034b4-a093-4272-80fb-56b368d882b4"
/dev/sda7: UUID="5cdfa54c-575f-41a6-83f5-9c3ee08d37e4" TYPE="ext4" PARTUUID="78c7fdd4-8896-4d7a-87a7-55d849ca426d"
/dev/sda9: UUID="c076cd32-7e9f-48da-83bb-b7b3d334be41" TYPE="ext4" PARTUUID="bcbef691-e268-4e39-9965-51c8ebe25d75"
/dev/loop0: TYPE="squashfs"
/dev/sda8: UUID="01167711-9c37-406e-8f54-dd992288e7e9" TYPE="swap" PARTUUID="0f1af1ce-07fc-4210-aa05-e18093182aa0"
/dev/sdb1: UUID="2016-12-13-11-00-33-00" LABEL="Linux Mint 18.1 MATE 64-bit" TYPE="iso9660" PTUUID="01217391" PTTYPE="dos" PARTUUID="01217391-01"
/dev/sdb2: SEC_TYPE="msdos" UUID="B1F5-0A13" TYPE="vfat" PARTUUID="01217391-02"

arebek
Level 1
Level 1
Posts: 15
Joined: Thu Feb 19, 2015 5:46 pm

Re: How do I repair my grub file (dual boot)?

Postby arebek » Thu Nov 09, 2017 10:41 am

I don't know if this is useful or relevant information, but when I boot off of my live usb stick, I can use the File Explorer to see my old Linux files in different chunks on the left side bar, listed as "devices" to be mounted, which seem to correspond to the sda's.

The 165 gb secion had 2 folders, one called "boot" and one called my own name, which had all my personal files inside (e.g. documents, desktop, etc)
The 60 gb section had a bunch of folders with names like "bin" "boot" "cdrom" "dev" "tmp" "etc" "home" "lib" "mnt" "root" (though that had an 'X' on the folder).
And then there was a 500 mb section that had some folders named 'efi' and the like. I attached it here:
Screenshot at 2017-11-09 14-33-27.png

arebek
Level 1
Level 1
Posts: 15
Joined: Thu Feb 19, 2015 5:46 pm

Re: How do I repair my grub file (dual boot)?

Postby arebek » Thu Nov 09, 2017 10:47 am

I tried the code from the bunsenlabs link

Code: Select all

sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi

and got this:

grub-probe: error: failed to get canonical path of `/cow'.
grub-install.real: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory.

User avatar
WharfRat
Level 19
Level 19
Posts: 9956
Joined: Thu Apr 07, 2011 8:15 pm

Re: How do I repair my grub file (dual boot)?

Postby WharfRat » Thu Nov 09, 2017 11:49 am

arebek,

You provided the crucial information that's needed to unravel this mess.

You have gpt partitioning and there is an efi partition which is /dev/sda2.

However you also show three ext4 partitions /dev/sda6 7 and 9

From the live media, paste back the results of mount|grep sda to determine what's getting mounted where and to try and figure out which partition the linux resides.

Also return the results of [ -d /sys/firmware/efi ] && echo "Currently in EFI mode" || echo "Currently in Legacy mode"
Image ImageImage

lmintnewb2

Re: How do I repair my grub file (dual boot)?

Postby lmintnewb2 » Thu Nov 09, 2017 12:58 pm

Pretty much as usual ... not quite sure where the info presented got lost in translation. :) Did you do this from a live usb session or as you are supposed to while your actual Linux Mint install/OS was booted into ? Not tough to reinstall grub while in a live session either but that command you ran from the tute doesn't describe that process.

It is for when someone is actually booted, into a gnu/Linux OS that is already installed on a partition(s) on their hard drive but (once booted) for whatever reason, they need to reinstall grub to the ESP, typical path yep, should be /boot/efi. So if you did attempt to reinstall grub while in live session from a thumb-drive, then no it's not going to work.

Actually believe Hoas = Head_on_a_stick actually covers doing that in chroot in the thread too though, shrugs.

Did you use Supergrubdisk2, as outlined ... to actually boot your Mint OS on the hard drive ? *scratches head and wonders how it all went wrong. No worries ... it'll get sorted out. :D

Just to make it overly abundantly clear, the first part of that how-to I linked to covers. Times when you have a perfectly working gnu/Linux-Linux Mint OS installed ( as is the OP's case) but it's bootloader isn't working correctly due to something like a window$ update or "security feature" has decided to take back control of the boot process and as it tends to do, decide it won't bother recognizing or booting Mint. You create a Supergrubdisk2 media( or tons of others which do similar). The utility scans the hard drive on the system, finding any operating systems on it and will let you bypass the window$ boot-manager and boot any of them present on the system.

You boot the Mint install, open a terminal and run the command if your system is ESP + 64bit Linux Mint. Whamo ... grub2 is reinstalled to the ESP and given control over the boot process again, so when you reboot there it is that lovely grub menu and your option to boot Mint restored ! Yay ! In YOUR FACE M$ and window$ boot-manager !! :P

Laurent85
Level 13
Level 13
Posts: 4766
Joined: Tue May 26, 2015 10:11 am

Re: How do I repair my grub file (dual boot)?

Postby Laurent85 » Thu Nov 09, 2017 2:12 pm

Windows likely changed the EFI boot loader priority, also provide command output:

Code: Select all

[ -d /sys/firmware/efi ] && sudo efibootmgr -v

A fix might only consist in restoring efi boot priority to grub.
Image

lmintnewb2

Re: How do I repair my grub file (dual boot)?

Postby lmintnewb2 » Thu Nov 09, 2017 2:39 pm

+1 that, already mentioned it and really is the most effective and time saving way to deal with this situation. There are ways to make window$ boot-manager leave grub alone. Depending on which version of window$ varies a bit but you can tell it, grub is in charge, GOT IT ??!!! With bcdedit commands run in an admin console in the M$ OS itself. Think remember that win10 went with a new approach to it's boot-manager, can't remember so don't quote me on it. Still ways to make win10 leave grub2 alone.

At least have seen credible information to that effect from the guy mentioned below R. S. Never actually used win10, had systems which came with a free upgrade to it and chose HADES NO M$, your idea of an "upgrade" and mine are vastly different things. This old box came with win10, only stayed onboard for a couple hours before I overwrote it and had gnu/Linux installed.


Did it on win8 and 8.1 via admin console and yeppers from then onwards it left grub2 alone and let it continue handling the boot process. Have the info in a how-to file somewhere on this pc but too lazy and (google is open 24/7. :) ) <-- That is actually probably the easiest and most time saving way in fact, do it right the 1st time vs. It'll happen again and having to use efibootmgr to sort it out however many times.

Also other options like easybcd, had good experiences with it on 1 laptop. It now supposedly supports efi/gpt ... win10 etc. Then there's rEFInd which also gets left alone by such M$ scumtastic-ness. Didn't like it but the guy who maintains it is imo a uber-tech skilled guy and knows EFI and secureboot like the back of his hand. aka: Rod Smith.

Sighs ... one more edit in fact do some searches for his name +keywords ie: "Rod smith" +grub2 and similar, you'll find tons of him all over the place helping people sort out this type of thing and EFI, secureboot etc issues on their system's. Plus if diligent in those searches he'll no doubt outline much good info on this ... including getting winX-win10 to leave grub alone. Dude very clearly has skillz and generosity when comes to sharing info and helping nixers out.


Still didn't like either, they work perfectly or always have in my experience but wanted the full POWA of grub2 and all that comes with it acting as xyz-system's bootloader. Tried em both, liked them well enough but always ended up removing them and using grub2 proper.

I2k4
Level 4
Level 4
Posts: 426
Joined: Thu Feb 02, 2012 8:33 pm

Re: How do I repair my grub file (dual boot)?

Postby I2k4 » Thu Nov 09, 2017 5:36 pm

If you haven't tried Boot-repair, it's the first thing - if it doesn't work there's something more serious wrong.

https://sourceforge.net/p/boot-repair/home/Home/

I haven't experienced GRUB recognition problems recently but the simple "recommended repair" (below) worked great for some dual boot problems a few years ago. Can be installed on and run from the LIve USB.

https://help.ubuntu.com/community/Boot-Repair
TRUST BUT VERIFY any advice from anybody, including me. Ubuntu / Mint user since 10.04 LTS. M17.3 Cinnamon (Dell 1520). Dual booting M17.3 XFCE / W7 (Acer netbook) and M18.2 Cinnamon / W7 (Lenovo desktop). Testing M18.2 64bit on persistent live USB.


Return to “Newbie Questions”