基于linux的家用网关_第1页
基于linux的家用网关_第2页
基于linux的家用网关_第3页
基于linux的家用网关_第4页
基于linux的家用网关_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、基于linux的家用网关准备工作:1.linux-2.6.9.tar.gz-linux内核源代码2.busybox-1.10.1.tar.gz- busybox是很多标准 Linux 工具的一个单个可执行实现。 3.实验环境虚拟机实验步骤:一、 制作RAM盘映像文件(/root)1.创建空白文件系统dd if=/dev/zero of=initrd bs=16M count=12.格式化空白文件系统mke2fs -F -m0 initrd3.挂载mount -t ext2 -o loop initrd /mnt/initrd4.创建必要的目录(/mnt/initrd)脚本:install -d

2、 bin,dev,etc,lib,mntinstall -d sbin,usr,var,sys,procinstall -d root -m 0750install -d tmp /var/tmp -m 1777install -d usr/bin,lib,sbin,shareinstall -d usr/share/terminfoinstall -d var/lock,log,run,lib,local,tmp5. 创建初始设备节点(/mnt/initrd/dev)脚本:mknod -m 622 console c 5 1mknod -m 660 null c 1 3chown root:

3、root *chmod +x MAKEDEV./ 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/l

4、ibdl* ./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)fstabrootlocalhost etc# cat fstab/dev/ram / rootfs defaults 1 1Proc /proc proc defaults 0 0inittabrootlocalhost etc# chmod +x inittabrootl

5、ocalhost etc# cat inittabconsole:sysinit:-/etc/rcStty0:askfirst:-/bin/login#ttyS0:respanwn:-/bin/ash:respawn:/sbin/getty -L ttyS0 9600 vt100:ctrlaltdel:/sbin/reboot:shutdown:/bin/umount -a -r:shutdown:/sbin/swapoff -arcSrootlocalhost etc# chmod +x rcSrootlocalhost etc# cat rcShostname GWmount -t pro

6、c /proc /procmount -t sysfs /sys /sysmount -t devpts devpts /dev/ptsmount -t tmpfs /dev/shm /dev/shmudevd -daemonudevstart/sbin/klogd/sbin/syslogd/sbin/runcfgtelnetd -p 10023nsswitch.confrootlocalhost etc# cat nsswitch.confpasswd: filesgroup: filesshadow: fileshosts: files dnsnetworks: files dnsprot

7、ocols: filesservices: filesethers: filesrpc: filesnetgroup: filespasswdrootlocalhost etc# cat passwdroot:x:0:0:root:/:/bin/ashnobody:x:99:99:Nobody:/:/sbin/nologin grouprootlocalhost etc# cat grouproot:x:0:rootnobody:x:99:shadowrootlocalhost etc# cat shadowroot:$1$FIC8K/qi$enuz4oqXR2FkjRgpcmU76.:138

8、70: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)tar zxvf busybox-1.10.1.tar.gzcd bubybox-1.10.11. 修改init.c(/root/bubybox-1.10.1/init)vi init.c默认:#define INIT_SCRIPT /

9、etc/init.d/rcS /* Default sysinit script. */改为:#define INIT_SCRIPT /etc/rcS /* Default sysinit script. */2. 配置、编译、安装(/root/bubybox-1.10.1/)make menuconfigmakemake install我的配置文件:.config,要使用的话先修改为.config,然后放入bubybox目录下,运行一次make menuconfig然后退出。注意安装路径,我这里是安装到/mnt/initrd三、 卸载RAM盘并压缩(/root)umount /mnt/ini

10、trdgzib -9 initrd四、 为新磁盘分区fdisk /dev/hda Command (m for help):n Command action e extended p primary partition (1-4)pPartition number (1-4): 1Command (m for help): aPartition number (1-4): 1Command (m for help): pDisk /dev/hda: 536 MB, bytes16 heads, 63 sectors/track, 1040 cylindersUnits = cylinders

11、of 1008 * 512 = bytes Device Boot Start End Blocks Id System/dev/hda1 * 1 1040 + 83 Linux五、 编译内核(/root)tar zxvf linux-2.6.9.tar.gzcd linux-2.6.9make mrpropermake menuconfigmake bzImage我的配制文件:.config六、 使用Grub引导(/mnt/lfs/)1.复制引导所需要的文件mount /dev/hda1 /mnt/lfs/mkdir bootmkdir boot/grub/cd boot/grub/cp /

12、boot/grub/grub.conf./cp /boot/grub/menu.lst ./cp /boot/grub/stage1 ./cp /boot/grub/stage2 ./2.编辑grub.confrootlocalhost grub# cat grub.confdefault=1timeout=5#splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle GW (2.6.9) root (hd0,0) kernel /vmlinuz root=LABEL=/dev/ram0 ramdisk_size=64000 rhgb quie

13、t initrd /initrd.img3. 运行grub rootlocalhost grub#grub GNU GRUB version 0.95 (640K lower / 3072K upper memory) Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename.grub root (hd0,

14、0)grub setup (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

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论