Use Grub 2 in Ubuntu to repair mobile hard drive boot

Source: Internet
Author: User

To use Grub 2 in Ubuntu to fix the installation of grub 2, you must install the following package: grub-pc. grub-common can be found in the package management tool. Grub-install-v to check the current version. The traditional grub version is 0.97 or below, and the grub2 version is 1.96 or higher. The configuration file of grub 2 is/boot/grub. cfg, but this file cannot be modified. d/and/etc/default/grub files are edited, and update-grub is used to generate the configuration file. That is to say, a normal process should be: sudo apt-get install grub-pc, grub-common # If grub2 is already installed, sudo grub-install -- root-directory = // dev/sda is not required # install grub2 on the device to boot sudo update-grub # generate grub the current problem with the configuration file is update-grub, grub-install can be installed on a specified device, but update-grub in the generated configuration file cannot be specified. Whereis update-grub finds it in the/usr/sbin/directory. The editor finds that it is a shortcut for grub-mkconfig. The Code is as follows [plain] #! /Bin/sh set-e exec grub-mkconfig-o/boot/grub. cfg "$ @", let's continue to view the grub-mkconfig Code (the following section only describes the definition of the previous key Directories) [plain] prefix =/usr exec_prefix =$ {prefix} sbindir =$ {exec_prefix}/sbin libdir =$ {exec_prefix}/lib sysconfdir =/etc PACKAGE_NAME = GRUB PACKAGE_VERSION = 1.98 + 20100804-5ubuntu3 host_ OS = linux-gnu datarootdir =$ {prefix}/share datadir =$ {datarootdir} pkgdatadir =$ {datadir}/'echo grub | sed "$ {transform}" 'gru B _cfg = "" grub_mkconfig_dir =$ {sysconfdir}/grub. d. It can be seen that the path is defined here. sysconfdir specifies the path of the system configuration file. After a simple check, the following code uses grub in this directory. d/* and default/grub to generate the configuration file... Then, we can modify sysconfdir to point it to the etc directory of the mobile hard disk to be repaired, and then run sudo grub-mkconfig-o/custom path/grub. cfg will generate grub under "/custom path. cfg of course, there is still a problem at this time, because the system found now uses the hard disk of the current operating system as the master hard disk scan, so for grub. modify the operating system settings in cfg, this part focuses on the system kernel version and device ls-l/dev/disk/by-uuid # view uuidls-l of all devices {hard disk mount points to be repaired }/ boot # Check the available kernel, at this point, change the modified grub. cfg moves to "{hard disk mount point to be repaired}/boot/grub/", and restarts to boot the target hard disk .. I have succeeded here ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.