Linux install apparently destroyed my Windows MBR or Boot partition (Win7 on a separate hard drive)
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Copy and paste the command in post 31 above by JSB. I've never used the nano text editor so can't help with that. If you don't understand it, you can use the vi text editor by copying and entering the command below.
When the sources.list opens, put your computer mouse aside, you won't need it.
Hit the i key on the keyboard,
use the arrow keys on the keyboard to go to the beginning of the line you want to comment out and enter the hash mark (# ) and hit the Del key.
Use the arrow keys on the keyboard to go to the beginning of the other lines listed in post 25 above and remove the hash mark.
When you finish, hit the Esc key in the upper left of the keyboard, enter a colon ( : ),
then hit the w and q keys consecutively and hit Enter and that should edit and save the changes.
Thank you, Yancek. When I executed the (sudo nano....) I didn't know what I was looking at, and the instructions to uncomment all of the comment lines so they would try to be executed didn't make sense to me, plus some the comments sounded scary. I didn't know how to get out of it, so I finally hit the red x to close the terminal.
Now when I try to execute the "sudo vi..." that you sent me (with instructions that I understood better, thanks), I am told that a previous editing of that file (source.list) crashed (from my closing the terminal, no doubt, since I had no idea how to get out of it).
What should I do to fix this ? (Seems like everything I try to do requires hours of trying to learn to do something else before I get there). Do I just reiterate the "sudo nano..." instruction and then close that some other way so it doesn't think it crashed? I think I can probably do the editing in the "sudo nano..." now that I know more what to do, but surely I'm not really supposed to uncomment ALL of the comments??
The only thing that really makes sense to me would be to deactivate the lines (# ) the lines starting with "deb-cdrom", and activate those starting with "# deb-src"
sudo nano /etc/apt/sources.list
or
sudo vi /etc/apt/sources.list
I should ADD a # to the beginning of this line:
deb cdrom:[Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731)]/ focal main rest>
I should REMOVE the # from EVERY line that begins with:
# deb-src ...
What should I do with these three lines ? Leave them as they are?
Or ADD a # to the first two and REMOVE the # from the last one? I don't know what these do, but think I should do the latter (reverse the #s)? Which should I do?
What is the difference between # and ##?
My guess #=don't execute, ##=don't execute - comment for programmer?
And, no, I haven't read the cmd line editing instructions yet - I would have done by now, but I HAVE to get window up and running again before I take time to do ANYthing else.
Thank you to each one of you trying to help me do that - I'm grateful, -Anne
.
Last edited by AnneF; 01-04-2021 at 07:58 PM.
Reason: correction
If you use nano to edit this/any file, in the bottom left corner is the an up arrowX exit. To exit the file you hold ctrl and press X. There follows a few questions yes you want to save the file and the name doesn't change (accept the defaults).
In your file I'll mark every change in red.
If you follow this suggestion you should insert 1 and remove 6 # marks, plus 6 spaces.
Quote:
Originally Posted by AnneF
Code:
GNU nano 4.8 /etc/apt/sources.list
# deb cdrom:[Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731)]/ focal main rest>
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ focal restricted main universe
deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe >
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu focal partner
deb http://security.ubuntu.com/ubuntu focal-security restricted main universe
deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb-src http://security.ubuntu.com/ubuntu focal-security multiverse
# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.
then save your work by holding ctrl and pressing x and enter a few times (to accept the defaults).
Last edited by quickbreakfast; 01-05-2021 at 01:15 PM.
Reason: removed the unsupported repo's
am told that a previous editing of that file (source.list) crashed (from my closing the terminal
Yes, done that. What happens then is another file is created with a 'crash' like that, and the file will have been created with that same name (sources.list.swp) with the .swp extension (might be swap?). Open your terminal and type: [
Code:
sudo su
This will allow you to run the commands with root privileges, type in your user password when prompted. Change to that directory with the following command"
Code:
cd /etc/apt/
Then when you are in that directory, run the following command to see the files there (that's a lower case Letter L in the command).
Quote:
ls
If you see a file with the name sources.list with a .swp extension. When you run the command 'ls' it should show both the sources.list and sources.list.swp. Delete the one with the swp extension with the following command:
Code:
rm sources.list.swp
Type carefully and get the name correct so you don't delete the wrong file. You should then be able to open sources.list with either nano or vi. If you don't see the sources.list.swp file then it is another problem but this is pretty common.
If you decide to use nano, you might look for a tutorial, can't help you there. Closing it is shown in post 48 above.
Let see if we can get windows to boot,
at the grub menu press c for a prompt ****
Code:
grub> ntldr (hd0,1)/bootmgr
grub> boot
(hd0,1) is first drive first partition, if windows doesn't boot change the 1 to 2,3 or 4.
If it still doesn't work change to (hd2,3)
in grub drives count from zero, partitions from 1
**** I'm not seeing a grub menu come up during boot. I seem to remember that I did, when I first installed, and actually booted windows once from it. But then I believe I reinstalled Ubuntu because I wanted the partitions to be different, and after that Windows was lost to me - I think the linux install overwrote my Windows boot section.
Just to be sure we're on the same page - double-check the disk designations in the instructions. I'm not sure which disk we're supposed to be using, but I'm positive the assignments above and below are correct in Linux (just not positive which is Disk1 or Disk2 in windows).
sda Windows is on sda (Disk 0)
sdb Linux is on sdb (Disk 1 or 2)
sdc Uninvolved 1T HDD is on sdc (Disk 1 or 2)
sda1 Fat32 flagged as boot, esp
sda2 Reserved by Windows
sda3 Win7 ntfs system partition
sda4 Win7 ntfs data partition
Also, I have gparted installed in Ubuntu now, that's where I double-checked my disk information.
Windows is on a Hitachi 500gb HDD, which is disk 0 in windows and sba in Linux. Linux Ubuntu is on a WD 500gb disk, which is sdb in Linux (I'm not sure if it is disk1 or disk2 in Windows - I'd have to look at the BIOS again).
What I have on the WD 1TB disk (sdc) is completely unrelated to this issue.
I have booted directly from the windows disk (sda) (but it won't boot now).
I have booted directly from the linux disk (sdb), but I'm not seeing grub, it just boots right into Linux.
Do you still want me to do what is outlined above, or was that to see if I was booting wrong.
My boot order right now is:
Thumbdrive
DVD
---------------------------------I have switched these last two and the only change was, with Win above Linux, it tried to boot windows and showed
----------------------------------a progress bar, saying loading windows files, but then the screen blacks and Linux loads,
Linux
Windows
However, the Lenovo initial bootup always offers me a choice of disks, usb, or cd to boot from if I press F10. The problem is that, since the Ubuntu 20.04 install, Windows will not boot at all (even tho it apparently tries to "read Windows files" - it will no longer boot into Win7. Linux did something bad to the Windows boot loader.
.
Last edited by AnneF; 01-04-2021 at 07:10 PM.
Reason: correction
Yes, done that. What happens then is another file is created with a 'crash' like that, and the file will have been created with that same name (sources.list.swp) with the .swp extension (might be swap?).
Code:
rm sources.list.swp
Type carefully and get the name correct so you don't delete the wrong file. You should then be able to open sources.list with either nano or vi. If you decide to use nano, you might look for a tutorial, can't help you there. Closing it is shown in post 48 above.
Got it. Did it. THANK YOU. The additional file was named sources.list.save, so I removed that. I haven't tried it yet because I don't know how to get OUT of sudo (the sudo su put me into a "sudo mode" or something, didn't it? How do I get out of it?
I haven't tried it yet because I don't know how to get OUT of sudo (the sudo su put me into a "sudo mode" or something, didn't it? How do I get out of it?
If you use nano to edit this/any file, in the bottom left corner is the an up arrowX exit. To exit the file you hold ctrl and press X. There follows a few questions yes you want to save the file and the name doesn't change (accept the defaults).
If you follow this suggestion you should insert 1 and remove 10 # marks, plus 10 spaces, then save your work by holding ctrl and pressing x and enter a few times (to accept the defaults).
Hi quickbreakfast. Thanks for this. The red didn't come thru, but I understand it. Except for one line, quoted above. Should I remove the "# " from that line also, since it starts with "deb-src"?
Thank you again - I can do this. I guess it will have to be tomorrow though.
Last edited by AnneF; 01-04-2021 at 07:49 PM.
Reason: removed unnecessary information
I haven't tried it yet because I don't know how to get OUT of sudo
Use the default user name, if your user on the computer is anne type: su anne, hit the Enter key. You could also just close the terminal window in the standard manner, click on the x in the upper right of the window. Or as pointed out above, type exit and hit Enter.
**** I'm not seeing a grub menu come up during boot. I seem to remember that I did, when I first installed, and actually booted windows once from it. But then I believe I reinstalled Ubuntu because I wanted the partitions to be different, and after that Windows was lost to me - I think the linux install overwrote my Windows boot section.
Which suggests to me that with the first ubuntu install you didn't instruct the electronic marvel to write anything to the MBR, but you did during the second ubuntu install. (or vice versa)
How you fix the MBR of windoze is well beyond my pay scale. But I suggest you beg or borrow a windows7 and see if there is a resuce choice at boot.
Quote:
Also, I have gparted installed in Ubuntu now, that's where I double-checked my disk information.
Interesting. Did you install it, or find it?
If you installed it then you are now connected to a mirror and should be able to update your system. To check type.
Code:
sudo apt update
sudo apt upgrade
Quote:
---------------------------------I have switched these last two and the only change was, with Win above Linux, it tried to boot windows and showed
----------------------------------a progress bar, saying loading windows files, but then the screen blacks and Linux loads,
Linux
Windows
Have you returned the cables back to their original configuration? If so what happened?
Quote:
The problem is that, since the Ubuntu 20.04 install, Windows will not boot at all (even tho it apparently tries to "read Windows files" - it will no longer boot into Win7.
.
My guess is that the MBR of the windoze disc is now instructing your electronic marvel to look for a linux format/OS to boot, not a windoze format/OS, so boots ubuntu when it finds what the MBR has been instructed the electronic marvel to find.
Yesterday, I suggested that you type
Code:
sudo update-grub
So that you'll have the choice of OS, when booting from the ubuntu HDD (if of course grub finds your windows HDD).
In the roughly 24 hours since I made this suggestion, no body has corrected, or advised you against the suggestion.
By the way, I have amended my post suggesting removing the # mark against some mirrors. The mirrors which say they are unsupported should remain unchanged. Because you don't, at this stage, want to install unsupported software.
Last edited by quickbreakfast; 01-05-2021 at 04:03 PM.
Reason: removed a link
Originally Posted by Now follow the instructions at this site to repair the MBR (or google and pick a random site that explains how to fix the windows 7 MBR using a windows cd).
If you dont know the windows product key its normally on the laptop somewhere, so have a look for the genuine windows sticker with a bunch of letters and numbers on it.
Hopefully that is helpful, if not I apologise and maybe someone else can help you.
Thank you - that sounds really good.
I have a backup of my data.
I have TrueImage partition backups.
I have the Win7 disk I was given with the machine.
I have my Product Key.
I went to the site to download a copy of Windows7, but when I entered the product key, it told me that it was for a pre-installed version and I couldn't download it.
I have a boxed, separately purchased XP disk. Could I boot from that and restore the MBR? No, probably not, because when I tried that with the win7 I have, it said it wasn't the right disk. I'm exhausted. Linux should have made a backup of my MBR before it clobbered it, so it could be restored. Was Linux programmed to do this on purpose to retaliate against M$? Can I get Linux to boot windows for me - what would I have to do to get Linux to boot Windows?
Should I just give up? I hate to have to buy a new computer just because I wanted to try Linux, but I have to get to my work software, which is Windows.
Thank you all for trying to help. I was extremely frustrated; now I have become very depressed, and so, so sorry that I started this. I appreciate all your efforts, but eveything I try just runs into a brick wall, This is, I think, about three weeks I've been struggling with this. Even Firefox is screwed up in my Linux install and my email sites aren't displaying/working right.
I think there are suggestions I haven't done, because one thing always led to a prerequisite, & when I tried to do that, there was something else I needed to learn and do before I could do the prerequisite - and I kinda got lost and so far afield from what I needed to do, that I lost track of what I needed to do next.
I'm grateful for all of you who tried to help me with this, but I think it's hopeless - I feel sick. -Anne
.
Which suggests to me that with the first ubuntu install you didn't instruct the electronic marvel to write anything to the MBR, but you did during the second ubuntu install. (or vice versa)
How you fix the MBR of windoze is well beyond my pay scale. But I suggest you beg or borrow a windows7 and see if there is a resuce choice at boot.
Interesting. Did you install it, or find it?
-------------------------I FOUND WIN7 DISK-----------
------------------------I INSTALLED GPARTED--------
If you installed it then you are now connected to a mirror and should be able to update your system. To check type.
Code:
sudo apt update
sudo apt upgrade
----------------- I THINK I STILL HAVE TO EDIT SOURCE.LIST FIRST ---------------------
Have you returned the cables back to their original configuration? If so what happened?
-----------------I HAVEN'T RECABLED ANYTHING,
-----------------I JUST REARRANGED THE BOOT ORDER
My guess is that the MBR of the windoze disc is now instructing your electronic marvel to look for a linux format/OS to boot, not a windoze format/OS, so boots ubuntu when it finds what the MBR has been instructed the electronic marvel to find.
Yesterday, I suggested that you type
Code:
sudo update-grub
So that you'll have the choice of OS, when booting from the ubuntu HDD (if of course grub finds your windows HDD).
-----------------------------I WILL DO THIS AFTER I EDIT SOURCE.LIST-------------
In the roughly 24 hours since I made this suggestion, no body has corrected, or advised you against the suggestion.
By the way, I have amended my post suggesting removing the # mark against some mirrors. The mirrors which say they are unsupported should remain unchanged. Because you don't, at this stage, want to install unsupported software.
--------------------------------OKAY, I'LL GO BACK AND READ THAT POST AGAINBEFORE I EDIT SOURCE.LIST---------
I just found this post. I got mixed up and lost. I will try this, if I can, tomorrow (or if I'm not able to, then Thursday). I guess I can't give up till I've tried everything. I never got back to edit the source.list file, or got through all the pre-steps to run something that was supposed to show what the MBR looked like. I will see if I can trace everything back & do it all. I just got so lost and confused with so many different things to try. But I'll get it done before I give up. Thank you, --Anne
.
Sources.list does need to be fixed so you can keep you system updated and to be able to install additional software, but has nothing to do with your windows boot problem.
Try this to see if windows will boot:
When you first turn on the computer after the bios post you should see a grub menu. If you don't see a grub menu when you turn on the computer hold down the Shift key while grub is loading to get the grub boot menu.
at the grub menu press c for a grub prompt:grub>
and enter the following:
Code:
grub> ntldr (hd0,1)/bootmgr
grub> boot
(hd0,1) is first drive first partition, if windows doesn't boot change the 1 to 2,3 or 4.
If it still doesn't work change to (hd2,3)
grub counts drives from zero, partitions from 1
A usb key plugged into the system will sometimes throw off the grub drive count.
Last edited by colorpurple21859; 01-05-2021 at 09:10 PM.
I'm not sure why you are messing with the sources.list file. As pointed out above, that has nothing to do with your ability to boot windows from Grub in Ubuntu. In post 36, I explained how you could determine if windows 7 and was installed UEFI. It would be extremely unusual (although possible) for windows 7 to be UEFI. Entering the commands given in post 36 would tell us this. If you don't have a folder named Microsoft on that partition then windows 7 is not UEFI. If you have a folder named ubuntu, then Ubuntu is UEFI and you need to reinstall Ubuntu in Legacy mode.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.