使用QEMU仿真程序运行Raspberry Pi镜像
Raspberry Pi image running from QEMU
1. 工具 (Tools)
[1] Host linux version: Ubuntu 12.04 LTS (Linux 3.2.0-29-generic-pae)
[2] Raspberry Pi image 3.6.8
[3] QEMU: QEMU emulator version 1.5.0
2. 操作步骤 (Steps)
2.1. 启动 (Startup)
1# Raspberry Pi image file is 2013-05-29-wheezy-armel.zip
2unzip 2013-05-29-wheezy-armel.zip
3# 2013-05-29-wheezy-armel.img
4
5qemu-system-arm \
6-kernel kernel-qemu \
7-cpu arm1176 \
8-m 256 \
9-M versatilepb \
10-no-reboot \
11-serial stdio \
12-append "root=/dev/sda2 panic=1" \
13-hda 2013-05-29-wheezy-armel.img \
14-net nic,macaddr=00:1a:80:d2:0b:3f,addr=192.168.9.11 \
15-net tap,ifname=tap0,script=no
16# Above the tap network is optional.
2.2. 改变镜像文件大小 (Resize image file)
1# From host machine
2qemu-img resize 2013-05-29-wheezy-armel.img +1024M # (1024 * n)
3# Startup QEMU, follow 2.1 section
1# From of QEMU shell
2# Review partition information
3df -h
4# /dev/sda is image file, or is naming like /dev/mmcblk0, which will be represent different storage type.
5fdisk /dev/sda
6# Type command p for display partition information as below.
7p
8# Disk /dev/sda: 8382 MB, 8382316544 bytes
9# 64 heads, 32 sectors/track, 7994 cylinders, total 16371712 sectors
10# Units = sectors of 1 * 512 = 512 bytes
11# Sector size (logical/physical): 512 bytes / 512 bytes
12# I/O size (minimum/optimal): 512 bytes / 512 bytes
13# Disk identifier: 0x00099f20
14#
15# Device Boot Start End Blocks Id System
16# /dev/sda1 8192 122879 57344 c W95 FAT32 (LBA)
17# /dev/sda2 122880 1xxxxx 2124416 83 Linux
18#
19# Command (m for help):
20
21# The 122880 is start sector of partition, record that number for below.
22# Type command d for remove partition 2 follow the tips of console.
23d
242
25# Type p to review partition information again.
26
27# Disk /dev/sda: 8382 MB, 8382316544 bytes
28# 64 heads, 32 sectors/track, 7994 cylinders, total 16371712 sectors
29# Units = sectors of 1 * 512 = 512 bytes
30# Sector size (logical/physical): 512 bytes / 512 bytes
31# I/O size (minimum/optimal): 512 bytes / 512 bytes
32# Disk identifier: 0x00099f20
33#
34# Device Boot Start End Blocks Id System
35# /dev/sda1 8192 122879 57344 c W95 FAT32 (LBA)
36#
37# Command (m for help):
38
39# Type n for new partition, Partition type will be P(Primary), and Partition number will be 2.
40
41# Type p to review partition information again.
42
43# Disk /dev/sda: 8382 MB, 8382316544 bytes
44# 64 heads, 32 sectors/track, 7994 cylinders, total 16371712 sectors
45# Units = sectors of 1 * 512 = 512 bytes
46# Sector size (logical/physical): 512 bytes / 512 bytes
47# I/O size (minimum/optimal): 512 bytes / 512 bytes
48# Disk identifier: 0x00099f20
49#
50# Device Boot Start End Blocks Id System
51# /dev/sda1 8192 122879 57344 c W95 FAT32 (LBA)
52# /dev/sda2 122880 16371711 8124416 83 Linux
53#
54# Command (m for help):
55
56# If all done, type w to make the partition table rewrite.
57
58# Don't do anything, have to reboot now.
59reboot
60
61# When the reboot done, need to resize file system as below.
62# The device reference maybe naming as /dev/mmcblk0p2, it determinated by different device type.
63resize2fs /dev/sda2
作者|Author: RockSolid
发表日期|Publish Date: Jul 8, 2013
修改日期|Modified Date: Jul 8, 2013
版权许可|Copyright License: CC BY-NC-ND 3.0 CN