Customize a simple Linux system

Source: Internet
Author: User
Tags network function

Customize a simple Linux system

Production ideas:

Add a new hard disk, set up two partitions, a save/boot, a save/, create file system and format. Note that now our hard drive is to be able to unplug and install to other machines to use, otherwise there is no point. The hard drive SDB in the experiment is the same as the SDA we are familiar with when switching to other machines.

A simple Linux system should include: Kernel files, Grub,bash, and a few more tools to use.

Preparatory work:

Adding tools and commands can be done by script, so we'll first prepare a script that can copy the commands and install them.

#!/bin/bash#-----------------------------#Filename: copycmd.sh#revision:1.0#Date: .- the- +#Author: zyx#emali: [email protected] #Description: #------------------------------fcopy () {AA= ' which $1| Tail-1' LDD $aaif[$?-eq0]; Thenif[-A/System];then CP--parents $AA/system && Echo"Command has been copied!"Elsemkdir/system CP--parents $AA/mnt/sysroot/&& Echo"Command has been copied!"fiif[-a/testdir/copycmd];then ldd $aa| Sed-r-E"[email protected]*[[:space:]]+ (/.*) [[: Space:]].*@\[email protected]"-E'1d'>/testdir/CopycmdElsemkdir/TestDir Touch/testdir/copycmd ldd $aa| Sed-r-E"[email protected]*[[:space:]]+ (/.*) [[: Space:]].*@\[email protected]"-E'1d'>/testdir/copycmd fi whileRead line; DoCP--parents $line/mnt/sysroot/ Done</testdir/Copycmd Echo"libary file has been copied!"fi}SelectChoiceinchRun quit; Do Case$choiceinchrun) Read-P"Please enter a command:"cmdfcopy $cmd;; Quit) echo"Bye"Exit0;;*) echo"Error"Exit2Esacdone

Start Making :

New Hard disk :

Create a new hard disk on the virtual machine with a size of 20G (modified according to your preferences).

If you add a hard drive online, the system does not recognize it immediately after adding it, using the command

Echo '---' >/sys/class/scsi_host/host0/scan can add a hard drive online.

System boot, view disk lsblk

Disk partition Fdisk/dev/sdb

Save exit: W

To format a partition:

Mkfs.ext4/dev/sdb1

Mkfs.ext4/dev/sdb2

Create/boot file, in that directory is not important, must be/boot, because the data is placed under the hard disk grub, directory must be/boot.

Mount Mount/dev/sdb1/mnt/boot/

Install Grub Pack Grub-install-–root-directory=/mnt/dev/sdb

It can be seen that grub has been installed successfully, and it is not far from success.

You can view the binary to see if the installation was successful

Hexdump–c/dev/sdb–n 512

Next, copy the files from the original system itself to the new system.

cp/boot/vmlinuz-2.6.32-696.el6.x86_64/mnt/boot/

cp/boot/initramfs-2.6.32-696.el6.x86_64.img/mnt/boot/

Specific version can be tab key

To create a grub file

Vim/mnt/boot/grub/grub.conf

Default=0

Timeout=5

Title Linux

kernel/vmlinuz-2.6.32-696.el6.x86_64 root=uuid=2ca667c0-a6d5-4267-8b19-598430499167 selinux=0

Initrd/initramfs-2.6.32-696.el6.x86_64.img

Such a simple system is basically complete, then you need to use a script to copy some of the frequently used commands.

Create a post-boot directory and mount the SDB2 in the directory

Add Execute permission to script, run script

You can copy all the commands you want.

The command can be copied, but do not forget the NIC driver module, so that the system can use the network function.

Locate e1000

You can copy E1000.ko.

As an operating system, some folders under the root because it is to have

mkdir {Etc,dev,sys.proc,tmp,root,lib,user,home,var,boot}

Of course don't forget sync let the cache data write into the disk.

Then you can shut down the machine and transfer the disk. Here we are creating a new virtual machine, removing the system's own silver plate and loading our own hard drive.

Start the virtual machine.

The exciting moment is coming!

Finally, the system started successfully!

The following network functions are implemented:

Add the NIC driver manually

insmod /lib64/e1000.ko

View IP IP a

Add IP Address

ifconfig eth0 192.168. 252.62/ up

This system can also use the network function.

A simple Linux system is done!

Customize a simple Linux system

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.