Transplanting the mkfs.vfat command in busybox under Linux system

Transplanting the mkfs.vfat command in busybox under Linux system

In order to extend the disk life for storing audio and video files, it is recommended to set a larger cluster size when formatting the disk. Because the stored audio and video files are relatively large, the cluster size is set as large as possible, which can enhance the performance of disk reading data without wasting too much space.

But we found that mkfs.vfat of our device does not support the -s parameter to set the cluster size.

So I plan to re-port mkfs.vfat.

Idea 1

Re-porting busybox

1. Download the latest busybox source code from the official website

2. Modify Makefile

ARCH =arm

CROSS_COMPILE = /opt/hisi-linux-nptl/arm-hisiv100-linux/target/bin/arm-hisiv100nptl-linux- 

2.make menuconfig

Set as static library

3.make

An error occurred

make: *** [busybox_unstripped] Error 1
root@chenwr-pc:/home/soft/busybox-1.31.0# make
 LINK busybox_unstripped
Your linker does not support --sort-section,alignment
Your linker does not support --sort-common
Static linking against glibc, can't use --gc-sections
Trying libraries: crypt m resolv
Failed: -Wl,--start-group -lcrypt -lm -lresolv -Wl,--end-group
Output of:
/opt/hisi-linux-nptl/arm-hisiv100-linux/target/bin/arm-hisiv100nptl-linux-gcc -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wno-format-security -Wdeclaration-after-statement -Wold-style-definition -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-builtin-printf -Os -static -march=armv7l -o busybox_unstripped -Wl,--start-group applets/built-in.o archival/lib.a archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a klibc-utils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a printutils/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a archival/built-in.o archival/libarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o klibc-utils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o printutils/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group -Wl,--start-group -lcrypt -lm -lresolv -Wl,--end-group
==========
networking/lib.a(ipcalc.o): In function `ipcalc_main':
ipcalc.c:(.text.ipcalc_main+0x24c): warning: gethostbyaddr is obsolescent, use getaddrinfo() instead.
libbb/lib.a(inet_common.o): In function `INET_resolve':
inet_common.c:(.text.INET_resolve+0x60): warning: gethostbyname is obsolescent, use getnameinfo() instead.
coreutils/lib.a(mktemp.o): In function `mktemp_main':
mktemp.c:(.text.mktemp_main+0x8c): warning: the use of `mktemp' is dangerous, better use `mkstemp'
networking/lib.a(nslookup.o): In function `add_query':
nslookup.c:(.text.add_query+0x70): undefined reference to `res_mkquery'
networking/lib.a(nslookup.o): In function `send_queries':
nslookup.c:(.text.send_queries+0x2d0): undefined reference to `__ns_initparse'
nslookup.c:(.text.send_queries+0x308): undefined reference to `__ns_parserr'
nslookup.c:(.text.send_queries+0x480): undefined reference to `__ns_get16'
nslookup.c:(.text.send_queries+0x5cc): undefined reference to `__ns_get32'
nslookup.c:(.text.send_queries+0x5e4): undefined reference to `__ns_get32'
nslookup.c:(.text.send_queries+0x5fc): undefined reference to `__ns_get32'
nslookup.c:(.text.send_queries+0x614): undefined reference to `__ns_get32'
nslookup.c:(.text.send_queries+0x628): undefined reference to `__ns_get32'
util-linux/lib.a(fallocate.o): In function `fallocate_main':
fallocate.c:(.text.fallocate_main+0x80): undefined reference to `posix_fallocate'
util-linux/lib.a(unshare.o): In function `unshare_main':
unshare.c:(.text.unshare_main+0x1ec): undefined reference to `unshare'
collect2: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"
make: *** [busybox_unstripped] Error 1

Re-make menuconfig, enter the settings, close the module that reports an error and uncheck it.

Referring to the statements on the Internet, there are still many errors. And I shut down a lot of network stuff and system configurations, for fear that it might affect other commands. Because I found that the original ported busybox, such as the ls command, is not a separate bin file. Instead, it is soft-linked to busybox

And I found that the space of the device is limited. The original busybox is only more than 800k, and even if the new transplant is successful, it will take more than 2M. So I changed my mind and transplanted mkfs.vfat from source code alone

This completes the command transplantation.

Summarize

The above is what I introduced to you about porting the mkfs.vfat command in busybox under Linux system. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Docker uses busybox to create a base image
  • Telnet is moved to busybox-extras in Alpine image
  • What to do if the Android device does not recognize the awk command and lacks busybox

<<:  Detailed explanation of the relationship between the primary key being 0 and the primary key self-selection constraint in MySQL (details)

>>:  Key knowledge summary of Vue development guide

Recommend

JDBC Exploration SQLException Analysis

1. Overview of SQLException When an error occurs ...

Understand the principles of MySQL persistence and rollback in one article

Table of contents redo log Why do we need to upda...

MySQL 8.0.14 installation and configuration method graphic tutorial (general)

MySQL service 8.0.14 installation (general), for ...

Detailed explanation of the interaction between React Native and IOS

Table of contents Prerequisites RN passes value t...

Tutorial on installing MySQL 5.7.9 using RPM package under CentOS 7

Recorded MySQL 5.7.9 installation tutorial, share...

Detailed explanation of the difference between uniapp and vue

Table of contents 1. Simple page example 2.uni-ap...

Explanation of the usage scenarios of sql and various nosql databases

SQL is the main trunk. Why do I understand it thi...

How to align text boxes in multiple forms in HTML

The form code is as shown in the figure. The styl...

Detailed tutorial on configuring nginx for https encrypted access

environment: 1 CentOS Linux release 7.5.1804 (Cor...

How to set up Spring Boot using Docker layered packaging

The Spring Boot project uses docker containers, j...

Linux ssh server configuration code example

Use the following terminal command to install the...

How to install and configure GitLab on Ubuntu 20.04

introduce GitLab CE or Community Edition is an op...