User jane can boot Fedora since she was granted the permission in the configuration. Anyone can boot Red Hat Enterprise Linux Server, because of the --unrestricted option, but only john can edit the menu entry as a superuser has been defined. When a superuser is defined then all records are protected against unauthorized changes and all records are protected for booting if they do not have the --unrestricted parameter. If you do not specify a user for a menu entry, or make use of the --unrestricted option, then only the superuser will have access to the system.
By default, passwords are saved in plain text in GRUB 2 scripts. Although the files cannot be accessed on boot without the correct password, security can be improved by encrypting the password using the grub2-mkpasswd-pbkdf2 command. This command converts a desired password into a long hash, which is placed in the GRUB 2 scripts instead of the plain-text password. To generate an encrypted password, run the grub2-mkpasswd-pbkdf2 command on the command line as root. Enter the desired password when prompted and repeat it.
The command then outputs your password in an encrypted form. Reinstalling GRUB 2 is a convenient way to fix certain problems usually caused by an incorrect installation of GRUB 2, missing files, or a broken system.
Other reasons to reinstall GRUB 2 include the following:. The user requires the GRUB 2 boot loader to control installed operating systems. However, some operating systems are installed with their own boot loaders. Reinstalling GRUB 2 returns control to the desired operating system. When using the grub2-install command, the boot information is updated and missing files are restored. Note that the files are restored only if they are not corrupted.
Use the grub2-install device command to reinstall GRUB 2 if the system is operating normally. For example, if sda is your device :. When using the dnf reinstall grub2-efi shim command, the boot information is updated and missing files are restored. Use the dnf reinstall grub2-efi shim command to reinstall GRUB 2 if the system is operating normally. This method completely removes all GRUB 2 configuration files and system settings.
Apply this method to reset all configuration settings to their default values. Removing of the configuration files and subsequent reinstalling of GRUB 2 fixes failures caused by corrupted files and incorrect configuration. To do so, as root , follow these steps:. If you use computers with no display or keyboard, it can be very useful to control the machines through serial communications.
To set the system to use a serial terminal only during a single boot process, when the GRUB 2 boot menu appears, move the cursor to the kernel you want to start, and press the e key to edit the kernel parameters. Remove the rhgb and quit parameters and add console parameters at the end of the linux16 line as follows:. For example, to update the entry for the default kernel, enter a command as follows:. The --update-kernel parameter also accepts the keyword ALL or a comma separated list of kernel index numbers.
The first line disables the graphical terminal. On the second line, adjust the baud rate, parity, and other values to fit your environment and hardware. A much higher baud rate, for example , is preferable for tasks such as following log files.
In order to access the grub terminal over a serial connection an additional option must be added to a kernel definition to make that particular kernel monitor a serial connection. For more information on serial console settings, see Installed Documentation. The screen tool serves as a capable serial terminal. To install it, run as root :. By default, if no option is specified, screen uses the standard baud rate.
To set a higher baud rate, enter:. Menu entries can be modified and arguments passed to the kernel on boot. This is done using the menu entry editor interface, which is triggered when pressing the e key on a selected menu entry in the boot loader menu.
The Esc key discards any changes and reloads the standard menu interface. The c key loads the command line interface. The command line interface is the most basic GRUB interface, but it is also the one that grants the most control. The command line makes it possible to type any relevant GRUB commands followed by the Enter key to execute them.
In addition, the arrow , Home , End , and Delete keys work as they do in the bash shell. Rescue mode provides a convenient single-user environment and allows you to repair your system in situations when it is unable to complete a normal booting process. In rescue mode, the system attempts to mount all local file systems and start some important system services, but it does not activate network interfaces or allow more users to be logged into the system at the same time.
In Fedora, rescue mode is equivalent to single user mode and requires the root password. To enter rescue mode during boot, on the GRUB 2 boot screen, press the e key for edit. Note that equivalent parameters, 1 , s , and single , can be passed to the kernel as well. Emergency mode provides the most minimal environment possible and allows you to repair your system even in situations when the system is unable to enter rescue mode.
In emergency mode, the system mounts the root file system only for reading, does not attempt to mount any other local file systems, does not activate network interfaces, and only starts few essential services. In Fedora, emergency mode requires the root password. Note that equivalent parameters, emergency and -b , can be passed to the kernel as well. Setting up the root password is a mandatory part of the Fedora installation. If you forget or lose the root password it is possible to reset it, however users who are members of the wheel group can change the root password as follows:.
The root password is now required to operate in single-user mode as well as in emergency mode. Resetting the Root Password Using an Installation Disk takes you to a shell prompt, without having to edit the grub menu. It is the shorter of the two procedures and it is also the recommended method. You can use a server boot disk or a netinstall installation disk. These include items such as backgrounds and themes.
The placement of the menu items in the grub. Files with a leading numeral are executed first, beginning with the lowest number. If files with alphabetic names exist, they are run after the numerically-named files. Only executable files generate output to grub. Users normally do not need to make changes to this file. In the absence of a splash image, this file sets a monochromatic theme for the initial menu display. This includes the associated recovery mode option if enabled.
In GRUB 1. Note: For earlier versions of GRUB 2, all kernels residing in the boot folder are included on the main menu. There is currently no line option to remove this entry from the menu. Users familiar with basic scripting can alter these variables to change the format of the displayed menu entries.
Removing the executable bit from the file will also prevent it from searching for other operating systems. By default os-prober ignores any disks that possess "dmraid" signatures, which can be listed via sudo dmraid -r -c if installed.
If not found, the script will construct a menuentry from the actual boot information it locates. The file can be renamed or copied. The file must be executable to be incorporated into the GRUB 2 menu. As mentioned in the introduction of this section, the name of the file determines the location of its contents in the GRUB 2 menu. These files contain no menuentries and thus will not interfere with a menuentry from a custom script with a lower priority.
Options include the time the menu is displayed, the default OS to boot, etc. The default options included in file upon installation are only a small number of the variables which GRUB 2 can recognize.
The file is a simple text file and can be edited by any text editor. In Ubuntu the default text mode editor is nano and the graphical mode editor is gedit , and the file can be edited with one of the following commands. The first "menuentry" in grub. Note: Grub 1. For a menu item in a submenu, the entry becomes a two-digit entry. The first entry is the position of the submenu title in the main menu. The second entry is the position within the submenu. In this case, location in the menu will not matter.
The "saved" entry enables the "grub-reboot" and "grub-set-default" commands to set the default OS for future boots. The default OS for future boots will not be set merely by selecting an OS when booting. The format is sudo grub-set-default X , with X being the menu entry position starting with 0 as the first entry or the exact menu string. Example: sudo grub-set-default 3 Example: sudo grub-set-default "Ubuntu, Linux 2.
The format of the command is the same as for grub-set-default see above. No commands need be run to set the default OS. Nevertheless, it does not hurt to start exploring. Be aware that you may encounter some compatibility issues down the road, especially with more conservative distributions that do not embrace new technologies too quickly.
At the time being, GRUB 2 is only used by the Ubuntu family, which makes about a third to one half of the Linux desktop market. That makes this tutorial rather relevant, as about one in every two or three Linux home users will probably be interested in learning more about GRUB 2 and its uses.
Let's now move on to the actual mechanics. This will help you understand this article better. GRUB 2 introduces many new changes.
All these are pretty much irrelevant for most users. What you need to know are the changes in the configuration files and the way GRUB 2 operates. Old GRUB files were and still are! GRUB 2 places its files in three core locations:. Unlike menu. I strongly advise against trying to tamper with this file, using chattr command or anything of the sort. Let it be. These scripts are building blocks from which the grub. When the relevant GRUB command is executed, the scripts are read in a certain sequence and grub.
It is the customization part of the GRUB, similar to the old menu. This means that if you want to change the GRUB menu, you will have to edit existing scripts or create new ones, then update the menu. It is not really interesting, because it's just a shell script. Most people will probably not want to read its contents or be able to fully understand them. This file is still worth a quick look any time you update the GRUB menu, to make sure the correct entries are included as you expected. But only if you're comfortable with scripts!
We will talk more about these soon. The name of this script is definitely going to change to when other distributions adopt GRUB 2. Have you noticed the numbering in the script names? The numbering defines precedence. The scripts are not very interesting. Like the grub. You need to very careful when working with these scripts. We will soon see what they look like and learn how to use them. This directory contains many other files so do not assume it is just used for GRUB. You can make your changes here, if you want.
We will talk about these later, in the Customization section. When the update-grub command is run, it reads the contents of the grub file and the grub. That's all. To change the grub. Scripts are meant to be executed. This means that they have the execute bit turned on. If you turn the execute bit off, they will not run. This means that you can place as many files as you want into the grub. If you want to use them, you will activate the executable bit, or vice versa, turn it off.
Let's examine the scripts. Don't worry, we will soon learn everything. If you want the new entry to be placed above others, use lower numbers, if you want it to be placed below others, use higher numbers. The next step is to write the actual content. Here's a sample:. Example: Linux. This is terribly important to remember! In other words, devices are still numbered from 0, but partitions start with 1.
For example, this means that sda1 is now hd0,1 and NOT hd0,0 as before! In Linux, you may want to use something like:. As we've seen just now, the cat command defines the start of the code in the script that will be added to the GRUB menu literally and NOT interpreted by the shell. We have used a number of different commands in this script.
Some of these you may have seen before in GRUB legacy, some may appear new and strange. Not to worry, there's a full list, including a comparison to GRUB legacy. Some of the commands have been replaced and others added.
For more details, please check GRUB 2 command list. The new script is in place, but the GRUB menu grub. We need to run the update-grub command to make it happen. Here's an example from a dual-boot configuration, which we will examine more deeply later on. But let's move slowly. Our first task is to add the new scripts. After we ascertain that they boot fine, we will get rid of the duplicates. You can also change the numbers if you want. For instance, I changed the Kubuntu entries to 08 and 09, to make them boot first, before default entries and the custom Ubuntu script.
This is something you may want to do, just as we have shown above. In order to make sure your new scripts boot correctly, you can refer to a working example of grub.
Here's an example of what I have:. OS Prober can also help you. It will find additional entries on your hard disks and add them to the menu. You can use the added information to create your own scripts. Again, refer to the grub. You do not need a live environment for that. Just execute the grub-install command against the device or the partition you desire. It is important that you pay attention to the output produced by the command.
If you have external disks connected at the time you run the command, it will add these disks to the list of mapped devices. There should be no big harm in that, but if some entries are incorrect, remove them.
That's it for now. You have the tools you need to start working. Still, to make things clearer, I've prepared a short summary that concludes the introduction and basic usage sections. Here we go. GRUB 2 has three main parts:. The scripts are read, in the order of their numbering, and written into the grub. Boot entries come from several sources - the default that comes with the distribution, other operating systems probed on the connected disks and custom scripts written by the user, following a strict syntax.
The scripts are written as shell sh. Good so far? You see, it's rather simple. Now, let's see a few real-life cases. Afterwards, we will customize GRUB 2 and learn how to recover from serious errors and misconfigurations. In this section, we will discuss several common multi-boot cases that the average user might encounter, including GRUB and GRUB 2 mix, Windows and Linux side by side, chainloading, and some others.
Some of the experiments were conducted on real physical systems, so some screenshots of boot menus come from actual photos, so they may look slightly twisted and less appealing that you would like, but this is in order to reassure you that working with GRUB 2 is as simple as any other administrative task.
It just requires some patience and care. This is probably the simplest dual-boot configuration. Both operating systems use GRUB 2, so they can easily interact with one another.
The two systems are Ubuntu 9. Kubuntu was installed second, again to MBR, overwriting the previous instance. However, the OS probe script found and added Ubuntu successfully. If you've read my Kubuntu tutorial, you will notice that Kubuntu entries are also labeled Ubuntu, which can be confusing if you have several, different Ubuntu entries on your machine. In this section, we will:. This will give us the initial clues into how GRUB 2 works and what users have to do to make it work.
And then, we will add Windows, too. We have seen snippets of this testcase earlier. We have our default entries, which do not look well and want them replaced. So we refer to grub. Just like we did earlier. Job done, very easy! This is a very interesting case.
Let's say you have two operating systems, like Ubuntu 9. This is something you need to decide. You have two bootloader options and you need to choose the default one. If you're asking me, at the time being, you should use GRUB legacy as your default bootloader, because it is production quality and has known, established support channels. Running GRUB 2 will place you in a minority. Therefore, if you are going to use GRUB legacy for booting, then you should:.
Otherwise, if you plan on using GRUB 2 as your default, you need to do things the other way around. Since we want to use the GRUB legacy bootloader, then:. Now that this is done, let's boot and see what happens. You will have to do this manually. Boot into openSUSE and open the menu.
Back it up first! So we will assume that it's the same thing like Windows. We will chainload the other operating system, passing the command to the other bootloader. Will this work?
0コメント