天天看点

TCC8900开发板上挂载NFS root的步骤

目标板信息

Target: Telechips TCC8900 development board

Linux kernel: Linux 2.6.29

Ethernet: DM9000

主机

OS: Ubuntu 9.04

交叉编译器: arm-2008q3-72

Busybox: 1.14.2

移植方法

1. 在主机上配置NFS服务及共享目录

2. 编译Linux内核,配置启动命令使得其支持NFS启动加载

3. 编译Busybox,并以此为基础创建NFS文件系统的目录

在主机上配置NFS服务及共享目录

1. 安装软件

sudo apt-get install nfs-kernel-server

2. 编辑/etc/default/portmap,删除以下行:

-i 127.0.0.1

3. 编辑/etc/hosts.deny,加入以下内容:

### NFS DAEMONS

portmap:ALL

lockd:ALL

mountd:ALL

rquotad:ALL

statd:ALL

4. 编辑/etc/hosts.allow,加入以下内容(将IP地址改为内网所在网段):

portmap: 192.168.2.

lockd: 192.168.2.

rquotad: 192.168.2.

mountd: 192.168.2.

statd: 192.168.2.

5. 编辑/etc/exports,加入需要共享的目录,例如:

/opt/nfsroot/linux_nfs *(rw,sync,no_root_squash,no_subtree_check)

6. 执行以下命令重启NFS服务:

1

sudo

/etc/init.d/portmap restart

2

sudo

exportfs -r

3

sudo

/etc/init.d/nfs-kernel-server restart

编译Linux内核

1. 设置交叉编译器,用于编译内核和Busybox:

将arm-2008q3-72解压,并将arm-2008q3-72/bin加入到PATH里。

2. 在.config中将以下选项使能:

Network File System -> root file system on NFS

并设置command line:

“root=/dev/nfs rw nfsroot=192.168.2.2:/opt/nfsroot/linux_nfs ip=dhcp init=/linuxrc console=ttySAC0″

其中192.168.2.2为已配置NFS服务的主机IP地址

创建NFS文件系统的目录

1. 编译Busybox

Busybox Settings -> Build Options -> Cross Compile prefix: arm-none-linux-gnueabi-

Busybox Settings -> Build Options -> Build BusyBox as a static binary

Busybox Settings -> Installation Options-> [*] Don’t use /usr

Init Utilities -> Run commands with leading dash with controlling tty

Shells -> Choose your default shell: ash

取消以下编译选项:

Shells -> ash -> Job control

make install

会将Busybox安装到源代码_install目录下。

2. 以Busybox为基础,创建NFS目录:

1

cd

/opt/nfsroot

2

mkdir

linux_nfs

3

cd

linux_nfs

4

cp

-r ${BUSYBOX_DIR}/_install/* .

3. 创建一些必须的目录和设备文件:

01

mkdir

bin dev etc lib proc sbin sys usr tmp root var mnt home

02

mkdir

usr/bin usr/lib usr/sbin lib/modules

03

chmod

777 tmp

04

mkdir

var/lib var/lock var/log var/run var/tmp

05

mkdir

etc/init.d

06

chmod

1777 var/tmp

07

08

mknod

-m 644 dev/console c 5 1

09

mknod

-m 644 dev/null c 1 3

10

mknod

-m 640 dev/

ram

b 1 1

11

mknod

-m 644 dev/mem c 1 1

4. 创建文件etc/profile,内容如下:

# 设置库目录

export LD_LIBRARY_PATH=/lib:/usr/lib

# 设置PATH

PATH=/bin:/sbin:/usr/bin:/usr/sbin

export PATH

5. 创建文件etc/inittab,内容如下:

::sysinit:/etc/init.d/rcS

::respawn:-/bin/sh

ttySAC0::askfirst:-/bin/sh

::restart:/sbin/init

::ctrlaltdel:/bin/umount -a -r

::shutdown:/bin/umount -a -r

::shutdown:/sbin/swapoff -a

6. 创建文件etc/fstab,内容如下:

proc  /proc proc  defaults i 0 0

none  /tmp  ramfs defaults 0 0

mdev  /dev  ramfs defaults 0 0

sysfs /sys  sysfs defaults 0 0

7. 创建文件etc/init.d/rcS,内容如下:

#!/bin/sh

/bin/mount -t proc none /proc

hostname tcc8900

/bin/ash

8. 赋予文件相关权限:

1

chmod

644 etc/inittab

2

chmod

755 etc/init.d/rcS

3

touch

etc/mdev.conf

9. 拷贝用户所需相关文件:

cp /etc/group etc/

cp /etc/passwd etc/

cp /etc/shadow etc/

修改etc/passwd如下:

root:x:0:0:root:/root:/bin/bash –>

root:x:0:0:root:/root:/bin/ash

10. 重新启动开发板,即可加载NFS。

继续阅读