Shortcuts to kernel boot (grub2 installation to USB flash drives, virtual images, etc)

Source: Internet
Author: User
For the kernel files we have prepared earlier, we also need the following three steps: create an image. install grub2 3. starting the USB flash drive does not describe how to install it. If you can master the method for creating a virtual image, you can simply modify some steps to complete the installation. all the steps are completed in UBUNTU.

For the kernel files we have prepared earlier, we also need the following three steps: create an image. install grub2 3. starting the USB flash drive does not describe how to install it. If you can master the method for creating a virtual image, you can simply modify some steps to complete the installation. all the steps are completed in UBUNTU.

The following three steps are required for the previously created kernel file:

I. Image Creation

2. Install grub2

Iii. Start

Here we will not describe how to install a USB flash drive. If you can master the method for creating a virtual image, you can simply modify some steps to complete the installation.

All the steps here are completed in UBUNTU. Other linux commands are slightly different. I have not installed any other version of linux, so I have not tried it. However, you can refer to my ideas, then modify the command to complete the document creation.

1. Create a virtual device image. Here we simulate a USB flash disk 1 to generate a virtual image. Method 1: DD tool creates an image dd if =/dev/zero bs = 512 count = 20480 of =. img * Method 2: (you need to install BOCHS, of course there are various ways) Then try the second method, bochs comes with bximage tool linux input command bximage prompt: One way press enter to create a 10 m image! 2. Use fdisk to partition the generated imgfile sudo fdisk. img m: Help a: Add boot tag n: Create new partition w: write after completing the operation *** p: display Device List 3.1 n create a new partition all by default (2048-20479) There is only one primary partition (the space previously reserved for booting) 3.2 a add boot flag into Boot * mark 3.3 p to see if the device is correct start end block number Id system. img1 * 2048 20159 9056 83 Linux 3.4 w save 3 Format partition mkfs an image file may contain multiple partitions, so you cannot simply mount-o loop. img, we need. after each partition in the img is mapped out, it is mounted one by one (because the partition needs to be formatted !!) Therefore, a tool is required to read the partition table. kpartx is such a tool that reads the partition table on a specific device and creates a ing for each partition. The-a parameter indicates that the partition ing is added; -v parameter indicates the output result after completion: 3.1 set. img maps to the loop device and generates the partition device * sudo kpartx-av. img (note that you are prompted to see which device is mounted. Or 3.2) 3.2 view the Mount directory. When the above large command is executed, the loop (x) is generated in the/dev/mapper/directory) here,/dev/loop (x) p1 is linked to/dev/loop (x ). ls-l/de v/mapper brw-r -- 1 crazy 252, 0 October 22:16 loop0p1 and then format the partition: * sudo mkfs/dev/mapper/loop0p1 (based on loop0p1) II. install grub21 and mount the partition where grub needs to be mounted (loop0p1 has not been uninstalled) sudo mkdir/mnt/img sudo mount/dev/mapper/loop0p1/mnt/img2. install GRUB2 (ubuntu is like this, others may be grub2-install) * sudo grub-install -- no-flopp Y -- boot-directory =/mnt/img/dev/loop0 (note! Here is/dev/loop0, which corresponds to the loop device mapped to the previous kpartx, for example,/dev/mapper/loop0p1 corresponds to/dev/loop0. (Some tips may be reported: check that the installation is complete. If grub can be started normally, it will be successful. 3. Make sure that the VM memory is set before the kernel is started (265 MB is recommended for memory). If the memory setting is too small, the following message is displayed: out of memory causes startup failure) If grub is not configured. cfg file: set root = hd0, msdos1 (this is based on your actual situation, please enter ls to view your disk device and related partition information) multiboot/kernel. img boot # aside, you can start the kernel command configuration here. /grub. cfg is much more convenient. for more information, see grub2. configure a configuration file set timeout = 15 set root = (hd0, msdos1) # set default = 0 # Set the default menu entryinsmod jpeg if loadfont/grub/fonts/unicode. pf2; then set gfxmode = 800x600 insmod gfxterm set lang = zh_CN insmod vbe if terminal_output gfxterm then true else terminal gfxterm fi fiset Limit = white/blackset Limit = white/empty (hd0, msdos1)/grub/logo.jpg // The module loaded in front of an image is also prepared for this image, which also slows down the virtual speed. // if you don't need it, you can destroy all the above. insmod jpeg. Here menuentry "cows" {set root = (hd0, msdos1) // here is also your Partition Number. Self-changing # chainloader + 1 # authorization transfer + '1 is to read the first sector multiboot/kernel of the partition installed in another operating system. img boot} paste a cool grub Interface

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.