Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

reinstall/reconfigure GRUB for a new OS

Ask for help with issues regarding the Installations of the Debian O/S.
Message
Author
mzimmers
Posts: 86
Joined: 2016-12-11 23:49

reinstall/reconfigure GRUB for a new OS

#1 Post by mzimmers »

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.

User avatar
4D696B65
Site admin
Site admin
Posts: 2696
Joined: 2009-06-28 06:09
Been thanked: 85 times

Re: reinstall/reconfigure GRUB for a new OS

#2 Post by 4D696B65 »

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

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#3 Post by mzimmers »

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

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

#4 Post by phenest »

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.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#5 Post by mzimmers »

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.

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

#6 Post by phenest »

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.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#7 Post by mzimmers »

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.

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

#8 Post by phenest »

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?[/list]
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.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#9 Post by mzimmers »

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.

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

#10 Post by phenest »

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.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#11 Post by mzimmers »

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...

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

#12 Post by phenest »

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
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#13 Post by mzimmers »

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?

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

#14 Post by phenest »

If your computer can boot from a flash drive, then yes.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#15 Post by mzimmers »

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.

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

#16 Post by phenest »

Code: Select all

dd if=debian.iso of=/dev/flash_disk
A common mistake is to copy the ISO to a partition. It should be copied to the root of the flash disc, i.e. /dev/sdb and not /dev/sdb1.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#17 Post by mzimmers »

phenest wrote:

Code: Select all

dd if=debian.iso of=/dev/flash_disk
A common mistake is to copy the ISO to a partition. It should be copied to the root of the flash disc, i.e. /dev/sdb and not /dev/sdb1.
OK...did the dd command and rebooted to the flash drive. Now I get a grub prompt, which I don't think is what I want. True?

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: reinstall/reconfigure GRUB for a new OS

#18 Post by phenest »

No, that's not right. But the reason is one of many.

1. Is the flash drive ok?
2. Did you download Debian successfully? MD5 sum check
3. Which ISO did you download?

I'm off to bed now.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

mzimmers
Posts: 86
Joined: 2016-12-11 23:49

Re: reinstall/reconfigure GRUB for a new OS

#19 Post by mzimmers »

OK, thanks. I'll play with it a little and report back anything of note.

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: reinstall/reconfigure GRUB for a new OS

#20 Post by sunrat »

I'm not familiar with converting MBR boot to UEFI so will leave that advice to others. I've only installed Debian in full MBR (on my old system) or full UEFI with GPT partitions on my new system. Both multi-boot fine with Windows. Just a couple of minor points:
phenest wrote:
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.
ESP does not have to be first partition. Mine is /dev/sda2.

Code: Select all

mount /dev/sdb1 /boot/efi
apt-get install --reinstall grub-efi
grub-install /dev/sdb
update-grub
exit
Your ESP is actually /dev/sda1 on the Windows disk.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

Post Reply