How to make a Linux grub boot on a USB disk

Source: Internet
Author: User
Tags file system

GNU GRUB (Grand Unified bootloader "Grub") is a multiple operating system startup program from the GNU Project. Grub is an implementation of the multiple-boot specification, which allows users to have multiple operating systems in the computer at the same time, and select the operating system that they want to run when the computer starts. Grub can be used to select different cores on the operating system partition or to pass startup parameters to these cores.

When started by a hard disk, the BIOS is usually the first sector to the first hard drive, the master boot Record (MBR).

The process of loading grub and the operating system includes the following steps:

Mount Records-The only thing the basic boot loader does is load the second boot loader.

Mount grub--This second boot loader is actually a more advanced feature that allows the user to load a particular operating system.

Mount Systems-such as the Linux kernel. Grub transfers control of the machine to the operating system.

The difference is that the Microsoft operating system is launched using a boot method called chained loading, which simply points to the first sector of the partition where the operating system is located.

Many distributions are supported by USB boot, then we can make a USB boot of the tool plate, the answer is YES!

Make the following assumptions first

USB device is/dev/sdb

USB Disk mount point/mnt/usbdisk

Let's just say the following steps to install the Grub loader onto a USB disk

Determine the location of the USB disk, generally/DEV/SDB

The code is as follows:

[root@localhost]# fdisk-l

Use the following command to clear MBR boot bytes

The code is as follows:

[root@localhost]# DD If=/dev/zero of=/dev/sdb bs=512 count=1

Load on a USB disk using the Mbr.bin in Syslinux

The code is as follows:

[root@localhost]# Locate Mbr.bin

[root@localhost]# cat/somepath/share/syslinux/mbr.bin >/dev/sdb

Use FDISK to partition the USB disk, similar results are as follows:

The code is as follows:

Device Boot Start End Blocks Id System

/DEV/SDB1 * 1 1018 993537+ Linux

Create the Ext3 file system on the partition and hang it on the USB disk

The code is as follows:

[root@localhost]# MKFS.EXT3/DEV/SDB1

[root@localhost]# mkdir-p/mnt/usbdisk

[root@localhost]# Mount/dev/sdb1/mnt/usbdisk

Install the Grub boot loader to the USB disk

The code is as follows:

[root@localhost]# grub-install--no-floppy--root-directory=/mnt/usbdisk/dev/sdb

Creating a grub.conf configuration file

The code is as follows:

[root@localhost]#

Cat >/mnt/usbdisk/boot/grub/grub.conf << EOF

Title USB Linux

Root (hd0,0)

Kernel/boot/kernel-xxxx root=/dev/sda1 RO

Initrd/boot/initrd-xxxx.img

Eof

Copy the kernel and INITRD to the USB disk and reboot the system to boot the system.

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.