基于linux的家用网关

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

基于linux的家用网关准备工作:1.linux-2.6.9.tar.gz-----linux内核源代码2.busybox-1.10.1.tar.gz-----busybox是很多标准Linux®工具的一个单个可执行实现。3.实验环境虚拟机实验步骤:一、制作RAM盘映像文件(/root)1.创建空白文件系统ddif=/dev/zeroof=initrdbs=16Mcount=12.格式化空白文件系统mke2fs-F-m0initrd3.挂载mount-text2-oloopinitrd/mnt/initrd4.创建必要的目录(/mnt/initrd)脚本:install-d{bin,dev,etc,lib,mnt}install-d{sbin,usr,var,sys,proc}install-droot-m0750install-dtmp/var/tmp-m1777install-dusr/{bin,lib,sbin,share}install-dusr/share/terminfoinstall-dvar/{lock,log,run,lib,local,tmp}5.创建初始设备节点(/mnt/initrd/dev)脚本:mknod-m622consolec51mknod-m660nullc13chownroot:root*chmod+xMAKEDEV./MAKEDEV6.复制所需要的动态连接库(/mnt/initrd/lib/)cp-rdf/lib/libc-*.*.*.so./cp-rdf/lib/libc.so.6./cp-rdf/lib/ld-*.*.*.so./cp-rdf/lib/ld-linux.so.2./cp-rdf/lib/libcrypt-*.*.*.so./cp-rdf/lib/libcrypt.so.1./cp-rdf/lib/libnss_*./cp-rdf/lib/libresolv*./cp-rdf/lib/libdl*./cp-rdf/lib/libnsl*./cp/lib/libm.so.6./cp/lib/libselinux.so.1./cp–R/lib/tls/./cp-R/lib/iptables/./检查:(查看一是否有红名的文件)7.创建配置文件(当前目录/mnt/initrd/etc)fstab[root@localhostetc]#catfstab/dev/ram/rootfsdefaults11Proc/procprocdefaults00inittab[root@localhostetc]#chmod+xinittab[root@localhostetc]#catinittabconsole::sysinit:-/etc/rcStty0::askfirst:-/bin/login#ttyS0::respanwn:-/bin/ash::respawn:/sbin/getty-LttyS09600vt100::ctrlaltdel:/sbin/reboot::shutdown:/bin/umount-a-r::shutdown:/sbin/swapoff-arcS[root@localhostetc]#chmod+xrcS[root@localhostetc]#catrcShostnameGWmount-tproc/proc/procmount-tsysfs/sys/sysmount-tdevptsdevpts/dev/ptsmount-ttmpfs/dev/shm/dev/shmudevd--daemonudevstart/sbin/klogd/sbin/syslogd/sbin/runcfgtelnetd-p10023nsswitch.conf[root@localhostetc]#catnsswitch.confpasswd:filesgroup:filesshadow:fileshosts:filesdnsnetworks:filesdnsprotocols:filesservices:filesethers:filesrpc:filesnetgroup:filespasswd[root@localhostetc]#catpasswdroot:x:0:0:root:/:/bin/ashnobody:x:99:99:Nobody:/:/sbin/nologingroup[root@localhostetc]#catgrouproot:x:0:rootnobody:x:99:shadow[root@localhostetc]#catshadowroot:$1$FIC8K/qi$enuz4oqXR2FkjRgpcmU76.:13870:0:99999:7:::其他配置文件直接从系统里复制cp/etc/resolv.conf./cp/etc/services./cp/etc/mime.types./cp/etc/protocols./cp/etc/securetty./cp/etc/hosts./cp–R/etc/udev./二、Buby的编译和安装(/root)tarzxvfbusybox-1.10.1.tar.gzcdbubybox-1.10.11.修改init.c(/root/bubybox-1.10.1/init)viinit.c默认:#defineINIT_SCRIPT/etc/init.d/rcS/*Defaultsysinitscript.*/改为:#defineINIT_SCRIPT/etc/rcS/*Defaultsysinitscript.*/2.配置、编译、安装(/root/bubybox-1.10.1/)makemenuconfigmakemakeinstall我的配置文件:.config,要使用的话先修改为.config,然后放入bubybox目录下,运行一次makemenuconfig然后退出。注意安装路径,我这里是安装到/mnt/initrd三、卸载RAM盘并压缩(/root)umount/mnt/initrdgzib-9initrd四、为新磁盘分区fdisk/dev/hdaCommand(mforhelp):nCommandactioneextendedpprimarypartition(1-4)pPartitionnumber(1-4):1Command(mforhelp):aPartitionnumber(1-4):1Command(mforhelp):pDisk/dev/hda:536MB,536870912bytes16heads,63sectors/track,1040cylindersUnits=cylindersof1008*512=516096bytesDeviceBootStartEndBlocksIdSystem/dev/hda1*11040524128+83Linux五、编译内核(/root)tarzxvflinux-2.6.9.tar.gzcdlinux-2.6.9makemrpropermakemenuconfigmakebzImage我的配制文件:.config六、使用Grub引导(/mnt/lfs/)1.复制引导所需要的文件mount/dev/hda1/mnt/lfs/mkdirbootmkdirboot/grub/cdboot/grub/cp/boot/grub/grub.conf./cp/boot/grub/menu.lst./cp/boot/grub/stage1./cp/boot/grub/stage2./2.编辑grub.conf[root@localhostgrub]#catgrub.confdefault=1timeout=5#splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitleGW(2.6.9)root(hd0,0)kernel/vmlinuzroot=LABEL=/dev/ram0ramdisk_size=64000rhgbquietinitrd/initrd.img3.运行grub[root@localhostgrub]#grubGNUGRUBversion0.95(640Klower/3072Kuppermemory)[MinimalBASH-likelineeditingissupported.Forthefirstword,TABlistspossiblecommandcompletions.AnywhereelseTABliststhepossiblecompletionsofadevice/filename.]grubroot(hd0,0)grubsetup(hd0)七、安装内核(/mnt/lfs/)cp/root/linux-2.6.9/arch/i386/boot/bzImage./vmlinuzcp/root/initrd.gz./initrd.img八、调试(自己调吧)一些文件:/var/log/messages/var/log/wtmp/var/run/syslogd.pid/var/run/utmp/usr/lib/libncurses.so.5/usr/lib/libncurses.so.5.4/usr/lib/libpanel.so.5/usr/lib/libpanel.so.5.4/usr/lib/libpopt.a/usr/lib/libpopt.so/usr/lib/libpopt.so.0/usr/lib/libpopt.so.0.0.0/lib/libselinux.so.1/sbin/cfmount/sbin/cfumount/sbin/iptables/sbin/runcfg/sbin/savecfg/sbin/udevd--记得复制这些文件到/sbin目录下/sbin/udevstart出现的问题及解决方法:问题1:解决:问题2:解决:

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功