构建linux之最小系统Word格式.docx
《构建linux之最小系统Word格式.docx》由会员分享,可在线阅读,更多相关《构建linux之最小系统Word格式.docx(13页珍藏版)》请在冰豆网上搜索。
![构建linux之最小系统Word格式.docx](https://file1.bdocx.com/fileroot1/2022-12/12/b38bb27a-7c1c-4044-b764-91781d6e99cb/b38bb27a-7c1c-4044-b764-91781d6e99cb1.gif)
A.有字符显示。
B。
能通过键盘输入字符
C。
能执行ls等简单命令
根据以上需求,并分析Linux平台的架构。
该最小系统特征如下
A。
kernel+rootfs,不使用initrd.
B.ls等命令放在rootfs中,elf格式。
静态编译,不支持动态链接库。
kernel支持elf可执行文件格式
D。
kernel不支持可加载模块功能。
必要的驱动直接编译到kernel中。
E。
kernel应包含字符的显示驱动、键盘驱动。
F。
rootfs放在IDE硬盘上,所以kernel应包含PATA驱动
G。
rootfs为EXT3文件系统,kernel应包含EXT2、EXT3文件系统驱动。
[root@goldway~]#cat/proc/version
Linuxversion2.6.18-1.2798.fc6(brewbuilder@hs20-bc2-)(gccversion4.1.120061011(RedHat4.1.1-30))#1SMPMonOct1614:
37:
32EDT2006
[root@goldway~]#cat/proc/cpuinfo
processor
:
0
vendor_id
GenuineIntel
cpufamily
:
15
model
2
modelname
Intel(R)Celeron(R)CPU2.60GHz
stepping
9
cpuMHz
2625.987
cachesize
128KB
fdiv_bug
no
hlt_bug
f00f_bug
coma_bug
fpu
yes
fpu_exception
cpuidlevel
wp
flags
fpuvmedepsetscmsrpaemcecx8apicmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmpbeupcidxtpr
bogomips
5257.90
[root@goldway~]#lspci
00:
00.0Hostbridge:
VIATechnologies,Inc.P4M266HostBridge
01.0PCIbridge:
VIATechnologies,Inc.VT8633[ApolloPro266AGP]
10.0USBController:
VIATechnologies,Inc.VT82xxxxxUHCIUSB1.1Controller(rev80)
10.1USBController:
10.2USBController:
10.3USBController:
VIATechnologies,Inc.USB2.0(rev82)
11.0ISAbridge:
VIATechnologies,Inc.VT8235ISABridge
11.1IDEinterface:
VIATechnologies,Inc.VT82C586A/B/VT82C686/A/B/VT823x/A/CPIPCBusMasterIDE(rev06)
11.5**audiocontroller:
VIATechnologies,Inc.VT8233/A/8235/8237AC97AudioController(rev50)
12.0Ethernetcontroller:
VIATechnologies,Inc.VT6102[Rhine-II](rev74)
01:
00.0VGAcompatiblecontroller:
nVidiaCorporationNV34[GeForceFX5200](reva1)
[root@goldway~]#fdisk-l
Disk/dev/hda:
160.0GB,160041885696bytes
255heads,63sectors/track,19457cylinders
Units=cylindersof16065*512=8225280bytes
DeviceBoot
Start
End
Blocks
Id
System
/dev/hda1
*
1
1001
8040501
7
HPFS/NTFS
/dev/hda2
1002
19457
148247820
f
W95Ext'
d(LBA)
/dev/hda5
5001
32129968+
7
/dev/hda6
5002
9001
/dev/hda7
9002
13001
c
W95FAT32(LBA)
/dev/hda8
13002
17001
/dev/hda9
18213
10000431
83
Linux
/dev/hda10
17002
18081
8675068+
/dev/hda11
18082
18212
1052226
82
Linuxswap/Solaris
Partitiontableentriesarenotindiskorder
[root@goldway~]#mount
/dev/hda10on/typeext3(rw)
procon/proctypeproc(rw)
sysfson/systypesysfs(rw)
devptson/dev/ptstypedevpts(rw,gid=5,mode=620)
tmpfson/dev/shmtypetmpfs(rw)
/dev/hda7on/mnt/windows/ftypevfat(rw)
/dev/hda8on/mnt/windows/gtypevfat(rw)
noneon/proc/sys/fs/binfmt_misctypebinfmt_misc(rw)
sunrpcon/var/lib/nfs/rpc_pipefstyperpc_pipefs(rw)
/dev/hda9on/mnt/cdromtypeext3(rw)
请注意以下几点:
硬盘是IDE接口,所以这篇文档描述的操作不适合于使用SATA硬盘的朋友。
我使用的linuxdist是fedoracore6.gccversion4.1.1
/dev/hda10是fc6的/,即将构建的最小系统的文件将放在/dev/hda9中。
A.选择busybox-1.15.3构建rootfs.
B.内核版本选择linux-2.6.26.5。
gcc4.1.1不支持最新版的kernel.
[root@goldway~]#ll/mnt/cdrom
总计728
drwxr-xr-x2rootroot
409612-3119:
20bin
-rw-r--r--1rootroot70187201-0100:
28bzImage
27dev
-rw-r--r--1rootroot
39002010-01-01dmesg.txt
drwxr-xr-x3rootroot
409601-0113:
03etc
07mnt
25proc
20sbin
25sys
drwxr-xr-x4rootroot
20usr
以上文件夹打包给大家
[root@goldwaycdrom]#tarjcf../rootfs.tar.bz2*
[root@goldwaycdrom]#ll..
总计1508
drwxr-xr-x10rootroot
40962010-01-01cdrom
-rw-r--r--
1rootroot151670901-0113:
14rootfs.tar.bz2
drwxr-xr-x
2rootroot
409612-1119:
14usb
6rootroot
409611-0717:
38windows
以下为grub引导设置:
[root@goldway~]#cat/etc/grub.conf
#grub.confgeneratedbyanaconda
#
#Notethatyoudonothavetorerungrubaftermakingchangestothisfile
#NOTICE:
Youdonothavea/bootpartition.
Thismeansthat
#
allkernelandinitrdpathsarerelativeto/,eg.
root(hd0,9)
kernel/boot/vmlinuz-versionroroot=/dev/hda10
initrd/boot/initrd-version.img
#boot=/dev/hda
default=2
timeout=5
splashimage=(hd0,9)/boot/grub/splash.xpm.gz
hiddenmenu
titlekerneltest
root(hd0,8)
kernel/bzImageroroot=/dev/hda9
titleFedoraCore(2.6.18-1.2798.fc6)
root(hd0,9)
kernel/boot/vmlinuz-2.6.18-1.2798.fc6roroot=LABEL=/1rhgbquiet
initrd/boot/initrd-2.6.18-1.2798.fc6.img
titleOther
rootnoverify(hd0,0)
chainloader+1
Linuxversion2.6.26.5(root@goldway)(gccversion4.1.120061011(RedHat4.1.1-30))#12FriJan100:
28:
28CST2010
BIOS-providedphysicalRAMmap:
BIOS-e820:
0000000000000000-000000000009fc00(usable)
000000000009fc00-00000000000a0000(reserved)
00000000000f0000-0000000000100000(reserved)
0000000000100000-000000000fff0000(usable)
000000000fff0000-000000000fff3000(ACPINVS)
000000000fff3000-0000000010000000(ACPIdata)
00000000fec00000-0000000100000000(reserved)
0MBHIGHMEMavailable.
255MBLOWMEMavailable.
Enteringadd_active_range(0,0,65520)0entriesof256used
ZonePFNranges:
DMA
0->
4096
Normal
4096->
65520
HighMem
65520->
MovablezonestartPFNforeachnode
early_node_map[1]activePFNranges
0:
0->
Onnode0totalpages:
DMAzone:
32pagesusedformemmap
0pagesreserved
4064pages,LIFObatch:
Normalzone:
480pagesusedformemmap
60944pages,LIFObatch:
15
HighMemzone:
0pagesusedformemmap
Movablezone:
DMI2.3present.
AllocatingPCIresourcesstartingat20000000(gap:
10000000:
eec00000)
Built1zonelistsinZoneorder,mobilitygroupingon.
Totalpages:
65008
Kernelcommandline:
roroot=/dev/hda9
EnablingfastFPUsaveandrestore...done.
EnablingunmaskedSIMDFPUexceptionsupport...done.
InitializingCPU#0
PIDhashtableentries:
1024(order:
10,4096bytes)
Detected2625.912MHzprocessor.
Console:
colourVGA+80x25
console[tty0]enabled
Dentrycachehashtableentries:
32768(order:
5,131072bytes)
Inode-cachehashtableentries:
16384(order:
4,65536bytes)
Memory:
257764k/262080kavailable(912kkernelcode,3808kreserved,300kdata,100kinit,0khighmem)
virtualkernelmemorylayout:
fixmap
0xfffee000-0xfffff000
(
68kB)
pkmap
0xff800000-0xffc00000
(4096kB)
vmalloc:
0xd0800000-0xff7fe000
(751MB)
lowmem
0xc0000000-0xcfff0000
(255MB)
.init:
0xc0232000-0xc024b000
(100kB)
.data:
0xc01e4097-0xc022f42c
(300kB)
.text:
0xc0100000-0xc01e4097
(912kB)
CheckingifthisprocessorhonourstheWPbiteveninsupervisormode...Ok.
CPA:
pagepoolinitialized1of1pagespreallocated
SLUB:
Genslabs=12,HWalign=128,Order=0-3,MinObjects=0,CPUs=1,Nodes=1
Calibratingdelayusingtimerspecificroutine..5257.16BogoMIPS(lpj=10514322)
Mount-cachehashtableentries:
512
CPU:
Tracecache:
12Kuops,L1Dcache:
8K
L2cache:
128K
Intel(R)Celeron(R)CPU2.60GHzstepping09
Checking'
hlt'
instruction...OK.
FreeingSMPalternatives:
0kfreed
SettingupstandardPCIresources
ioschedulernoopregistered(default)
UniformMulti-PlatformE-IDEdriver
ide:
Assuming50MHzsystembusspeedforPIOmodes;
overridewithidebus=xx
ide_generic:
pleaseuse"
probe_mask=0x3f"
moduleparameterforprobingalllegacyISAIDEports
ProbingIDEinterfaceide0...
hda:
ST3160215A,ATADISKdrive
ProbingIDEinterfaceide1...
ide0at0x1f0-0x1f7,0x3f6onirq14
ide1at0x170-0x177,0x376onirq15
maxrequestsize:
512KiB
312581808sectors(160041MB)w/2048KiBCache,CHS=19457/255/63
cacheflushessupported
hda1hda2<
hda5hda6hda7hda8hda9hda10hda11>
serio:
i8042KBDportat0x60,0x64irq1
i8042AUXportat0x60,0x64irq12
mice:
PS/2mousedevicecommonforallmice
UsingIPIShortcutmode
input:
ATTranslatedSet2keyboardas/devices/platform/i8042/serio0/input/input0
kjournaldstarting.
Commitinterval5seconds
EXT3-fs:
mountedfilesystemwithordereddatamode.
VFS:
Mountedroot(ext3filesystem)readonly.
Freeingunusedkernelmemory:
100kfreed
EXT3-fswarning:
maximalmountcountreached,runninge