NFS启动
准备环境
硬件环境: Neardi LPA3588开发板、Ubuntu20.04系统电脑
软件环境: LPA3588 最新SDK
内核添加NFS支持
--- a/kernel/arch/arm64/configs/rockchip_linux_defconfig
+++ b/kernel/arch/arm64/configs/rockchip_linux_defconfig
@@ -24,7 +24,6 @@ CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_PERF=y
CONFIG_NAMESPACES=y
CONFIG_USER_NS=y
-CONFIG_BLK_DEV_INITRD=y
CONFIG_EMBEDDED=y
# CONFIG_COMPAT_BRK is not set
CONFIG_PROFILING=y
@@ -91,6 +90,10 @@ CONFIG_NET_KEY=y
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
CONFIG_IP_MROUTE=y
CONFIG_SYN_COOKIES=y
CONFIG_INET_ESP=y
@@ -118,6 +121,7 @@ CONFIG_IP_NF_TARGET_NETMAP=y
CONFIG_IP_NF_TARGET_REDIRECT=y
CONFIG_IP_NF_MANGLE=y
CONFIG_BRIDGE=y
+CONFIG_DNS_RESOLVER=y
CONFIG_CGROUP_NET_PRIO=y
CONFIG_CAN=y
CONFIG_CAN_ROCKCHIP=y
@@ -228,9 +232,11 @@ CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_USB_RTL8150=y
CONFIG_USB_RTL8152=y
+CONFIG_USB_NET_QMI_WWAN=y
CONFIG_WL_ROCKCHIP=y
CONFIG_WIFI_BUILD_MODULE=y
CONFIG_AP6XXX=m
+CONFIG_USB_NET_RNDIS_WLAN=y
CONFIG_INPUT_FF_MEMLESS=y
CONFIG_INPUT_EVDEV=y
CONFIG_KEYBOARD_ADC=y
@@ -637,6 +643,19 @@ CONFIG_NFS_FS=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_NFS_SWAP=y
+CONFIG_NFS_V4_1=y
+CONFIG_NFS_V4_2=y
+CONFIG_NFS_V4_1_MIGRATION=y
+CONFIG_ROOT_NFS=y
+CONFIG_NFS_USE_LEGACY_DNS=y
+CONFIG_NFS_V4_2_READ_PLUS=y
+CONFIG_NFSD=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_BLOCKLAYOUT=y
+CONFIG_NFSD_SCSILAYOUT=y
+CONFIG_NFSD_FLEXFILELAYOUT=y
+CONFIG_NFSD_V4_2_INTER_SSC=y
CONFIG_NLS_DEFAULT="utf8"
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_CODEPAGE_936=y
@@ -670,11 +689,3 @@ CONFIG_RCU_CPU_STALL_TIMEOUT=60
CONFIG_FUNCTION_TRACER=y
CONFIG_BLK_DEV_IO_TRACE=y
CONFIG_LKDTM=y
-CONFIG_USB_NET_DRIVERS=y
-CONFIG_USB_USBNET=y
-CONFIG_USB_NET_QMI_WWAN=y
-CONFIG_USB_WDM=y
-CONFIG_USB_SERIAL_WWAN=y
-CONFIG_USB_NET_CDCETHER=y
-CONFIG_USB_NET_CDC_NCM=y
-CONFIG_USB_NET_RNDIS_WLAN=y
更新kernel
./build.sh kernel
生成路径SDK/rockdev/boot.img
参考相应型号单独烧录boot分区
创建NFS Server
sudo apt update
sudo apt install nfs-kernel-server
安装完成后,需要配置,更改如下文件,添加最后一行(注意, 需要依据实际情况来修改, NFS目录不一定是/home/neardi/nfs
)
neardi@ubuntu2004:~$ cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/home/neardi/nfs *(rw,sync,no_root_squash,no_subtree_check)
/home/neardi/nfs
目录就是rootfs文件系统, 也就是rockdev/rootfs.img
文件里的内容。
NFS配置OK后, 重启NFS server, 如下命令:
sudo systemctl restart nfs-kernel-server
验证NFS Server是否配置成功
mkdir nfs
sudo mount -t nfs -o nfsvers=3 192.168.0.103:/home/neardi/nfs ./nfs/
以上192.168.0.103信息为安装NFS server的主机IP地址。 如果成功, 则nfs目录内容就是NFS Server里/home/neardi/nfs内容。
验证NFS启动
LPA3588开发板接入UART调试, 并在启动的时候按ctrl + c停留在u-boot状态
Hit key to stop autoboot('CTRL+C'): 0
=>
设置u-boot环境变量, 如下:
=> setenv ipaddr 192.168.0.100
=> setenv nfsroot /home/neardi/nfs
=> setenv nfsserverip 192.168.0.103
=> setenv bootargs console=ttyS2,1500000 root=/dev/nfs rw nfsroot=${nfsserverip}:${nfsroot},v3,tcp ip=${ipaddr}
IP地址需要根据实际情况修改
最后输入启动命令(如果想保存这些配置, 则输入saveenv):
=> boot
启动到mount NFS时, 需要一点时间。 由于NFS目录比较大(大概3~4G), 因此mount需要时间。
LPA3588板子mount NFS 成功后, 可以看见如下log:
[ 510.528586] #0: rockchip,es8388
[ 510.528593] #1: rockchip-hdmi0
[ 510.548504] VFS: Mounted root (nfs filesystem) on device 0:17.
[ 510.549499] devtmpfs: mounted
[ 510.565141] Freeing unused kernel memory: 7104K
[ 510.594388] Run /sbin/init as init process
完全启动后, 我们也可以分别在LPA3588板子上面创建一个文件,之后再查看NFS server对应的目录是否有此文件。比如:
root@LPA3588:/# echo "neardi nfs test" > test.log
查看NFS server目录:
neardi@ubuntu2004:~/nfs$ ls
bin boot.img dev firmware lib media opt rockchip-test run sdcard sys test.log udisk var
boot data etc home Lost+found mnt proc root sbin srv system tmp usr vendor
neardi@ubuntu2004:~/nfs$ cat test.log
neardi nfs test
若需要拷贝 eMMC里的rootfs系统, 则先mount /dev/mmcblk0p7
, 如下:
root@LPA3588:/# mount -t ext4 /dev /mmcblk0p7 /mnt
root@LPA3588:/# ls /mnt
bin dev home media proc run srv tmp var
boot etc lib mnt rockchip-test sbin sys udisk vendor
data fireware lost+found opt root sdcard system usr
最后copy /mnt/* 到U盘即可