tiny4412 BusyBox Making root file System Rootfs NFS Mount Ubuntu 14.04

Source: Internet
Author: User

http://blog.csdn.net/liudijiang/article/details/50555429 (ext)

First of all have to have a good uboot and Linux kernel image zimage, first burned to the SD card, this is already done Work.

first, Set up NFS services on Ubuntu

1. Create a new file to mount

[email protected]:~/share$ pwd

/home/liudijiang/share

I've built it, This is my path

2. Installing NFS Services

[email protected]:~/share$ sudo apt-getinstall nfs-kernel-server

3. Modify The/etc/exports File

[email protected]:~/share$ sudo vim/etc/exports

Add the following at the end of the file

/home/liudijiang/share * (rw,sync,no_root_squash,no_subtree_check)

*: allow all network segments to be accessed or use specific IP

Rw: clients hooking up this directory have read and write access to the shared directory

Sync: data is written to memory and hard disk synchronously

No_root_squash:root users have full administrative access to the root directory.

No_subtree_check: the permissions of the parent directory are not Checked.

Note that * and the parentheses below cannot appear spaces.

Then save the Exit.

4. Restart the Rpcbind service, (14.04 version is rpcbind, older version seems to be Portmap)

[email protected]:~/share$ sudo/etc/init.d/rpcbind Restart

5. Restart Nfs-kernel-server

[email protected]:~/share$ Sudo/etc/init.d/nfs-kernel-serverrestart

*stopping NFS Kernel daemon [OK]

*unexporting directories for NFS kernel daemon ... [OK]

*exporting directories for NFS kernel daemon ... [OK]

*starting NFS Kernel daemon [OK]

6. Test whether the NFS service is successful

[email protected]:~/share$ sudo mount-tnfs localhost:/home/liudijiang/share/mnt

Mount the Local/home/liudijiang/share folder on The/mnt

The new and modified items in the share file appear on The/mnt.

un-mount, sudo umount/mnt

Note that in the case of/mnt, the execution of the cancel mount cannot succeed, and it is not allowed to cancel the mount at this path.

At this point, the NFS service has been set up, and once the Development Board can ping the Ubuntu IP address, you can mount the Ubuntu folder.

second, make BusyBox

BusyBox official website

https://busybox.net/

1. Find the busybox-1.23.2.tar.bz2 and download it and unzip it.

[email protected]:~/work$ Tar xfbusybox-1.23.2.tar.bz2

2. Configure BusyBox

[email Protected]:~/work/busybox-1.23.2$make Menuconfig

1) Configure the Dynamic-link library and set the compiler prefix

Enter the BusyBox setting menu and go to the Build Options menu

Here the compiler is arm-linux-gcc, so the prefix fill arm-linux-, here Select the dynamic link library, link is arm-linux-gcc library, after the installation ARM-LINUX-GCC from the place to test out the library to Use.

2) Installation Path

Enter Installation Options

3) Configure module commands

Enter the Linux Module Utilities

Pretty output, blacklist support, depmod can be selected in the Line.

4) Save Configuration

Enter save Configuration to an Alternate File menu

Just Ok.

3. compiling, Installing

[email Protected]:~/work/busybox-1.23.2$make-j16;make install-j16

[email protected]:~/work$ ls rootfs/

Bin Linuxrc sbin usr

Bin Sbin usr three folders store various commands

LINUXRC is a soft connection file that connects to the Bin/busybox program

4. Check if BusyBox is successful

[email protected]:~/work/rootfs$ Filebin/busybox

Bin/busybox:elf 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), stripped

The above shows the ARM platform running, indicating that the installation was Successful.

5. Improve the dynamic link library

We set up the dynamic link library in busybox, and the compiler is arm-linux-gcc, find the installation path of the installation ARM-LINUX-GCC

[email protected]:~/work/rootfs$ which ARM-LINUX-GCC

/opt/friendlyarm/toolschain/4.5.1/bin/arm-linux-gcc

Above is my path,/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/lib, this is the path of the dynamic library to be copied out, the inside of the dynamic link file copied to the Rootfs folder

Create another folder under the Rootfs file, mimic the Ubuntu system, and see what folders are in his root directory

[email protected]:~/work/rootfs$ mkdiretc/init.d Dev home proc tmp var mnt root sys opt lib–p

Copy a dynamic Link file

[email protected]:~/work/rootfs$ cp/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/lib/*.so* Lib/-rap

6. Create Console device files

[email protected]:~/work/rootfs$ sudo mknoddev/console C 5 1

This file is a character device, the main device number is 5, the secondary device number is 1, can only be created with the Mknod command

7. Create the necessary documents under etc/

[email protected]:~/work/rootfs/etc$ tree./

./

├──fstab necessary files, hangs all file systems specified in the file

├──group is not a necessary file, you need to set the password

├──INIT.D the necessary folders

│├──rcs Necessary Documents

│└──rcs.bak Necessary Documents

├──inittab Copy from Busybox's example file

├──PASSWD is not a necessary file, you need to set the password

├──profile is not a necessary file and can be created to support command prompt format configuration, Configure system environment variables

└──shadow is not a necessary file, you need to set the password

1) Create a Etc/inittab file

We can copy it with the sample file provided by Busybox.

[email Protected]:~/work/busybox-1.23.2/examples$ls

Inittab ...

The following (about 59 lines)

# Start an "askfirst" shell onthe console (whatever, May)

:: Askfirst:-/bin/sh

# Start an "askfirst" shell on/dev/tty2-4

tty2::askfirst:-/bin/sh add "console" in line, commentline 62-64

Tty3::askfirst:-/bin/sh

Tty4::askfirst:-/bin/sh

Revision changed to

# Start an "askfirst" shell onthe console (whatever, May)

Console::askfirst:-/bin/sh #这里加上console, which is the console created in front of the Dev folder

# Start an "askfirst" shell on/dev/tty2-4

#tty2:: askfirst:-/bin/sh add "console" in line Commentline 62-64

#tty3:: askfirst:-/bin/sh

#tty4:: askfirst:-/bin/sh

2) fstab File

Create a Fstab file manually and add the following

TMPFS/DEV/SHM TMPFS Defaults 0 0

Devpts/dev/pts devpts Defaults 0 0

Sysfs/sys Sysfs Defaults 0 0

PROC/PROC proc Defaults 0 0

The first column is the Mount device, the second column is the Mount directory, the third column is the Mount file system type, The fourth column is the Mount option, respectively

Auto: the system Mounts automatically, fstab is this option by default

Ro:read-only

Rw:read-write

Defaults:rw,suid,dev,exec,auto,nouser,and Async

The dump option, set whether to let the Backup program dump backup file system, 0 is ignored, 1 is backup

The six column is the fsck option, which tells the FSCK program to check the file system in what order, 0 for ignoring

3) RCS File

Create under the INIT.D folder, add the Following:

#!/bin/sh

Mount–a #挂载fstab文件中所有指定的文件系统

Mkdir/dev/pts

Mount-t devpts devpts/dev/pts

Echo/sbin/mdev >/proc/sys/kernel/hotplug

Mdev–s #创建控制台

/bin/hostname Ubuntu #这里修改hostname

Note that the Linux kernel of the board cannot run this file if the permissions for the RCS file are not Executed.

sudo chmod +x rcS Add permissions

4) profile File

Add the following content

user= "' Id-un '"

Logname= $USER

Ps1= ' [\[email protected]\h \w]# '

Path= $PATH

Hostname= '/bin/hostname '

#导出环境变量

Export USER LOGNAME PS1 PATH

5) group, passwd, Shadow three files are to use the password to login, you can from the Linux System/etc/group,/etc/passwd,/etc/shadow copy come over

Then modify the Inittab file, the original changes to change the place:
# Start an "askfirst" shell on the console (whatever. May)

#console:: askfirst:-/bin/sh

:: Respawn:-/sbin/getty 115200 ttySAC0

# Start an "askfirst" shell on/dev/tty2-4

#tty2:: askfirst:-/bin/sh add "console" in line Commentline 62-64

#tty3:: askfirst:-/bin/sh

#tty4:: askfirst:-/bin/sh

The account password used here is the original Ubuntu Linux account password

You also need to modify the contents of the passwd file to change all "/bin/bash" to "/bin/sh"

This is the type of shell script modification, the Linux running on the PC is the bash shell script, and the Development Board Linux is running the SH shell script.

Do not use this also can, when the Development Board boot run directly into the command line, plus these when the boot to log on after the account password to enter the development Board of the Linux system, purely for fun ...

Summarize this section:

1. Inittab,rcs,fstab Relationship

System Boot mount file system--->

---> read The/etc/inittab file to resolve the actions defined therein

---> Execution/etc/init.d/rcs According to Sysinit defined process

---the first command in >/etc/init.d/rcs mount-a

---> read/etc/fstab File

---> mount one of the devices individually according to the file list contents to the specified place

2. Profile file

Set the environment variables, according to which the command prompt symbol related environment variables are set here

Users can add environment variables according to their needs

3. /etc/init.d/rcs Execution System initialization, you want to boot the program can be written in this file

4.group Store User ID information, command prompt symbol format configuration need to use this file

5.PASSWD and user-related passwords

And so will set up the computer, ubuntu, Development Board ip, The Development Board Uboot set up after the launch of the Ubuntu rootfs, can be in the computer and Xshell general Rootfs this folder. The Development Board Linux runs up to read the Rootfs inside these files, runs the contents of these Files.

third, set the computer host, virtual machine, Development Board IP address

First put the Development Board and computer network cable, let the Development board run up, Although nothing moved at this time, but should be able to see the Development Board and the Computer's network port lights are bright

Set up your Computer's IP

Manually set to static IP for ease of development

Save As you can

[email protected]:~/work/rootfs$ Ifconfig

eth0 Link encap: Ethernet Hardware Address 00:0c:29:29:30:8a

inet address: 192.168.3.27 broadcast: 192.168.3.255 mask: 255.255.255.0

Inet6 address: fe80::20c:29ff:fe29:308a/64 Scope:link

Up broadcast RUNNING multicast mtu:1500 Hop count: 1

Receive Packet: 2421 error: 0 Discard: 0 Overload: 0 Number of frames: 0

Send Packet: 2849 error: 0 Discard: 0 Overload: 0 Carrier: 0

Collisions: 0 Send Queue Length: 1000

Receive Bytes: 335705 (335.7 KB) send bytes: 2430579 (2.4 MB)

Interrupt: 19 Base Address: 0x2000

Lo Link encap: Local loopback

inet address: 127.0.0.1 mask: 255.0.0.0

Inet6 address::: 1/128 Scope:host

Up LOOPBACK RUNNING mtu:65536 metric: 1

Receive Packet: 506 error: 0 Discard: 0 Overload: 0 Number of frames: 0

Send Packet: 506 error: 0 Discard: 0 Overload: 0 Carrier: 0

Collisions: 0 Send Queue Length: 0

Receive Bytes: 48008 (48.0 kb) send bytes: 48008 (48.0 kb)

Set up your Computer's Ethernet network card and set it to static IP

Now you can use the virtual machine and the host computer to ping each other, to see the pass

[email protected]:~/work/rootfs$ ping192.168.3.30

PING 192.168.3.30 (192.168.3.30) bytes of Data.

Bytes from 192.168.3.30:icmp_seq=1ttl=64 time=5.70 ms

Bytes from 192.168.3.30:icmp_seq=2ttl=64 time=0.448 ms

Bytes from 192.168.3.30:icmp_seq=3ttl=64 time=0.474 ms

I have the computer host firewall is turned off, do not turn off when I can ping, if not ping the computer firewall off and then try it.

Next is to set the board ip, reset the development board, into the Uboot command line mode

Set the parameters of the command

Liudijiang # setenv Gatewayip 192.168.3.1

There is also an IP address, the mask is the same setting, the server IP settings are not set.

Set Bootargs

Liudijiang # setenv Bootargs root=/dev/nfs nfsroot=192.168.3.27:/home/liudijiang/work/rootfs/ip= 192.168.3.123:192.168.3.27:192.168.3.1:255.255.255.0::eth0:off init=/linuxrcconsole=ttysac0 lcd=S70

Set Bootcmd

Setenv bootcmd ' movi read kernel 040008000;movi read Rootfs 0 41000000 100000;bootm 40008000 41000000 '

View Results

Liudijiang # pri

baudrate=115200

BOOTARGS=NOINITRD Root=/dev/nfs nfsroot=192.168.3.27:/home/liudijiang/work/rootfs/ip= 192.168.3.123:192.168.3.27:192.168.3.1:255.255.255.0::eth0:off init=/linuxrcconsole=ttysac0 lcd=S70

Bootcmd=movi Read kernel 0 40008000;moviread rootfs 0 41000000 100000;bootm 40008000 41000000

Bootdelay=3

ethaddr=00:40:5c:26:0a:5b

gatewayip=192.168.3.1

Ipaddr=192.168.3.123

netmask=255.255.255.0

serverip=192.168.3.30

Options related to Nfs:

Root=/dev/nfs--using the NFS Device

NFS Folder-specific Path

Nfsroot=192.168.3.27:/home/liudijiang/work/rootfs Ip=192.168.3.123:192.168.3.27:192.168.3.1:255.255.255.0::eth0 : Off

Format description:

nfsroot= Virtual Machine Linux system ip: root file System absolute path ip= board ip: virtual Machine Linux system ip: gateway: subnet mask:: network card device name for Development Board (typically eth0, not virtual machine): off

The result of the above configuration, computer host, Virtual machine, Development Board are 192.168.3 This network segment, other network segment also line ... After restarting you will find the directory that is already attached to ubuntu, and ping ... Can be mounted on, certainly can ping pass ...

and I've been able to get into the board Linux command line in Xshell.

Create a new hello.c under the TMP directory, which of course is handy with vim on ubuntu, and then compile it by the Way. I've already written it, and the content is as follows

[email protected]:~/work/rootfs/tmp$ Cat hello.c

#include <stdio.h>

void Main (void)

{

printf ("hellolinux!\r\n");

}

[email Protected]:~/work/rootfs/tmp$arm-linux-gcc-o Hello hello.c

[email protected]:~/work/rootfs/tmp$ ls

Hello hello.c

Because it's going to run on the development board, it's ARM-LINUX-GCC.

It's OK ...

however, running this hello in Ubuntu is not possible, because Ubuntu is x86, and GCC compiles to Run.

tiny4412 BusyBox Making root file System Rootfs NFS Mount Ubuntu 14.04

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.