Linux rootfs (UBIFS)

Publisher:MysticalGlowLatest update time:2024-09-02 Source: elecfansKeywords:linux  rootfs  UBIFS Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The following switches to the root user to operate (the rootfs compiled in other user modes does not log in as root, which seems to be more troublesome, so let's keep it simple first)


Modify Makefile:


CROSS_COMPILE = /opt/arm-2010q1/bin/arm-none-linux-gnueabi-


ARCH = arm


After saving and exiting:


make menuconfig


1.18.1 has changed the make install directory to ./_install by default. And I don't plan to change it to a static library, so there is nothing to change. Let's take a look at it after saving and exiting:


make (build busybox)


make install (generate files to the _install directory)


Then modify the permissions of _install/bin/busybox:


chmod 4755 _install/bin/busybox


(Give busybox everyone readable and executable, the owner readable, writable and executable, 4 read, 2 write, 1 execute, 7=4+2+1, 5=4+1, the three are the owner, the owner group, and other groups. The first 4 means that when other users execute the file, the permissions are the same as the owner)


Enter the _install directory and create some directories required by Linux:


mkdir -p dev etc home lib mnt proc root sys tmp usr var/lib/misc var/lock var/log var/run var/tmp

And modify the permissions:


chmod 1777 tmp

chmod 1777 var/tmp


(The first one is prevented from being deleted by other users)


Create console and null devices under dev:

mknod -m 660 console c 5 1

mknod -m 660 null c 1 3


(These two devices are used for init startup)


Now let's take a look at what dynamic link libraries busybox needs. Return to the busybox directory and enter:


/opt/arm-2010q1/bin/arm-none-linux-gnueabi-readelf -a busybox  | grep Shared


It shows that libm.so.6 and libc.so.6 are required


Copy the library in the cross compiler to the _install/lib directory. Codesourcery's arm-2010q1, the default is armv5te, in the directory

In the lib under /opt /arm-2010q1/arm-none-linux-gnueabi/libc (corresponding to ARMv4T in armv4t, corresponding to armv7- a thumb2 in thumb2), since future applications may use these libraries except libm.so.6 and libc.so.6, copy all of them and execute under _install:


cp /opt/arm-2010q1/arm-none-linux-gnueabi/libc/lib/*.so*  lib -a


Then create some configuration files under _install/etc:


1 #

2 # /etc/fstab: static file system information.

3 #

4 #

5 #

6 # file system mount type options dump pass

7

8 #for mdev

9 proc /proc proc defaults 00

10 sysfs /sys sysfs defaults 00

11

12 #make sure /dev /tmp /var are tmpfs(tmpfs use ram as media) thus can be r/w

13 tmpfs /tmp tmpfs defaults 00

14 tmpfs /dev tmpfs defaults 00

15 tmpfs /var tmpfs defaults 00

16

17  #usbfs /proc/bus/usb usbfs defaults 0 0


The file system in fstab will be mounted by mount -a.


1 # see busybox/examples/inittab

2

3  # Boot-time system configuration/initialization script.

4 # This is run first except when booting in single-user mode.

5  ::sysinit:/etc/init.d/rcS

6

7  #Start an "askfirst" shell on the console (whatever that may be)

8 #use respawn instead askfirst to make sure console always active

9  ::respawn:-bin/sh

10

11  # Stuff to do when restarting the init process

12  ::restart:/sbin/init

13

14 # Stuff to do before rebooting

15 ::ctrlaltdel:/sbin/reboot

16 ::shutdown:/bin/umount -a -r

17 ::shutdown:/sbin/swapoff -a

18

19


inittab will be executed by init


1 #!/bin/sh

2

3 #add setting here for auto start program

4 PATH=/sbin:/bin:/usr/sbin:/usr/bin

5 runlevel=S

6 prevleval=N

7 umask 022

8 export PATH runlevel prevlevel

9

10 #See docs/mdev.txt

11 #mount all fs in fstab,proc and sysfs are must for mdev

12 mount -a

13

14 #create device nodes

15 echo /sbin/mdev >/proc/sys/kernel/hotplug

16

17 #seed all device nodes

18 mdev -s

19

20 #create pts directory for remote login such as SSH and telnet

21 mkdir -p /dev/pts

22 mount -t devpts devpts /dev/pts

23

24

25

26 if [ -f/etc/hostname ]; then

27 /bin/hostname -F/etc/hostname

28 fi

29

30 if [ -e /sys/class/net/eth0 ]; then

31 ifconfig eth0 192.168.1.15

32 fi

33

34 echo "etc init.d rcS done"

35


init.d/rcS will be automatically executed at boot time.


Change the permissions of rcS and inittab to 777:


chmod 777 init.d/rcS


chmod 777 inittab


There are also several files and directories:


The rc.d directory can store some self-starting scripts


mdev.conf (the content can be empty, you can also refer to busybox docs/mdev.txt)


profile


1 #id -un = whoami

2 export USER="id -un"

3 export LOGNAME=$USER

4 export PATH=$PATH

5

6 #a colorful prompt begin with "e[" end with "m"

7 export PS1='e[1;32mu@e[1;31mh#e[0m'


resolve.conf (marks the DNS server, just one sentence nameserver 202.96.134.133)


hostname (read by init.d/rcS, just a hostname, such as mx27)


passwd, group, shadow user/group/password can be replaced with those on the PC. Here are some instructions:


1 passwd consists of 7 fields, separated by 6 colons. Their meanings are:

2 1 Username

3 2 Whether there is an encryption password, x means yes, blank means no, MD5 and DES encryption are used.

4 3 User ID

5 4 Group ID

6 5 Comments field

7 6 Login Directory

8 7 Shell program used

9

10 Group consists of 4 fields, separated by 3 colons, and their meanings are:

11 1 Group Name

12 2 Is there an encrypted password? Same as passwd

13 3 Group ID

14 4 Array of pointers to user names

15

16 shadow consists of 9 fields, separated by 8 colons, and their meanings are:

17 1 Username

18 2 The encrypted password. If it is empty, it means that the user can log in without a password. If it is an asterisk, it means that the account is disabled. The above shows the encrypted password of 123456.

19 3 The number of days from January 1, 1970 to the last time the password was changed

20 4 The password cannot be changed by the user within a certain number of days

21 5 The number of days after which the password must be changed (0 means no change)

22 6 How many days after the password expires will the user account be banned?

23 7 How many days before the password expires should the user be warned?

24 8 Number of days the password has been banned since January 1, 1970

25 9 Reserved Domain


Now, except for the files in lib/modules/`uname -r`/kernel (`uname -r` is the Linux version of the development board, you can enter echo `uname -r` to view it), the rootfs is basically completed. Find the git address of mkfs in the FAQ of www.infradead.org (sweat, it's hard to find):


git clone git://git.infradead.org/mtd-utils.git


cd mtd-utils


git describe master (version number is v1.3.1-138-gf0cc488)


An error occurred when entering mkfs.ubifs. In the FAQ, I saw that three libraries were needed. I installed them:


sudo apt-get install zlib1g-dev


sudo apt-get install liblzo2-dev


sudo apt-get install uuid-dev


make successfully generates mkfs.ubifs



Then make _install into a ubifs file system:


./mkfs.ubifs -r /_install -m 512 -e 15360 -c 3897 -o ubifs.img


Among them, -m indicates the page size, -e indicates the logical erase block size, and -c indicates the maximum number of logical erase blocks. The specific information can be seen when executing ubiattach in barebox.



Power on and enter barebox:


erase /dev/nand0.root


ubiattach /dev/nand0.root


ubimkvol /dev/ubi0 root 0 (Note that the name here must match bootargs, the default is ubi0.root)


dhcp


tftp ubifs.img /dev/ubi0.root


Keywords:linux  rootfs  UBIFS Reference address:Linux rootfs (UBIFS)

Previous article:Successfully create CRAMFS file system using Busybox
Next article:Linux UART serial port driver development documentation

Recommended ReadingLatest update time:2024-11-16 09:31

Install arm-linux-gnueabi-xxx compiler in Ubuntu
Installing the ARM-Linux-GCC toolchain Assuming your Ubuntu system is up to date, you only need to execute the following command to successfully install it: sudo apt-get install gcc-arm-linux-gnueabi After the installation is complete, type directly in the terminal arm-linux-guneabi-gcc -v
[Microcontroller]
Install arm-linux-gnueabi-xxx compiler in Ubuntu
【ARM】Notes on porting Linux kernel 2.6.32
#Three files Teacher Cheng (1209050967) 19:05:41 Link: http://pan.baidu.com/s/1pLg8V8J Password: xu5r Teacher Cheng (1209050967) 19:06:03 Teacher Cheng (1209050967) 19:06:31 Everyone go to my network disk and download these three files and put them in your Ubuntu (gcc4.4.3, linux-2.6.32, roots_rtm_2440) After adding
[Microcontroller]
【ARM】Notes on porting Linux kernel 2.6.32
Embedded Linux Development (Thirteen) FLASH (3) s3c2440 external NAND FLASH
- JZ2440  S3C2440 ARM920T -built-in Steppingstone (4K-Byte SRAM) No rom -expansion MX29LV160DBTI: 2MB, parallel port NOR FLASH K9F2G08U0C: 256MB,NAND FLASH soc The S3C2440A is developed with ARM920T core, 0.13um CMOS standard cells and a memory complier. The ARM920T implements MMU, AMBA BUS, and Harvard
[Microcontroller]
IIC bare metal and linux communication, bare metal series - S3C2440IIC communication
After about a week, I finally got IIC almost done. I can only say that every program should be taken seriously, and every program written is a kind of progress. For IIC, I feel that I knew this thing when I was working on the microcontroller, but I didn't adjust it. Now RAM bare metal programming is a good opportunity
[Microcontroller]
OK6410A Development Board (VIII) 39 linux-5.11 OK6410A memblock alloc and free
Initialization process of memlbock The second stage is to build the memblock Management scope of memblock ATAG_MEM  or ATAG_CMDLINE  mem=size@start The management scope of memblock is determined by u-boot u-boot can reserve memory in this process Memblock lifespan Return from start_kernel- setup_arch- paging_ini
[Microcontroller]
4412 Development Board Linux System Programming Practice - Character Device Control
Character drivers are a must in Linux drivers. This chapter mainly introduces the programs for character device applications. Whether you write your own character drivers after learning the following knowledge, or you already have character drivers, you need to be able to write some simple applications. Even if you
[Microcontroller]
4412 Development Board Linux System Programming Practice - Character Device Control
Linux 6.2 kernel has been officially released, widely supporting Apple M1 series chips
Linux founder Linus Torvalds has now released a stable Linux 6.2 kernel update, which brings some new drivers, new features, etc., as well as some hardware support and security improvements. This is the first major kernel version update of 2023 for Linux. The Linux 6.3 merge window has officially opened today, and L
[Embedded]
OK6410A development board (eight) 13 linux-5.11 OK6410A start_kernel print angle first stage console
In u-boot, u-boot manages the console and controls it through the u-boot environment variable stdout In linux-5.11, linux also manages the console, and manages it through some fields in u-boot's bootargs (or dts). The following are these fields in bootargs // The same driver, different kernels support different bootar
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号