In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Busybox: Swiss Army knife, which contains a lot of small orders.
STEP 1: build directory structure
Create the root file system directory, which mainly includes the following directories
/ dev / etc / lib / usr / var / proc / tmp / home/root / mnt / bin / sbin / sys#mkdir / home/rootfs#cd / home/rootfs#mkdir dev etc lib usr var proc tmp home root mnt sys
STEP 2: build / bin / sbin linuxrc using busybox
Enter the busybox-1.16.1 directory and execute
# make defconfig#make menuconfigBusybox Setting-> Build Options-> / / 1 choose to compile busybox statically [*] Build BusyBox as a static binary (no shared libs) / / 2. Specify the cross compiler as (/ usr/local/arm/4.3.2/bin/arm-linux-) Cross Compiler prefixInstallation Options-> (choose the generated file storage directory, or you can put it directly under rootfs without copying) / / 3. Select Don't use / usr Busybox Library Tuning--- > [*] Username completion [*] Fancy shell prompts [*] Query cursor position from terminal / / 4. The compiled busybox shell command interpreter supports the display of current path and host information
Save exit
# make # make install
In the busybox directory, you will see the _ install directory, which contains three files / bin / sbin linuxrc. Copy these three directories or files to the rootfs folder you created in the first step.
# cp bin/ sbin/ linuxrc / home/rootfs-ra
Be sure to take the parameter-a with you, because most of the bin directories are links. If you don't have the parameter-a, you will copy it accordingly after you copy it, instead of in the form of links.
STEP 3 build etc directory: (mainly etc/inittab files, etc/init.d/rcs, etc/fstab)
1) enter the etc directory of the root file system rootfs, and do the following:
Copy Busybox-1.16.1/examples/bootfloopy/etc/* to the current directory
# cp-r busybox-1.16.1/examples/bootfloopy/etc/* rootfs/etc
Modify inittab, (create other child processes based on it)
The original file is:
1:: sysinit:/etc/init.d/rcS 2 tty2::askfirst:-/bin/sh: respawn:-/bin/sh 3 tty2::askfirst:-/bin/sh 4:: ctrlaltdel:/bin/umount-a-r
After modification, it is:
-(1): boot-free login, directly open shell (the preceding number is the line number)
1:: sysinit:/etc/init.d/rcS 2 #:: respawn:-/bin/sh 3 #:: respawn:-/bin/login 4 console::askfirst:-/bin/sh 5 # tty2::askfirst:-/bin/sh 6:: ctrlaltdel:/bin/umount-a-r
-(2): login is required when starting the computer (the preceding number is the line number)
1:: sysinit:/etc/init.d/rcS 2 #:: respawn:-/bin/sh 3:: respawn:-/bin/login 4 # console::askfirst:-/bin/sh 5 # tty2::askfirst:-/bin/sh 6:: ctrlaltdel:/bin/umount-a-r
2) copy / etc/passwd, / etc/group, / etc/shadow on the virtual machine to rootfs/etc
# cp / etc/passwd rootfs/etc # cp / etc/group rootfs/etc # cp / etc/shadow roofs/etc
For the following three file changes, only the items related to root are saved, and the contents will vary according to the situation.
Change passwd to root:x:0:0:root:/root:/bin/sh, that is, save only items related to root, and finally change to / bin/ash.
Change group to root:x:0:root
Change the shadow to root:$1 $x9yv1WlBandABJ2v9jOlOc9xWUniqwPs.Fr14034VOUR 99999WlBJUR:
You need to enter a user name and password when logging in to the development board, which is the same as the virtual machine.
3) modify profile
PATH=/bin:/sbin:/usr/bin:/usr/sbin / / executable program environment variable export LD_LIBRARY_PATH=/lib:/usr/lib / / dynamic link library environment variable / bin/hostname osee USER= "`id-un`" LOGNAME=$USER HOSTNAME='/bin/hostname' PS1=' [\ u@\ h\ W] #'/ displays hostname, current path and other information:
4) modify the etc/init.d/rc.S file (add auto-execute command) #! / bin/sh
/ bin/mount-n-t ramfs ramfs / var/ bin/mount-n-t ramfs ramfs / tmp / bin/mount-n-t sysfs none / sys / bin/mount-n-t ramfs none / dev/ bin/mkdir / var/tmp / bin/mkdir / var/modules / bin/mkdir / var/run / bin/mkdir / var/log / bin/mkdir-p / dev/pts / / telnet Service needs / Bin/mkdir-p / dev/shm / / telnet service requires # echo / sbin/mdev > / proc/sys/kernel/hotplug//USB auto-mount / sbin/mdev-s / / start mdev to automatically create device file node under / dev / bin/mount-a # configure network # # # / sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 / sbin/ifconfig eth0 192.168.1.70 / sbin/ifconfig eth0 netmask 255.255.255.0 / sbin/route add default gw 192.168.1.1 eth0 / sbin/ifconfig eth2 192.168.1.71 netmask 255.255.255.0 / sbin/route add default gw 192.168.1.1 eth2
5) modify the etc/fstab file and add the following files to mount the proc tmpfs file system
# device mount-point type options dump fsck order none / dev/pts devpts mode=0622 0 0 tmpfs / dev/shm tmpfs defaults 0 0 proc / proc proc defaults 0 0
STEP 4 builds the lib directory:
(~ / at91/x-tools/arm-zch-linux-gnueabi/arm-zch-linux-gnueabi/sysroot/lib I just copy the SO file in this directory)
1) # cd / usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib
Copy the following dynamic libraries to rootfs/lib
# cp * so* roofs/lib-a
2) # cd / usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib
Copy the following dynamic libraries to rootfs/lib
# cp. / libstdc++.so.* rootfs/lib-a
STEP 5 build the lmdev directory:
Method 1: create the device file cat / proc/devices statically
Mknod console c 5 1mknod null c 1 3mknod ttySAC0 c 204 64mknod mtdblock0 b 31 0
Method 2: create a device file using mdev
Make sure the kernel sets CONFIG_SYSFS CONFIG_TMPFS
Run mdev automatically when the kernel starts
Modify etc/fstab to automatically mount the root file system modify etc/init.d/rcS to join the autorun command.
Summary
The above is the detailed explanation of the steps of porting busybox to build the minimum root file system introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!
If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.