日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

剪辑内核linux,Linux01-Linux编辑内核定制属于自己的内核49

發(fā)布時(shí)間:2025/3/11 linux 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 剪辑内核linux,Linux01-Linux编辑内核定制属于自己的内核49 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

一、編譯內(nèi)核相關(guān)命令

1、重裝initrd文件命令:

mkinitrd:creates initial ramdisk p_w_picpaths for

preloading modules

格式:mkinitrd ?initrd文件路徑?內(nèi)核版本號(hào),如:mkinitrd

/boot/initrd-`uname -r`.img ?`uname -r`

2、I/O處理命令

a、命令格式說明2

${parameter#*word}

${parameter##*word}

The

word is expanded to produce a pattern just as in pathname expansion. ?If

the pattern matches the beginning of the value of

parameter, then the result of the expansion is the expanded value of parameter

with the shortest matching pattern ?(the ??..?.

case)

or ?the ?longest ?matching pattern (the ?..#?..case)

deleted. ?If parameter is @ or *, the pattern removal operation is

applied to each positional parameter in turn, and the expansion is the

resultant list. ?If parameter is an array variable sub-

scripted ?with ?@ or *, the pattern removal operation is applied to

each member of the array in turn, and the expansion is the

resultant list.

${parameter%word*}

${parameter%%word*}

The

word is expanded to produce a pattern just as in pathname expansion. ?If

the pattern matches a ?trailing ?portion ?of ?the

expanded ?value ?of ?parameter, then the result of the expansion

is the expanded value of parameter with the shortest matching

pattern (the ?..?..case) or the longest matching pattern (the ?..%?..case)

deleted. ?If parameter ?is ?@ ?or ?*, ?the

pattern

removal ?operation ?is applied to each positional parameter in turn,

and the expansion is the resultant list. ?If parameter is

an

array variable subscripted with @ or *, the pattern removal operation is

applied to each member of the array in ?turn, ?and

the

expansion is the resultant list.

b、命令格式

#

FILE=/usr/local/src

#

echo ${FILE#*/}: usr/local/src

#?echo

${FILE##*/}: src

#?${FILE%/*}:

/usr/local

#?${FILE%%/*}:

二、編譯系統(tǒng)內(nèi)核、grub和文件系統(tǒng)到新的磁盤

1、在原有CentOS5.9中添加一塊IDE硬盤分2個(gè)磁盤并格式化為ext3文件系統(tǒng)

2、掛載分區(qū)

mkdir /mnt/boot

mkdir /mnt/sysroot

mount /dev/hda1 /mnt/boot

moutn /dev/hda2 /mnt/sysroot

3、創(chuàng)建grub

grub-install --root-directory=/mnt

/dev/hda

4、復(fù)制系統(tǒng)內(nèi)核到/mnt/boot下cp

/boot/vmlinuz-2.6.18-348.el5 /mnt/boot/vmlinuz

5、重裝initrd文件:mkinitrd ?/boot/initrd-`uname -r`.img ?`uname -r`

6、重新編譯根文件系統(tǒng)文件

cp /boot/initrd-2.6.18-348.el5.img

/root

mv initrd-2.6.18-348.el5.img

initrd-2.6.18-348.el5.img.gz

gzip -d

initrd-2.6.18-348.el5.img.gz

mkdir test

cd test

cpio -id <

../initrd-2.6.18-348.el5.img或zcat

/boot/initrd-2.6.18-348.el5.img | cpio -id

vim init(修改其中一行為mkrootdev -t ext3 -o defaults,ro

/dev/hda2注釋掉#resume

LABEL=SWAP-sda5)

7、封裝新的根文件系統(tǒng)

find . | cpio -H newc --quiet -o |

gzip -9 > /mnt/boot/initrd.gz

8、編輯新的grub文件vim

/mnt/boot/grub/grub.conf

default=0

timeout=5

title Test Linux (Magedu Team)

root (hd0,0)

kernel /vmlinuz

initrd /initrd.gz

9、創(chuàng)建根文件系統(tǒng)中必要的文件

cd /mnt/sysroot

mkdir -pv proc sys dev etc/rc.d lib

bin sbin boot home var/log usr/{bin,sbin} root tmp

10、復(fù)制文件系統(tǒng)的bash環(huán)境

cp /sbin/init /mnt/sysroot/sbin/

cp /bin/bash /mnt/sysroot/bin

11、復(fù)制系統(tǒng)共享庫文件

ldd /sbin/init

cp /lib/libsepol.so.1 /mnt/sysroot/lib

cp /lib/libselinux.so.1

/mnt/sysroot/lib

cp /lib/libc.so.6 /mnt/sysroot/lib

cp /lib/libdl.so.2 /mnt/sysroot/lib

ldd /bin/bash

cp /lib/libtermcap.so.2

/mnt/sysroot/lib

12、編輯inittab為linux初始化文件系統(tǒng)時(shí)init初始化程序用到的配置文件

vim /mnt/sysroot/etc/inittab

id:3:initdefault:

si::sysinit:/etc/rc.d/rc.sysinit

chmod +x

/mnt/sysroot/etc/inittab

13、編輯vim /mnt/sysroot/etc/rc.d/rc.sysinit

#!/bin/bash

#

echo -e "\tWelcome to

\033[31mMageEdu Team\033[0m Linux."

/bin/bash

chmod +x /mnt/sysroot/etc/rc.d/rc.sysinit

14、編輯腳本用于復(fù)制二進(jìn)制程序及其依賴的庫文件的腳本可復(fù)制所有要用到的系統(tǒng)命令

#!/bin/bash

#

DEST=/mnt/sysroot

libcp() {

LIBPATH=${1%/*}

[ ! -d $DEST$LIBPATH ] && mkdir -p

$DEST$LIBPATH

[ ! -e $DEST${1} ] && cp $1

$DEST$LIBPATH && echo "copy lib $1 finished."

}

bincp() {

CMDPATH=${1%/*}

[ ! -d $DEST$CMDPATH ] && mkdir -p

$DEST$CMDPATH

[ ! -e $DEST${1} ] && cp $1

$DEST$CMDPATH

for LIB in ?`ldd $1 | grep -o

"/.*lib\(64\)\{0,1\}/[^[:space:]]\{1,\}"`; do

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,\}"`

bincp $COMMAND

echo "copy $COMMAND finished."

read -p "Continue: " CMD

done

15、復(fù)制系統(tǒng)的網(wǎng)卡模塊

mkdir /mnt/sysroot/lib/modules

cp

/lib/modules/2.6.18-348.el5/kernel/drivers/net/mii.ko /mnt/sysroot/lib/modules

cp

/lib/modules/2.6.18-348.el5/kernel/drivers/net/pcnet32.ko

/mnt/sysroot/lib/modules

16、編輯/mnt/sysroot/etc/inittab文件加載網(wǎng)卡模塊添加

insmod /lib/modules/mii.ko

insmod /lib/modules/pcnet32.ko

ifconfig eth0 172.16.100.13/16

ifconfig lo 127.0.0.1/8

/bin/bash

17、切入到定制的系統(tǒng)內(nèi)核進(jìn)行測試chroot /mnt/sysroot

18、***原有宿主機(jī)的第一塊磁盤保留第二塊磁盤啟動(dòng)系統(tǒng)測試效果。

總結(jié)

以上是生活随笔為你收集整理的剪辑内核linux,Linux01-Linux编辑内核定制属于自己的内核49的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。