Ubuntu下安装NFS的一些资料、经验总结

来源:互联网 发布:网络技能大赛 编辑:程序博客网 时间:2024/05/16 05:45

安装NFS服务,在minicom下烧写文件系统

安装NFS

ubuntu上默认没有安装NFS服务器,因此先安装:
->apt-get install nfs-kernel-server
->apt-get install nfs-common
NFS
服务程序和客户端程序安装完成

配置portmap:
dpkg-reconfigure portmap
Should portmap be bound to the loopback address?
N

配置:/etc/hosts.deny(禁止任何主机能和你的NFS服务器进行连接),加入:

### NFS DAEMONS
portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL

配置/etc/hosts.allow
允许那些你想要的主机和你的NFS服务器建立连接。下列步骤将允许任何IP地址以192.168.1.开头的主机(连接到NFS服务器上),也可以指定特定的IP地址。

### NFS DAEMONS
portmap: 192.168.1.*
lockd: 192.168.1.*
rquotad: 192.168.1.*

mountd: 192.168.1.*

statd: 192.168.1.*
有了/etc/hosts.deny/etc/hosts.allow就可以指定用户访问了

/etc/init.d/portmap restart
重启portmap daemon

修改/etc/exports文件:

vi /etc/exports

将下面一行加入到该文件中:

/working/rootfs *(rw,sync,no_root_squash)

这里目录/working/ 应该包含解压缩后的rootdisk文件。然后运行以下命令:

%exportfs -rv

/etc/init.d/nfs-kernel-server restart 重启nfs服务

测试NFS:
可以尝试一下挂载本地磁盘(假设本地主机IP地址为:192.168.1.100, /working t挂载到
/mnt)
#mount 192.168.1.100/f/working  /mnt
运行#df 看看结果

用以下命令

# umount /mnt

卸载

 

烧写文件系统(烧写文件系统必须用交叉网线连接主机和MDK(连接debug板子上的网口))【我用的是辰汉的IMX27的板子】

重新启动MDK将会在HyperTerminal中看到如下信息:

Linux 2.6 Freescale MXC processor

 

Choose an option from below:

 

1. Load kernel to RAM and then boot from [0x80008000]

2. Change kernel loading address [0x80008000]

3. Enter command line option for kernel

选择3.

输入以下命令行并回车:

  noinitrd console=ttymxc0 root=/dev/nfsroot rootfstpye=nfsroot nfsroot=192.168.1.100:/working/rootfs rw ip=192.168.1.88

 

这个命令要注意两个地方:一是ttymxc0不能写错,它不同于minicom设置的ttyS0;二是ip地址设定为固定192.168.1.88(与主机同段),否则无法连接;

 

回车之后,会再次出现

Linux 2.6 Freescale MXC processor

 

Choose an option from below:

 

1. Load kernel to RAM and then boot from [0x80008000]

2. Change kernel loading address [0x80008000]

3. Enter command line option for kernel

选择1启动kernel, 启动过程中系统会用NFS来挂载文件系统.

 

使用NFS启动MDK之后再将YAFFS2文件系统烧写到MDK Nand Flash中。当YAFFS2被烧写到NAND Flash中去后MDK就可以不需要连接到网络(NFS Server)也可以启动了,烧写步骤如下:

  1. MDK板上运行以下命令:

%flash_eraseall /dev/mtd/2

%mkdir /mnt/yaffs

%mount -t yaffs2 /dev/mtdblock/2 /mnt/yaffs/

2. Linux PC上运行如下命令,其中$ROOTFS_DIRLinux PC上挂载到MDK上的rootfs所在的目录: 

%mkdir $ROOTFS_DIR/download

%cd $ROOTFS_DIR/download

%cp ~/mx27-mdk-rootfs.tgz .

3. MDK上运行以下命令: 

%cd /download

%tar -zxvf mx27-mdk-rootfs.tgz -C /mnt/yaffs/

%cd /mnt/yaffs/

%mv rootfs/* ./

%rmdir rootfs

4. Reset MDK,等待几秒钟让kernel以默认command line启动。此时kernel会以YAFFS2来挂载根文件系统

原创粉丝点击