06 File System Making

Keywords: Linux vim network

busybox is used to make small file systems and is often used in embedded systems.
Production process:
busybox's Compression Packet (or other versions can be downloaded) is included in the Development Board Data Pack of Xunwei itop4412.

1. Copy the busybox-1.22.1.tar.bz2 compressed package to "/ARM4412" and decompress it. ("/ARM4412" is a folder I created specifically to store all the information of itop4412, which can be changed according to personal preferences)

[root@localhost ARM4412]# tar xf busybox-1.22.1.tar.bz2 

2. Enter the bottom of the busybox-1.22.1 directory (as decompressed above)

[root@localhost ARM4412]# cd busybox-1.22.1/

3. Clear compiled files and configuration files first

[root@localhost busybox-1.22.1]# make distclean

4. Configuring busybox

[root@localhost busybox-1.22.1]# make menuconfig
//Enter Configuration Interface

Then you will see the following interface

Then configure the following options
1. Enter Busybox Settings

Busybox Settings  --->          
            Build Options  ---> 
                │[*] Build BusyBox as a static binary (no shared libs)  //busybox is compiled statically, and the program is not dependent on other dynamic libraries
                (arm-linux-gnueabihf-) Cross Compiler prefix  //After the cursor moves this line, press the confirmation key to enter the input mode. Specify the use of the cross-compiler

2. After setting up the first step, return to the menu of the previous level.

3. Enter Installation Options

Select by return

Change. /_install to... / The purpose of system is to store the generated files in this directory, of course, without changing here, then the default is to store them in. /_install.

After the above settings are completed, exit and save, and then execute

[root@localhost busybox-1.22.1]# make
 // Start compiling busybox

Note: If the following errors are found
 collect2: Error: ld returns 1
 make: *** [busybox_unstripped] error 1
 // Solutions
 Go to make menuconfig, find the following options and remove the selection
 Linux System Utilities - > [] Support mounting NFS file systems network file system
 Networking Utilities - > [] inetd (Internet Super Server)
// Then make is executed again

To be compiled and executed

[root@localhost busybox-1.22.1]# make install

Then enter the system. / System)

[root@localhost system]# Some files generated after ls // compilation
bin  linuxrc  sbin  usr
[root@localhost system]# pwd
/ARM4412/system

The directory needed to create a filesystem in the system directory

//Create dev proc sys tmp var mnt

[root@localhost system]# mkdir dev
[root@localhost system]# mkdir proc
[root@localhost system]# mkdir sys
[root@localhost system]# mkdir tmp
[root@localhost system]# mkdir var
[root@localhost system]# mkdir mnt
[root@localhost system]# mkdir etc
[root@localhost system]# mkdir lib
[root@localhost system]# ls
bin  dev  etc  linuxrc  mnt  proc  sbin  sys  tmp  usr  var lib

//Create the following files in the var directory
[root@localhost system]# mkdir var/log
[root@localhost system]# mkdir var/lock
[root@localhost system]# mkdir var/lib
[root@localhost system]# mkdir var/run
[root@localhost system]# mkdir var/tmp
[root@localhost system]# ls ./var/
lib/  lock/ log/  run/  tmp/

//To enter the etc directory, complete the following steps
[root@localhost etc]# mkdir init.d
[root@localhost etc]# ls
init.d

[root@localhost etc]# touch init.d/rcS

//Open rcS file
[root@localhost etc]# vim init.d/rcS 

//Write the following.
mount -t proc none /proc
mount -t sysfs none /sys
mount -t tmpfs none /tmp
mount -t ramfs none /dev
mdev -s
syslogd 
echo /sbin/mdev > /proc/sys/kernel/hotplug

//Next
[root@localhost etc]# touch inittab
[root@localhost etc]# ls
init.d  inittab
[root@localhost etc]# vim inittab 

//After opening the inittab file, add the following

::sysinit:/etc/init.d/rcS
ttyS0::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
::restart:/sbin/init 

//Continue
[root@localhost etc]# touch profile
[root@localhost etc]# ls
init.d  inittab  profile
[root@localhost etc]# vim profile 

//Open profile to add environment variables
	export PS1="[uboot@itop4412 \W] # "
	//Note:
            \d : Represents the date in the format of ____________ weekday month date,For example:"Mon Aug1"
            \H: Full host name. For example, my machine name is: fc4.linux,Then the name is fc4.linux
            \h : Take only the first name of the host, as in the example above. fc4,.linux It is omitted. 
            \t : The display time is in 24-hour format, such as: HH: MM: SS 
            \T : Display time in 12-hour format 
            \A : The display time is in 24-hour format: HH: MM 
            \u : The current user's account name
            \v : BASH Version information
            \w : Full working directory name. Home catalogue will use ~replace
            \W : utilize basename Get the working directory name, so only the last directory will be listed.
            \# Several orders issued
            \$ : Prompt character, if yes root When the prompt is:# Ordinary users are:$

Enter the lib directory of system

[root@localhost system]# cd lib/
//Copy the dynamic libraries required by the application from the cross-compiler to the directory
[root@localhost lib]# cp /usr/local/arm/arm-gcc/arm-linux-gnueabihf/libc/lib/* ./

After the above steps are completed, set permissions for the entire file system directory

[root@localhost system]# chmod 0777 -R /ARM4412/system/

The next step is to generate a filesystem image

Copy linux_tools.tgz to the root directory for decompression

[root@localhost /]# tar xf linux_tools.tgz

Then go into / ARM4412

[root@localhost ARM4412]# make_ext4fs -s -l 314572800 -a root -L linux system.img system
//Mirror files can be generated and burned (refer to uboot compiler chapters).

To complete the production of this file system

Posted by Alffallen on Wed, 04 Sep 2019 05:48:31 -0700