reinstall/reconfigure GRUB for a new OS

Help with issues regarding installation of Debian

reinstall/reconfigure GRUB for a new OS

Postby mzimmers » 2017-04-04 22:57

Hi -

I have a system with two drives. One boots Jessie and the other Windows 7. Something happened to the Windows 7 drive, so I cleaned it and reinstalled. I also took advantage of the opportunity to format the drive for UEFI.

The Windows install is good, and when I disconnect my Debian disk, it boots and runs fine. Whatever entry i have in my GRUB is no longer valid, though, as when both disks are connected, I get an error when I try to boot to Windows.

When I run os-prober, nothing visible happens (I just get a prompt back). When I run fdisk -l, I get this:

Code: Select all
root@debian:/etc/grub.d# fdisk -l

Disk /dev/sdb: 59.6 GiB, 64023257088 bytes, 125045424 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa6955aaf

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sdb1  *         2048 119883775 119881728 57.2G 83 Linux
/dev/sdb2       119885822 125044735   5158914  2.5G  5 Extended
/dev/sdb5       119885824 125044735   5158912  2.5G 82 Linux swap / Solaris

Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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: gpt
Disk identifier: 582D05DC-E7BC-4C6B-8C5A-BBD9DD3DAEA3

Device         Start       End   Sectors  Size Type
/dev/sda1       2048    206847    204800  100M EFI System
/dev/sda2     206848    239615     32768   16M Microsoft reserved
/dev/sda3     239616 467836927 467597312  223G Microsoft basic data
/dev/sda4  467836928 468860927   1024000  500M Windows recovery environment


When I run update-grub, I get this:
Code: Select all
root@debian:/etc/grub.d# update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-3.16.0-4-amd64
Found initrd image: /boot/initrd.img-3.16.0-4-amd64
done
root@debian:/etc/grub.d#


So, to my freshman eyes, it seems like it can't "see" the Windows disk. I have no trouble opening it from the desktop, though.
Is this enough information for someone to tell me what I need to do to get GRUB working again? Thanks.
mzimmers
 
Posts: 73
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

Postby 4D696B65 » 2017-04-05 00:21

mzimmers wrote: I also took advantage of the opportunity to format the drive for UEFI.

Did you replace grub with grub-efi?

https://packages.debian.org/jessie/grub-efi-amd64
User avatar
4D696B65
 
Posts: 1961
Joined: 2009-06-28 06:09

Re: reinstall/reconfigure GRUB for a new OS

Postby mzimmers » 2017-04-05 00:26

Ah...I thought that the GRUB I'd installed a few months ago (on my Debian disk) was already UEFI-prepared, and that my Debian disk was formatted for UEFI. If this was a bad assumption, I may have begun painting myself into a corner. How can I verify or refute these assumptions?
UPDATE:
I just ran disk, and while it doesn't explicitly say anything about UEFI or BIOS, it says the partitioning is "Master Boot Record." Does this imply that the Debian disk is formatted for BIOS? If so, I've got some cleaning up to do. Would it be appropriate to:
1. remove GRUB
2. tar my Debian disk onto a flash drive
3. reformat my Debian disk
4. restore from the tar I made
5. install the correct version of GRUB
mzimmers
 
Posts: 73
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

Postby phenest » 2017-04-05 13:51

If the disk has an MBR (Master Boot Record), then it is not UEFI. There may not be any need to reinstall Debian though. When you installed Windows 7, it created an ESP (EFI System Partition). The ESP can be shared amongst OS's, so you could use the Debian Rescue mode on the installation media to fix this. Or, shrink the space down on the Debian disk to create 100MB space for a new ESP, and use Rescue mode.
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

Postby mzimmers » 2017-04-05 14:06

Thank you for the reply, phenest. I'm not sure I understand your answer, though. I just looked up the details on rescue mode, and I don't understand how this is going to address my particular problem. As the system currently sits, GRUB does find (and boot) Debian. I believe it's not finding Windows because of its disk format, but I'd prefer to reformat my Debian disk to match the Windows disk, rather than the other way around. Does this not seem like a good idea to you? What's your opinion of my idea I posted earlier?

Thanks again.
mzimmers
 
Posts: 73
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

Postby phenest » 2017-04-05 16:53

mzimmers wrote:I believe it's not finding Windows because of its disk format

Correct. Debian, which you have installed as Legacy (MBR), will not detect another OS that was installed via UEFI.
mzimmers wrote:but I'd prefer to reformat my Debian disk to match the Windows disk, rather than the other way around. Does this not seem like a good idea to you?

This is the bit I was trying to explain. there is no need to reinstall Debian to fix this. Any OS that was installed via UEFI requires an ESP (EFI System Partition). Your disc with Windows 7 should now have one. To Boot Debian via UEFI, it will also need one. Fortunately, ESP's are the same format regardless of OS. Therefore Debian can share the ESP on the disc with Windows on it. You can use the Rescue mode to tell it that you want to use the ESP on the other disk and then install GRUB via UEFI on the Debian disc. You can have a separate ESP on the Debian disc if you prefer, you will just need to create a space of 100MB for the ESP, and then you Rescue mode as already described.

It is interesting to note that you installed Windows 7 via UEFI, but can still boot Debian via MBR.
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

Postby mzimmers » 2017-04-05 17:35

phenest wrote:...You can use the Rescue mode to tell it that you want to use the ESP on the other disk and then install GRUB via UEFI on the Debian disc. You can have a separate ESP on the Debian disc if you prefer, you will just need to create a space of 100MB for the ESP, and then you Rescue mode as already described.


OK, I think I understand this in concept. A few questions, please.

  • When I googled, I found entries for GRUB rescue and Debian rescue. You're talking about GRUB, right?
  • Can I do this from my existing system, or do I need to create an installation flash drive?
  • What is the specific command from the GRUB console? I couldn't determine this from https://www.gnu.org/software/grub/manual/grub.html
  • I believe the partition on my Windows disk to use is the first one: /dev/sda1, (SYSTEM), 105MB, EFI. Correct?
  • At what point should I remove my existing GRUB installation?

Thanks for all the help.
mzimmers
 
Posts: 73
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

Postby phenest » 2017-04-05 18:17

mzimmers wrote:OK, I think I understand this in concept. A few questions, please.

Fire away.
mzimmers wrote:
  • When I googled, I found entries for GRUB rescue and Debian rescue. You're talking about GRUB, right?

No. Boot the CD ISO that you used to install Debian. You will be offered Advanced options > Rescue mode in the boot menu.
mzimmers wrote:
  • Can I do this from my existing system, or do I need to create an installation flash drive?

  • Your existing system will be left intact. No other media necessary, apart from installation CD.
    mzimmers wrote:
  • What is the specific command from the GRUB console? I couldn't determine this from https://www.gnu.org/software/grub/manual/grub.html

  • None. Rescue mode allows you to do specific tasks rather than a normal installation.
    mzimmers wrote:
  • I believe the partition on my Windows disk to use is the first one: /dev/sda1, (SYSTEM), 105MB, EFI. Correct?

  • That's correct. I believe the ESP must always be the first partition on a hard drive.
    mzimmers wrote:
  • At what point should I remove my existing GRUB installation?

  • You will install GRUB as UEFI and not MBR. There is no need to remove anything.

    If all has gone to plan, you can then boot your Debian disc in UEFI mode, and it should detect the Windows OS.

    EDIT: Please note that backing up all your data should be done first. Just in case it goes horribly wrong. I'm not trying to scare you as it should go well, but better to be safe than sorry.
    NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
    ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
    User avatar
    phenest
     
    Posts: 1571
    Joined: 2010-03-09 09:38
    Location: The Matrix

    Re: reinstall/reconfigure GRUB for a new OS

    Postby mzimmers » 2017-04-05 19:02

    OK, thanks, phenest. I'll give this a try and report back. As far as backing up my current system, can I just do a tar -xvf onto a flash drive? Both the installation drive and the flash drive are 64MB.

    I'll have to build an installation disk first; I didn't use one to install Debian.
    mzimmers
     
    Posts: 73
    Joined: 2016-12-11 23:49

    Re: reinstall/reconfigure GRUB for a new OS

    Postby phenest » 2017-04-05 19:16

    You mean 64GB?

    If the flash drive is the same size, I'd be inclined to use dd to back it up, as it's going to be temporary.
    Code: Select all
    dd if=dev/sda of=/dev/flash_drive

    That would be quicker than waiting for tar to compress the data.

    And remember, if at any point you feel you just want to reinstall instead, nothing will be learnt. I'm keen to know the outcome myself.
    NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
    ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
    User avatar
    phenest
     
    Posts: 1571
    Joined: 2010-03-09 09:38
    Location: The Matrix

    Re: reinstall/reconfigure GRUB for a new OS

    Postby mzimmers » 2017-04-05 19:22

    phenest wrote:You mean 64GB?

    Oops...yeah. I'm old enough to remember when we measured memory by the K and disks by the M, so sometimes I suffer from scale confusion.

    If the flash drive is the same size, I'd be inclined to use dd to back it up, as it's going to be temporary.
    Code: Select all
    dd if=dev/sda of=/dev/flash_drive

    That would be quicker than waiting for tar to compress the data.

    And remember, if at any point you feel you just want to reinstall instead, nothing will be learnt. I'm keen to know the outcome myself.


    I'm eager to learn more about all of this myself. It still seems a little weird to me that my system will have two disks with different formatting, but at this point, if it works, it works. And, there's merit to using my Windows disk to hold that information anyway; it's newer and bigger and likely will be employed longer.

    I'm still jigdo-ing the files needed for my ISO disk; I'll report back when I have something. Thanks...
    mzimmers
     
    Posts: 73
    Joined: 2016-12-11 23:49

    Re: reinstall/reconfigure GRUB for a new OS

    Postby phenest » 2017-04-05 19:59

    When you're ready:

    1. Boot the installation ISO into Rescue mode.
    2. Start a root shell into /dev/sda2 (or whatever your root partition is)
    3.
    Code: Select all
    mount /dev/sdb1 /boot/efi
    apt-get install --reinstall grub-efi
    grub-install /dev/sdb
    update-grub
    exit

    4. Reboot system

    I did all this with a VM and it worked perfectly. This is all possible because Windows is using GPT rather than MBR (DOS). If you wanted the ESP on the Debian disc, you would most likely have to reinstall.

    Source of information: https://wiki.debian.org/GrubEFIReinstall
    NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
    ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
    User avatar
    phenest
     
    Posts: 1571
    Joined: 2010-03-09 09:38
    Location: The Matrix

    Re: reinstall/reconfigure GRUB for a new OS

    Postby mzimmers » 2017-04-05 20:07

    Well, I just hit a snag -- evidently my system doesn't like my DVDs (something about a "power calibration error"). Should I run out and get some new ones, or can I just copy the ISO file onto a flash drive and boot from that?
    mzimmers
     
    Posts: 73
    Joined: 2016-12-11 23:49

    Re: reinstall/reconfigure GRUB for a new OS

    Postby phenest » 2017-04-05 20:14

    If your computer can boot from a flash drive, then yes.
    NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
    ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
    User avatar
    phenest
     
    Posts: 1571
    Joined: 2010-03-09 09:38
    Location: The Matrix

    Re: reinstall/reconfigure GRUB for a new OS

    Postby mzimmers » 2017-04-05 20:32

    I copied the ISO and tried booting off it, but it didn't work - just took me to the GRUB menu. I guess I'll head out and get some DVDs, though I don't know why mine didn't work. I'll report back in a bit.
    mzimmers
     
    Posts: 73
    Joined: 2016-12-11 23:49

    Next

    Return to Installation

    Who is online

    Users browsing this forum: No registered users and 10 guests

    fashionable