TESA Developer Space
  • 👏Welcome
  • 📺TESA Podcast
  • ⭐Getting Started
    • Who we are?
    • What we do?
    • Who's our Networking?
  • 🏫TESA University Program
    • RT-Thread IoT OS
      • University Program
        • RT-Thread Architecture
          • Hardware supported
          • RT-Thread Layers
          • RT-Thread x Renesas
        • Edge AI Workshop
          • Installation & First Coding
          • External IRQ via Button
          • Enable Ulog for FinSH
          • Enable WiFi for FinSH
          • IoT Connectivity using MQTT
          • OpenMV IDE
          • MicroPython Programming
          • TFLite in OpenMV
          • AI Model Training via Edge Impulse
      • RT-Thread on RISC-V
    • FPGA Edge AI
      • Professional Courses
    • Problem-based Learning
      • STM32 Development Toolchain
  • 📚TESA Technical Contents
    • Linux OS
      • Zero to Linux Hero
        • Computer OS Architecture
        • Anatomy of Linux System
          • Busybox
          • Linux Environment for Developer
        • Anatomy of Linux Kernel
          • UNIX/Linux History
          • GNU Project
          • Linux OS Architecture
        • Anatomy of Linux Kernel
          • Linux Kernel Principles
    • Karel Robot
  • 🤘RECOMMENDED by TESA
    • Embedded Systems Roadmap
Powered by GitBook
On this page
  1. TESA Technical Contents
  2. Linux OS
  3. Zero to Linux Hero
  4. Anatomy of Linux System

Busybox

BusyBox ได้ถูกพัฒนาขึ้นโดยนาย Bruce Perens ในปี ค.ศ. 1996 ซึ่งเดิมทีถูกนำมาใช้เป็นโปรแกรมช่วยในการติดตั้งและกู้คืนในแผ่นดิสก์เก็ตแบบบูทตัวเองได้ของระบบปฏิบัติการ Debian (bootable Debian Linux system) โดยมีเงื่อนไขว่าลีนุกซ์คอร์เนลและโปรแกรมพื้นฐานทั้งหมดจะมีขนาดรวมกันแล้วไม่เกิน 1.4 MB ถึง 1.7 MB เนื่องจากข้อจำกัดในการเก็บข้อมูลภายในแผ่นดิสก์เก็ตในยุคนั้น ดังนั้นหลักการสำคัญที่จะต้องทำให้ BusyBox มีขนาดเล็กแต่ยังคงเต็มไปด้วยชุดคำสั่งมากมายคือการใช้ส่วนฟังก์ชันพื้นฐานที่เหมือนกันร่วมกันตัวอย่างเช่น ตัว BusyBox จะทำการรวมโปรแกรม grep และ find เป็นโปรแกรมเดียวกันเนื่องจากใช้หลักการค้นหาไฟล์โดยจะเข้าไปถึงภายในไดเรกทอรีทุกไดเรกทอรี (recursive) เช่นเดียวกัน เป็นผลให้ขนาดไฟล์ที่เกิดจากการรวมโปรแกรมทั้งสองลดลงอย่างมาก ดังนั้น BusyBox ก็สามารถใช้หลักการนี้กับโปรแกรมอื่นๆที่มีฟังก์ชันพื้นฐานเดียวกันจากเดิมที่มีขนาดทั้งสิ้น 3.5 MB ก็สามารถลดลงเหลือเพียงไม่เกิน 800 KB เท่านั้นได้

ดังนั้น BusyBox จึงกลายมาเป็นเครื่องมือสำคัญที่ถูกนำมาใช้ภายในระบบปฏิบัติการของระบบสมองกลฝังตัวอื่นๆจนถูกตั้งฉายาว่าเป็น “มีดพกพาสารพัดประโยชน์” (Swiss Army Knife) ซึ่งได้รวมชุดโปรแกรมและชุดคำสั่งอรรถประโยชน์ของคำสั่งพื้นฐานต่างๆที่จำเป็นในระบบปฏิบัติการลีนุกซ์ ตัวอย่างเช่น ชุดโปรแกรมที่ใช้จัดการบริการต่างๆของระบบในขณะเครื่องกำลังเริ่มทำงาน (Init program), ชุดคำสั่งจัดการระบบและตั้งค่าระบบ (System & Configuration) เป็นต้น ตัวอย่างคำสั่งใน BusyBox version 1.30 ได้แก่

$ busybox                                                                                                        
BusyBox v1.30.1 (Ubuntu 1:1.30.1-7ubuntu3) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list[-full]
   or: busybox --show SCRIPT
   or: busybox --install [-s] [DIR]
   or: function [arguments]...

	BusyBox is a multi-call binary that combines many common Unix
	utilities into a single executable.  Most people will create a
	link to busybox for each function they wish to use and BusyBox
	will act like whatever it was invoked as.

Currently defined functions:
	[, [[, acpid, adjtimex, ar, arch, arp, arping, ash, awk, basename, bc, blkdiscard, blockdev, brctl, bunzip2, bzcat, bzip2, cal, cat, chgrp, chmod, chown, chpasswd, chroot, chvt, clear, cmp, cp, cpio, cttyhack, cut,date, dc, dd, deallocvt, depmod, devmem, df, diff, dirname, dmesg, dnsdomainname, dos2unix, du, dumpkmap, dumpleases, echo, egrep, env, expand, expr, factor, fallocate, false, fatattr, fgrep, find, fold, free, freeramdisk, fsfreeze, fstrim, ftpget, ftpput, getopt, getty, grep, groups, gunzip, gzip, halt, head,hexdump, hostid, hostname, httpd, hwclock, i2cdetect, i2cdump, i2cget, i2cset, id, ifconfig, ifdown, ifup, init, insmod, ionice, ip, ipcalc, ipneigh, kill, killall, klogd, last, less, link, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, ls, lsmod, lsscsi, lzcat, lzma, lzop, md5sum, mdev, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mt, mv, nameif, nc, netstat, nl, nologin, nproc, nsenter, nslookup, nuke, od, openvt, partprobe, paste, patch, pidof, ping, ping6, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, realpath, reboot, renice, reset, resume, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, run-init, run-parts, sed, seq, setkeycodes, setpriv, setsid, sh, sha1sum, sha256sum, sha512sum, shred, shuf, sleep, sort, ssl_client, start-stop-daemon, stat, strings, stty, svc, svok, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, taskset, tee, telnet, test, tftp, time, timeout, top, touch, tr, traceroute, traceroute6, true, truncate, tty, ubirename, udhcpc, udhcpd, uevent, umount, uname, uncompress, unexpand, uniq, unix2dos, unlink, unlzma, unshare, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, w, watch, watchdog, wc, wget, which, who, whoami, xargs, xxd, xz, xzcat, yes, zcat

ด้วยแนวคิดการรวมฟังก์ชันพื้นฐานที่ใช้ร่วมกันของชุดคำสั่งต่างๆในระบบปฏิบัติการลีนุกซ์ให้กลายมาเป็น BusyBox เพียงโปรแกรมเดียวนั้น จะสามารถลดขนาดโปรแกรมลงได้ถึง 3 ถึง 4 เท่าเมื่อเทียบกับการใช้โปรแกรมพื้นฐานทั้งหมด ซึ่งจะสังเกตจากการใช้คำสั่ง ls -al ดังรูปข้างล่างว่าทุกคำสั่งจะถูกชี้ (symbolic link) ไปยังโปรแกรม busybox ทั้งสิ้น

PreviousAnatomy of Linux SystemNextLinux Environment for Developer
📚