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

Summary of commonly used operators and functions in MySQL

Let’s build the data table first. use test; creat...

Mysql Sql statement comments

You can add comments to MySQL SQL statements. Her...

Advanced crawler - Use of Scrapy_splash component for JS automatic rendering

Table of contents 1. What is scrapy_splash? 2. Th...

How to delete node_modules and reinstall

Table of contents Step 1: Install node_modules in...

Quickly learn MySQL basics

Table of contents Understanding SQL Understanding...

A case study on MySQL optimization

1. Background A sql-killer process is set up on e...

How to modify the default encoding of mysql in Linux

During the development process, if garbled charac...

Example code for CSS to achieve horizontal lines on both sides of the text

This article introduces the sample code of CSS to...

Detailed steps for installing Harbor, a private Docker repository

The installation of Harbor is pretty simple, but ...

MySQL 5.7.20 Green Edition Installation Detailed Graphic Tutorial

First, let’s understand what MySQL is? MySQL is a...

Detailed explanation of the frame and rules attributes of the table in HTML

The frame and rules attributes of the table tag c...