Qemu build ARM vexpress development environment (three) ---- NFS network file system root

Qemu build ARM vexpress development environment (three) ---- NFS network file system root

Tags (separated by spaces): Qemu ARM Linux


After Previous " Qemu build ARM vexpress development environment (two) ---- start the Linux kernel by u-boot ", has been implemented by u-boot boot loader Kernel development board, and mount the root file system, this article describes through NFS network mount the root file system.

By NFS network file system root, it can be achieved through the development board after u-boot boot the kernel via NFS network mount the root file system on another PC host. For the development of learning commissioning phase provides a great convenience, can be developed directly on a Linux host, compile the driver or APP, and NFS files are copied to the target directory service carried out using (Because the file is copied to the equivalent of a development board the root file system). Rootfs may directly modify the file in another file system on the host side is equivalent to directly modify the development board.

This article describes the NFS mount procedure to the network root file system, the present method is not only applicable to Qemu ARM vexpress development board built environment, but also to all other boards entity.

Since the network file system NFS individual development board manufacturing method is the same, reference may be made part of a method Exynos4412 NanopiNEO boards and the environment to build a network file system NFS.

1. Environment Configuration

Linux host support NFS service
modify bootargs startup parameters
set NFS root file system is
set up NFS file systems address a host
kernel supports NFS mount the file system

2. Install and configure NFS service

2.1 Linux host open NFS service

installation:

# sudo apt install nfs-kernel-server

Configuring NFS:

# vim /etc/exports
// 添加NFS共享目录
/home/mcy/qemu/rootfs    *(rw, sync, no_root_squash, no_subtree_check)
    rw    可读可写操作
    sync    内存和磁盘上的内容保持同步
    no_root_squash    Linux主机不再将开发板设置为匿名用户,可以操作文件读写
    no_subtree_check    不检查根文件系统子目录文件

Restart NFS services:

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

or:

# systemctl restart nfs-kernel-server

Check the NFS shared directory is created:

# sudo showmount -e
Export list for mcy-VirtualBox:
/home/mcy/qemu/rootfs *

Note:
Use NFS network file system, you need to shut down the system firewall Linux host, otherwise, the system is in operation will be abnormal.

2.2 development board supports NFS network configuration

Modify the startup parameters in the u-boot:

# vim include/configs/
CONFIG_BOOTCOMMAND
    setenv bootargs 'root=/dev/nfs rw    \
    nfsroot=192.168.0.105:/home/mcy/qemu/rootfs init=/linuxrc    \
    ip=192.168.0.110 console=ttyAMA0';    \

Configure the kernel to support NFS mounted file system

Improve the NFS file system
reboot reboot command

3. Make the root file system

Compile busybox

nfs
Linux System Utilities  --->
    [*] mount (30 kb)
        [*]   Support mounting NFS file systems on Linux < 2.6.23

Creating rootfs directory, and create files in the directory rootfs:

# mkdir etc
# cd etc
# vim inittab
::sysinit:/etc/init.d/rcS        // 执行rcS脚本
#::respawn:-/bin/sh
#tty2::askfirst:-/bin/sh
#::ctrlaltdel:/bin/umount -a -r

console::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
# vim init.d/rcS
#! /bin/sh
PATH=/sbin:/bin:/user/sbin:/usr/bin
LD_LIBRARY_PATH=/lib
export PATH LD_LIBRARY_PATH

mount -a        // 挂载根文件系统 fstab
mkdir -p /dev/pts
mount -t devpts devpts dev/pts
mdev -s
mkdir -p /var/lock

echo "......"
# vim fstab
proc    /proc    proc    defaults    0    0
tmpfs    /tmp    tmpfs    default    0    0
sysfs    /sys    sysfs    default    0    0
tmpfs    /dev    tmpfs    default    0    0
var    /dev    tmpfs    default    0    0
ramfs    /dev    ramfs    default    0    0
# vim profile
PS1='xiami@vexpress:\w #'
export PS1

May also be modified or provided in PS1 in ~ / .bashrc

Start process:
After the Linux kernel boots, mounts the root file system
starts the init process, bootargs init = / linuxrc, a user first starts the process of
reading inittab script in the user process,

Construction of other directory
other directories may be empty directory

# cd rootfs
# mkdir proc mnt tmp sys root

Guess you like

Origin www.cnblogs.com/microxiami/p/11093276.html