📜 ⬆️ ⬇️

Booting the operating system from the Grub command line

I have two operating systems on my home computer, Windows 7 and Linux (Arch). And the second appeared relatively recently. Yes, and special knowledge about the new (for me) OS was not. Nevertheless, I set the system, and even relatively customized. Enthusiasm and programmer curiosity overpowered me, therefore, as an acquaintance, I began experimenting with various kinds of packages. Unfortunately, not always reading in details.
I decided to rearrange Grub , or rather upgrade to Grub2 . (I heard this opinion that, in the spirit of Linux, it is customary to keep the latest version of the package ... Grub2 changes are well written here .)
Well, as a result of a “rush” installation, the system stopped loading. The only thing you could catch on was the command line prompt:


By pressing Tab, a list of possible commands is displayed. They are significantly smaller than the Linux command line, but they are enough to boot the system. After reading about grub here, I decided to load Windows, yet here I feel more confident. To do this, it was necessary to indicate where the OS loader is and transfer control to it:

grub> root (hd0,2) [ . , ]

Record (hd0,2) means the device disk number 0 (master), section number 2.
which corresponds to the device / dev / sda2 (in my case). You can have it either / dev / hd2, or something else, depending on the distribution. The device numbering is in order and starts with (hd0,1) or / dev / sda1.
Next, enter:
grub> chainloader +1 [ "+" . hainloader - . NTLDR]
grub> boot

NTLDR is a Windows bootloader.
The system began to boot, and once it gave the result - you can dig further (after all, not Windows is now the subject of study).
Reboot and re-enter.

grub> root (hd0,6)
grub> linux /boot/vmlinuz26 root=/dev/sda6 [ linux- (/boot/vmlinuz26) (root=/dev/sda6)]

Here it is necessary to distinguish the root command (hd0,6) and the root parameter = / dev / sda6. The first mounts the partition to the runtime environment. And the second indicates where to be the root boot OS. In my case, the core and root were on the same partition, although this may not be the case.

grub> initrd /boot/kernel26.img [ initrd-]
grub> boot

It helped me, I hope it will not be useful to you, and if it is useful, it will help.
By the way, if you specify the root incorrectly, the boot process will end with an error and the following prompt will appear:
[ramfs /]#
You can dial:
[ramfs /]# ls /dev
and see the list of devices (if you suddenly forgot it like me).
My problem with installing gurb2 was that when installing, the grub menu file was erased (usually it is /boot/grub/menu.lst), but I did not create a new file. To create a configuration file, you had to run grub-mkconfig.
If you have lost grub settings, then the differences in the commands will be minimal:

UPD: added about the differences in the boot with grub from grub2. Thank you bliznezz

Source: https://habr.com/ru/post/102230/

All Articles