Arch linux grub restore

How to Restore/Reinstall GRUB Bootloader in Arch Linux

Sometimes disaster may happen and your GRUB bootloader may stop working. In this situation you may need to reinstall/restore GRUB bootloader. For this you need a bootable drive with Arch Linux.

So if you don’t have Arch Linux download iso file and create one.

Recover GRUB Bootloader in Arch Linux

  • Insert and boot your Arch Linux installation media.
  • Select Arch Linux archiso x86_64 UEFI CD.
  • If you want to connect to WiFi then you can connect using # wifi-menu , but it is optional.
  • After that you need to mount the root partition of Arch Installation to /mnt .
  • To check your boot / EFI and root partitions use, # fdisk -l
  • Then mount your root partition to /mnt , # mount /dev/sda4 /mnt
  • chroot using, # arch-chroot /mnt /bin/bash
  • Then you need to mount boot partition, mount it to /boot/efi , # mount /dev/sda2/ /boot/efi
  • You can check if all are mounted using, # lsblk -l
  • Now install GRUB, # grub-install —target=x86_64-efi —efi-directory=/boot/efi —bootloader-id=GRUB
  • Then, generate grub.cfg, # grub-mkconfig -o /boot/grub/grub.cfg
  • Now you are done, # exit , # reboot .

If you have problems then feel free to comment.

You Might Also Like

Read more about the article Dual Boot Phoenix OS with Linux

Dual Boot Phoenix OS with Linux

Read more about the article Using Android/PC as a Second Monitor in Linux

July 7, 2019

Using Android/PC as a Second Monitor in Linux

Read more about the article How to Install uGet and Setup for Torrent in Ubuntu

August 1, 2019

Источник

Как восстановить загрузчик Grub в Linux

Большой унифицированный загрузчик GRUB – это мощная и гибкая утилита, которая связывает BIOS материнской платы с ядром операционной системы. Она работает путем загрузки небольшой программы в память материнской платы, которая используется для загрузки более крупного двоичного файла мультизагрузки.

Но бывают случаи, когда GRUB не может загрузить ядро операционной системы. Например, двойная загрузка с Linux и Windows часто приводит к тому, что последняя стирает загрузчик. В этом руководстве показано, как можно восстановить систему, переустановив GRUB , используя некоторые из наиболее популярных дистрибутивов Linux.

Восстановление GRUB в Ubuntu и Debian

Одним из самых быстрых способов переустановки GRUB в Ubuntu и Debian является загрузка живой копии любого из этих дистрибутивов. Это позволит вам подключить корневой раздел вашей системы и использовать исполняемые файлы GRUB дистрибутива для воссоздания загрузчика вашей системы.

Примечание: когда вы загрузитесь с живого USB , нажмите «Try Ubuntu» для доступа к рабочему столу. Не нажимайте «Установить Ubuntu.»

    Откройте терминал в среде дистрибутива.

sudo fdisk -l | grep "Linux filesystem$"

sudo grub-install --force --boot-directory=/mnt/ /dev/sda1

Совет: хотя переустановка GRUB исправит большинство проблем с мультизагрузкой, новичкам может показаться сложной командная строка. В связи с этим, вы также можете исправить GRUB с помощью графической утилиты Boot Repair Utility.

Читайте также:  Обработка raw файлов linux

Восстановление GRUB в Arch Linux

Наряду с Ubuntu и Debian, для восстановления загрузчика можно использовать живую копию Arch Linux. Одним из преимуществ этого является то, что живой Arch Linux не полагается на графическое отображение, поэтому вы можете легко восстановить GRUB даже на машинах по SSH .

    Определите корневой раздел вашей системы с помощью lsblk:

mount --bind /sys /mnt/sys mount --bind /proc /mnt/proc mount --bind /run /mnt/run mount --bind /dev /mnt/dev

/sbin/grub-install --target=i386-pc /dev/sda

/sbin/grub-mkconfig > /boot/grub/grub.cfg

Нажмите Ctrl + D , чтобы выйти из корневой сессии вашей системы.

Восстановление GRUB на Fedora

Подобно Ubuntu и Debian, восстановление Grub на Fedora также просто.

#Найдите корневой раздел вашей машины:

sudo fdisk -l | grep "Linux filesystem$"

    Смонтируйте корневой раздел вашей системы и создайте связующее монтирование между ним и вашей живой сессией:

sudo mount /dev/sda3 /mnt sudo mount --bind /sys /mnt/root/sys sudo mount --bind /proc /mnt/root/proc sudo mount --bind /run /mnt/root/run sudo mount --bind /dev /mnt/root/dev
sudo chroot /mnt/root bash mount /dev/sd3 / mount /dev/sda2 /boot

rm -f /etc/grub.d/* rm -f /etc/sysconfig/grub

grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install --target=i386-pc /dev/sda

Часто задаваемые вопросы

Можно ли восстановить GRUB , если моя система использует LVM ?

Да. Вы можете восстановить GRUB , даже если ваша система использует LVM . Для этого выполните ls /dev/mapper/*—vg-root , чтобы определить абсолютный путь к корневому разделу вашей машины. Используйте этот абсолютный путь вместо традиционного «/dev/sda1.»

Восстановление GRUB сотрет другие операционные системы на моем диске?

Нет. Загрузчик, по своей конструкции, знает, где найти только первые несколько байт ядра операционной системы. Замена загрузчика не повлияет на существующую на диске операционную систему.

Можно ли переустановить GRUB на системе UEFI ?

Да. Для этого вам нужно убедиться, что вы правильно смонтировали раздел «/boot/efi» вашей системы UEFI . Вам также нужно изменить значение флага —boot-directory в grub-install на «/boot/efi».

Для Fedora, вам также нужно изменить значение флага -o для grub2-mkconfig на /boot/efi/EFI/fedora/grub.cfg

Опытный системный администратор с большим стажем работы на крупном российском заводе. Иван является энтузиастом OpenSource и любителем Windows, проявляя высокую компетентность в обоих операционных системах. Благодаря его технической грамотности и умению решать сложные задачи, Иван стал неотъемлемой частью команды нашего проекта, обеспечивая непрерывную авторскую работу.

Источник

How to Reinstall the Boot Loader in Arch Linux

Jeremy Morgan

Jeremy

Let’s learn together on YouTube!

Recently I tried dual-booting FreeBSD and Arch Linux on my laptop. I already installed Arch Linux and left a partition open for FreeBSD later. I hosed my Grub, and the machine wouldn’t boot.

It’s an easy fix, so I wanted to share it. This is similar to how to restore your bootloader after installing Windows. The only difference is this laptop is 100% Arch Linux, and it’s a UEFI machine.

So, let’s say you’re like me and have Arch Linux installed, and you’ve toasted your GRUB bootloader. Here’s what you do.

Boot from an Arch Linux ISO

The first step is to get an Arch Linux ISO, burn it to a USB stick, and boot it.

Читайте также:  Linux get root rights

How to reinstall boot loader Arch Linux

You’ll land on a prompt that looks like this:

How to reinstall boot loader Arch Linux

Know Your Disks

It’s important to know where your disks are and what partitions are where. You can do this by checking with:

How to reinstall boot loader Arch Linux

As you can see on my machine, I have my hard drive (/dev/sda), an SDcard (/dev/mmcblk0), and the USB drive I booted into Arch with (/dev/sdb1). I’m most concerned with /dev/sda.

/dev/sda1 is my EFI system. /dev/sda2 is where my Linux installation is that I need to point to again.

Technically since I only have one operating system, I don’t need GRUB, but I have it set up because someday I’ll take the time to wrangle in FreeBSD or something else. I digress.

Mount Your Arch System

I need to mount the / partition of my Arch system.

mkdir /mnt/arch mount -t auto /dev/sda2 /mnt/arch 

Ok, now it’s mounted, and time to chroot into it.

Now my system is up and running on my root drive. Any changes made here will be as if I logged into my system.

Next, I’ll mount my EFI folder:

I’ll need that when running my update.

Updating GRUB

Now I need to update GRUB. First, I’ll run OS Prober:

I only have one, but it will update my GRUB config. If you have multiple operating systems, you should do this as well. It should find them.

Now I’ll copy over the new grub config:

grub-mkconfig > /boot/grub/grub.cfg 

Cool! I’m ready to install it now.

Installing GRUB

Now I’ll need to install GRUB again, and I do that with the following command:

grub-install --efi-directory=/efi --target=x86_64-efi /dev/sda 

Now, this is the string that’s tricky to find in the documentation. There are many options for grub-install, and I learned the above string works due to trial and error, which is why I’m sharing it.

How to reinstall boot loader Arch Linux

Sweet! Now it’s time to reboot.

You’re Done!

How to reinstall boot loader Arch Linux

If you see this, you’re a happy camper! There’s the GRUB menu!

I’ve hosed my GRUB boot so many times I’ve become a pro at this. I hope it helps! Let me know if you have any questions!

Want to learn more about Linux? Of course you do. Check out this Linux Fundamentals course. You can sign up for a free trial here and take it today!

Published: Aug 14, 2020 by Jeremy Morgan. Contact me before republishing this content.

Источник

How to Restore Arch Linux Boot after Installing Windows

Jeremy Morgan

Jeremy

Let’s learn together on YouTube!

This week they released the RTM Version of Windows 10, and I decided to install it on my laptop. Most of my development is done on my desktop Mac at home, but the laptop is good for collaborating, coffee shop coding, etc. I decided Windows 10 and Visual Studio 2015 would be good for this. There’s only one issue: I also have Arch Linux on this laptop, and it’s dialed in very nice and I definitely don’t want to remove it.

I haven’t upgraded Windows on this machine since I put Windows 8.1 on it over a year ago, so I never had to deal with the issue of fixing grub. It is slightly different from other distributions, and there is no “boot repair” yet. I decided to Google a few things and figure out how to restore it but didn’t find a complete article on it, so I decided to write one. I installed Windows 10 on the machine without changing any of the partition data, and that’s crucial. After doing that it would only boot into Windows 10, so here’s what I did.

Читайте также:  Linux открыть папку через консоль

1. Download an Arch Linux ISO

Download a live ISO for Arch Linux here. If you’re using Windows, LiLi is a great free tool for creating bootable Linux USBs.

boot to this USB drive and you’ll be taken to a command prompt.

2. Restore Grub

This assumes of course that you were using GRUB to begin with, but here’s how to restore it.

Find the partition your Linux is installed on:

You’ll see something like this:

How to restore GRUB in Arch Linux

In my case my Linux installation is at /dev/sda4. Note where yours is, then exit this application.

So mount your Linux partition:

Then, change root with this command (specific to Arch Linux)

And yes, it does detect Windows 10 properly.

After you reboot, you’ll see your familiar boot screen again:

How to restore GRUB in Arch Linux

And you can now boot into Linux (or Windows) again.

Configure Grub

Now if you’re like me (which you probably are if you’re reading this blog) you will be bothered that it incorrectly says “Windows 8” or whatever your previous version was. This is easy to fix by editing some entries in your Grub configuration:

Make a backup of your grub.cnf

sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.8.1 
sudo nano /boot/grub/grub.cfg 

Look for the Windows 8 or Windows 7 entry in the file:

How to restore GRUB in Arch Linux

and change it to whatever you want. Then reboot. Now it should look like this:

How to restore GRUB in Arch Linux

This is how I have mine set up. If you’d like to learn more about GRUB menu options click here

Summary

This is how you can restore your dual boot options if you reinstall or upgrade Windows on a dual boot Arch Linux system. I have heard of people just reinstalling Linux afterword, and it’s a terrible idea unless you were going to change it anyway. It only takes a few minutes to fix.

A note about Arch Linux:

As I said in the article I have Arch Linux installed and it’s “dialed in” meaning I have a nice system compiled with only what I need, lean custom kernel, and my development environment is all set up. I wouldn’t advise an Arch install to everyone, but it has been fantastic for me personally. It runs very fast and reliably and it’s easy to update everything.

If you’re looking for a new Linux distribution or just want to escape the Ubuntu crowd, you should give it a try. It has a steep learning curve as you’ll need to know Linux really well, or be able to follow the directions explicitly, but if you do you’ll find a nice solid system that’s fast and lean.

Want to learn more about Linux? Of course you do. Check out this Linux Fundamentals course. You can sign up for a free trial here and take it today!

Published: Aug 1, 2015 by Jeremy Morgan. Contact me before republishing this content.

Источник

Оцените статью
Adblock
detector