现在我们经常会用busybox生成根文件系统,可是根文件系统起来以后命令行提示符只有一个“#”号,没有像linux发行版那样是[user@hostname currentpath] #,那么我们这里就说说如何让我们的根文件系统按这个方式显示。
要修改命令行提示符,首先我们需要知道一个环境变量PS1,我们可以查看bash的帮助文档查看关于PS1的说明:
bash有两级命令提示符,我们这里说的是级,这缺省的提示符是字符“$”(超级用户是“#”),我们可以通过修改PS1修改这个提示符,格式为:
PS1=“command list”
命令列表有很多参数如下:
\! 显示该命令的历史记录编号。
\# 显示当前命令的命令编号。
\$ 显示$符作为提示符,如果用户是root的话,则显示#号。
\\ 显示反斜杠。
\d 显示当前日期。
\h 显示主机名。
\n 打印新行。
\nnn 显示nnn的八进制值。
\s 显示当前运行的shell的名字。
\t 显示当前时间。
\u 显示当前用户的用户名。
\W 显示当前工作目录的名字。
\w 显示当前工作目录的路径
我们查看我们发行版linux中的PS1.
$echo echo $PS1
[\u@\h \W] \$
看了发行版是如何显示命令行提示符,那么我们再看一下为什么我们做的根文件系统只显示一个#,用busybox生成的根文件系统使用的是ash,我们看下busybox中关于ash的文件。
在busybox-1.15.4/shell/ash.h中有这样的语句
/*
* PS1 depends on uid
*/
#if ENABLE_FEATURE_EDITING && ENABLE_FEATURE_EDITING_FANCY_PROMPT
vps1.text = “PS1=\\w \\$ ”;
#else
if (!geteuid())
vps1.text = “PS1=# ”;
#endif
结合上面PS1参数我们可以看出在busybox生成的根文件系统中可能出现两种显示方式,一种是“currentpath $”另一种是 “#”这两种显示在较老的版本中都有。
按照上面的方法修改我们的根文件系统中的命令行提示符。首先我们需要修改buxybox中配置,添加如下两个选项:
Busybox Settings --->
Busybox Library Tuning --->
[*] Username completion
[*] Fancy shell prompts
如果不选择上面两项,文件系统是不是别PS1这个环境变量的参数的。
创建/etc/hostname添加如下内容(我们的主机名):
farsight
修改/etc/init.d/rcS添加如下内容(导入主机名配置文件):
/bin/hostname –F /etc/hostname
修改根文件系统中/etc/profile文件添加如下内容:
HOSTNAM=`/bin/hostname`
PS1=`[\u@\h \W]\# `
export PS1 HOSTNAME
创建/etc/passwd添加如下内容:
root:x:0:0:root:/root:/bin/sh
这个时候我们重新启动我们的开发板会发现命令行提示符已经是我们想要的那种现实了:
[root@farsight /etc] #
给出我的实验过程的打印信息
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
RCU-based detection of stalled CPUs is disabled.
Verbose stalled-CPUs detection is disabled.
NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop… 201.93 BogoMIPS (lpj=504832)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
MINI2440: Option string mini2440=0tb
MINI2440: 't' ignored, touchscreen not compiled in
MINI2440: LCD [0:240x320] 1:800x480 2:1024x768
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.23.
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
JFFS2 version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 118
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x53
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
at24 0-0050: 1024 byte 24c08 EEPROM (writable)
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=1, 9ns Twrph0=3 29ns, Twrph1=2 19ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit
)
Creating 4 MTD partitions on “nand”:
0x000000000000-0x000000050000 : “u-boot”
0x000000050000-0x000000060000 : “u-boot-env”
0x000000060000-0x000000560000 : “kernel”
0x000000560000-0x000004000000 : “root”
UBI: attaching mtd3 to ubi0
UBI: physical eraseblock size: 16384 bytes (16 KiB)
UBI: logical eraseblock size: 15872 bytes
UBI: smallest flash I/O unit: 512
UBI: sub-page size: 256
UBI: VID header offset: 256 (aligned 256)
UBI: data offset: 512
UBI: max. sequence number: 1307
UBI: attached mtd3 to ubi0
UBI: MTD device name: “root”
UBI: MTD device size: 58 MiB
UBI: number of good PEBs: 3752
UBI: number of bad PEBs: 0
UBI: max. allowed volumes: 92
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 1
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 3752
UBI: number of PEBs reserved for bad PEB handling: 37
UBI: max/mean erase counter: 4/1
UBI: image sequence number: 0
UBI: background thread “ubi_bgt0d” started, PID 677
dm9000 Ethernet Driver, V1.31
dm9000 dm9000: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000e at c4886300,c488a304 IRQ 51 MAC: 00:00:00:00:00:00 (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
s3c2440-usbgadget s3c2440-usbgadget: S3C2440: increasing FIFO to 128 bytes
mice: PS/2 mouse device common for all mice
input: gpio-keys as /devices/platform/gpio-keys/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: powered down.
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
#0: S3C24XX_UDA134X (UDA134X)
TCP cubic registered
NET: Registered protocol family 17
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2000-05-13 01:01:51 UTC (958179711)
UBIFS: recovery needed
UBIFS: recovery completed
UBIFS: mounted UBI device 0, volume 0, name “rootfs”
UBIFS: file system size: 58440704 bytes (57071 KiB, 55 MiB, 3682 LEBs)
UBIFS: journal size: 8110592 bytes (7920 KiB, 7 MiB, 511 LEBs)
UBIFS: media format: w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root: 0 bytes (0 KiB)
VFS: Mounted root (ubifs filesystem) on device 0:13.
Freeing init memory: 136K
/etc/init.d/rcS: line 20: tarp: not found
ifconfig: SIOCSIFFLAGS: Cannot assign requested address
ln: tty0: File exists
Please press Enter to activate this console.
[\u@\h \W]\#
[\u@\h \W]\#
[\u@\h \W]\#
[\u@\h \W]\# tftp ubifs11.img
BusyBox v1.13.3 (2010-06-04 22:52:32 CST) multi-call binary
Usage: tftp [OPTION]… HOST [PORT]
Transfer a file from/to tftp server
Options:
-l FILE Local FILE
-r FILE Remote FILE
-g Get file
-p Put file
-b SIZE Transfer blocks of SIZE octets
[\u@\h \W]\# tftp ubifs11.img
U-Boot 2010.06-rc1-00073-g54841ab-dirty (Jan 10 2011 - 17:27:06)
DRAM: 64 MiB
Flash: 2 MiB
NAND: 64 MiB
In: serial
Out: serial
Err: serial
Net: dm9000
arch type: 1999
Hit any key to stop autoboot: 0
[mini2440]#
[mini2440]#
[mini2440]# tftp ubifs11.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at unknown: 0 mode
Using dm9000 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.6
Filename 'ubifs11.img'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
#################################################################
#################################################################
###################
done
Bytes transferred = 4094976 (3e7c00 hex)
[mini2440]# ubi write 0x30008000 rootfs 0x3e7c00
mtdparts variable not set, see 'help mtdparts'
Error, no UBI device/partition selected!
[mini2440]# mtdpart
mtdparts variable not set, see 'help mtdparts'
no partitions defined
defaults:
mtdids : nand0=nandflash0
mtdparts: mtdparts=nandflash0:320k@0(uboot),64k(params),5m(kernel),-(root)
[mini2440]# mtdpart default
[mini2440]# mtdpart
device nand0 <nandflash0>, # parts = 4
#: name size offset mask_flags
0: uboot 0x00050000 0x00000000 0
1: params 0x00010000 0x00050000 0
2: kernel 0x00500000 0x00060000 0
3: root 0x03aa0000 0x00560000 0
active partition: nand0,0 - (uboot) 0x00050000 @ 0x00000000
defaults:
mtdids : nand0=nandflash0
mtdparts: mtdparts=nandflash0:320k@0(uboot),64k(params),5m(kernel),-(root)
[mini2440]# nand erase root
NAND erase: device 0 offset 0x560000, size 0x3aa0000
Erasing at 0x3ffc00000000000 -- 0% complete.
OK
[mini2440]# ubi part root
Creating 1 MTD partitions on “nand0”:
0x5600003304698c-0x400000000000000 : “<NULL>”
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size: 16384 bytes (16 KiB)
UBI: logical eraseblock size: 15872 bytes
UBI: smallest flash I/O unit: 512
UBI: sub-page size: 256
UBI: VID header offset: 256 (aligned 256)
UBI: data offset: 512
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd1 to ubi0
UBI: MTD device name: “mtd=3”
UBI: MTD device size: 249108103168 MiB
UBI: number of good PEBs: 3752
UBI: number of bad PEBs: 0
UBI: max. allowed volumes: 92
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 0
UBI: available PEBs: 3711
UBI: total number of reserved PEBs: 41
UBI: number of PEBs reserved for bad PEB handling: 37
UBI: max/mean erase counter: 1/0
[mini2440]# ubi create rootfs
Creating dynamic volume rootfs of size 58900992
[mini2440]# tftp ubifs22.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at unknown: 0 mode
Using dm9000 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.6
Filename 'ubifs22.img'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
done
Bytes transferred = 20808192 (13d8200 hex)
[mini2440]# ubi write 0x30008000 roofs 0x13d8200
roofs volume not found
[mini2440]# mtdpart
device nand0 <nandflash0>, # parts = 4
#: name size offset mask_flags
0: uboot 0x00050000 0x00000000 0
1: params 0x00010000 0x00050000 0
2: kernel 0x00500000 0x00060000 0
3: root 0x03aa0000 0x00560000 0
active partition: nand0,0 - (uboot) 0x00050000 @ 0x00000000
defaults:
mtdids : nand0=nandflash0
mtdparts: mtdparts=nandflash0:320k@0(uboot),64k(params),5m(kernel),-(root)
[mini2440]# ubi write 0x30008000 rootfs 0x13d8200
Volume “rootfs” found at volume id 0
[mini2440]# boot
NAND read: device 0 offset 0x60000, size 0x500000
5242880 bytes read: OK
## Booting kernel from Legacy Image at 30008000 …
Image Name: Linux Kernel Image
Created: 2011-01-18 6:56:00 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2218728 Bytes = 2.1 MiB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum … OK
XIP Kernel Image … OK
OK
Starting kernel …
Uncompressing Linux… done, booting the kernel.
Linux version 2.6.36.3 (root@songzi) (gcc version 4.4.3 (ctng-1.6.1) ) #5 Tue Ja
n 18 14:50:35 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: ubi.mtd=3 root=ubi0:rootfs console=ttySAC0,115200 mem=64M r
ootfstype=ubifs rw
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60440k/60440k available, 5096k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xe0000000 ( 440 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc002a000 ( 136 kB)
.text : 0xc002a000 - 0xc03f4000 (3880 kB)
.data : 0xc040c000 - 0xc042dc80 ( 136 kB)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
RCU-based detection of stalled CPUs is disabled.
Verbose stalled-CPUs detection is disabled.
NR_IRQS:85
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop… 201.93 BogoMIPS (lpj=504832)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
MINI2440: Option string mini2440=0tb
MINI2440: 't' ignored, touchscreen not compiled in
MINI2440: LCD [0:240x320] 1:800x480 2:1024x768
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.23.
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
JFFS2 version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 118
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x53
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
at24 0-0050: 1024 byte 24c08 EEPROM (writable)
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=1, 9ns Twrph0=3 29ns, Twrph1=2 19ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit
)
Creating 4 MTD partitions on “nand”:
0x000000000000-0x000000050000 : “u-boot”
0x000000050000-0x000000060000 : “u-boot-env”
0x000000060000-0x000000560000 : “kernel”
0x000000560000-0x000004000000 : “root”
UBI: attaching mtd3 to ubi0
UBI: physical eraseblock size: 16384 bytes (16 KiB)
UBI: logical eraseblock size: 15872 bytes
UBI: smallest flash I/O unit: 512
UBI: sub-page size: 256
UBI: VID header offset: 256 (aligned 256)
UBI: data offset: 512
UBI: max. sequence number: 1294
UBI: attached mtd3 to ubi0
UBI: MTD device name: “root”
UBI: MTD device size: 58 MiB
UBI: number of good PEBs: 3752
UBI: number of bad PEBs: 0
UBI: max. allowed volumes: 92
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 1
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 3752
UBI: number of PEBs reserved for bad PEB handling: 37
UBI: max/mean erase counter: 4/1
UBI: image sequence number: 0
UBI: background thread “ubi_bgt0d” started, PID 677
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c4886300,c488a304 IRQ 51 MAC: 08:00:3e:26:0a:5b (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
s3c2440-usbgadget s3c2440-usbgadget: S3C2440: increasing FIFO to 128 bytes
mice: PS/2 mouse device common for all mice
input: gpio-keys as /devices/platform/gpio-keys/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: powered down.
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
#0: S3C24XX_UDA134X (UDA134X)
TCP cubic registered
NET: Registered protocol family 17
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2000-05-13 01:17:00 UTC (958180620)
UBIFS: mounted UBI device 0, volume 0, name “rootfs”
UBIFS: file system size: 58440704 bytes (57071 KiB, 55 MiB, 3682 LEBs)
UBIFS: journal size: 8110592 bytes (7920 KiB, 7 MiB, 511 LEBs)
UBIFS: media format: w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root: 0 bytes (0 KiB)
VFS: Mounted root (ubifs filesystem) on device 0:13.
Freeing init memory: 136K
/etc/init.d/rcS: line 20: tarp: not found
eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
ln: tty0: File exists
Please press Enter to activate this console.
[root@songzi /]#
[root@songzi /]#
[root@songzi /]# ls
bin etc lib mnt root sys tty0
dev fs linuxrc proc sbin tmp usr
[root@songzi /]# ls
bin etc lib mnt root sys tty0
dev fs linuxrc proc sbin tmp usr
[root@songzi /]# ?
-/bin/sh: ?: not found
[root@songzi /]# cd usr/
[root@songzi /usr]# ls
bin button helloworld listview pda_kero
bmpbkgnd dialogbox listbox local sbin
[root@songzi /usr]# ./helloworld
IAL: Does not find the request engine: cosole.
IAL: Use the first engine: dummy
^C[root@songzi /usr]#
[root@songzi /usr]#
[root@songzi /usr]#
[root@songzi /usr]#
[root@songzi /usr]# ls
bin button helloworld listview pda_kero
bmpbkgnd dialogbox listbox local sbin
[root@songzi /usr]# ./pda_kero
./pda_kero: line 1: syntax error: “(” unexpected
[root@songzi /usr]#
[root@songzi /usr]#
[root@songzi /usr]# ls
bin button helloworld listview pda_kero
bmpbkgnd dialogbox listbox local sbin
[root@songzi /usr]# ./listbox
IAL: Does not find the request engine: cosole.
IAL: Use the first engine: dummy
busybox是一个集成了一百多个常用linux命令和工具的软件,他甚至还集成了一个http服务器和一个telnet服务器,而所有这一切功能却只有区区1M左右的大小.我们平时用的那些linux命令就好比是分立式的电子元件,而busybox就好比是一个集成电路,把常用的工具和命令集成压缩在一个可执行文件里,功能基本不变,而大小却小很多倍,在嵌入式linux应用中,busybox有非常广的应用,另外,大多数linux发行版的安装程序中都有busybox的身影,安装linux的时候案ctrl+alt+F2就能得到一个控制台,而这个控制台中的所有命令都是指向busybox的链接.
Busybox的小身材大作用的特性,给制作一张软盘的linux带来了及大方便.
busybox的用法
可以这样用busybox
#busybox ls
他的功能就相当运行ls命令
常用的用法是建立指向busybox的链接,不同的链接名完成不同的功能。
#ln -s busybox ls
#ln -s busybox rm
#ln -s busybox mkdir
然后分别运行这三个链接:
#./ls
#./rm
#./mkdir
就可以分别完成了ls rm 和mkdir命令的功能。虽然他们都指向同一个可执行程序busybox,但是只要链接名不同,完成的功能就不同,很多linux网站都提供busybox的源代码。
配置busybox
busybox的配置程序和linux内核菜单配置方式简直一模一样。熟悉用make menuconfig方式配置linux内核的朋友很容易上手。
#cp busybox-1.00.tar.gz /babylinux
#cd /babylinux
#tar xvfz busybox-1.00.tar.gz
#cd busybox-1.00
#make menuconfig
下面是需要编译进busybox的功能选项。
General Configuration应该选的选项
Show verbose applet usage messages
Runtime SUID/SGID configuration via /etc/busybox.conf
Build Options
Build BusyBox as a static binary (no shared libs)
这个选项是一定要选择的,这样才能把busybox编译成静态链接的可执行文件,运行时才独立于其他函数库。否则必需要其他库文件才能运行,在单一个linux内核不能使它正常工作。
Installation Options
Don't use /usr
这个选项也一定要选,否则make install 后busybox将安装在原系统的/usr下,这将覆盖掉系统原有的命令。选择这个选项后,make install后会在busybox目录下生成一个叫_install的目录,里面有busybox和指向它的链接。
其它选项都是一些linux基本命令选项,自己需要哪些命令就编译进去,一般用默认的就可以了,配置好后退出并保存。
编译并安装busybox
#make
#make install
编译好后在busybox目录下生成子目录_install,里面的内容:
drwxr-xr-x 2 root root 4096 11月 24 15:28 bin
rwxrwxrwx 1 root root 11 11月 24 15:28 linuxrc -> bin/busybox
drwxr-xr-x 2 root root 4096 11月 24 15:28 sbin
其中可执行文件busybox在bin目录下,其他的都是指向他的符号链接。
希望本文能够给从事相关工作的人一些小小的帮助,也希望新人在本文的帮助下更快的掌握提示符的用法.
免责声明: 凡注明来源本网的所有作品,均为本网合法拥有版权或有权使用的作品,欢迎转载,注明出处。非本网作品均来自互联网,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。