Procedure:
Use cfdisk to create two partitions in the USB flash drive, and use the second partition as the boot partition.
0: mkfs. ext3/dev/sdc5
1: mount/dev/sdc5/tmp/boot
2: grub-install -- root-directory =/tmp/boot -- no-floppy/dev/sdc (* Note *)
Modify the menu. lst file by yourself. This is simple.
**************************************** ************************************
All of the above are overturned and rewritten. You must understand the theoretical knowledge to make the correct results.
**************************************** ************************************
First, understand the boot process of the USB flash drive.
1: When BISO is powered on to the disk, the MBR area is checked (MBR: 446 + DPT: 64 + ENDFLAG: 2 = 512)
There must be a boot program in the MBR, which is usually familiar With grub, dos, and 95dos boot. Otherwise, boot fails.
Here is a brief description: We usually install the system on the hard disk, usually windows, and then linux, and usually when installing linux, will prompt you whether to install in MBR, or install it in a disk partition, which is usually the partition where your/boot is located.
Installed in MBR or a disk partition. There is a difference between the two.
A: When the MBR is installed, the existing Windows boot program in the MBR will be replaced by GRUB boot.
B: When installed to a partition, Grub will be directed to the partition by the existing Win boot program, and Grub will then be directed to each operating system.
This is the difference between the two. Win has not considered it for other systems. After it reaches its own disk partition, it does not provide commands that can be directly booted for other systems. It can only enter and modify its boot. ini file. Grub provides command menus for manual guidance.
2: Create grub
I found that win can only automatically identify the first partition of the USB flash drive, but is indifferent to the second partition.
Therefore, this partition scheme is implemented. The first partition is used to store data, and the second partition is used to place the boot information, so that you do not need to delete or format the grub boot partition created by yourself during use.
My 1g usb flash drive partition is as follows:
/Dev/sdc1 950 M ntfs for normal data storage
/Dev/sdc5 60 M ext3 (boot ID, which can be boot and can be easily modified when cfdisk is used .) Used to store boot files.
Execute Command
Mount/dev/sdc5/tmp/boot
Grub-install -- root-directory =/tmp/boot -- no-floppy/dev/sdc
Note that grub is installed in/dev/sdc. Otherwise, no boot program is available for the MBR of the USB flash disk.
After this command is executed, files such as * stage * are generated in the/tmp/boot/directory, that is,/dev/sdc5.
Finally, create the menu. lst file in the/boot/grub directory. The file content is as follows:
Timeout 20
Default 0
Title windows xp
Map (hd0) (hd1)
Map (hd1) (hd0)
Rootnoverify (hd1, 0)
Makeactive
Chainloader + 1
If you use a USB flash drive, it will mark itself as hd0. The Windows operating system that has been installed on the hard disk considers its host hard disk to be hd0. In this case, the drive letter is misplaced when the Windows operating system is guided. Therefore, we need to use map for the ing conversion.
The description and usage of map are as follows:
Map TO_DRIVE FROM_DRIVE
Map the drive FROM_DRIVE to TO_DRIVE.
This ing is required when you chain the boot to a dos-like operating system that is not on the first drive.
That's OK!
**************************************** ************************************
As I use it more frequently, there is more content on menu. lst.
**************************************** ************************************
Next, let's share the content. The first is the directory structure.
Root @ kook :~ # Fdisk-l/dev/sdb
Disk/dev/SDB: 1010 MB, 1010826752 bytes
32 heads, 61 sectors/track, 1011 Cylinders
Units = cylinders of 1952*512 = 999424 bytes
Device boot start end blocks ID system
/Dev/sdb1 1 951 928145 + 6 fat16
/Dev/sdb2*952 1011 58560 83 Linux
Root @ kook :~ # Mount/dev/sdb2/tmp/boot/
Root @ kook :~ # Tree-d/tmp/boot
/Tmp/boot
| -- Boot
| '-- Grub
| -- Centos4.4
| -- Centos4.4-64
| -- Lost + found
'-- Ubuntu704
6 directories
Below is the content of menu. lst.
Root @ kook :~ # Cat/tmp/boot/grub/menu. lst
Color light-gray/blue
Timeout 20
Default 0
Title Windows 95/98/NT/2000
Map (hd0) (hd1)
Map (hd1) (hd0)
Rootnoverify (hd1, 0)
Makeactive
Chainloader + 1
Title CentOS 4.4 x86_64 Net Install
Root (hd0, 1)
Kernel/centos4.4-64/vmlinuz root =/dev/hda2 ro single
Initrd/centos4.4-64/initrd. img
Boot
Title CentOS 4.4 i386 Net Install
Root (hd0, 1)
Kernel/centos4.4/vmlinuz root =/dev/hda2 ro single
Initrd/centos4.4/initrd. img
Boot
Title Ubuntu 7.04 AMD 64 Net Install
Root (hd0, 1)
Kernel/ubuntu704/linux root =/dev/hda2 ro single
Initrd/ubuntu704/initrd.gz
Boot
Note:
1: The key to success is the MBR content. You can use dd if =/dev/sdc of =/tmp/mbr. bin bs = 446 count = 1 to extract the data. Hexdump-C
/Tmp/mbr. bin view
2: Sometimes MBR may be faulty. Use this command to clear it.
Dd if =/dev/zero of =/dev/sdc bs = 446 count = 1
Link: http://www.52zhe.cn/read.php/22.htm
Author: kook (if you are talking about technical issues in the blog, please contact me via MSN or Gmail below)
Contact information of the original author: (MSN: kook # live.com) (Google talk: kookliu)
No copyright: GNU. During reprinting, please note that "reposted" owes me a meal and redeem it when you come to the next day! Thank you for your cooperation!
Nwpulei was modified on