- Как восстановить загрузчик Windows в главной загрузочной записи (MBR) из Ubuntu
- Требования
- Загрузка в Ubuntu live USB
- Способ первый: утилита Boot Repair
- Метод второй: Syslinux
- Метод третий: LILO
- Заключение
- Восстановление загрузчика GRUB через Boot-Repair в Ubuntu
- Восстанавливаем загрузчик GRUB через Boot-Repair в Ubuntu
- Шаг 1: Установка Boot-Repair
- Шаг 2: Запуск Boot-Repair
- Шаг 3: Исправление найденных ошибок
- Restore windows bootloader with ubuntu
- 88 Comments »
- Leave a comment
Как восстановить загрузчик Windows в главной загрузочной записи (MBR) из Ubuntu
Оригинал: How to Fix Windows MBR from Ubuntu
Автор: Matthew Muller
Дата публикации: 21 августа 2018 года
Перевод: А. Кривошей
Дата перевода: март 2019 г.
Если вы пытались настроить двойную загрузку Windows с Linux, то вы, вероятно, столкнулись с некоторыми изменениями, которые могут вами не приветствоваться. При установке Linux в такой среде загрузчик GRUB перезаписывает загрузчик Windows в основной загрузочной записи (MBR).
Это также верно в обратном направлении: если вы сначала установили Linux, а затем решили установить Windows, загрузчик Windows перезапишет GRUB, и вы обнаружите, что невозможно загрузить вашу систему Linux. Или, возможно, вы решили, что Linux не для вас, и хотите полностью удалить его, оставив только Windows.
Любой из этих сценариев может быть проблематичным для нового пользователя, но, к счастью есть способы восстановить загрузчик и MBR.
Примечание. В качестве дополнительной информации, который затронет многих пользователей, похоже, что Windows 10 Anniversary Update перезаписывает загрузчик как само собой разумеющееся.
Требования
Первым шагом будет скачивание и создание вашего Linux live CD или USB. Ubuntu — безусловно, самый простой и доступный дистрибутив, хотя для наших целей могут использоваться большинство дистрибутивов Linux. Используя другой компьютер, перейдите на веб-сайт Ubuntu и загрузите версию, подходящую для вашей архитектуры. Если вы сомневаетесь, возьмите 32-битную версию, так как она будет загружаться на любой машине.
Следуйте этому руководству , чтобы создать Linux live USB в Windows.
Загрузка в Ubuntu live USB
Создав свой live-носитель, необходимо загрузить компьютер с вашего носителя с Ubuntu и выбрать в загрузочном меню пункт «Try Ubuntu without installing». Если это не удается, убедитесь, что в BIOS отключена secure boot, иначе ваша система никогда не загрузится с диска Linux.
После запуска рабочего стола вам нужно будет открыть терминал, который можно найти в меню «Приложения».
Примечание: на этом этапе имейте в виду, что вы имеете дело напрямую с жестким диском, и полностью прочитайте руководство, прежде чем вносить какие-либо изменения, в противном случае вся ваша система может стать нестабильной или неработоспособной.
Безусловно, самый простой способ восстановить MBR — использовать небольшую утилиту под названием «boot-repair», а не работать непосредственно в терминале.
Способ первый: утилита Boot Repair
Во-первых, вам нужно добавить репозиторий. Введите:
После установки найдите приложение в меню «Приложения» и кликните, чтобы запустить.
После запуска утилиты выберите тип восстановления. Для большинства случаев это будет рекомендуемое восстановление.
Когда утилита завершит работу, вы сможете загрузить свою систему и выбрать либо Windows, либо Linux из меню GRUB. Запуск утилиты также позволит вам изменить или изучить некоторые другие опции, если вам требуется более сложное восстановление загрузки. Кликнув «Restore MBR», вы сможете использовать вкладку MBR.
Если вы застряли, у Ubuntu есть руководство на их сайте.
Метод второй: Syslinux
Это немного сложнее и требует от вас работы с терминалом. Если вы не уверены, то, пожалуйста, придерживайтесь первого метода.
Откройте терминал, как и раньше, и введите:
По завершении установки введите следующую команду, не забывая изменить имя диска «sda» на свое:
Кроме того, вы можете восстановить MBR, введя:
Метод третий: LILO
Загрузитесь с live CD или USB, и в терминале введите:
где «/dev/sda» — это имя вашего диска. Это должно исправить вашу MBR.
Заключение
Если вы используете двойную загрузку Windows и Linux, очень легко перезаписать MBR. Описанные выше действия должны помочь вам восстановить MBR.
Восстановление загрузчика GRUB через Boot-Repair в Ubuntu
Достаточно частой практикой у пользователей является установка двух операционных систем рядом. Чаще всего это Windows и один из дистрибутивов, основанных на ядре Linux. Иногда при такой инсталляции возникают проблемы с работой загрузчика, то есть загрузка второй ОС не производится. Тогда его нужно восстановить собственными силами, изменив системные параметры на правильные. В рамках данной статьи мы бы хотели обсудить восстановление GRUB через утилиту Boot-Repair в Ubuntu.
Восстанавливаем загрузчик GRUB через Boot-Repair в Ubuntu
Сразу хочется отметить, что дальнейшие инструкции будут приведены на примере загрузки из LiveCD с Ubuntu. Процедура создания такого образа имеет свои нюансы и сложности. Однако разработчики операционной системы максимально детально описали эту процедуру в своей официальной документации. Поэтому мы настоятельно рекомендуем ознакомиться с ней, создать LiveCD и загрузиться с него, а уже потом переходить к выполнению руководств.
Шаг 1: Установка Boot-Repair
Рассматриваемая утилита не входит в стандартный набор инструментов ОС, поэтому ее придется установить самостоятельно, воспользовавшись пользовательским репозиторием. Все действия осуществляются через стандартный «Терминал».
- Запустите консоль любым удобным способом, например, через меню или зажатие горячей клавиши Ctrl + Alt + T.
Загрузите необходимые файлы в систему, прописав команду sudo add-apt-repository ppa:yannubuntu/boot-repair .
Ожидайте завершения загрузки всех необходимых пакетов. Для этого должно иметься активное подключение к интернету.
Обновите системные библиотеки через sudo apt-get update .
Запустите процесс инсталляции новых файлов, вписав строку sudo apt-get install -y boot-repair .
Когда вся процедура прошла успешно, можно смело переходить к запуску Boot-Repair и сканированию загрузчика на наличие ошибок.
Шаг 2: Запуск Boot-Repair
Для запуска установленной утилиты вы можете использовать иконку, которая была добавлена в меню. Однако не всегда получается работать в графической оболочке, поэтому достаточно просто ввести в терминале boot-repair .
Будет произведен процесс сканирования системы и восстановления загрузки. Во время этого не делайте ничего на компьютере, а также не завершайте принудительно функционирование инструмента.
Шаг 3: Исправление найденных ошибок
После окончания анализа системы программа сама предложит вам рекомендованный вариант восстановления загрузки. Обычно он исправляет самые часто встречающиеся проблемы. Для его запуска просто потребуется нажать на соответствующую кнопку в графическом окне.
Если вы уже сталкивались с работой Boot-Repair или прочитали официальную документацию, в разделе «Расширенные настройки» можете применить собственные параметры восстановления, чтобы обеспечить стопроцентный результат.
По окончании восстановления перед вами откроется новое меню, где будет видно адрес с сохраненными логами, а также отобразится дополнительная информация касаемо результатов исправления ошибок GRUB.
В случае когда у вас нет возможности использовать LiveCD, потребуется загрузить образ программы из официального сайта и записать его на загрузочную флешку. При ее запуске на экране сразу отобразятся инструкции, и потребуется выполнить их все, чтобы решить возникшую проблему.
Обычно с возникновением неполадок GRUB сталкиваются юзеры, которые поставили Ubuntu рядом с Windows, поэтому следующие материалы по теме создания загрузочного накопителя будут максимально полезны, советуем детально ознакомиться с ними.
В большинстве случаев применение простой утилиты Boot-Repair помогает быстро справиться с наладкой работоспособности загрузчика Ubuntu. Однако если вы и дальше сталкиваетесь с различными ошибками, рекомендуем запомнить их код и описание, а после обратиться к документации Убунту для поиска доступных решений.
Restore windows bootloader with ubuntu
I’m often, at least more than I care, asked how to restore a Windows MBR/bootloader without having a windows install cd or a dos boot disk at hand. It’s quite easy you need just a Linux live cd like (the Ubuntu live cd or Knoppix) or an installed Linux you want get rid of. I really don’t know why you want to do the second, but anyway here are the 2 solutions I know of.
Boot Linux and make sure you’ve a working Internet connection and type following on the terminal/konsole.
1. Solution
sudo apt-get install syslinux
if the package got installed use following to write the MBR.
sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda
2. Solution
sudo apt-get install mbr
if the package got installed use following to write the MBR.
sudo install-mbr -i n -p D -t 0 /dev/sda
Common for both
Replace sda if you want to install the MBR to a different drive. Take a look at your hard disks with sudo fdisk -l if you’re unsure. Finally reboot and your windows should boot.
On request I put this comment from a guy (whats to be anonymous) up to the main article.
You have given an excellent article. And I know how much useful it may be to a frustrated person trying to get their work done.
But I sincerely request you to do one last job of giving them a last revealing information about alleged non friendliness of linux derivatives. I think at the moment when people are visiting your post they are frustrated and they vent their ire on linux without getting the other side of the story.
Please consider my suggestions below:
In response to your post, people have been wrongly complaining (in the comments) about the user unfriendliness of ubuntu and other linux variants etc in favour of Microsoft Windows. They think that after installing a linux variant they are unable to install the Microsoft’s Windows back, even after deleting all the partitions.
This actually happens because as soon as a Microsoft Windows OS installer sees a non Microsoft bootloader (for example, GRUB), it refuses to install and says something like the environment is incorrect. Sadly further, it does not explain the ‘environment’ (which could allow a user may look up a solution). And neither does it provide there, a straightforward option to overwrite the other bootloader with its own (even if you delete all the partitions on the disk from the Windows Installer or from the outside!).
I think the Windows implementers chose not to overwrite a foreign boot loader because they did not want to support a non Microsoft OS alongside their own. But the unfortunate thing is they should not do this when not even a single partition is allocated (then obviously there can be no OS installed).
Please let the readers know that it is the Microsoft windows which does not support any non Microsoft OS sitting along side itself and not necessarily the other way round. Please put this information in the main post itself, since otherwise it gets buried under the volume of the comments.
88 Comments »
thankk you thank you … you are great genius
Comment by mohan — March 26, 2013 #
I will recommend it to all the ones who have a problem with this … great you are .. cant appreciate n words
Comment by mohan — March 26, 2013 #
An installed version of Linux you want to get rid of? Do your solutions damage Linux? (Will try them)
Comment by Mike — May 2, 2013 #
Please the commands seem not to work with my fedora, which command should I use for fedora?
Comment by Cubby — May 16, 2013 #
i mistakenly used sda1 instead of sda ….i am getting some different type of problem…how to undo what i did??
Comment by shubham — May 24, 2013 #
Comment by slwk — May 24, 2013 #
Comment by Ken — June 19, 2013 #
Solution 1 worked like a charm. Thank you!
Comment by Dobly — June 23, 2013 #
Thanks a lot. Just in case somebody’s as dumb as me: in BIOS, I first had to change diskmode back to AHCI (I had set it to compatibility mode…) – then it worked fine!
Comment by Jaydot — July 16, 2013 #
Thanks man, you just saved my day
Comment by Rafael — July 25, 2013 #
THANK YOU. I COULD KISS YOU SIR. After attempting to install 13.04 from an old usb stick you got my family’s laptop working again. I love you man.
Comment by Will — August 21, 2013 #
[…] Ref: Mini-Howto: Restore Windows MBR/Bootloader with Linux | Robert Penz Blog […]
Pingback by 復原 Windows MBR 的各種方式 « Jamyy’s Weblog — September 13, 2013 #
Software 1 was already on Wary Puppy Linux CD and the proposed solution did the trick in seconds…
Thanks for sharing.
Comment by Michel — October 14, 2013 #
You have given an excellent article. And I know how much useful it may be to a frustrated person trying to get their work done.
But I sincerely request you to do one last job of giving them a last revealing information about alleged non friendliness of linux derivatives. I think at the moment when people are visiting your post they are frustrated and they vent their ire on linux without getting the other side of the story.
Please consider my suggestions below:
In response to your post, people have been wrongly complaining (in the comments) about the user unfriendliness of ubuntu and other linux variants etc in favour of Microsoft Windows. They think that after installing a linux variant they are unable to install the Microsoft’s Windows back, even after deleting all the partitions.
This actually happens because as soon as a Microsoft Windows OS installer sees a non Microsoft bootloader (for example, GRUB), it refuses to install and says something like the environment is incorrect. Sadly further, it does not explain the ‘environment’ (which could allow a user may look up a solution). And neither does it provide there, a straightforward option to overwrite the other bootloader with its own (even if you delete all the partitions on the disk from the Windows Installer or from the outside!).
I think the Windows implementers chose not to overwrite a foreign boot loader because they did not want to support a non Microsoft OS alongside their own. But the unfortunate thing is they should not do this when not even a single partition is allocated (then obviously there can be no OS installed).
Please let the readers know that it is the Microsoft windows which does not support any non Microsoft OS sitting along side itself and not necessarily the other way round. Please put this information in the main post itself, since otherwise it gets buried under the volume of the comments.
Comment by Helper (Anonymous) — November 15, 2013 #
I’ve added the comment to the article.
Comment by robert — November 15, 2013 #
In following your instructions I rather mucked up by attempting to do it to a partition rather than a drive.
I ran:
sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda1
GParted is now unable to detect the file system of sda1.
I would consult your Linux knowledge in how to reverse my muck-up.
Comment by Zig13 — January 1, 2014 #
By using sda1 instead of sda you overwrote the first 512 byte of the partition. The fix depends on the file system you used on sda1. General information on that topic can be found at https://help.ubuntu.com/community/DataRecovery
Comment by robert — January 2, 2014 #
I thought this was THE fix I was looking for but I think I made a big mistake by executing these commands.
Basically, my problem was that when I was installing Fedora on top of Windows XP. I accidentally or unknowingly shrink the windows partition as far as I can to make more space for Fedora Linux. That was a huge mistake. As a result, my window xp MBR is destroyed and XP is not listed as part of the grub bootloader. So, I was trying to recover Windows XP MBR. I tried other website work around. Still, didn’t work, even though it recognized Fedora partition. I came to your website and tried your commands. Now my desktop is completely dead. The only think that comes up is NO OS found, please insert CD/DVD or something like that. I am simply dumbfounded as to what to do now. I even tried Boot-Repair-Disk and it also didn’t fix my problem. I really don’t care for the Windows OS, it is the files I had in my windows partition I desperately want.
I hope I didn’t destroy the files or the filesystem. I am still going to around the Internet for solution.
Comment by David — February 11, 2014 #
Awesome – thanks so much. It seems this is a pretty common problem. I installed Mint beside Windows and then, after I didn’t like it and decided to go for Ubuntu, I resized my Windows partition to take away Mint. Little did I know how important Grub2 was, that it had taken over booting sequence, and that by deleting it I had taken Windows out of commission! But your option 1 worked a charm. Many thanks!
Comment by David W — May 2, 2014 #
Thanks a million. All other guides said i needed a windows boot cd, this is perfect!
Comment by Frederik — May 4, 2014 #
dude you are a genius.
Comment by Raul — August 2, 2014 #
I have a Lenovo Y50-70 Laptop with Windows 8.1 pre-installed. Two days ago it stopped booting into windows. There is a boot partition of SYSTEM_DRV with boot flag but it doesn’t detect anything in the BIOS. Before this problem the partition was listed in the BIOS now it’s not. I tried boot-repair too but it didn’t work. What to do so BIOS detects the partition & boots? Also i checked using TestDisk that the boot sector is with status Ok. Please help.
Comment by Tanmay — December 16, 2014 #
Thank you very much.
Comment by Vasanth — January 7, 2015 #
That was awesome Robert. Thanks. I was all out of options. Didnt think overwriting MBR of a syslinux bin would solve it, but it did!
Comment by Ben — March 7, 2015 #
[…] Info habe ich von http://robert.penz.name/221/mini-howto-restore-windows-mbrbootloader-with-linux/ etwas abgeändert für […]
Pingback by wie ich einen kaputten GRUB2 Bootloader repariert habe – a linux addict in a linux world — March 22, 2015 #
I have troubles to boot the win7. I have downloaded kubuntu liveCD that is booted like a flower and after I have followed the instructions:
1) sudo apt-get install mbr
2) sudo install-mbr -i n -p D -t 0 /dev/sda
However, I obtained message after booting
MBR
bootmgr is missing press ctrl+alt+del
What I have to do ?
Comment by Desesperate — May 2, 2015 #
boot manager is not the mbr. you need to run the recovery function of the windows install cd.
Comment by robert — May 3, 2015 #
Comment by Stefan — June 8, 2015 #
Would’ve been so wrong to just use ur solution and leave without thanking u. So, thanks a million, man. U save my ass.
Comment by Issam Kenzi — September 12, 2015 #
Comment by François — October 10, 2015 #
A wonderful tutorial.
My windows installation disc is refusing to restore the windows boot loader while using the same disc used to install the system.
“We cannot repair your windows install it is incompatible with this setup disc”
Stupid brain dead POS.
Well anyway thanks for the tutorial, helps a lot on restoring the boot loader to my Windows gaming drive. 🙂
I keep my Linux install on a separate partition, so my dual boot setup still leaves the windows boot loader intact on its drive, but I accidentally nuked it.
Comment by Dreyeth — October 21, 2015 #
Comment by Brian Kevin Calmes — May 11, 2017 #
Thanks a lot for this Robert. I was stuck on grub rescue and didn’t have a window live boot cd but this solved my problem.
Comment by Oshal — May 25, 2017 #
Very useful. One note: on the CloneZilla live CD I was using the mbr.bin was located in a slightly different path.
sudo dd if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sda
Comment by Tim — July 12, 2017 #
Thank you very much for this, I used a UBUNTU USB stick to reboot my Windows10 Laptop.
Did not need to install syslinux as this was already installed, also the directory containing mbr.bin was in SYSLINUX rather than syslinux so just needed to run this command
sudo dd if=/usr/lib/SYSLINUX/mbr.bin of=/dev/sda
Comment by Peter — September 23, 2017 #
Thank you so much.:)
Comment by Andreas — January 21, 2018 #
Well, I have the blinking cursor problem after having : – cloned xp from a compag slimsomething desktop on an SSD drive ( on the first partition of course ) … i then installed Ubuntu, and… same for Windows after grub2… i’ve tried your first solution, and i wanted to tell that for me the correct path to mbr.bin wasn’t in /usr/lib/syslinux/ but in ../syslinux/mbr/
i was wondering what if i wouldn’t have checked before and just lauchned the command line as a noob who just su last command line to download and install syslinux and mtool… ? no boot and no boot loader… what a joke… but nice anyway…
well, … rebooting.. ( Q9550 ) … not okay, as i expected, no bootloader at all, no menu, just the blinking cursor… pretty funny
Comment by StonyCat — May 11, 2019 #
Thank you so much! I was unable to boot from my Win-CD (no ps/2-keyboard). Now I could restore the MBR! Great!
Comment by armin — October 7, 2019 #
Leave a comment
Powered by WordPress
Entries and comments feeds. Valid XHTML and CSS. 50 queries. 0.283 seconds.