https://blog.csdn.net/yejingx/article/details/6525405
一. 最小系統(tǒng)要求
1. 接受鍵盤(pán)輸入蜒滩,能顯示字符信息
2. 能處理普通linux發(fā)行版中的大部分基本命令,如:ls, mv...
3. 具有網(wǎng)絡(luò)功能
4. 不使用ramdisk, 所需驅(qū)動(dòng)全部編譯進(jìn)內(nèi)核
二. 主機(jī)環(huán)境
1. VMware 7.0 / windows 7
2. 主機(jī)系統(tǒng)Ubuntu 10.04 x86 (kernel version 2.6.32)
3. 最小系統(tǒng)內(nèi)核版本 linux-2.6.38
三. 詳細(xì)構(gòu)建過(guò)程
1. 下載linux-2.6.38內(nèi)核
[c-sharp] view plain copy
#cd?/usr/src??
#wget?http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.38.tar.gz??
#tar?xvf?linux-2.6.38.tar.gz??
#cd?linux-2.6.38???
2.編譯內(nèi)核
這一步主要就是內(nèi)核的配置苟蹈,如果配置錯(cuò)了可能導(dǎo)致系統(tǒng)無(wú)法啟動(dòng)扣孟,因此需要非常仔細(xì)钓丰。
[c-sharp] view plain copy
#make?mrproper???????????????
#make?allnoconfig??
#make?menuconfig???
首先利用lspci查看硬件信息:
[c-sharp] view plain copy
#lspci????
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
................... ......................... .......................
00:18.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.7 PCI bridge: VMware PCI Express Root Port (rev 01)
02:00.0 USB Controller: Intel Corporation 82371AB/EB/MB PIIX4 USB
02:01.0 Ethernet controller: Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev 10)
02:02.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 02)
02:03.0 USB Controller: VMware USB2 EHCI Controller
根據(jù)查到的硬件型號(hào)配置.config文件
以下詳細(xì)介紹內(nèi)核的配置(除以下選項(xiàng)外其它都可以不選)
General setup --->
[*] System V IPC
[*] Enable loadable module support --->
Processor type and features --->
Processor family (Pentium Pro) --->
[*] Generuc x86 support
Bus options (PCI etc.) --->
[*] PCI support
PCI access mode (Any) --->
Executable file formats / Emulations --->
[*] Kernel support for ELF binaries
[*] Write ELF core dumps with partial segments
[*] Networking support? --->
Networking options --->
<*> Packet socket
<*> Unix domain sockets (NEW)
[*] TCP/IP networking
<*>?? IP: IPsec transport mode (NEW)
<*>?? IP: IPsec tunnel mode (NEW)
<*>?? IP: IPsec BEET mode (NEW)
<*>?? Large Receive Offload (ipv4/tcp) (NEW)
<*>?? INET: socket monitoring interface (NEW)
Device Drivers? --->
[*] Block devices --->
<*> Loopback device support
SCSI device support --->
<*> SCSI device support
[*] legacy /proc/scsi/ support (NEW)
<*> SCSI disk support
[*] SCSI low-level drivers (NEW) --->
<*> BusLogic SCSI support
[*] Fusion MPT device support --->
<*> Fusion MPT ScsiHost drivers for SPI
<*> Fusion MPT ScsiHost drivers for FC
<*> Fusion MPT ScsiHost drivers for SAS
<*> Fusion MPT misc device (ioctl) driver
[*] Network device support --->
[*] Ethernet (10 or 100Mbit) --->
[*] EISA, VLB, PCI and on board controllers
<*> AMD PCnet32 PCI support
Graphics support? --->
<*> Support for frame buffer devices --->
File systems? --->
<*> Second extended fs support
[*]?? Ext2 extended attributes
[*]???? Ext2 POSIX Access Control Lists?
[*]???? Ext2 Security Labels
[*] Ext2 execute in place support
<*> Ext3 journalling file system support
[*]?? Default to 'data=ordered' in ext3 (NEW)
[*]?? Ext3 extended attributes (NEW)?
[*]???? Ext3 POSIX Access Control Lists??
[*]???? Ext3 Security Labels??
CD-ROM/DVD Filesystems --->
<*> ISO 9660 CDROM file system support
<*> Native language support --->
<*> Codepage 437 (United States, Canada)
<*> Simplified Chinese charset (CP936, GB2312)
配置完成后就可以開(kāi)始編譯了:
[c-sharp] view plain copy
#make?bzImage????
注意:在make menuconfig的時(shí)候一定要選對(duì)磁盤(pán)驅(qū)動(dòng)疹蛉,否則會(huì)出現(xiàn)
kernel panic -- VFS error: unable to mount …
這里我用的是SCSI的磁盤(pán)磺平,IDE的要做相應(yīng)修改靴姿。
3. 制作根文件系統(tǒng)
為簡(jiǎn)單起見(jiàn)沃但,我們利用busybox制用根文件系統(tǒng)。
[c-sharp] view plain copy
#wget?http://busybox.net/downloads/busybox-1.18.4.tar.bz2??
#tar?xvf?busybox-1.18.4.tar.bz2??
#cd?busybox-1.18.4??
#make?menuconfig??
下面是需要編譯進(jìn)busybox的功能選項(xiàng)佛吓。
General Configuration應(yīng)該選的選項(xiàng)
Don't use /usr
????? 這個(gè)選項(xiàng)一定要選,否則make install 后busybox將安裝在原系統(tǒng)的/usr下宵晚,這將覆蓋掉系統(tǒng)原有的命令垂攘。
Build Options
Build BusyBox as a static binary (no shared libs)
這個(gè)選項(xiàng)也是一定要選擇的,這樣才能把busybox編譯成靜態(tài)鏈接的可執(zhí)行文件,運(yùn)行時(shí)才獨(dú)立于其他函數(shù)庫(kù).否則必需要其他庫(kù)文件才能運(yùn)行淤刃,在單一個(gè)linux內(nèi)核不能使它正常工作晒他。
其它選項(xiàng)都是一些linux基本命令選項(xiàng),自己需要哪些命令就編譯進(jìn)去逸贾,一般用默認(rèn)的就可以了陨仅,配置好后退出并保存。
編譯并安裝busybox
[c-sharp] view plain copy
#make??
#make?install???
make install后會(huì)在busybox目錄下生成一個(gè)叫_install的目錄铝侵,里面有busybox和指向它的鏈接灼伤。
接下來(lái)給虛擬機(jī)添加一塊SCSI磁盤(pán)并分區(qū),假設(shè)根分區(qū)為sdb1
[c-sharp] view plain copy
#mount?/dev/sdb1?/mnt???????將根分區(qū)掛載到/mnt????
#cp?_install/*?/mnt/????????????將_install下的文件全復(fù)制到sdb1????
#rm?-f?linuxrc????
#cp?-r?./examples/bootfloppy/etc?/mnt???????將etc下的配置文件拷到sdb1下????
#cd?/mnt/????
#mkdir?proc?mnt?usr?var?tmp?dev?sys?????????創(chuàng)建目錄????
#cp?-a?/dev/{console,tty,tty2}?dev/??
4. 更新grub
這步既可以在ubuntu的grub中引導(dǎo)也可以在sdb上裝上grub咪鲜,從sdb1進(jìn)行引導(dǎo)狐赡。
為簡(jiǎn)單起見(jiàn)我們就用ubuntu中的grub來(lái)引導(dǎo)。
修改/boot/grub/grub.cfg
[c-sharp] view plain copy
#gedit?/boot/grub/grub.cfg??
新添加
menuentry "My Linux-2.6.38" {
insmod ext2
set root='(hd1,1)'
linux /bzImage ro root=/dev/sdb1
}
5. 最后重啟一下(啟動(dòng)時(shí)按住shift疟丙,否則不進(jìn)入grub2引導(dǎo)菜單)
[c-sharp] view plain copy
#reboot????
選擇My Linux-2.6.38
如果一切順利颖侄,就會(huì)出現(xiàn)下圖的信息, ----- 啟動(dòng)成功享郊。
---------------------
作者:yejingx
來(lái)源:CSDN
原文:https://blog.csdn.net/yejingx/article/details/6525405
版權(quán)聲明:本文為博主原創(chuàng)文章览祖,轉(zhuǎn)載請(qǐng)附上博文鏈接!