Use grub and grub2 to create dual-system boot USB flash drives

Source: Internet
Author: User
Use grub and grub2 to create dual-system boot USB flash drives. After I plug in the USB flash drive, fdisk-l will view the USB flash drive information and learn that it is/dev/sdbwww.2cto.com. Fdisk/dev/sdb run the p command to check that there is a fat32 partition, remove it, run the d command, and then run the n command to add... use grub and grub2 to create dual-system boot USB flash drives. After I plug in the USB flash drive, fdisk-l will view the USB flash drive information and learn that it is/dev/sdb www.2cto.com. Fdisk/dev/sdb run the p command to check that there is a fat32 partition, remove it, run the d command, and then run the n command to add a new primary partition, after n, select p (primarypartition), and then Partition number (1-4): 1. then run the n command to add the second primary Partition, and then run the command, set the first and second primary partitions as bootable. Finally, use the w command to write data. The format of www.2cto.com is ext3, mkfs-t ext3/dev/sdb1mkfs-text3/dev/sdb2 then mount the system mkdir/mnt/sdb1mount-text3/dev/sdb1/mnt/sdb1mkdir/mnt/sdb2mount-text3/dev /sdb2/mnt/sdb2, after unmounting the bt5 disc, copy the casper and preseed folders to the root directory of the first partition. Put the entire CD iso file of linux deepin into the root directory of the second partition. Then install grub to/mnt/sdb1grub-install -- root-directory =/mnt/sdb1/dev/sdb to/boot/grub. copy the conf file to the directory corresponding to the USB flash drive and edit grub. conf [html] timeout 20 default 0 title Windows 7 map (hd0) (hd1) map (hd1) (hd0) rootnoverify (hd1, 0) makeactive chainloader + 1 title backtrack 5 root (hd0, 0) kernel/casper/vmlinuz root =/dev/sdb1 file =/preseed/custom. seed boot = casperlocale = zh_CN text -- initrd/casper/initrd.gz title linux Deepin root (hd0, 1) kernel/boot/grub/core. the configuration file img savedefault boot indicates that the first partition of the U disk is bt5 guided by grub, and the second partition of the U disk is guided by grub core. img then directs to core. img, this core. img is the img of grub2. At this time, there is no core. img in the second partition, which will be created later. let's write it like this first. Then install grub on the MBR and enter the grub command [html] grub> root (hd1, 0) Filesystem type is ext2fs, partition type 0x83 grub> setup (hd1) checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed/boot/grub/e2fs_stage1_5 (hd1 )"... 15 sectors are embedded. succeeded Running "install/boot/grub/stage1 (hd1) (hd1) 1 + 15 p (hd1, 0)/B Oot/grub/stage2/boot/grub. conf "... succeeded Done. grub> quit, and then plug in the USB flash drive to restart the system, you should be able to smoothly enter the bt5 system. bt5 is based on ubuntu. after entering the system, write grub2 to the second partition. Grub-install -- root-directory =/mnt/sdb2/dev/sdb write grub2 at this time. Then edit the configuration file grub2, grub. cfg. the content of this file is as follows: [html] # do not edit thisfile # It isautomatically generated by/usr/sbin/grub-mkconfig using templates # from/etc/grub. dand settings from/etc/default/grub #### BEGIN/etc/grub. d/00_header ### set timeout = 10 ### END/etc/grub. d/00_header ###### BEGIN/etc/grub. d/05_debian_theme ### setmenu_color_normal = white/black setmenu_color_highlight = black/light-gray ### END /Etc/grub. d/05_debian_theme ###### BEGIN/etc/grub. d/10_linux ### menuentry "linux deepin" {loopbackloop (hd0, 2)/deepin_12.06_zh-hans_i386.iso linux (loop) /casper/vmlinuz boot = casperiso-scan/filename =/deepin_12.06_zh-hans_i386.iso locale = zh_CN.UTF-8 nopromptnoeject initrd (loop)/casper/initrd. lz} the partition in the grub configuration file is (hd0, 0), while the partition in the configuration file of grub2 is (hd0, 2), because the partition in grub starts from 0, the partition in grub2 starts from 1. Www.2cto.com at this time grub2 MBR will overwrite grub MBR, so we need to restart the system, enter a normal linux system, and then execute the command to install grub to MBR again, overwrite the grub2 MBR. [Html] grub> root (hd1, 0) Filesystem type is ext2fs, partition type 0x83 grub> setup (hd1) checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed/boot/grub/e2fs_stage1_5 (hd1 )"... 15 sectors are embedded. succeeded Running "install/boot/grub/stage1 (hd1) (hd1) 1 + 15 p (hd1, 0)/boot/grub/stage2/boot/gr Ub/grub. conf "... succeeded Done. grub> after you restart quit, you have a dual-linux USB flash drive.
Related Article

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.