1、NFS 文件系统实验1)设置环境变量:$ source /usr/local/src/EduKit-IV/Mini2410/set_env_linux.sh2)安装配置 nfs 服务:$ cd $SIMPLEDIR/6.5-nfs-server安装脚本如下:#!/bin/bash# E-pack-install.sh - Install NFS server.# Copyright (C) 2002-2007 # Created. lusi sudo apt-get install nfs-kernel-server nfs-common portmapcd /etc/default/sudo
2、 sed s/OPTIONS=“-i 127.0.0.1“/# OPTIONS=“-i 127.0.0.1“/ portmap portmap-tempsudo rm -f portmapsudo mv portmap-temp portmapcd /etc/sudo sed s/# /srv/nfs4/homes gss/krb5i(rw,sync)/home/example/nfs *(rw,sync)/exports exports-tempsudo rm -f exportssudo mv exports-temp exportssudo exportfs -rsudo /etc/in
3、it.d/nfs-kernel-server restart3)拷贝 6.3 节中已经创建好的文件结构$NFSDIR 目录下:$ cp -av /6.3-busybox/root-mini/* $NFSDIR4)连接好交叉串口线(连接实验平台 COM2 到 PC 端串口)连接好交叉网线(连接实验平台5)设置 IP:$ ifconfig eth0 192.192.192.1906)查看一下设置的 IP:$ ifconfig7)编辑配置文件:sudo gedit /etc/exports在最后一行添加如下内容:/home/example/nfs *(rw,sync,no_root_squash)8
4、)与 NFS相关的几个文件介绍:与 NFS相关的几个文件, 文件路径及简单的说明:1, /etc/exports对 NFS卷的访问是由 exports来批准, 它枚举了若干有权访问 NFS服务器上文件系统的主机名.2, /sbin/exportfs维护 NFS的资源共享. 可以通过它重新设定 /etc/exports 的共享目录, 卸载NFS Server共享的目录或者重新共享等.3, /usr/sbin/showmount用在 NFS Server 端,而 showmount 则主要用在 Client 端. showmount 可以用來查看 NFS 共享的目录资源.4, /var/lib/n
5、fs/xtabNFS的记录文档: 通过它可以查看有哪些 Client 连接到 NFS主机的记录.下面这几个并不直接负责 NFS, 实际上它们负责所有的 RPC5, /etc/default/portmap实际上, portmap 负责映射所有的 RPC服务端口, 它的内容非常非常之简单(后面详述)6, /etc/hosts.deny设定拒绝 portmap服务的主机7, /etc/hosts.allow设定允许 portmap服务的主机9)其他的一些配置( 配置 NFS 和 配置 portmap)(使用 sudo gedit filename 命令):方法 1: 编辑/etc/default/
6、portmap, 将 -i 127.0.0.1 去掉.(10.04 的已经去掉了。但这步我也做了一下)方法 2: $ sudo dpkg-reconfigure portmap , 对 Should portmap be bound to the loopback address? 选 N. (嗯嗯,这步也做了)配置/etc/hosts.deny(这步也做了)(禁止任何 host(主机)能和你的 NFS服务器进行 NFS连接),加上如下内容:# NFS DAEMONSportmap:ALLlockd:ALLmountd:ALLrquotad:ALLstatd:ALL配 置/etc/hosts.
7、allow(这步做了,但是不知道起作用没)允许那些你想要的主机和你的 NFS服务器建立连接。下列步骤将允许任何 IP地址以 192.168.197开头的主机(连 接到 NFS服务器上),也可以指定特定的IP地址。参看 man页 hosts_access(5), hosts_options(5)。加入:# NFS DAEMONSportmap: 192.168.197.lockd: 192.168.197.rquotad: 192.168.197.mountd: 192.168.197.statd: 192.168.197.总结:/etc/hosts.deny 和 /etc/hosts.allo
8、w 设置对 portmap的访问. 采用这两个配置文件有点类似“mask“的意思. 现在/etc/hosts.deny 中禁止所有用户对 portmap的访问. 再/etc/hosts.allow 中允许某些用户对 portmap的访问.若在 ubuntu7.04下,没有 hosts.deny,hosts.allow两个文件,所以在 exports文件里,对于 ip不能用通配符*,而必须指明 ip当然,可以通过修改这两个文件来解决【我的是 ubuntu10.10,但是一些选项我还是坚持试了试,呵呵。】运行 $ sudo /etc/init.d/portmap restart 重启 portma
9、p daemon.(10.04 里做了修改,命令为:server portmap restart)(这个我不知道,我也没有做)配置/etc/exports比如我要将将我的 home目录中的/home/example/nfs 目录让 192.192.192.190的 IP共享, 则在该文件末尾添加下列语句:/home/example/nfs 192.192.192.*(rw,sync,no_root_squash)或者: /home/example/nfs *(rw,sync,no_root_squash)(* 代表通配符,第二个说明 NFS挂载的目录允许所有 IP共享)192.192.192.
10、* 网段内的 NFS客户端能够共享 NFS服务器/home/example/nfs目录内容.且有读,写权限, 并且该用户进入/home/example/nfs 目录后的身份为 root最好加上 sync, 否则 $ sudo exportfs -r 时会给出警告, sync 是 NFS的默认选项.运行 $ showmount -e 查看 NFS server的 export list.若更改了/etc/exports, 运行 $ sudo exportfs -r 更新运行 $ sudo /etc/init.d/nfs-kernel-server restart 重启 nfs服务10)打开 mi
11、nicomsudo minicom按住空格键,给开发板上电,进入 vivi输入以下内容:viviparam set linux_cmd_line “root=/dev/nfs nfsroot=192.192.192.190:/home/example/nfs ip=192.192.192.200:192.192.192.190:192.192.192.1:255.255.255.0:EDUK4:eth0:off console=ttySAC1,115200 mem=64M init=/linuxrc noinitrd“【注意】上面的内容中没有回车符,是文档排版时自动换行的,在 vivi中输入时
12、一定要注意!viviparam save / 注释:输入次命令将会保存修改后的 vivi参数信息到Flash,可以不保存viviboot /输入命令启动内核,可以看到正确引导 nfs 文件系统。11)minicom 终端将正确启动 linux:【哈哈。终于正确启动了。整了一下午总算有点收获】vivi boot Copy linux kernel from 0x00030000 to 0x30008000, size = 0x001d0000 . size = 1900544donezImage magic = 0x016f2818Copy ramdisk from 0x00200000 to
13、0x30800000, size = 0x00200000 . size = 2097152=/dev/nfs nfsroot=192.192.192.190:/home/example/nfs ip=192.192.192.200:192.192.192.190:192.192.192.1:255.255.255.0:EDUK4:eth.Linux version 2.6.14 (niugshylmfos) (gcc versioemory 100.000 MHz, peripheral 50.000 MHzS3C241Hz), fast, MPLL on, UPLLmand line: r
14、oot=/dev/nfs nfsroot=192.192.192.190:/home/example/nfs ip=192.192.192.200:192.192.dirq: clearing subpending status 00000038irq: clearing subpending status 00000010PID hash table entries: 512 (order: 9, 8192 bytes)timer tcon=00000000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8Console: colour d)
15、Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)Memory: 64MB = 6, 690K data, 492K init)Mount-cache hash table entries: 512CPU: Testing write buffer coherency: oksoftlockup thread 0 started up.NET: Registered protocol family 16S3C2410: Initialising architectureSCSI subsystem initializedus
16、bcore: registered new driver usbfsNET: Registered protocol family 31Bluetooth: HCI device and connection manager initializedBluetooth: HCI socket layer initializedS3C2410 DMA Driver, (c) 2003-2004 Simtec ElectronicsDMA channel 0 at c4800000, irq 33DMA channel 1 at c4800040, irq 34DMA channel 2 at c4
17、800080, irq 35DMA channel 3 at devfs: boot_options: 0x1JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.yaffs Dec 13 2010 11:16:54 Installing. switching to colour frame buffer device 100x30c: rtc disabled, re-enablings3c2410_serial0 at MMIO 0x50000000 (irq = 70) isirq = 73) is a S3C2410s3c2410_s
18、erial2 at MMIO 0x50008000 (irq = 76) is a S3C2410io scheduler noop registeredio scheduler agisteredio scheduler cfq registeredRAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksizeloop: loaded (max 8 devices)nbd: registered device at major 43usbcore: registered new driver ubdm9000_eth
19、0: readwrong id 0x2b2a2928dm9000_eth0: wrong id: 0x2b2a2928dm9000_eth0: not found (0).eth0: dm9000 at e0000000,e0100000 IRQ 53 MAC: 12:23:34:45:56:67Linux video capture interface: v1.00ovcamchip: v2.27 for Linuufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)Scanning device for bad b
20、locksCreating0x00200000-0x00400000 : “ramdisk“0x00400000-0x03c00000 : “yaffs“0x03c00000-0x03d00000 : “jffs2“data“usbmon: debugfs is not availables3c2410-ohci s3c2410-ohci: S3C24XX OHCIs3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x
21、49000000hub 1-0:1.0: USB hub foundhub : registered new driver usb-storageUSB Mass Stpport registered.usbcore: registered n usbhiddrivers/usb/input/hid-core.c: v2.6:USB HID core driverusbcore: registered new4:DAB-USB Interface Driver for Linux (c)1999s3c2410_udc: version 28 Aug 2005s3c2410_udc_probeg
22、ot and enabled clocks3c2410_udc: got irq 41mice: PS/2 mouse device common for all micets: Compaq touchscreen protocol outputs3c2410 TouchScreen successfully loadedi2c /dev entries drivers3c2410-i2c s3c2410-i2c: slave address 0x10s3c2410-i2c s3c2410-i2c: bus frequency set to 9 KHzs3c2410-i2c s3c2410-
23、i2c: i2c-0: S3C I2C adapterBluetooth: HCI USB driver initialisation done.UDA1341 audio driver initializedNET: Registered protocol family 26NET: Registered protocol family 2IP route cache hash table entries: 1024 TCP biished 4096 bind 4096)TCP reno registeredTCP bic registeredNET: Registered protocol
24、M ver 1.5Bluetooth: RFCOMM socket layer initializedBluetooth: RFCOMM TTY layer initice=eth0, addr=192.192.192.200, mask=255.255.255.0, gw=192.192.192.1,host=EDUK4, domain=, h=Looking up port of RPC 100003/2 on 192.192.192.190eth0: link up, 100Mbps, full-duplex, lpa 0x41E1VFS: Mounted root (nfs files
25、ystem). / 此处正确加载 nfs根文件系统Mounted devfs on /devFreeing init memory: 492Kinit started: BusyBox v1.1.2 (2010.12.13-04:04+0000) multi-call binaryStarting pid 768, console /dev/console: /etc/init.d/rcSrunning /etc/init.d/rcSmount tmpfs file press Enter to activate this console./ $ / $ lsbin etc lib media proc sbin tmp vardev home linux