Use the kernel to create a small linux]

Source: Internet
Author: User
Tags network function

In the first article, we used linux kernel, driver file, init file, and grub file to create a linux system dedicated to ourselves, but created a system, yes, so we need to add some features to it for our convenience. Every time we need some features, we will add them to it. Over time, the linux operating system will be born ..... Start now !!


1. First, we will add the shutdown and restart functions to it.

The restart and shutdown information is recorded in the/etc/rc. d/rc0.d/S01halt file. Let's take a look.

222 exec $ command $ HALTARGS // in the last row of the file, it indicates that he wants to execute these two variables.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94U508-0.png "title =" 2013-08-09_202544.png "/>

In this way, we can add the init 0 and init 6 commands by analogy with the method of adding ls and other commands.

Edit two execution scripts. Run these two scripts to shut down and restart the system when init 0 6 is required.

[Root @ localhost ~] # Vim syshalt

#! /Bin/bash

Exec/sbin/halt-p

[Root @ localhost ~] # Vim sysreboot

#! /Bin/bash

Exec/sbin/reboot-f

[Root @ localhost ~] # Cp/sbin/halt/mnt/root/sbin/

[Root @ localhost ~] # Cp/sbin/reboot/mnt/root/sbin/

[Root @ localhost etc] # cp/root/sys */mnt/root/etc/rc. d/

[Root @ localhost etc] # sync

Test: Successful 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94RD9-1.png "title =" 17.png"/>


Add your host name: hostname command

[Root @ localhost ~] # Cp/bin/hostname/mnt/root/bin/

View the hostname description in/etc/rc. d/sysinit.

14 if [-f/etc/sysconfig/network]; then

15./etc/sysconfig/network

16 fi

17 if [-z "$ HOSTNAME"-o "$ HOSTNAME" = "(none)"]; then

18 HOSTNAME = localhost

19 fi

Write this content to/etc/rc. d/rc. sysinit in linux.

Then, create the/etc/sysconfig directory in the self-made linux and copy the/etc/sysconfig/network file of the original system.

Finally, add it to the self-made linux. rc. sysinit and execute the hostname command.

#! /Bin/bash

If [-f/etc/sysconfig/network]; then

./Etc/sysconfig/network

Fi

If [-z "$ HOSTNAME"-o "$ HOSTNAME" = "(none)"]; then

HOSTNAME = localhost

Fi

/Bin/hostname $ HOSTNAME

/Bin/bash

Test: Successful

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94U2J-2.png "title =" 18.png"/>


Add a network function, add a module, configure an ip address, and view the ip address.

To implement network functions, commands alone are a little powerless. This involves adding modules. modules related to network functions include pcnet32.ko mii. ko.

At the same time, the command related to the module also needs to add idconfig to view the system ipsettings] ping test network function]

First, copy the module to our small linux system.

[Root @ localhost ~] # Cp/lib/modules/2.6.18-164. el5/kernel/drivers/net/pcnet32.ko/mnt/root/lib/modules/

[Root @ localhost ~] # Cp/lib/modules/2.6.18-164. el5/kernel/drivers/net/mii. ko/mnt/root/lib/modules/

Then we put the module loading in the system initialization phase, then we need to edit the rc. sysinit file and write them.

/Sbin/insmod/lib/modules/mii. ko

/Sbin/insmod/lib/modules/pcnet32.ko




/Sbin/ifconfig eth0 192.168.1.44/24 // set a static ip Address

/Sbin/ifconfig lo 127.0.0.1/8 // set a local loopback address

Then add the corresponding file and Link Library File

/Sbin/ifconfig/sbin/insmod are copied to the simplified linux sbin directory.


Test:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94Q5B-3.png "title =" 4.png" style = "float: none;"/>

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94U5I-4.png "title =" 5.png" style = "float: none;"/>


Add a background image to the grub menu

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94U301-5.png "title =" 11.png"/>

Because the grub menu background image requires the color depth and size, the color depth should be small, and the size should be 640*480, so you need an image processing tool, gimp, installed using yum !!

Then, start the gimp tool in the graphic interface.

1. Pass the image to the linux System

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94R346-6.png "title =" 7.png"/>

1. Open the image with gimp

2. Adjust the size to 640*480.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94S027-7.png "style =" float: none; "title =" 8.png"/>

3. Change the color depth to 14.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94U613-8.png "style =" float: none; "title =" 9.png"/>

4. Save it as xpm format. Note that this format must be used here.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94WK4-9.png "style =" float: none; "title =" 10.png"/>


5. Reference, place the processed image to the boot partition, and modify the/boot/grub. conf file.

[Root @ localhost ~] # Mv psbe _ \ (5 \). xpm/mnt/boot/grub/

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94U301-5.png "title =" 11.png"/>


Test: restart the computer

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1F94S949-11.png "title =" 12.png"/>







This article is from the "LN __@ linux" blog, please be sure to keep this http://6839976.blog.51cto.com/6829976/1272177

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.