Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Grub2: Save Your bootloader     - Firewall settings oracle remote connection in Linux systems (Linux)

- About phpwind 5.01-5.3 0day analysis of the article (Linux)

- PLSQL often lose resolution process automatically disconnect the connection (Database)

- Mounting kit under Fedora Linux (Linux)

- Let OS X support NTFS write file (Linux)

- Vim Common Command Summary (Linux)

- Linux uses the SMTP proxy to send mail (Linux)

- Fedora network set up simple (Linux)

- Based on OpenSSL for HTTPS service configuration (Server)

- Apple Mac computer to install Windows 10 Concise Guide (Linux)

- Use JMS listener Oracle AQ, trigger the execution of Java programs in the database changes (Database)

- SELinux multi-level security (Linux)

- Linux System Getting Started Learning: DeVeDe installed on Linux to create a video DVD (Linux)

- ORA-12154: TNS: could not resolve the connect identifier specified solve (Database)

- Linux pwd command learning experience (Linux)

- Let Markdown code syntax highlighting and support Django1.6 (Linux)

- Linux security configuration (Linux)

- Installation and configuration of Hadoop under Linux (Server)

- Redhat Close SELinux correct step (Linux)

- Linux system installation Gitlab (Server)

 
         
  Grub2: Save Your bootloader
     
  Add Date : 2018-11-21      
         
         
         
  Nothing broken bootloader than people leaving the gas. Give full play to the role of Grub 2, so that law-abiding bootloader work.

Why do you say that?

Grub 2 is the most popular bootloader, used in almost all Linux distributions.
bootloader is a critical software, but very easy to damage.
Grub 2 is both a scalable and flexible boot loader, provides a number of customization options.
Grub 2 is a wonderful powerful software. It is not a bootloader thriving community, but the most popular, almost all major desktop distributions are using it. Grub work with two. First, it uses a menu shows all installed on the computer operating system for you to choose. Secondly, when you choose a Linux operating system from the boot menu, Grub will load the Linux kernel.

You know, if you use Linux, you can not do without bootloader. However, it is most known Linux distribution inside the part. In this article, we will take some of you are familiar with Grub 2 well-known properties, strengthen your relevant skills, so you run the bootloader time can fly themselves.

Grub 2 is the most important part of a bunch of two text files and script files. First, you need to know is the / etc / default / grub. This is a text file, you can set general configuration variables inside and Grub 2 menu (see below "common user settings") in the other properties.

Grub 2 Another important part is /etc/grub.d folder. All scripts define each menu item are placed here. The name of the script must be preceded by a number of two. Its purpose is to order the execution order of the script and the corresponding menu item is defined when building Grub 2 menu. 00_header file is first read, is responsible for parsing / etc / default / grub configuration file. Then the Linux kernel menu items, located 10_linux file. The script in the default / boot partition for each core and create a regular menu items and restore a menu item.

Followed by a third-party application used by the script, such as 30_os-prober and 40_custom. os-prober script for the kernel and other partition of the operating system to create a menu item. It identifies the installed Linux, Windows, BSD and Mac OS X. If your hard drive layout is unique, so os-prober Unable to find release has been installed, you can 40_custom file (see below "add a custom menu item") to add a menu item.

Grub 2 does not require you to manually maintain the profile of your boot options: Instead of using the grub2-mkconfig command generation /boot/grub/grub.cfg file. This function parses /etc/grub.d directory scripts and / etc / default / grub file settings to define your setup situation.

Graphical boot repair

Thanks to Boot Repair application, just click the button, Grub 2 many problems can be easily resolved. This beautiful small application has an intuitive user interface, you can scan and identify a variety of hard disk partitioning scheme and layout, but also to find and correctly identify the operating system installed therein. This application can be processed in a conventional computer's master boot record (Master Boot Record) (MBR), can also handle the new UEFI computer GUID partition table (GUID Partition Table) (GPT).

Boot Repair easiest way is to use to install Live Ubuntu session. Bootloader start on a damaged machine Ubuntu Live release, first install Boot Repair by adding its PPA repository, the command is as follows:

sudo add-apt-repository ppa: yannubuntu / BootRepair
Then refresh the repository list:

sudoapt-get update
Install the application, as follows:

sudoapt-get install -y BootRepair
Start the application after installation is complete. Display its interface (composed by a pair of keys) will scan your hard drive before. According to the instructions of the tool, simply press the Recommended Repair (recommended repair) button to fix most broken bootloader. After repair bootloader, this tool will output a short URL, you should record it. The URL contains detailed information on the hard disk: partition information and content important Grub 2 file (such as / etc / default / grub and /boot/grub/grub.cfg) of. If the tool does not resolve the problem bootloader, you can share this URL on your distro forums, so others can analyze your hard disk layout to give you advice.

Boot Repair Grub also lets you customize option 2.

Bootloader aid

Grub 2 boot problems leave the system in several different states. Screen (as you might imagine, this show where the bootloader menu) demonstrated the text indicate the current status of the system. If the system terminates in grub> prompt, indicating that Grub 2 module has been loaded, but can not find grub.cfg file. The current version is fully Grub 2 command shell, you can solve this problem in several ways. If you see the grub rescue> prompt, indicating bootloader Grub 2 module can not be found or could not find any boot files (boot files). However, if your screen displays only 'GRUB' word indicating bootloader find basic information is usually located in the master boot record (Master Boot Record) inside.

You can use the live CD or correct such errors in the Grub 2 shell. If you're lucky, bootloader appeared grub> prompt, you can get control over the Grub 2 shell, and to help you troubleshoot.

The next few commands work in grub> and grub rescue> prompt. set pager = 1 command to set the display tab (pager), to prevent a text on the screen and roll over. You can also use the ls command to list all partitions Grub identified, as follows:

grub> ls
(Hd0) (hd0, msdos5) (hd0, msdos6) (hd1, msdos1)
As you can see, this command lists the partition at the same time together with a list of the partition table scheme (ie msdos).

You can also use ls in each partition above to find your root file system:

grub> ls (hd0,5) /
lost + found / var / etc / media / bin / initrd.gz
boot / dev / home / selinux / srv / tmp / vmlinuz
You can not write msdos portion of the partition name. Similarly, if you forget the trailing slash (trailing slash) enter only ls (hd0,5), then you will get the partition information, such as the file system type, the overall size and last modification time. If you have multiple partitions, you can use cat to read / etc / issue file contents to determine the release, formats like cat (hd0,5) / etc / issue.

Suppose you find the root file system (hd0,5), make sure it contains the / boot / grub directory, and you want to boot into the kernel image, such as vmlinuz-3.13.0-24-generic. Now enter the following command:

grub> set root = (hd0,5)
grub> linux /boot/vmlinuz-3.13.0-24-generic root = / dev / sda5
grub> initrd /boot/initrd.img-3.13.0-24-generic
The first point we ordered the Grub boot partition into the release is located. Followed by a second command tells Grub kernel image position in the partition, and the location of the root file system. The last line sets the location of the virtual file system (initial ramdisk) files. You can use tab-completion to complement the kernel name and the virtual file system (initrd: initial ramdisk) name, saving time and effort.

After inputting the next grub> prompt enter boot, Grub will boot into the specified operating system.

If you are in the grub rescue> prompt, the situation will be slightly different. Because the bootloader is not able to find and load any necessary modules, you need to manually add these modules:

grub rescue> set root = (hd0,5)
grub rescue> insmod (hd0,5) /boot/grub/normal.mod
grub rescue> normal
grub> insmod linux
As indicated above, the same as before, and then use the ls command to list all partitions, use the set command to mark up. Then add a normal module, when the module will be activated to restore to normal grub> mode. If linux module is not loaded, the next command will be added. If the module has been loaded, you can talk to before, the boot loader to the kernel image and the virtual file system (initrd) file, and then start using the boot release, the perfect ending.

Once you have successfully started release, do not forget to Grub re-generate a new configuration file, use

grub-mkconfig -o /boot/grub/grub.cfg
command. You also need to install a copy of the MBR bootloader using

sudo grub2-install / dev / sda
command.

/etc/grub.d Want to disable script directory, you just remove its executable bits, such as using chmod -x /etc/grub.d/20_memtest86+ will be able to 'Memory Test' options removed from the menu .

Grub 2 and UEFI

In support UEFI machines (in recent years, most of them are listed on the machine) debugging broken Grub 2 adds another level of complexity. Recovery is installed on UEFI machines Grub did not much difference between 2 and is mounted on a non-UEFI machines, but the new firmware approach is not the same, resulting in a variety of recovery results.

For UEFI-based systems, do not install anything on the MBR. Instead, you want to install the EFI System Partition (EFI System Partition) (ESP) in Linux EFI bootloader, and the use of tools set it as EFI default startup program, this tool for Linux users efibootmgr, the window the user is bcdedit.

As things stand now, before installing any mainstream desktop Linux distributions compatible with Windows 8, it should be properly installed Grub 2. However, if the bootloader is damaged, you can use the live release repair machines. At the time of launch live media, make sure that is UEFI mode. Each mobile computer drives start menu will have two: a general and a mark of EFI. The latter will use / sys / firmware / efi / EFI file variable.

In a live environment, mount the previously mentioned tutorial hang system installation root file system. In addition, we need to mount the ESP partition. Suppose partition is / dev / sda1, you can mount as follows:

sudomount / dev / sda1 / mnt / boot / efi
Then before the previous releases in the chroot to the installed, use modprobe efivars efivars load module.

Here, Fedora users can use the following command to re-install the bootloader

yum reinstall grub2-efi shim
But before that, we need to use

grub2-mkconfig -o /boot/grub2/grub.cfg
To generate a new configuration file. Ubuntu users will use the following command

apt-get install --reinstall grub-efi-amd64
Once the bootloader is properly seated, Exiting the chroot, unmounting all partitions, reboot the Grub 2 menu.

 

Dude, my Grub where to go?

Grub 2 The best feature is you can always reinstall. Therefore, when other alternatives with their own bootloader such as Windows systems, leading to Grub 2 is lost, you can use live release, a few steps to reinstall Grub. Suppose you are in the / dev / sda5 installed a release, to reinstall Grub, you only need to first use the following command to create a mount directory for the release:

sudomkdir-p / mnt / distro
Then mount the partition, as follows:

mount / dev / sda5 / mnt / distro
Then you can reinstall Grub, the following:

grub2-install --root-directory = / mnt / distro / dev / sda
This command will overwrite / dev / sda MBR information on the device, point to Current Linux systems, and rewrite some of Grub 2 files, such as grubenv and device.map.

Another problem common to multiple releases mounted on a computer. When you install a new Linux distribution, its bootloader should be able to find all the releases have been installed. If not, as long as the boot into the installation of the new release, and running

grub2-mkconfig
Before running this command, make sure the boot menu missing release root partition has been mounted. If you want to release a separate add / root and / home partition before running grub2-mkconfig, simply mount containing / root partition.

Although Grub 2 can be found on most distributions, but try Fedora system requires additional installation to add a step in Ubuntu. If you set the default installation of Fedora, the release of the installer has been created LVM partitions. At this point you need to use the distribution's package management system to install lvm2 drive, as follows

sudoapt-get install lvm2
In order to make Grub os-prober script 2 can be found and added to the Fedora boot menu.

Common User Settings

Grub 2 had a lot of configurable variables. Here are some of the / etc / default / grub file, you are most likely to modify the common variable. GRUB_DEFAULT variable specifies the default startup items, can be set to a numeric value, such as 0, represents the first menu item, or set to "saved", will start at a point on the selected menu item. GRUB_TIMEOUT variable specifies the default menu item start dwell time before. GRUB_CMDLINE_LINUX lists all the Linux kernel command line parameters to pass to the menu items.

If GRUB_DISABLE_RECOVERY variable is set to true, it will not generate a recovery mode menu item. These menu items will start distribution in single-user mode, this mode allows you to use the command-line tool to repair the system. Also useful GRUB_GFXMODE variable that specifies the text displayed on the menu of the resolution, it can be set to any value for your video card supports.

Grub 2 has a command line mode, the bootloader menu, press C to enter.

 

Thorough repair

If grub2-install command does not work properly, so you can not boot into Linux, you need to completely reinstall and reconfigure the bootloader. To this end, the need to use a powerful chroot function changes the operating environment from the live CD environment we want to repair the installation position of Linux. Anyone with chroot tools Linux live CD can achieve this goal. However, the need to ensure consistent system architecture architecture live media and hard disk on the system. So when you want to chroot to a 64-bit system, you must use amd64 live release.

After you start entering live releases, you first need to check the partition on the machine. Use fdisk -l lists all partitions on the disk, recording the partitions you want to fix the Grub 2 system is located.

Suppose we want to restore the bootloader from the release installed in / dev / sda5 in the middle. Start the terminal use the following command to mount the partition:

sudomount / dev / sda5 / mnt
At this point you need to bind (bind) Grub 2 bootloader need to enter the directory, in order to detect other operating systems:

$ Sudomount - bind / dev / mnt / dev
$ Sudomount - bind / dev / pts / mnt / dev / pts
$ Sudomount - bind / proc / mnt / proc
$ Sudomount - bind / sys / mnt / sys
You can now leave the release into the live environment installed in / dev / sda5 partition, and through chroot:

$ Sudochroot / mnt / bin / bash
Now you can install, test, and upgrading Grub, and just like before, use

sudo grub2-install / dev / sda
Command to reinstall the bootloader. Since grub2-install command can not create grub.cfg file, you need to manually create, as follows

sudo grub-mkconfig -o /boot/grub/grub.cfg
This should be up. Now you have a brand-new copy of Grub 2, a list of all of the operating system and releases the machine. Before restarting the computer, you need to turn the system to exit the chroot, unmounting all partitions, as follows:

$ Exit
$ Sudoumount / mnt / sys
$ Sudoumount / mnt / proc
$ Sudoumount / mnt / dev / pts
$ Sudoumount / mnt / dev
$ Sudoumount / mnt
Now you can safely restart the computer, but it should fall back to Grub Control 2 among you've repaired the bootloader.

Adding custom menu items

If you want to bootloader menu, add menu items, you need to add a section to start (boot stanza) in 40_custom file. For example, you can use it to display a menu item to launch Linux distributions installed on a removable USB drive inside. Assuming your USB drive is sdb1, and vmlinuz kernel image and the virtual file system (initrd) are located in the root (/) directory, add the following 40_custom file:

menuentry "Linux on USB" {
   set root = (hd1,1)
   linux / vmlinuz root = / dev / sdb1 ro quiet splash
   initrd /initrd.img
}
Compared to the use of the device and partition name, the UUID can use them to obtain more accurate results, such as

set root = UUID = 54f22dd7-eabe
use

sudoblkid
UUID to get all the connected drives and partitions. You can also release your disk has not been found os-prober script adds a menu item, as long as you know the installation position and release their kernel and virtual file system (initrd) location.
     
         
         
         
  More:      
 
- Spacewalk remove packages install the update (Linux)
- It is time to upgrade your gulp 4.0 (Programming)
- Linux operating system log system (Linux)
- Analysis of memory mapping process in Linux x86-64 mode (Linux)
- Nine tips to protect the security of Linux desktop (Linux)
- Precautions against hackers Linux environment (Linux)
- RedHat / CentOS ext4 partition can not be formatted large supplementary ext4 formatting (Linux)
- NaSC using simple mathematical operations on Ubuntu and Elementary OS (Linux)
- To create a file in Linux directory by setfacl (Linux)
- Oracle: RETURNING clause (Database)
- Linux processes in memory and memory cgroup statistics (Linux)
- Puppet 3.5 Source package Installation and Configuration (Server)
- Read and write files efficiently from Apache Kafka (Server)
- How dependent on Fedora, CentOS, RHEL check RPM packages (Linux)
- rpm package specify the installation path (Linux)
- Ubuntu 14.04 install PostgreSQL 9.2 (Database)
- GO five stages of language learning (Programming)
- xCAT line installation on CentOS 6.X (Linux)
- CentOS6 5 Configure SSH password Free (Linux)
- Log4Net (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.