QEMU,
QEMU,
==Building Debian Images for QEMU==
Install qemu and debootstrap:
apt-get install qemu debootstrap
Create image:
qemu-img create disk.img 512M
Associate image file with a loopback device:
losetup.orig -f # take note of the filename returned
losetup.orig /dev/loop0 disk.img # replace with name returned above
Create a ext2 filesystem on the image:
mkfs.ext3 /dev/loop0
Mount the image:
mkdir -p /mnt
mount /dev/loop0 /mnt
Run debootstrap to install the Debian system :
debootstrap etch /mnt ftp://ftp.de.debian.org/debian/
Create a basic /mnt/etc/fstab on the image so the init scripts do not complain:
proc /proc proc defaults 0 0
/dev/sda / ext3 defaults,errors=remount-ro 0 1
== Compile kernel ==
Download and uncompress kernel source :
cd ~
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.bz2
tar -xvjf linux-2.6.32.tar.bz2
Compile kernel :
cd linux-2.6.32 # inside kernel tree
make defconfig # make default configuration
make menuconfig # add what you want to use
make # compile kernel
make modules # compile modules
make modules_install INSTALL_MOD_PATH=/mnt # install modules in filesystem
== Booting ==
Umount filesystem:
umount /mnt
Detach loopback device:
losetup -d /dev/loop0
Done! You can run QEMU using the following command:
qemu -hda image.raw -kernel ~/linux-2.6.32/arch/i386/boot/bzImage -append “root=/dev/sda”
@gmail.com>@indt.org.br>
== Connecting host<->guest ==
Recompile the kernel with the network drivers available. I don’t remember the correct option, so active all in :
-> Device Drivers
-> Network device support (NETDEVICES [=y])
-> Ethernet (10 or 100Mbit) (NET_ETHERNET [=y])
Define ip used by host(real machine) in (/etc/qemu-ifup) :
#!/bin/sh
sudo -p “Password for $0:” /sbin/ifconfig $1 192.168.0.1
Boot up your virtual system again adding(-net tap -net nic)
sudo qemu -net tap -net nic -hda image.raw -kernel linus-2.6/arch/i386/boot/bzImage -append “root=/dev/sda”
Define the ip and route used by guest(virtual machine):
ifconfig eth0 182.168.0.2 netmask 255.255.255.0
route add default gw 192.168.0.1
Test it:
ping 192.168.0.1
Define DNS servers:
scp 192.168.0.1:/etc/resolv.conf /etc/resolv.conf
阅读(264) | 评论(0) | 转发(0) | 0
上一篇:程序设计中多核的影响--多核系列之三
下一篇:c 语言中的宏,井号,可变参数
相关热门文章- linux 常见服务端口
- 什么是shell
- linux socket的bug??
- linux的线程是否受到了保护?...
- 一个适用于windows和linux的抓...
- shell将变量当命令执行问题【...
- 深入理解Linux网络技术内幕-设...
- 高性能网络I/O框架-netmap源码...
- 深入理解Linux网络技术内幕-...
- Linux下bin文件的安装
评论暂时关闭