搭建《深入Linux内核架构》的Linux环境

作者

彭东林

[email protected]

软件

Host: Ubuntu14.04 64

Qemu 2.8.0

Linux 2.6.24

busybox 1.24.2

gcc 4.4.7

概述

为了尽量还原《深入Linux内核架构》这本书的环境,我下载了Linux 2.6.24,由于这个内核版本比较老,所以用最新的gcc编译会有问题,所以需要安装一个比较老的gcc,从该内核的README得知,gcc的版本最少应该是3.2.

正文

一、安装GCC

使用apt-cache search gcc发现,目前可以安装的最老的gcc版本是4.4,安装命令如下:

sudo apt-get install gcc-4.4*

为了便于跟原来的高版本的gcc切换,可以使用下面的命令:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 0
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 1

这样,在切换gcc版本时就方便多了,可以使用下面的命令切换:

sudo update-alternatives --config gcc

此时会列出如下信息:

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path              Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-4.4   1         auto mode
* 1            /usr/bin/gcc-4.4   1         manual mode
  2            /usr/bin/gcc-4.8   0         manual mode

Press enter to keep the current choice[*], or type selection number: 

根据需求选择我们需要的版本即可。

二、编译Linux内核

编译命令如下:

#!/bin/bash
make ARCH=i386 i386_defconfig
make ARCH=i386 menuconfig
make ARCH=i386 bzImage V=1 -j8

在编译的时候会提示如下的错误:

arch/x86/boot/boot.h: Assembler messages:
arch/x86/boot/boot.h:112: Error: bad register name `%dil‘

也就是下面的一行代码出现问题:

asm volatile("movb %%fs:%1,%0" : "=r" (v) : "m" (*(u8 *)addr));

在网上搜索一番后,出现这个问题的原因如下:(http://nxlhero.blog.51cto.com/962631/702421/

"r"表示的时任何寄存器,而dil寄存器时x86_64上才有的,所以将上面的"=r"换为"=q",即限定为只能选eax,ebx,ecx,edx之一。

修改完成后,就可以编译通过了。

支持ramdisk:

General setup
  ----> [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support

Device Drivers
  ----> [*] Block devices
        ----> (16)    Default number of RAM disks
        ----> (65535) Default RAM disk size (kbytes)
        ----> (1024)  Default RAM disk block size (bytes)

三、制作跟文件系统

这一节参考用Qemu搭建x86学习环境

制作脚本mk_ramdisk.sh稍有不同:

#!/bin/bash

sudo rm -rf rootfs
sudo rm -rf tmpfs
sudo rm -rf ramdisk*
sudo mkdir rootfs
sudo cp /home/pengdonglin/disk_ext/Third_Part/Busybox/x86_2_6_24/_install/*  rootfs/ -raf
sudo mkdir -p rootfs/proc/
sudo mkdir -p rootfs/sys/
sudo mkdir -p rootfs/tmp/
sudo mkdir -p rootfs/root/
sudo mkdir -p rootfs/var/
sudo mkdir -p rootfs/mnt/
sudo cp etc rootfs/ -arf
sudo mkdir -p rootfs/lib
sudo cp -arf /lib/i386-linux-gnu/* rootfs/lib/
sudo rm -f rootfs/lib/*.a
sudo strip rootfs/lib/*
sudo mkdir -p rootfs/dev/
sudo mknod rootfs/dev/tty1 c 4 1
sudo mknod rootfs/dev/tty2 c 4 2
sudo mknod rootfs/dev/tty3 c 4 3
sudo mknod rootfs/dev/tty4 c 4 4
sudo mknod rootfs/dev/console c 5 1
sudo mknod rootfs/dev/null c 1 3
sudo dd if=/dev/zero of=ramdisk bs=1M count=32
sudo mkfs.ext2 -F ramdisk
sudo mkdir -p tmpfs
sudo mount -t ext2 ramdisk ./tmpfs/  -o loop
sudo cp -raf rootfs/*  tmpfs/
sudo umount tmpfs

这里不需要压缩ramdisk,因为Linux 2.6.24不支持gzip压缩的ramdisk,我们直接使用制作出的32M的ramdisk就好了。

四、运行qemu

run.sh:

sudo qemu-system-i386        -smp 2        -m 1024M        -kernel ./Linux-2.6.24/arch/x86/boot/bzImage        -nographic        -append "root=/dev/ram1 rw rootfstype=ext2 console=ttyS0 init=/linuxrc"        -initrd ./rootfs/ramdisk        -net nic,vlan=0 -net tap,vlan=0,ifname=tap0

注意上面的root是/dev/ram1,initrd使用的是未压缩的ramdisk。

五、启动log

$./run.sh
[sudo] password for pengdonglin:
sudo tunctl -u root -t tap0
TUNSETIFF: Device or resource busy
sudo ifconfig tap0 0.0.0.0 promisc up
sudo brctl addif br0 tap0
brctl show
bridge name    bridge id        STP enabled    interfaces
br0        8000.027fb716b96e    no        eth0
                            tap0
[    0.000000] Linux version 2.6.24-gcbe024b4-dirty ([email protected]) (gcc version 4.4.7 (Ubuntu/Linaro 4.4.7-8ubuntu1) ) #7 SMP Sun Jul 2 12:29:54 CST 2017
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
[    0.000000]  BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 000000003ffe0000 (usable)
[    0.000000]  BIOS-e820: 000000003ffe0000 - 0000000040000000 (reserved)
[    0.000000]  BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved)
[    0.000000] 127MB HIGHMEM available.
[    0.000000] 896MB LOWMEM available.
[    0.000000] found SMP MP-table at 000f6a90
[    0.000000] Zone PFN ranges:
[    0.000000]   DMA             0 ->     4096
[    0.000000]   Normal       4096 ->   229376
[    0.000000]   HighMem    229376 ->   262112
[    0.000000] Movable zone start PFN for each node
[    0.000000] early_node_map[1] active PFN ranges
[    0.000000]     0:        0 ->   262112
[    0.000000] DMI 2.8 present.
[    0.000000] Using APIC driver default
[    0.000000] ACPI: RSDP 000F6860, 0014 (r0 BOCHS )
[    0.000000] ACPI: RSDT 3FFE1936, 0030 (r1 BOCHS  BXPCRSDT        1 BXPC        1)
[    0.000000] ACPI: FACP 3FFE180A, 0074 (r1 BOCHS  BXPCFACP        1 BXPC        1)
[    0.000000] ACPI: DSDT 3FFE0040, 17CA (r1 BOCHS  BXPCDSDT        1 BXPC        1)
[    0.000000] ACPI: FACS 3FFE0000, 0040
[    0.000000] ACPI: APIC 3FFE187E, 0080 (r1 BOCHS  BXPCAPIC        1 BXPC        1)
[    0.000000] ACPI: HPET 3FFE18FE, 0038 (r1 BOCHS  BXPCHPET        1 BXPC        1)
[    0.000000] ACPI: PM-Timer IO Port: 0x608
[    0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
[    0.000000] Processor #0 6:6 APIC version 20
[    0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled)
[    0.000000] Processor #1 6:6 APIC version 20
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[    0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0])
[    0.000000] IOAPIC[0]: apic_id 0, version 32, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[    0.000000] Enabling APIC mode:  Flat.  Using 1 I/O APICs
[    0.000000] ACPI: HPET id: 0x8086a201 base: 0xfed00000
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] Allocating PCI resources starting at 50000000 (gap: 40000000:bffc0000)
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260065
[    0.000000] Kernel command line: root=/dev/ram1 rw rootfstype=ext2 console=ttyS0 init=/linuxrc
[    0.000000] Enabling fast FPU save and restore... done.
[    0.000000] Enabling unmasked SIMD FPU exception support... done.
[    0.000000] Initializing CPU#0
[    0.000000] PID hash table entries: 4096 (order: 12, 16384 bytes)
[    0.000000] Detected 3591.653 MHz processor.
[    0.440318] Console: colour VGA+ 80x25
[    0.441036] console [ttyS0] enabled
[    0.449033] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[    0.450203] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.526150] Memory: 1000056k/1048448k available (3234k kernel code, 47704k reserved, 1580k data, 264k init, 130944k highmem)
[    0.526566] virtual kernel memory layout:
[    0.526571]     fixmap  : 0xffe14000 - 0xfffff000   (1964 kB)
[    0.526577]     pkmap   : 0xff800000 - 0xffc00000   (4096 kB)
[    0.526582]     vmalloc : 0xf8800000 - 0xff7fe000   ( 111 MB)
[    0.526586]     lowmem  : 0xc0000000 - 0xf8000000   ( 896 MB)
[    0.526591]       .init : 0xc05bb000 - 0xc05fd000   ( 264 kB)
[    0.526596]       .data : 0xc0428b57 - 0xc05b3f0c   (1580 kB)
[    0.526601]       .text : 0xc0100000 - 0xc0428b57   (3234 kB)
[    0.527733] Checking if this processor honours the WP bit even in supervisor mode... Ok.
[    0.529667] SLUB: Genslabs=11, HWalign=32, Order=0-1, MinObjects=4, CPUs=2, Nodes=1
[    0.610936] Calibrating delay using timer specific routine.. 7223.22 BogoMIPS (lpj=14446442)
[    0.612052] Mount-cache hash table entries: 512
[    0.616757] CPU: L1 I cache: 32K, L1 D cache: 32K
[    0.616915] CPU: L2 cache: 4096K
[    0.617011] CPU: L3 cache: 16384K
[    0.617364] Compat vDSO mapped to ffffe000.
[    0.617873] Checking ‘hlt‘ instruction... OK.
[    0.633293] SMP alternatives: switching to UP code
[    0.634978] ACPI: Core revision 20070126
[    0.656303] Parsing all Control Methods:
[    0.657602] Table [DSDT](id 0001) - 319 Objects with 54 Devices 88 Methods 9 Regions
[    0.658273]  tbxface-0598 [00] tb_load_namespace     : ACPI Tables successfully acquired
[    0.659332] evxfevnt-0091 [00] enable                : Transition to ACPI mode successful
[    0.663913] CPU0: Intel QEMU Virtual CPU version 2.5+ stepping 03
[    0.665581] SMP alternatives: switching to SMP code
[    0.667474] Booting processor 1/1 eip 3000
[    0.678304] Initializing CPU#1
[    0.758847] Calibrating delay using timer specific routine.. 7237.43 BogoMIPS (lpj=14474868)
[    0.758965] CPU: L1 I cache: 32K, L1 D cache: 32K
[    0.758971] CPU: L2 cache: 4096K
[    0.758976] CPU: L3 cache: 16384K
[    0.759066] CPU1: Intel QEMU Virtual CPU version 2.5+ stepping 03
[    0.760347] Total of 2 processors activated (14460.65 BogoMIPS).
[    0.760865] ENABLING IO-APIC IRQs
[    0.761888] ..TIMER: vector=0x31 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.909441] checking TSC synchronization [CPU#0 -> CPU#1]: passed.
[    0.930299] Brought up 2 CPUs
[    0.936650] net_namespace: 64 bytes
[    0.939296] NET: Registered protocol family 16
[    0.941882] ACPI: bus type pci registered
[    0.944310] PCI: PCI BIOS revision 2.10 entry at 0xfd536, last bus=0
[    0.944708] PCI: Using configuration type 1
[    0.944969] Setting up standard PCI resources
[    0.965663] evgpeblk-0956 [00] ev_create_gpe_block   : GPE 00 to 0F [_GPE] 2 regs on int 0x9
[    0.967935] evgpeblk-1052 [00] ev_initialize_gpe_bloc: Found 0 Wake, Enabled 3 Runtime GPEs in this block
[    0.987575] Completing Region/Field/Buffer/Package initialization:................................
[    0.993463] Initialized 6/9 Regions 0/0 Fields 22/22 Buffers 4/4 Packages (328 nodes)
[    0.993951] Initializing Device/Processor/Thermal objects by executing _INI methods:.
[    0.996741] Executed 1 _INI methods requiring 0 _STA executions (examined 58 objects)
[    0.997565] ACPI: Interpreter enabled
[    0.997789] ACPI: (supports S0 S3 S5)
[    0.998529] ACPI: Using IOAPIC for interrupt routing
[    1.033396] ACPI: PCI Root Bridge [PCI0] (0000:00)
[    1.037227] PCI quirk: region 0600-063f claimed by PIIX4 ACPI
[    1.037557] PCI quirk: region 0700-070f claimed by PIIX4 SMB
[    1.601786] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10 11)
[    1.602799] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 *10 11)
[    1.603545] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10 *11)
[    1.604263] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
[    1.604751] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
[    1.605642] Linux Plug and Play Support v0.97 (c) Adam Belay
[    1.606005] pnp: PnP ACPI init
[    1.606194] ACPI: bus type pnp registered
[    1.613416] pnp: PnP ACPI: found 11 devices
[    1.613718] ACPI: ACPI bus type pnp unregistered
[    1.615432] SCSI subsystem initialized
[    1.617297] usbcore: registered new interface driver usbfs
[    1.618416] usbcore: registered new interface driver hub
[    1.619362] usbcore: registered new device driver usb
[    1.620612] PCI: Using ACPI for IRQ routing
[    1.620944] PCI: If a device doesn‘t work, try "pci=routeirq".  If it helps, post a report
[    1.635350] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
[    1.635660] hpet0: 3 64-bit timers, 100000000 Hz
[    1.638597] Time: tsc clocksource has been installed.
[    1.681402] NET: Registered protocol family 2
[    1.720234] IP route cache hash table entries: 32768 (order: 5, 131072 bytes)
[    1.723501] TCP established hash table entries: 131072 (order: 8, 1048576 bytes)
[    1.726897] TCP bind hash table entries: 65536 (order: 7, 524288 bytes)
[    1.729321] TCP: Hash tables configured (established 131072 bind 65536)
[    1.730276] TCP reno registered
[    1.746360] checking if image is initramfs...it isn‘t (bad gzip magic numbers); looks like an initrd
[    1.938773] Freeing initrd memory: 32768k freed
[    1.943777] IA-32 Microcode Update Driver: v1.14a <[email protected]>
[    1.947253] highmem bounce pool size: 64 pages
[    1.947632] Total HugeTLB memory allocated, 0
[    1.963164] Installing knfsd (copyright (C) 1996 [email protected]).
[    1.964768] io scheduler noop registered
[    1.964965] io scheduler anticipatory registered (default)
[    1.965183] io scheduler deadline registered
[    1.965438] io scheduler cfq registered
[    1.965701] Limiting direct PCI/PCI transfers.
[    1.965926] PCI: PIIX3: Enabling Passive Release on 0000:00:01.0
[    1.966507] Activating ISA DMA hang workarounds.
[    1.970978] input: Power Button (FF) as /class/input/input0
[    1.971269] ACPI: Power Button (FF) [PWRF]
[    2.108664] Real Time Clock Driver v1.12ac
[    2.109772] Linux agpgart interface v0.102
[    2.110646] Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
[    2.111801] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    2.114751] 00:06: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    2.116457] Floppy drive(s): fd0 is 2.88M AMI BIOS
[    2.132601] FDC 0 is a S82078B
[    2.139792] RAMDISK driver initialized: 16 RAM disks of 65535K size 1024 blocksize
[    2.141816] loop: module loaded
[    2.142121] Intel(R) PRO/1000 Network Driver - version 7.3.20-k2
[    2.142610] Copyright (c) 1999-2006 Intel Corporation.
[    2.147196] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
[    2.147869] ACPI: PCI Interrupt 0000:00:03.0[A] -> Link [LNKC] -> GSI 11 (level, high) -> IRQ 11
[    2.402031] e1000: 0000:00:03.0: e1000_probe: (PCI:33MHz:32-bit) 52:54:00:12:34:56
[    2.441061] e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection
[    2.442663] e100: Intel(R) PRO/100 Network Driver, 3.5.23-k4-NAPI
[    2.442895] e100: Copyright(c) 1999-2006 Intel Corporation
[    2.447368] console [netcon0] enabled
[    0.000000] Linux version 2.6.24-gcbe024b4-dirty ([email protected]) (gcc version 4.4.7 (Ubuntu/Linaro 4.4.7-8ubuntu1) ) #7 SMP Sun Jul 2 12:29:54 CST 2017
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
[    0.000000]  BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 000000003ffe0000 (usable)
[    0.000000]  BIOS-e820: 000000003ffe0000 - 0000000040000000 (reserved)
[    0.000000]  BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved)
[    0.000000] 127MB HIGHMEM available.
[    0.000000] 896MB LOWMEM available.
[    0.000000] found SMP MP-table at 000f6a90
[    0.000000] Zone PFN ranges:
[    0.000000]   DMA             0 ->     4096
[    0.000000]   Normal       4096 ->   229376
[    0.000000]   HighMem    229376 ->   262112
[    0.000000] Movable zone start PFN for each node
[    0.000000] early_node_map[1] active PFN ranges
[    0.000000]     0:        0 ->   262112
[    0.000000] DMI 2.8 present.
[    0.000000] Using APIC driver default
[    0.000000] ACPI: RSDP 000F6860, 0014 (r0 BOCHS )
[    0.000000] ACPI: RSDT 3FFE1936, 0030 (r1 BOCHS  BXPCRSDT        1 BXPC        1)
[    0.000000] ACPI: FACP 3FFE180A, 0074 (r1 BOCHS  BXPCFACP        1 BXPC        1)
[    0.000000] ACPI: DSDT 3FFE0040, 17CA (r1 BOCHS  BXPCDSDT        1 BXPC        1)
[    0.000000] ACPI: FACS 3FFE0000, 0040
[    0.000000] ACPI: APIC 3FFE187E, 0080 (r1 BOCHS  BXPCAPIC        1 BXPC        1)
[    0.000000] ACPI: HPET 3FFE18FE, 0038 (r1 BOCHS  BXPCHPET        1 BXPC        1)
[    0.000000] ACPI: PM-Timer IO Port: 0x608
[    0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
[    0.000000] Processor #0 6:6 APIC version 20
[    0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled)
[    0.000000] Processor #1 6:6 APIC version 20
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[    0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0])
[    0.000000] IOAPIC[0]: apic_id 0, version 32, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[    0.000000] Enabling APIC mode:  Flat.  Using 1 I/O APICs
[    0.000000] ACPI: HPET id: 0x8086a201 base: 0xfed00000
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] Allocating PCI resources starting at 50000000 (gap: 40000000:bffc0000)
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260065
[    0.000000] Kernel command line: root=/dev/ram1 rw rootfstype=ext2 console=ttyS0 init=/linuxrc
[    0.000000] Enabling fast FPU save and restore... done.
[    0.000000] Enabling unmasked SIMD FPU exception support... done.
[    0.000000] Initializing CPU#0
[    0.000000] PID hash table entries: 4096 (order: 12, 16384 bytes)
[    0.000000] Detected 3591.653 MHz processor.
[    0.440318] Console: colour VGA+ 80x25
[    0.441036] console [ttyS0] enabled
[    0.449033] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[    0.450203] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.526150] Memory: 1000056k/1048448k available (3234k kernel code, 47704k reserved, 1580k data, 264k init, 130944k highmem)
[    0.526566] virtual kernel memory layout:
[    0.526571]     fixmap  : 0xffe14000 - 0xfffff000   (1964 kB)
[    0.526577]     pkmap   : 0xff800000 - 0xffc00000   (4096 kB)
[    0.526582]     vmalloc : 0xf8800000 - 0xff7fe000   ( 111 MB)
[    0.526586]     lowmem  : 0xc0000000 - 0xf8000000   ( 896 MB)
[    0.526591]       .init : 0xc05bb000 - 0xc05fd000   ( 264 kB)
[    0.526596]       .data : 0xc0428b57 - 0xc05b3f0c   (1580 kB)
[    0.526601]       .text : 0xc0100000 - 0xc0428b57   (3234 kB)
[    0.527733] Checking if this processor honours the WP bit even in supervisor mode... Ok.
[    0.529667] SLUB: Genslabs=11, HWalign=32, Order=0-1, MinObjects=4, CPUs=2, Nodes=1
[    0.610936] Calibrating delay using timer specific routine.. 7223.22 BogoMIPS (lpj=14446442)
[    0.612052] Mount-cache hash table entries: 512
[    0.616757] CPU: L1 I cache: 32K, L1 D cache: 32K
[    0.616915] CPU: L2 cache: 4096K
[    0.617011] CPU: L3 cache: 16384K
[    0.617364] Compat vDSO mapped to ffffe000.
[    0.617873] Checking ‘hlt‘ instruction... OK.
[    0.633293] SMP alternatives: switching to UP code
[    0.634978] ACPI: Core revision 20070126
[    0.656303] Parsing all Control Methods:
[    0.657602] Table [DSDT](id 0001) - 319 Objects with 54 Devices 88 Methods 9 Regions
[    0.658273]  tbxface-0598 [00] tb_load_namespace     : ACPI Tables successfully acquired
[    0.659332] evxfevnt-0091 [00] enable                : Transition to ACPI mode successful
[    0.663913] CPU0: Intel QEMU Virtual CPU version 2.5+ stepping 03
[    0.665581] SMP alternatives: switching to SMP code
[    0.667474] Booting processor 1/1 eip 3000
[    0.678304] Initializing CPU#1
[    0.758847] Calibrating delay using timer specific routine.. 7237.43 BogoMIPS (lpj=14474868)
[    0.758965] CPU: L1 I cache: 32K, L1 D cache: 32K
[    0.758971] CPU: L2 cache: 4096K
[    0.758976] CPU: L3 cache: 16384K
[    0.759066] CPU1: Intel QEMU Virtual CPU version 2.5+ stepping 03
[    0.760347] Total of 2 processors activated (14460.65 BogoMIPS).
[    0.760865] ENABLING IO-APIC IRQs
[    0.761888] ..TIMER: vector=0x31 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.909441] checking TSC synchronization [CPU#0 -> CPU#1]: passed.
[    0.930299] Brought up 2 CPUs
[    0.936650] net_namespace: 64 bytes
[    0.939296] NET: Registered protocol family 16
[    0.941882] ACPI: bus type pci registered
[    0.944310] PCI: PCI BIOS revision 2.10 entry at 0xfd536, last bus=0
[    0.944708] PCI: Using configuration type 1
[    0.944969] Setting up standard PCI resources
[    0.965663] evgpeblk-0956 [00] ev_create_gpe_block   : GPE 00 to 0F [_GPE] 2 regs on int 0x9
[    0.967935] evgpeblk-1052 [00] ev_initialize_gpe_bloc: Found 0 Wake, Enabled 3 Runtime GPEs in this block
[    0.987575] Completing Region/Field/Buffer/Package initialization:................................
[    0.993463] Initialized 6/9 Regions 0/0 Fields 22/22 Buffers 4/4 Packages (328 nodes)
[    0.993951] Initializing Device/Processor/Thermal objects by executing _INI methods:.
[    0.996741] Executed 1 _INI methods requiring 0 _STA executions (examined 58 objects)
[    0.997565] ACPI: Interpreter enabled
[    0.997789] ACPI: (supports S0 S3 S5)
[    0.998529] ACPI: Using IOAPIC for interrupt routing
[    1.033396] ACPI: PCI Root Bridge [PCI0] (0000:00)
[    1.037227] PCI quirk: region 0600-063f claimed by PIIX4 ACPI
[    1.037557] PCI quirk: region 0700-070f claimed by PIIX4 SMB
[    1.601786] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10 11)
[    1.602799] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 *10 11)
[    1.603545] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10 *11)
[    1.604263] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
[    1.604751] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
[    1.605642] Linux Plug and Play Support v0.97 (c) Adam Belay
[    1.606005] pnp: PnP ACPI init
[    1.606194] ACPI: bus type pnp registered
[    1.613416] pnp: PnP ACPI: found 11 devices
[    1.613718] ACPI: ACPI bus type pnp unregistered
[    1.615432] SCSI subsystem initialized
[    1.617297] usbcore: registered new interface driver usbfs
[    1.618416] usbcore: registered new interface driver hub
[    1.619362] usbcore: registered new device driver usb
[    1.620612] PCI: Using ACPI for IRQ routing
[    1.620944] PCI: If a device doesn‘t work, try "pci=routeirq".  If it helps, post a report
[    1.635350] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
[    1.635660] hpet0: 3 64-bit timers, 100000000 Hz
[    1.638597] Time: tsc clocksource has been installed.
[    1.681402] NET: Registered protocol family 2
[    1.720234] IP route cache hash table entries: 32768 (order: 5, 131072 bytes)
[    1.723501] TCP established hash table entries: 131072 (order: 8, 1048576 bytes)
[    1.726897] TCP bind hash table entries: 65536 (order: 7, 524288 bytes)
[    1.729321] TCP: Hash tables configured (established 131072 bind 65536)
[    1.730276] TCP reno registered
[    1.746360] checking if image is initramfs...it isn‘t (bad gzip magic numbers); looks like an initrd
[    1.938773] Freeing initrd memory: 32768k freed
[    1.943777] IA-32 Microcode Update Driver: v1.14a <[email protected]>
[    1.947253] highmem bounce pool size: 64 pages
[    1.947632] Total HugeTLB memory allocated, 0
[    1.963164] Installing knfsd (copyright (C) 1996 [email protected]).
[    1.964768] io scheduler noop registered
[    1.964965] io scheduler anticipatory registered (default)
[    1.965183] io scheduler deadline registered
[    1.965438] io scheduler cfq registered
[    1.965701] Limiting direct PCI/PCI transfers.
[    1.965926] PCI: PIIX3: Enabling Passive Release on 0000:00:01.0
[    1.966507] Activating ISA DMA hang workarounds.
[    1.970978] input: Power Button (FF) as /class/input/input0
[    1.971269] ACPI: Power Button (FF) [PWRF]
[    2.108664] Real Time Clock Driver v1.12ac
[    2.109772] Linux agpgart interface v0.102
[    2.110646] Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
[    2.111801] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    2.114751] 00:06: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    2.116457] Floppy drive(s): fd0 is 2.88M AMI BIOS
[    2.132601] FDC 0 is a S82078B
[    2.139792] RAMDISK driver initialized: 16 RAM disks of 65535K size 1024 blocksize
[    2.141816] loop: module loaded
[    2.142121] Intel(R) PRO/1000 Network Driver - version 7.3.20-k2
[    2.142610] Copyright (c) 1999-2006 Intel Corporation.
[    2.147196] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
[    2.147869] ACPI: PCI Interrupt 0000:00:03.0[A] -> Link [LNKC] -> GSI 11 (level, high) -> IRQ 11
[    2.402031] e1000: 0000:00:03.0: e1000_probe: (PCI:33MHz:32-bit) 52:54:00:12:34:56
[    2.441061] e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection
[    2.442663] e100: Intel(R) PRO/100 Network Driver, 3.5.23-k4-NAPI
[    2.442895] e100: Copyright(c) 1999-2006 Intel Corporation
[    2.447368] console [netcon0] enabled
[    2.490168] netconsole: network logging started
[    2.490426] Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
[    2.490751] ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
[    2.491802] PIIX3: IDE controller (0x8086:0x7010 rev 0x00) at  PCI slot 0000:00:01.1
[    2.492277] PIIX3: not 100% native mode: will probe irqs later
[    2.493036]     ide0: BM-DMA at 0xc040-0xc047, BIOS settings: hda:pio, hdb:pio
[    2.493638]     ide1: BM-DMA at 0xc048-0xc04f, BIOS settings: hdc:pio, hdd:pio
[    4.469939] hdc: QEMU DVD-ROM, ATAPI CD/DVD-ROM drive
[    4.471796] hdc: MWDMA2 mode selected
[    4.473365] ide1 at 0x170-0x177,0x376 on irq 15
[    5.044145] hdc: ATAPI 4X DVD-ROM drive, 512kB Cache
[    5.044537] Uniform CD-ROM driver Revision: 3.20
[    5.047601] 3ware Storage Controller device driver for Linux v1.26.02.002.
[    5.048199] Driver ‘sd‘ needs updating - please use bus_type methods
[    5.048598] Driver ‘sr‘ needs updating - please use bus_type methods
[    5.050191] Fusion MPT base driver 3.04.06
[    5.050357] Copyright (c) 1999-2007 LSI Corporation
[    5.050619] Fusion MPT SPI Host driver 3.04.06
[    5.052538] ieee1394: raw1394: /dev/raw1394 device initialized
[    5.052969] usbmon: debugfs is not available
[    5.053578] USB Universal Host Controller Interface driver v3.0
[    5.054255] usbcore: registered new interface driver usblp
[    5.054469] Initializing USB Mass Storage driver...
[    5.054809] usbcore: registered new interface driver usb-storage
[    5.055038] USB Mass Storage support registered.
[    5.055861] PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
[    5.057675] serio: i8042 KBD port at 0x60,0x64 irq 1
[    5.057993] serio: i8042 AUX port at 0x60,0x64 irq 12
[    5.059483] mice: PS/2 mouse device common for all mice
[    5.076443] input: AT Translated Set 2 keyboard as /class/input/input1
[    5.100959] device-mapper: ioctl: 4.12.0-ioctl (2007-10-02) initialised: dm-[email protected]
[    5.102606] usbcore: registered new interface driver usbhid
[    5.103054] drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
[    5.104214] oprofile: using NMI interrupt.
[    5.105193] TCP cubic registered
[    5.105441] NET: Registered protocol family 1
[    5.107096] NET: Registered protocol family 10
[    5.111118] IPv6 over IPv4 tunneling driver
[    5.112899] NET: Registered protocol family 17
[    5.114154] RPC: Registered udp transport module.
[    5.114367] RPC: Registered tcp transport module.
[    5.115520] Using IPI No-Shortcut mode
[    5.294197] input: ImExPS/2 Generic Explorer Mouse as /class/input/input2
[    5.330384] RAMDISK: ext2 filesystem found at block 0
[    5.331404] RAMDISK: Loading 32768KiB [1 disk] into ram disk... done.
[    6.704432] VFS: Mounted root (ext2 filesystem).
mount: mounting debugfs on /sys/kernel/debug failed: No such file or directory
[    7.024907] e1000: eth0: e1000_watchdog: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
[    7.028493] ADDRCONF(NETDEV_UP): eth0: link is not ready
[    7.033541] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

Please press Enter to activate this console.
[[email protected] ]#
[[email protected] ]#
[[email protected] ]# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:56
          inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:398 (398.0 B)
          Base address:0xc000 Memory:febc0000-febe0000 

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

[[email protected] ]# [  113.736471] Clocksource tsc unstable (delta = 42952780594 ns)
[  113.871004] Time: hpet clocksource has been installed.

[[email protected] ]# ping 192.168.1.105
PING 192.168.1.105 (192.168.1.105): 56 data bytes
64 bytes from 192.168.1.105: seq=0 ttl=64 time=7.657 ms
64 bytes from 192.168.1.105: seq=1 ttl=64 time=2.020 ms
64 bytes from 192.168.1.105: seq=2 ttl=64 time=0.371 ms
64 bytes from 192.168.1.105: seq=3 ttl=64 time=0.368 ms

--- 192.168.1.105 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.368/2.604/7.657 ms
[[email protected] ]# 

完。

时间: 2024-10-09 18:45:36

搭建《深入Linux内核架构》的Linux环境的相关文章

Linux内核架构读书笔记 - 2.5.3 处理优先级

1 优先级的内核表示 内核使用 0 - 139 表示内部优先级,值越低,优先级越高.0 -99 实时进程使用 nice 值 [-20,19]映射到范围100 - 139,如下图 内核定义了一系列宏来辅助优先级之间的转换 sched.h 1 /* 2 * Priority of a process goes from 0..MAX_PRIO-1, valid RT 3 * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH 4 *

Linux内核架构读书笔记 - 2.5.2 数据结构

调度系统各个组建关系如下 激活调度器两种方法:进程睡眠或其他原因放弃CPU,周期性检测 上述两个组件统称为通用调度器或核心调度器. 调度器用于判断接下来运行那个进程,内核支持不同的调度策略( 完全公平调度 实时调度 无事可做的空闲调度进程) 调度器被调用时候 需要执行体系相关的进程上下文切换 每个进程属于某个调度器类,各个调度器负责管理所属进程,通用调度器不涉及进程管理,都由调度器来 下面分别讲述: task_struct 成员 sched.h 1 struct task_struct { 2

Linux内核架构读书笔记 - 2.5.4 核心调度器

什么是核心调度器? 参考前面的博文http://www.cnblogs.com/songbingyu/p/3696414.html 1 周期性调度器 作用: 管理内核中与整个系统和各个进程的调度相关的统计量 负责当前调度类的周期性调度方法 kernel/sched.c 1 /* 2 * This function gets called by the timer code, with HZ frequency. 3 * We call it with interrupts disabled. 4

《深入Linux内核架构》附录A&lt;体系结构相关知识&gt;笔记

A.1 概述 为便于扩展到新的体系结构,内核严格隔离了体系结构相关和体系结构无关的代码.内核中特定于处理器的部分,包含定义和原型的头文件保存在include/asm-arch/(例如,include/asm-arm/)目录下,而C语言和汇编程序源代码实现则保存在arch/arch/(例如,arch/arm/)目录下. 联编系统也考虑到一般代码可能需要借助于特定于体系结构的机制.所有特定于处理器的头文件都位于include/asm-arch/.在内核配置为特定的体系结构之后,则建立符号链接incl

Linux内核架构与底层--读书笔记

linux中管道符"|"的作用 命令格式:命令A|命令B,即命令1的正确输出作为命令B的操作对象(下图应用别人的图片) 1. 例如: ps aux | grep "test"  在 ps aux中的結果中查找test. 2. 例如:   find . -name "*.txt" | xargs grep "good" -n --color=auto   把find的结果当成参数传入到grep中,即在那些文件内部查找good关键

【深入理解Linux内核架构】3.3 页表

页表:用于建立用户进程空间的虚拟地址空间和系统物理内存(内存.页帧)之间的关联. 向每个进程提供一致的虚拟地址空间. 将虚拟内存页映射到物理内存,因而支持共享内存的实现. 可以在不增加物理内存的情况下,将页换出到块设备来增加有效的可用内存空间. 内核内存管理总是假定使用四级页表. 3.3.1 数据结构 内核源代码假定void *和unsigned long long类型所需的比特位数相同,因此他们可以进行强制转换而不损失信息.即:假定sizeof(void *) == sizeof(unsign

深入Linux内核架构——进程管理和调度(上)

如果系统只有一个处理器,那么给定时刻只有一个程序可以运行.在多处理器系统中,真正并行运行的进程数目取决于物理CPU的数目.内核和处理器建立了多任务的错觉,是通过以很短的间隔在系统运行的应用程序之间不停切换做到的.由此,以下两个问题必须由内核解决:除非明确要求,否则应用程序不能彼此干扰:CPU时间必须在各种应用程序之间尽可能公平共享(一些程序可能比其他程序更重要).本篇博文主要涉及内核共享CPU时间的方法以及如何在进程之间切换(内核为各进程分配时间,保证切换之后从上次撤销其资源时执行环境完全相同)

【深入理解Linux内核架构】第3章:内存管理

3.1 概述 内存管理涵盖了许多领域: 内存中物理内存页的管理: 分配大块内存的伙伴系统: 分配小块内存的slab.slub.slob分配器: 分配非连续内存块的vmalloc机制: 进程的地址空间. Linux内核一般将虚拟地址空间划分为两部分:底部较大的部分用于用户进程,顶部则用于内核.虽然(在两个用户进程之间)上下文切换期间会改变下半部分,但是虚拟地址空间的内核部分中总是不变[这其实很好理解,内核是系统管理员,不能说因为每换一批游客,景区管理员都得跟着换一批?!].在IA-32系统上,虚拟

[Wolfgang Mauerer] 深入linux 内核架构 第一章 概述

作为Linux开发爱好者,从事linux 开发有两年多时间.做过bsp移植,熟悉u-boot代码执行流程:看过几遍<linux 设备驱动程序开发>,分析过kernel启动流程,写过驱动,分析过网卡驱动,制作过文件系统.但,仍无法对kernel有全局认识.为了更清晰的展示kernel概念,结构,实现,以思维导图的形式记录关键点,以便以记忆.增强理解.该部分是总体描述,大致介绍内核及其结构.同时也希望其能够帮助对linux 内核感兴趣朋友. 原文地址:https://www.cnblogs.com