今天总算是将nfs文件系统给挂载上去了,当然,这还得感谢那些前辈们的各种小总结,下面我就将我的移植内核与挂载文件系统的步骤列出来,希望对大家有所帮助。
首先我用虚拟机装的Ubuntu14.04最新的操作系统,当然是64位的,这是必备的,(注意电脑配置太低的话装64位可能会有点卡),配置好交叉编译环境,环境配置我这就不作介绍了,从www.kernel.org下载你需要的内核,我用的是3.2.8的,建议移植3.0以上的版本(2.x的已经过时了),下面开始编译内核:
一、移植内核
(1)解压内核并进入内核根目录修改Makefile的目标和编译工具前缀
ARCH = arm
CROSS_COMPILE = arm-linux-
(2)复制配置文件到内核根目录,因为s5pv210是基于arm核的,可在arch/arm/configs目录中找到s5pv210_deconfig,将其复制到内核根目录
一步步执行
make distclean (或make mrproper)
make clean,
cp s5pv210 .config
make menuconfig
如果什么都不改则直接退出保存,当然要后面要移植文件系统那需要配置内核使之支持nfs文件系统,同时需要确定网驱dm9000有没有配置OK,nfs的挂载离不开网络,移植这里不详述.需要配置的大概有以下方面:
1、boot options 注意开发板用的什么串口打印之类的,一般的情况下都是console = ttySAC0
2、networking support
3、file systems 支持的文件系统
(3)生成内核make uImage
如果不能生成uImage,很可能是因为没有工具mkimage,在uboot文件中和tools目录中可以找到,当然需要自己编译
(4)加载模块 make modules ;modules_install ;make uImage
至此内核编译完成了,可以直接通过tftp下载到板子上了
注意:如果你的各项参数都配置正确,但在“Uncompressing Linux... done, booting the kernel.”后任何反应了,要注意几种情况
1、机器码是否配对
2、串口
3、最重要的是编译环境,看看arm-linux-gcc -v,是否满足你的开发板要求
二、文件系统
1、建立一个脚本文件rootfs.sh,写入
#!/bin/sh
echo "------Create rootfs directons start...--------"
mkdir rootfs
cd rootfs
echo "--------Create root,dev....----------"
mkdir root dev etc boot tmp var sys proc lib mnt home usr
mkdir etc/init.d etc/rc.d etc/sysconfig
mkdir usr/sbin usr/bin usr/lib usr/modules
echo "make node in dev/console dev/null"
sudo mknod -m 600 dev/console c 5 1
sudo mknod -m 600 dev/null c 1 3
mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp
mkdir var/lib var/lock var/run var/tmp
chmod 1777 tmp
chmod 1777 var/tmp
echo "-------make direction done---------"
chmod a+x rootfs.sh,运行它可创建rootfs目录
2、etc目录下创建inittab文件,内容如下:
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
执行chmod a+x inittab
etc目录文件profile,内容
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
#set hostname
HOSTNAME='/bin/hostname'
export HOSTNAME
# Set PS1
PS1='[\u@\h \W]\$'
export PS1
etc目录文件etc/fstab
#evice mount-point type option dump fsck order
proc /proc proc defaults 0 0
none /tmp ramfs defaults 0 0
mdev /dev ramfs defaults 0 0
sysfs /sys sysfs defaults 0 0
etc/init.d/rcS内容如下:
#!/bin/sh
echo "----------mount all.........."
mount -a
echo "----------Starting mdev......"
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
/bin/hostname -F /etc/sysconfig/HOSTNAME
ifconfig eth0 192.168.1.10
此ip为开发板上的ip
执行chmod a+x rcS
(3)编译busybox
环境在内核编译时已经配置好,与内核一样修改一下makefile的ARCH 与cross_compile
然后执行make menuconfig
修改CONFIG_PREFIX中的内容为你的文件系统的目录,执行make ;make install
(4)将工具链所有动态库文件拷贝到文件系统中,
cp */arm-none-linux-gnueabi/sys-root/lib/*so* */nfsdirection/lib -d
cp */arm-none-linux-gnueabi/sys-root/usr/lib/*so* */nfdirection/usr/lib -d
(5)chmod 777 -R /nfsdirection
三、 配置nfs服务器
sudo apt-get install nfs-kernel-server portmap
portmap可能被rpcbind代替
修改etc/exports文件,指你需要导出的文件系统目录
我的为/tftpboot/rootfs *(rw,sync,no_root_squash)
修改/etc/hosts.allow文件内容如下:
portmap: ALL:allow
lockd: ALL:allow
rquotad: ALL:allow
mountd: ALL:allow
statd: ALL:allow
修改/etc/hosts.deny文件,内容如下 :
portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL
service nfs-kernel-server restart
service rpcbind restart