新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 最小的Linux系統(tǒng)制作過(guò)程詳解

最小的Linux系統(tǒng)制作過(guò)程詳解

作者: 時(shí)間:2016-10-08 來(lái)源:網(wǎng)絡(luò) 收藏

其中init.d是一個(gè)目錄,從busybox-1.00源代碼目錄下拷貝過(guò)來(lái).

#cp -R /babylinux/busybox-1.00/examples/bootflopyp/etc/init.d /babylinux/rootfs/etc/

busybox.conf是一個(gè)空文件.

其他文件的內(nèi)容如下:

fstab

/dev/fd0 / ext2 defaults 0 0

none /proc proc defaults 0 0

/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0

/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0

group

root:x:0:root

inittab

::sysinit:/etc/init.d/rcS

::askfirst:/bin/sh

tty2::respawn:/bin/getty 38400 tty2

tty3::respawn:/bin/getty 38400 tty3

tty4::respawn:/bin/getty 38400 tty4

# Stuff to do when restarting the init process

::restart:/bin/init

# Stuff to do before rebooting

::ctrlaltdel:/bin/reboot

::shutdown:/bin/umount -a -r

::shutdown:/bin/swapoff -a

issue

Baby Linux release 0.1

motd

mtab

passwd

root::0:0:root:/root:/bin/ash

profile

# /etc/profile: system-wide .profile file for the Bourne shells

echo

echo

export PS1=[u@h w]$

echo Done

alias ll='ls -l'

alias du='du -h'

alias df='df -h'

alias rm='rm -i'

echo

resolv.conf

nameserver 202.96.209.5

nameserver 202.96.209.6

shadow

root:$1$$adltAB9Sr/MSKqylIvSJT/:12705:0:99999:7:::

shadow-

root:$1$DWU.tenP$B7ANiXoGoiZMwJR6Ih8810:12705:0:99999:7:::

其中有很多是從原系統(tǒng)的/etc下拷貝過(guò)來(lái)修改的,如果你是一個(gè)具有中等以上水平的linux愛(ài)好者,那么應(yīng)該一看就明白了,當(dāng)然,你也可以根據(jù)自己的需要修改這些文件.其中最重要的是fstab和inittab,busybox內(nèi)建的init程序用到的inittab文件的語(yǔ)法和一般的不一樣,不能直接把原系統(tǒng)/etc下inittab文件拷貝過(guò)來(lái).可以把busybox-1.00目錄下的示例文件拷貝過(guò)來(lái)修改用.具體請(qǐng)看busybox的文檔. busybox的init也可以不用inittab.但是在我制作babylinux過(guò)程中有一個(gè)非常奇怪的bug.所有/sbin下的busybox鏈接在做成壓縮的根文件系統(tǒng),解壓后都不能正常運(yùn)行,顯示找不到該命令.只有當(dāng)我在/bin下做這些鏈接時(shí)才能運(yùn)行.具體原因還不太清除,所以你需要做下面的工作:

#cd /babylinux/rootfs/sbin

#ls

chroot getty ifconfig losetup pivot_root reboot swapoff sysctl

fdisk halt init mkswap poweroff route swapon telnetd

查看到sbin下有上述鏈接

轉(zhuǎn)到bin下

#cd /babylinux/rootfs/bin

重新做這些鏈接:

#ln -s busybox chroot

#ln -s busybox getty

#ln -s busybox ifconfig

...

然后把sbin下的鏈接刪除,以節(jié)省空間

#rm -rf /babylinux/rootfs/sbin/*

再把原先inittab中所有的sbin改成bin

init.d下的文件:

rcS

請(qǐng)確保這個(gè)文件是可執(zhí)行的,否則請(qǐng)改成可執(zhí)行的:

#chmod u+x rcS

rcS的內(nèi)容:

#! /bin/sh

mount -o remount,rw /

/bin/mount -a

>/etc/mtab

echo

echo

echo

echo

echo -en ttWelcom to \033[0;32mBabyLinux\033][0;39mn

echo -en \033][0;36mn

echo

echo -en ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ttn

echo -en + This is a tiny linux system based on a floppy.It contains ttn

echo -en + more than 100 basic Linux commands and tools.The kernel of ttn

echo -en + this tiny system support all kinds of normal filesystems. ttn

echo -en + linux ext2,ext3,jfs,reiserfs and windows fat,vfat,ntfs][readonly]ttn

echo -en + is supported! So it is a powerful small system you can use it ttn

echo -en + as a linux and windows rescue disk.Beside this,the kernel alsottn

echo -en + contains the drivers of Reltek8139,NE2000,via-rhine ethernetttn

echo -en + adpater. you can configure the IPaddress and netmask with toolsttn

echo -en + 'ifconfig' and config the default gateway with command 'route'. ttn

echo -en + Is there anything else? Haha,this is a telnet server build-inttn

echo -en + you can type 'telnetd' to startd it and thus your friends canttn

echo -en + logon to your system to help you solve the problem.ttn

echo -en + \033[0;32mAll these great features are powered by BusyBox 1.0\033][0;36mttn

echo -en + This is a free system tool developed by GuCuiwen.ttn

echo -en + RUN YOUR OWN RISK of using it ! if you have any problem pleasettn

echo -en + mailto : win2linux@163.com Enjoy!!ttn

echo -en ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ttn

echo -en \033][0;39mn



關(guān)鍵詞:

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉