To make a Linux USB system that starts with a U disk

Source: Internet
Author: User

simple steps to make a Linux system that starts with a U disk:

  First, the U disk for processing

1. Partition: (Insert the U disk)

# FDISK/DEV/SDB

D Enter Delete the existing partition

N Enter a new primary partition

W Enter Save Settings

# PARTPROBE/DEV/SDB Flash u disk

2. Set USB disk partition for active partition

# FDISK/DEV/SDB

A Enter is set to active partition

1 Enter Select partition

3. To format the hard disk partition format into ext3 format

# MKFS.EXT3/DEV/SDB1

  Second, pack filesystem package (objective: to generate the root of the Root,usr,var ... etc directory)

1. Configure Good Yum

2. Load u disk to/net

# mount/dev/sdb1/net

3. Installation

# yum-y Install--installrot=/net filesystem

After the installation is complete, you can view multiple catalogs under/net

  Third, loading system startup items

1.# cp/boot/vmlinuz-2.6.18-128.el5/net/boot/

2. Generate initrd.img ' uname-r ' to take the system version number

# mkinitrd--with=usb-storage/net/boot/initrd-usb.img ' uname-r '

3. See if there are Vmlinuz and INITRD under/net/boot/

  Iv. Production of boot loader (GRUB)

1.# yum-y Install--installroot=/net Grub

2.grub.conf is not automatically generated, to be created manually

# cp/boot/grub/grub.conf/net/boot/grub/grub.conf and make changes

# cat/net/boot/grub.conf

Default = 0

Timeout = 5

Title Redhat-usb-linux

Root (hd0,0)

Kernel/boot/vmlinuz-2.6.18-128.el5 ro root=/dev/sdb1 Init=/dev/bash

Initrd/boot/initrd-usb.img

The content to be filled out here is consistent with the file name under/net/boot/grub/

  V. Install Command library files

# yum-y Install--installroot=/net bash coreutils pam setup vim-enhanced vim-minimal util-

Linux net-tools sysvinit passwd shadow-utils authconfig

The package name can be viewed through rpm-qf/bin/mount

At this point chroot/net can use the command you just installed.

  Vi. Creating a disk partition

# Mknod/net/dev/sdb B 8 16

# MKNOD/NET/DEV/SDB1 B 8 17

b for block devices, 8 for the main device number, 16, 17 for the secondary device number

--------------------------

| For an explanation of the device number:

| 1. For a scsi/sata hard drive (format sd*), the main device number is 8,

| The first hard disk's secondary device number is 0-15, the second hard disk's secondary device number is 16-31, and so on. Because for the hard disk, the primary partition can be up to 4, 3 primary partitions an extended partition,

| Zones can still be partitioned, but the total number of partitions is 16, so the secondary device number for each hard disk is 16 (0-15,16-31).

| 2. For an IDE hard disk (format hd*), the main device number is 3, the secondary device number is 0-63, and the second block is 64-127.

| 3.# ls-l/dev/sd*

| Brw-r-----1 Root disk 8, 0 10-16 14:53/DEV/SDA

| Brw-r-----1 Root Disk 8, 1 10-16 14:54/dev/sda1

| Brw-r-----1 Root Disk 8, 2 10-16 14:53/dev/sda2

| Brw-r-----1 Root Disk 8, 3 10-16 14:54/dev/sda3

| Brw-r-----1 Root disk 8, 10-16 15:50/dev/sdb

| Brw-r-----1 Root disk 8, 10-16 15:50/DEV/SDB1

| Brw-r-----1 Root disk 8, 10-16 15:50/DEV/SDC

| Brw-r-----1 Root disk 8, 10-16 15:50/DEV/SDC4

| The above is a host I inserted 1 hard drives, two U disk display, we can see the display of equipment number.

| 4. All files in Linux, hardware is also reflected through the document, all hardware devices are displayed in the/dev/.

| 5. More specific device number studies can view the following files.

| # yum Install Kernel-doc

| #/usr/share/doc/kernel-doc-2.6.18/documentation/devices.txt

---------------------------

  Vii. Creating a Mount

  1. Create mTAB

# Cat/net/etc/mtab

/dev/sdb1/ext3 RW 0 0

  2. Create Fstab

# Cat/net/etc/fstab

/DEV/SDB1/EXT3 Default 1 1

  Eight, install Grub

# chroot/net

# GRUB-INSTALL/DEV/SDB1

  Note:

1. If you create a hard disk partition is not configured correctly, in the eighth step will be an error:

The File/boot/grub/stage1 not read correctly

2. After using the U disk to start, into the USB disk in the system, at this time we can use already

Installed command set, but at this time the file system is read-only, we can not vim,

Mount, and so on, you must use the following command to read and write the mount again:

# Mount-o REMOUNT,RW/

After the load is mounted, it is ready.

At this point, U disk Linux system Startup Disk production is completed, through the above methods, users can use U disk to start Linux system, no longer need to worry about accidentally deleted files into the system, and do not need to remove the hard drive to copy.

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.