1. Install Windows system
In addition to partitioning the installation process to set aside some space to install CentOS, and other operations as normal installation.
2. Installing the CentOS System
Using the CD-ROM boot installation, as installed as a server version, it is recommended to choose No interface, minimize the installation, what services need to add their own installation.
Install the partition into the reserved space. Other default installations are complete.
3. Modify the Boot file
Open the boot file using the root user login
Vi/boot/grub2/grub.cfg
Find # # # Begin/etc/grub.d/30_os-prober # #在后面添加
' Windows 7 ' {insmod Ntfsset root= (hd0,2+1}
Save restart
Note: (hd0,2) for the second partition of the first drive, the user should be configured according to the actual situation
4, modify boot order
Open/boot/geub2/grubenv file, comment out #saved_entry=centos ..... This line is inserted on the next line
Saved_entry=windows 7
Save reboot
============================ The following information for additional Reading ================================
In the early Ubuntu, using grub as the boot loader for the system, it is very simple to modify the system boot entry, just open the System menu settings file (sudo gedit/boot/grub/menu.lst) with gedit, modify the file to the content, However, in Grub 2, it is not possible to modify the system startup item in this way.
Grub 2 Features
Grub 2 (GRand Unified Bootloader, version 2) is the second version of Grub. Grub 2 has a complete rewrite of the Grub interface, based on the pupa (detailed) project to research, GRUB 2 is more modular and easier to extend, and some of the improvements to Grub 2 are as follows:
Graphical interface with support for themes
Modular loading
The compatibility of the boast platform
Support Scripts
Customizing the Startup Project definition
Modify partition naming
GRUB 2 Structure
Grub 2 contains the following sections:
/boot/grub/grub.cfg file
/etc/grub.d/folder
/etc/default/grub file
Let's start with a description.
Grub.cfg similar to/boot/grub/menu.lst in Grub. The format is similar in Menu.lst, but now it is not allowed to modify the startup item by directly modifying the file, because the file is dynamically generated after "Update-grub" or "update-grub2", according to the 2 and 32 items mentioned above, i.e., If you modify this file the next time the two commands are executed (for example, after the kernel is updated), you will overwrite the content when you modify it. Official documents only Www.2cto.com said/boot/grub/grub.cfg do not modify manually, this file is run Update-grub automatically generated. To modify a configuration file, simply open the/boot/grub/grub.cfg file, locate the location you want to modify, and then follow the comments to find the appropriate/etc/default/grub or/etc/grub.d/(folder) to modify.
The Grub.cfg file contains two parts, some of which are defined for each startup item, and the second part is the setup of the startup interface. You can open the file directly with Gedit to see what's in it. Since grub.cfg can not be modified, there is nothing to say in detail, a little research can understand the inside is how to write. Here is an introduction to the other two parts of Grub 2.
The other two parts of Grub 2 actually correspond to two parts of Grub.cfg.
First, the/etc/grub.d/folder defines the individual startup items, where the file represents one or more startup items, the naming convention is "Two number _ name", the preceding two digits determine the location of this or multiple startup items in the boot interface, the default "00_" is reserved for "00_header" , "10_ is reserved for the current system kernel, 20_ is reserved for third-party programs, in addition to these you can use, add their own, such as 05_, 15_, the smaller the number of the front. The file here seems to be code, I haven't researched it, I won't write it myself, I'll just change it. When you execute the "Update-grub" or update-grub2 "command previously said, the files in this folder are the definitions used to generate the startup items in the grub.cfg.
The last part of Grub 2 is the/etc/default/grub file, which is primarily the configuration of the boot interface, such as the default startup item, waiting for the user to select the startup item time, and so on. The file content is simple, is some key value pairs, detailed configurable properties can refer to the Grub 2 Wiki "grub (/etc/default/grub)" section. When the "Update-grub" or update-grub2 "command is executed, the contents of this file are used to generate the settings for the start-up interface in Grub.cfg.
/etc/default/grub file Detailed modification method
sudo gedit/etc/default/grub
After the system installation is complete, the user will find that the/boot/grub/grub.cfg file is only readable by root, and if you want to modify the Grub.cfg file directly, modify its permissions first. Finally grub.cfg modified, the system kernel or grub upgrade, will automatically execute the update-grub,grub.cfg file will be returned to the original, how to ensure that the modified configuration file can remain? Www.2cto.com
Instead of modifying the grub.cfg, simply write the personalization configuration to grub and/etc/in the/etc/default/directory The script file in the GURB.D directory, which will create a personalized grub.cfg as required, regardless of the upgrade kernel or the Update-grub performed by the upgrade grub.
1, first look at the/etc/default/grub, first open the terminal from the application-attachment, enter
sudo gedit/etc/default/grub
See what changes can be made to the open file:
# If You change this file, run ' Update-grub ' afterwards to update
#/boot/grub/grub.cfg.
grub_default=0--------> Set default Startup Items, in Menuentry order. For example, to start from the fourth menu item by default, the number is changed to 3, and if you change to saved, the default is the last startup item.
Grub_hidden_timeout=0 default to 0, single system when the boot menu is automatically hidden, to suppress the auto-hide menu, instead of more than 0 and sudo update-grub. (Note: Under the single system/etc/grub.d/30_os-prober may not refer to the variables here, if the changes can not be displayed in the menu, but also to modify the/etc/grub.d/30_os-prober, see below to modify the section)
Grub_hidden_timeout_quiet=true
grub_timeout= "3"-----------> Set the wait time to enter the default startup item, the default value of 10 seconds, modify as you want
Grub_distributor= ' lsb_release-i-s 2>/dev/null | | Echo Debian '
grub_cmdline_linux_default= "Quiet Splash"-----------> Add kernel boot parameters, this is the default
grub_cmdline_linux= "Noresume"---------> Manually add kernel boot parameters, such as Acpi=off noapic, etc. can be added here, plus the text parameter to start entering character mode.
# Uncomment to disable graphical terminal (GRUB-PC only)
#GRUB_TERMINAL =console----------> Set whether to use a graphics interface. Remove front #, use console terminal only, do not use graphics interface www.2cto.com
# The resolution used on graphical terminal
# Note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command ' Vbeinfo '
#GRUB_GFXMODE =640x480 Set the graphics interface resolution, if you do not use the default, remove the front #, change the resolution to 800x600 or 1024x768
# Uncomment if you don ' t want GRUB to pass "root=uuid=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID =true----------> Set GRUB command to use UUID, remove #, use Root=/dev/sdax instead of root=uudi=xxx
# Uncomment to disable generation of Recovery Mode menu Entrys
#GRUB_DISABLE_LINUX_RECOVERY = "true"-----------> Set whether to create a Repair mode menu item
/ETC/GRUB.D Folder Details Modification method
And look at what's under the/etc/grub.d folder:
00_header 05_debian_theme 10_linux 20_memtest86+ 30_os-prober 40_custom README
The previous five scripts corresponding to the various parts of grub.cfg, how to modify these script files to ensure that the update-grub will not be destroyed, but also to make grub.cfg fit your wishes? It's really simple, just find
Cat << EOF
********
********
********
Eof
In this type of statement, the text in the middle of EOF is written directly to the corresponding position in the grub.cfg, so a personalized statement is added to this place.
00_header There are two places that can be modified
Cat << EOF www.2cto.com
Load_env
Set Default=${grub_default} <-----Here according to the default variable set in/etc/default/grub, do not modify
If [/${prev_saved_entry}]; Then
Saved_entry=/${prev_saved_entry}
Save_env Saved_entry
prev_saved_entry=
Save_env Prev_saved_entry
Fi
Insmod JPEG <---------This place to add modules to load, tablet support, or system format support Insmod NTFS and insmod fat, etc.
Insmod PNG <---------
Eof
The other at the end
Cat << EOF
Set Timeout=${grub_timeout} <-------timeout is set according to the timeout variable in the above/etc/default/grub, there is no need to change
Background_image (hd0,7)/boot/images/012.jpg <----------The absolute path of the background picture (does not seem to function, meet "instance")
Eof
05_debian_theme Modifying the background color
Cat << EOF www.2cto.com
Set Menu_color_normal=white/black <--------
Set Menu_color_highlight=yellow/black <-------front font color can be customized, the background must be set to black, otherwise the background color will block the background image. Note: Set Menu_color_highlight=black/light-gray before modification
Eof
10_linux This part is automatic search the current system, set up the current system of the boot menu, including the system header, kernel and other information, do not arbitrarily modify, to use a personalized menu name, such as the Chinese menu, can be modified here, the rest of the place do not modify:
Cat << EOF
Menuentry "Start $" {<---------in double quotes "" and "variable" to add a character, or directly change the variable to a fixed character such as Ubuntu Karmic
Eof
If ["x$3" = "Xquiet"]; Then
Cat << EOF
Set Quiet=1
Eof
20_memtest86+ Add a Memory test startup item where you can make modifications:
Cat << EOF
Menuentry "Memory Test (memtest86+)" {<------can be modified to Chinese menu such as menuentry "Ram testing" {, double quotes must be English characters
linux16 $MEMTESTPATH
}
# The second menu item below can be deleted
Menuentry "Memory Test (memtest86+)"
linux16 $MEMTESTPATH *********
} www.2cto.com
Eof
30_os-prober look for systems that exist in other partitions and set up menu items, which are Windows >> Linux >> MacOS, which do not have to be modified here.
or modify it according to your own system.
Menuentry "${longname} (on ${device})" <-------to change the variable in the quotes to fixed, such as Windows XP, Vista or Linux, Fedora and other menu items.
40_custom a custom startup item, add it in the standard format of the menu, and automatically add it to the grub.cfg after Update-grub, such as:
Menuentry "Start Veket" {
Set root= (hd0,8)
Linux/veket/vmlinuz Root=/dev/ram0 PMEDIA=HD
Initrd/veket/initrd.gz
}
Menuentry "Start Cdlinux" {
Set root= (hd0,8)
Linux/cdlinux/bzimage root=/dev/ram0 vga=791 cdl_lang=zh_cn. UTF-8
Initrd/cdlinux/initrd
}
Menuentry "Start Grub4dos" {
Set root= (hd0,8)
Linux/grub.exe
}
Change the items and save them, then
sudo update-grub
Cat/boot/grub/grub.cfg
See if the configuration file is the same as you think.
Not the same??? Change again, and then sudo update-grub
Www.2cto.com
Instance:
To modify the default startup items, you can use the following methods:
1. Modify the order of the startup items in the/etc/grub.d/and set the order of the items you want to start by default to a smaller value. The advantage is that the changes will not be overwritten by the Update-grub command, as if there is no power shortage, only another program modified to be smaller than your value will become the default boot.
2. Modify the default startup item in/etc/default/grub, set the Grub_default in the file to the value you want, which is the subscript from 0 for each startup item in the generated grub.cfg. The advantage of this method is that the modification is not overwritten by the Update-grub command, and the disadvantage is that when the order of the Startup items changes, the subscript is changed ...
Adjust the Start screen resolution
First step: Open terminal, modify/etc/default/grub file
$ sudo gedit/etc/default/grub
Cancels #grub_gfxmode=640x480 the comment symbol in front of this line and modifies the following number to a suitable value, which does not need to be too high, such as 1024x768. This value also affects the resolution of the Grub boot menu and the text in the console.
Note: The boot menu and the boot interface resolution are the same, if the resolution is set too high, the boot menu will be very difficult to see, it seems that the change resolution does not affect the startup speed,
Step Two: Modify the/etc/grub.d/00_header file
$ sudo gedit/etc/grub.d/00_header
Press Ctrl+f to find the keyword "set Gfxmode=${grub_gfxmode}" (remove the double quotes) and add a new line below this line, with the following: "Set Gfxpayload=keep" (remove double quotes)
Step Three: Update grub
$ sudo update-grub
All right, restart, no surprises, you'll see Plymouth's boot screen is really prettier.
Add a picture to the Grub2 menu
1. Locate the 00_header file in the ETC/GRUB.D folder and open it in the
Save_env Prev_saved_entry
Fi add a sentence www.2cto.com
Insmod png
2. In Etc/grub.d/05_debian_theme, replace the
Set Menu_color_normal=white/black
Set Menu_color_highlight=yellow/black (the front font color can be customized, the background must be set to black, otherwise the background color will block the background image.) Details of the previous statement)
3. According to the picture location can determine the system Grub default picture folder location, put a picture file with the same name in the same location.
The file name in the figure is moreblue-orbit-grub.png
Note:
I. How to modify the/boot/grub/grub.cfg file (can be used as a reference to modify the/etc/grub.d/folder and/etc/default/grub file)
GRUB.CFG defaults to read-only, and is set to writable before being modified
sudo chmod +w/boot/grub/grub.cfg
Set default=0
#默认为0
Insmod jpg
#添加jpg支持, if you want to use a PNG or TGA file for background, plus insmod png or insmod TGA (adding a picture doesn't seem to work)
Insmod ext2
#除了用作启动的分区外, other partition formats can be added underneath the menu
Set root= (hd0,7)
#设定root分区
Search-no-floppy-fs-uuid-set f255285a-5ad4-4eb8-93f5-4f767190d3b3
#设定uuid =**** partition as root, and repeat on the previous sentence to delete
# The following is the terminal configuration
if LOADFONT/USR/SHARE/GRUB/UNICODE.PF2; Then
#设置终端字体, UNICODE.PF2 support Chinese display
Set gfxmode=640x480 www.2cto.com
#设置分辨率, the default is 640x480, available 800x600,1024x768, the recommended size is the same as the picture you want to set
Insmod Gfxterm
#插入模块 Gfxterm, supports Chinese display, it also supports 24-bit images
Insmod VBE
#插入 the VBE module, GRUB 2 introduces a lot of modules to something, to use it, you need to join here
If Terminal_output gfxterm; then true; Else
# for backward compatibility with versions of terminal.mod that don ' t
# Understand Terminal_output
Terminal Gfxterm
#设置 GRUB 2 terminal is gfxterm
Fi
Fi
Set timeout=10
Background_image (hd0,7)/boot/images/1.jpg (adding a picture doesn't seem to work)
#设置背景图片
# # # 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 Menu Color settings, if the default, you will find that the background is completely blocked by blue, you need to change blue to black, so the background will appear
# # # End/etc/grub.d/05_debian_theme # #
# 10_linux for automatically added current root partition Linux boot entry
# # # Begin/etc/grub.d/10_linux # #
#菜单项, to include menuentry double quotes "" and curly braces {} are not complete, otherwise the menu is not displayed
Menuentry "Ubuntu, Linux 2.6.31-9-386″{
Insmod ext2 www.2cto.com
Set root= (hd0,7)
Search-no-floppy-fs-uuid-set f255285a-5ad4-4eb8-93f5-4f767190d3b3
#这句与set root= (hd0,7) duplicates, can be deleted
linux/boot/vmlinuz-2.6.31-9-386 root=uuid=f255285a-5ad4-4eb8-93f5-4f767190d3b3 ro Quite splash
#不喜欢看到一长串的, roo=uuid=*** can be replaced with 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 entries that exist on other partitions
# # # Begin/etc/grub.d/30_os-prober # #
#windows Start Menu
Menuentry "Windows Vista (loader) (on/dev/sda1)" {
Insmod NTFS
#windows格式为ntfs, or change the FAT32 to Insmod fat
Set root= (hd0,1)
Search-no-floppy-fs-uuid-set ece067d2e067a196
#可删除
#grub2比较先进的地方就是如果发现windows启动是通过ntldr boot, 2000/xp/2003, will be added Drivemap-s (hd0) ${root}, the equivalent of the grub map, can normally start the non-first hard drive XP /2003 System.
Chainloader +1
}
# Find Linux systems on other partitions and add them 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
} www.2cto.com
#若存在macos会自动在这里添加.
# # # End/etc/grub.d/30_os-prober # #
# The following menu items are manually added
# # # 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 at 0 (hd0), the primary partition number starts from 1 (hd0,1), and the logical partition starts at 5 (hd0,5)
Second, GRUB2 Terminal part command introduction
When the Select menu appears, press C to enter terminal command line mode, press E to enter the current menu item editing mode (as with grub), edit Ctrl + C to exit, press CTRL + X to edit the content to start.
1. Help
View command usage, show all available commands
Help Search
Search command Usage
2. ls
Lists all the current devices. such as (hd0) (hd0,1) (hd0,5) (HD1) (hd1,1) (hd1,2) ....
Ls-l
Lists all current devices in detail. For a partition, its label and UUID are displayed.
LS/
List files under the partition that is currently set as root
LS (hd1,1)/
List (hd1,1) partitions under Files
3. Search
Search-f/ntldr
Lists the partition containing the Ntldr file in the root directory, returned as the partition number
Search-l LINUX www.2cto.com
The search label is a partition of Linux.
Search-set-f/ntldr
The search root directory contains the partition of the Ntldr file and is set to root, noting that if the multi-outer partition contains a NTLDR file, set loses its function.
4. Loopback
The loopback command can be used to set up playback devices, such as
Loopback Lo0 (hd1,1)/abc.iso
You can use the Lo0 device to access content in the Abc.iso, for example, you can start from a floppy 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
Use set to set the value of a variable
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
paginated display.
Set Pager=1
Pause on full page, continue as space
Set pager=0
Cancel page out
7. Linux
Linux replaces kernel in grub
Third, www.2cto.com
Single Linux system or
When the hard disk is installed, ISO is placed on the C drive, and the umount/isodevice caused by mistaken thinking single system
There are several ways to deal with menu items.
1. Press the SHIFT key after post to bring up the menu item
2. Sudo update-grub
Rebuilding the grub.cfg will find a new system and rewrite the grub.cfg, which can usually appear in menu items.
3. If the second method cannot be resolved, modify the Grub.cfg directly
Put in the section of # # # 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 three set timeout=< greater than 0>
Four, dual-drive dual-system Grub loading time too long solution
GRUB2 's boot.img set the root UUID from the first partition to search for the module under the partition's/boot/grub and load, if the Linux partition is on a second hard drive or even a third hard drive, the search time will be too long and the menu time will be up to more than 10 seconds.
For dual (multi) hard drives, it is recommended that grub be installed on the MBR of the hard disk where Ubuntu is located, and the boot time will be greatly shortened by booting the boot disk and/or partition as far forward as possible.
Five, grub2 several repair method www.2cto.com
1. Dual-System reload Windows causes GRUB2 to be rewritten
Method One grub4dos0.4.4
Add Grub4dos on Windows Startup items (not much to say, watch sticky stickers), reboot choose to go to grub, enter under command line (/boot separate partition)
Code:
Grub>find-set-root/boot/grub/core.img
Grub>kernel/boot/grub/core.img
Grub>boot
Enter the Grub2 menu, enter the system and then execute
Code:
sudo grub-install/dev/sd?
Method two enters LiveCD after repair (thanks billbear)
Reference:
Sudo-i
Mount your root partition/mnt
Mount your/boot partition/mnt/boot #如果有的话
#挂载你其他的分区, if you have one.
# Rebuilding GRUB to SDA's MBR
Grub-install-root-directory=/mnt/dev/sda
2. Unable to start properly due to changes in the root partition uuid, only the repair of Grub Rescue mode can be entered
Code: www.2cto.com
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
At this point, you can recall/boot/grub/grub.cfg, modify the corresponding 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 the system
hd ,? is the grub file located on the partition SDA? Yes/partition.
3. Grub module and configuration file Grub.cfg damaged cannot be started when fixed
LIVCD launch into trial
Reference:
Sudo-i
Mount your root partition/mnt
Mount your/boot partition/mnt/boot #如果有的话
# mount your other partitions, if any
# Rebuilding GRUB to SDA's MBR
Grub-install-root-directory=/mnt/dev/sda
# Rebuilding Grub.cfg www.2cto.com
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. Other Additional Notes
1. Chainloader
GRUB2 will support the use of chainloader/file.
Currently supported files are only grub2 boot.img and Grub4dos Grldr and Grub.exe. Hope that the official version can support NTLDR bootmgr Peldr and other documents.
2. Drivemap
Drivemap is a grub-compatible map, primarily for systems that boot only from (hd0) booting, such as Win2000 XP 2003, which can be used just like the map usage:
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 www.2cto.com
Set root= (hd1,1)
Drivemap-s (hd0) ${root}
Chainloader +1
}
3. GRUB2 Boot floppy img image boot
For example, to load (hd1,1) the root directory of the a.img image, first extract memdisk from the memdisk.gz, the usage is:
Linux (hd1,1)/memdisk #镜像文件超过2.88M to add c=* h=* s=*
INITRD (hd1,1)/a.img
Boot
Installing Windows and CentOS dual system