Grub2 configuration (grub1.97 beta4 for ubuntu9.10)

Source: Internet
Author: User
1. Grub. cfg

Grub. cfg is read-only by default. It must be set to writable before modification.
Sudo chmod + w/boot/GRUB/grub. cfg

Set default = 0
# The default value is 0.
Insmod JPEG
# Add JPG support. To use a PNG or TGA file as the background, add insmod PNG or insmod TGA.
Insmod ext2
# In addition to partitions used for startup, other partition formats can be added under the menu
Set root = (hd0, 7)
# Set the root Partition
Search -- no-floppy -- FS-UUID -- set f255285a-5ad4-4eb8-93f5-4f767190d3b3
# Set the uuid = *** to the root partition, which is the same as the previous sentence and can be deleted.
# Terminal Configuration
If loadfont/usr/share/GRUB/Unicode. pf2; then
# Set the terminal font. Unicode. pf2 supports Chinese display
Set gfxmode = 640x480
# Sets the resolution. The default value is
640x480, 800x768, X. We recommend that you set the image size to the same
Insmod gfxterm
# Insert the gfxterm module, which supports Chinese display and 24-bit Images
Insmod VBE
# Insert the VBE module. Grub 2 introduces many modules. to use it, you need to add them here.
If terminal_output gfxterm; then true; else
# For backward compatibility with versions of terminal. MOD that don't
# Understand terminal_output
Terminal gfxterm
# Set the grub 2 terminal to gfxterm
Fi
Fi
Set timeout = 10
Background_image (hd0, 7)/boot/images/1.jpg
# Setting background images
### End/etc/grub. d/00_header ###

### Begin/etc/grub. d/05_debian_theme ###
Set menu_color_normal = white/black
Set menu_color_highlight = cyan/Black
# Debian
In the left-side Navigation Pane. If it is set by default, you will find that the background is completely blocked by blue.
Blue is black, so the background will appear
### End/etc/grub. d/05_debian_theme ###

# 10_linux is the automatically added Linux boot item for the current root Partition
### Begin/etc/grub. d/10_linux ###
# The menu items must contain menuentry double quotation marks "" And braces {}. Otherwise, the menu is not displayed.
Menuentry "ubuntu, Linux 2.6.31-9-386 "{
Insmod ext2
Set root = (hd0, 7)
Search -- no-floppy -- FS-UUID -- set f255285a-5ad4-4eb8-93f5-4f767190d3b3
# This statement is repeated with set root = (hd0, 7) and can be deleted.
Linux/boot/vmlinuz-2.6.31-9-386
Root = UUID = f255285a-5ad4-4eb8-93f5-4f767190d3b3 Ro quite splash
# Do not like to see a long string, Roo = UUID = *** can be replaced by root =/dev/sda7
Initrd/boot/initrd. img-2.6.31-9-386
}
### End/etc/grub. d/10_linux ###

### Begin/etc/grub. d/20_memtest86 + ###
Menuentry "Memory Test (memtest86 + )"{
Linux16/boot/memtest86 +. Bin
}
### End/etc/grub. d/20_memtest86 + ###

# Automatically add system boot items that exist in other partitions
### Begin/etc/grub. d/30_os-prober ###
# Windows Startup Menu
Menuentry "Windows Vista (loader) (on/dev/sda1 )"{
Insmod NTFS
# Change the Windows format to NTFS or FAT32 to insmod fat
Set root = (hd0, 1)
Search -- no-floppy -- FS-UUID -- set ece067d2e067a196
# Deletable
# Grub2 is more advanced in that if you find that Windows is started through ntldr
Bootstrap value: 2000/XP/2003. drivemap-s (hd0) $ {root} will be added here}
The role is equivalent to the map of grub, and the XP/2003 system of non-first hard disk can be started normally.
Chainloader + 1
}
# Find the Linux system on another partition and add it automatically
Menuentry "ubuntu karmic (Development Branch) (9.10) (on/dev/sda3 )"{
Insmod ext2
Set root = (hd0, 3)
Search -- no-floppy -- FS-UUID -- set 4d893970-0685-44ed-86b3-1de45b2db84a
Linux/boot/vmlinuz-2.6.31-9-generic root =/dev/sda3
Initrd/boot/initrd. img-2.6.31-9-generic
}
# If MACOs exists, it will be automatically added here.
### End/etc/grub. d/30_os-prober ###
# The following are manually added menu items
### Begin/etc/grub. d/40_custom ###
Menuentry "cdlinux "{
Set root = (hd0, 8)
Linux/cdlinux/bzimage root =/dev/ram0 VGA = 791 cdl_lang = zh_CN.UTF-8
Initrd/cdlinux/initrd
}
### End/etc/grub. d/40_custom ###

#
When manually added, the hard disk number starts from 0 (hd0), the primary Partition Number starts from 1 (hd0, 1), and the logical Partition Number starts from 5 (hd0, 5)

II. Introduction to some commands of grub2 Terminal
When the menu is selected, press C to enter the terminal command line mode, press e to enter the current menu item editing mode (the same as grub), and press Ctrl
+ C Exit, press Ctrl + X to start the edit content.

1. Help
View command usage and display all available commands
Help search
SEARCH command usage
2. ls
Lists all current devices. For example, (hd0) (hd0, 1) (hd0, 5) (hd1) (hd1, 1) (hd1, 2 ).......
Ls-l
List all devices in detail. The label and UUID of the partition are displayed.
Ls/
List the files in the current root partition.
Ls (hd1, 1 )/
List objects in the (hd1, 1) Partition
3. Search
Search-F/ntldr
List the partitions in the root directory that contain the ntldr file. The return value is the Partition Number.
Search-l Linux
The search label is a LINUX partition.
Search -- Set-F/ntldr
Search for the partitions whose root directory contains the ntldr file and set it to root. Note that if multiple external partitions contain the ntldr file, Set
Ineffective.
4. loopback
The loopback command can be used to create a playback device, as shown in figure
Loopback lo0 (hd1, 1)/ABC. ISO

You can use the lo0 device to access content in ABC. ISO. For example, you can start from a floppy disk image in ABC. ISO.
Loopback lo0 (hd1, 1)/AA. ISO
Linux (lo0)/memdisk
Initrd (lo0)/ABC. img

To delete a playback device, you can use the-D parameter:
Loopback-D lo0
5. Set
You can use set to set variable values.
Set root =
Set timeout =
When you need to call the value of a variable, use $ {AA}, such as set root = (hd1, 1)
Then $ {root} = (hd1, 1)
6. Pager
Display by page.
Set pager = 1
When the page is full, pause and Press space to continue
Set pager = 0
Cancel Paging
7. Linux
Replacing kernel in grub with Linux

III,
For a single Linux system or
When the hard disk is installed, the ISO is placed on the drive C, and umount/isodevice causes the mistake of a single system
There are no processing methods for menu items.
1. After self-check, press the Shift key to adjust the menu item
2. sudo Update-grub
If you recreate grub. cfg, you will find the new system and rewrite grub. cfg. Generally, a menu item appears.
3. If the second method cannot be solved, modify grub. cfg directly.
Put this section in ### begin/etc/grub. d/30_os-prober
If keystatus; then
If keystatus -- shift; then
Set timeout =-1
Else
Set timeout = 0
Fi
Else
If sleep $ verbose -- interruptible 3; then
Set timeout = 0
Fi
Fi
Delete or modify set timeout = <greater than 0>

Iv. Dual-disk dual-system grub loading solution with long time

Boot. IMG of grub2 sets the root UUID to search for and load modules in/boot/grub from the first partition,
If the LINUX partition is on the second or third hard disk, the search takes a long time, and the menu appears for more than 10 seconds.
For dual (multiple) hard disks, it is recommended to install grub on the MBR of the disk where Ubuntu is located,/boot partition or/
Partitioning should be as front as possible, and setting the hard disk as the boot disk will greatly shorten the start time.

5. Several restoration methods of grub2

1. reinstalling windows on both systems causes grub2 to be rewritten and fixed
Method 1: grub4dos0.4.4
Add the grub4dos boot option to the Windows boot item (if you don't talk about it much, see the top post), restart and choose to enter grub, and enter it in the command line (remove the partition of/boot separately ).
/BOOT)
Code:
Grub> Find -- Set-root/boot/GRUB/CORE. img
Grub> kernel/boot/GRUB/CORE. img
Grub> boot

Go to the grub2 menu, enter the system, and then execute
Code:
Sudo grub-install/dev/sd?

Method 2: Repair after entering livecd
Reference:
Sudo-I
Mount your root partition/mnt
Mount your/boot partition/mnt/boot # If yes
# Mount your other partitions, if any
# Rebuilding MBR from grub to SDA
Grub-install -- root-directory =/mnt/dev/SDA

2. The root partition UUID cannot be started properly, so it can only be restored in grub rescue mode.

Code:
Grub rescue> set
Grub rescue> prefix = (HD ?,?) /GRUB
Grub rescue> root = HD ?,?
Grub rescue> set root = HD ?,?
Grub rescue> set prefix = (HD ?,?) /Boot/GRUB
Grub rescue> set
Grub rescue> root = HD ?,?
Grub rescue> prefix = (HD ?,?) /Boot/GRUB
Grub rescue> insmod/boot/GRUB/normal. Mod
Grub rescue> normal

You can call up/boot/GRUB/grub. cfg and modify the UUID,
Change to the command line
Grub> insmod/boot/GRUB/Linux. Mod
Grub> set root = HD ?,?
Grub> Linux/boot/vmlinuz-*** root =/dev/sd ??
Grub> initrd/boot/initrg. IMG -****
Enter System
HD ?,? Is the partition where the grub file is located, SDA? Yes/partition.

3. Repair when grub module and configuration file grub. cfg are damaged and cannot be started

Start livcd and start trial
Reference:
Sudo-I
Mount your root partition/mnt
Mount your/boot partition/mnt/boot # If yes
# Mount your other partitions, if any

# Rebuilding MBR from grub to SDA
Grub-install -- root-directory =/mnt/dev/SDA

# Rebuilding grub. cfg
Mount -- bind/proc/mnt/proc
Mount -- bind/dev/mnt/dev
Mount -- bind/sys/mnt/sys
Chroot/mnt Update-grub
Umount/mnt/sys
Umount/mnt/dev
Umount/mnt/proc

Vi. Some additional instructions

1. chainloader
Grub2 supports the use of chainloader/file.
Currently, only grub2 boot. IMG and grub4dos grldr and
Grub.exe. The official version is expected to support ntldr bootmgr peldr and other files.

2. drivemap
Drivemap is compatible with grub map and is mainly used for systems that can only be started from (hd0) boot, such as win2000
XP 2003, which can be used in the same way as map:

Menuentry "Windows XP "{
Insmod NTFS
Drivemap (hd0) (hd1)
Drivemap (hd1) (hd0)
Set root = (hd1, 1)
Chainloader + 1
}

In fact, drivemap has a more convenient usage:
Menuentry "Windows XP "{
Insmod NTFS
Set root = (hd1, 1)
Drivemap-s (hd0) $ {root}
Chainloader + 1
}

3. grub2 boot floppy disk IMG image startup
For example, to load a. IMG image under the root directory (hd1, 1 ),
To decompress the package. Usage:
Linux (hd1, 1)/memdisk # When the image file exceeds 2.88m, c = * H = * s = * must be added *
Initrd (hd1, 1)/A. img
Boot

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.