[Marco Study notes] The production of Linux system bootable Linux with network function

Source: Internet
Author: User
Tags network function knowledge base

Knowledge Base:

System Boot Process: Post-->bios (Boot sequence)-->grub (Bootloder (in Stage1:mbr;stage2:grub directory))-->kernel (INITRD)-- SHELL

Production steps:

1. Partition the target disk

Two:

Host:/DEV/SDB1/DEV/SDB2

Mount the/DEV/SDB1 to/mnt/boot,/dev/sdb2 mount to/mnt/sysroot

Mount/dev/sdb1/mnt/bootmount/dev/sdb2/mnt/sysroot

2. Install GRUB to target disk

Grub-install--root-directory=/mnt/dev/sdb

3. Copy kernel and INITRD files

1 CP /boot/vmlinuz-2.6. -279. el6.i686/mnt/boot/vmlinuz2cp /boot/initramfs-2.6. -279. el6.i686.img/mnt/boot/initramfs.img
View Code

4. Create the root system file of the target file

Mkdir-pv/mnt/sysroot/{/etc/rc.d,usr,var,media,home,root,src,sys,boot,tmp,lib,lib64,dev,proc,bin,sbin}

Porting Bash,ls to target root system files with BINCP scripts

Bincp.sh as follows:

1#!/bin/Bash2 #3dest=/mnt/Sysroot4 libcp () {5libpath=${1%/*}6 [!-D $DEST $libpath] && mkdir-p $DEST $libpath7 [!-e $DEST ${1}] && cp $DEST $libpath && echo "Copy lib $ finished"8 }9 BINCP () {Ten cmdpath=${1%/*} One [!-D $DEST $cmdpath] && mkdir-p $DEST $cmdpath A [!-e $DEST ${1}] && cp $DEST $cmdpath -    - For LIB in ' LDD $ | grep-o "/.*lib\ (64\) \{0,1\}/[^[:space:]]\{1,\}" ';d o the libcp $LIB -  Done - } - read-p "Your Command:" CMD + until [$CMD = = ' Q ']; do - ! which $CMD &>/dev/null && echo "wrong command" && read-p "Input again:" CMD && Continue + command= ' which $CMD | grep-v "^alias" | grep-o "[^[:space:]]\{1,\}" A BINCP $COMMAND at echo "Copy $COMMAND finished." - read-p "continues:" CMD -  Done
View Code

5. Writing/mnt/sysroot/sbin/init files

1#!/bin/Bash2 #3 Echo-E"Welcome to \033[34m My tiny\033[0m Linux"4 Mount-N-T proc proc/proc5 Mount-n-t SYSFS SYSFS/SYS6 Insmod/lib/modules/E1000.ko7[$?-eq0] &&Echo-E"Load e1000 modules succeed [\033[32mok\033[0m]"8Ifocnfig Lo127.0.0.1/89 ifconfigEth0192.168.0.225/ -Ten Mount-n-o remount,rw/dev/sda2/ One/bin/bash
View Code

6. Provide configuration files for grub

1 default=02 timeout=53title Test Linux4     Root (hd0,0)5     kernel/vmlinuz ro root=/dev/sda2 selinux=0 init=/ sbin/init6     initrd/initramfs.img
View Code

In this connection, a Linux with network function is finished.

[Marco Study notes] The production of Linux system bootable Linux with network function

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.