Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to mount the root file system using NFS in embedded Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how embedded Linux uses NFS to mount the root file system. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

It is a skill that must be mastered for embedded development programmers to use NFS to mount the root file system. Here are the specific methods of using NFS to mount the root file system in embedded Linux development.

1. Install NFS server (take ubuntu as an example) sudo apt-get install nfs-kernel-server

two。 Install NFS client sudo apt-get install nfs-common

3. Create a shared directory sudo mkdir / home/nfs

4. Configure NFS4.1 modify configuration file / etc/exports add on the last line: / home/nfs (rw,sync,no_root_squash,no_subtree_check) the directory before is the directory shared with the nfs service client Stands for allowing all network segments to access (you can also use a specific IP) rw: the client attached to this directory has read and write access to the shared directory sync: data synchronization writes to memory and hard disk no_root_squash: when the client accesses the shared folder with root, the root user is not mapped. (root_squash: when the client accesses the shared folder with the root user, the root user is mapped to an anonymous user.) no_subtree_check: the permissions of the parent directory are not checked.

4.2 nfs is a RPC program, before using it, you need to map the port and set it through rpcbind: sudo service rpcbind restart

4.3 restart the nfs service: sudo service nfs-kernel-server restart

4.4 check if NFS configures ok to enter showmount-exports to display all directories shared in the system

Next we configure the ARM side (embedded development board, which uses smart210 of the friendly arm)

Using NFS to hang on the root file system requires the support of the kernel, so the kernel needs to be compiled first

1.1 enter the kernel source directory to execute make menuconfig

In the Gnenral setup option, cancel the Initial RAM filesystem and RAM disk option

Go to the next level directory of the file systems option

Select the blue area option in the following figure

Then exit save and recompile the kernel

Make uImage ARCH=arm CROSS_COMPILE=arm-linux-

The recompiled kernel is located in the / arch/arm/boot/ directory. Copy the kernel to the SD card and replace the original kernel burn file zImage.

Set kernel boot parameters (in this article, the development board uboot, kernel, kernel parameters, and file system burning use SD card, so you only need to modify it in the configuration file in SD)

# Linux # Linux-BootLoader = Superboot210.binLinux-Kernel = Linux/zImage#Linux-CommandLine = root=/dev/mtdblock4 rootfstype=yaffs2 console=ttySAC0,115200 init=/linuxrc skipcali=yes ctp=3Linux-CommandLine = console=ttySAC0,115200 root=/dev/nfs nfsroot=192.168.1.12:/home/book/Codes/fs_mini_mdev_new ip=192.168.1.230:192.168.1.12:192.168. 1.12:255.255.255.0:linux.arm9.net:eth0:off skipcali=yes ctp=3#Linux-RootFs-InstallImage = Linux/rootfs_qtopia_qt4-mlc2.img

For development boards that do not need SD cards to burn, kernel configuration parameters need to be passed to the development board in the uboot command line. Where the PC IP address: 192.168.1.12, the development board address 192.168.1.230

After refreshing the kernel and kernel parameters in the SD card to the development board, restart the development board, and you can see that the development board is successfully hung on the NFS and the file system.

This is how the embedded Linux shared by the editor uses NFS to mount the root file system. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report