1. 编译qemu 用SuSE10.0自带的gcc-4.0.2编译qemu会出现下面的问题 # cd /usr/local/qemu-0.9.0 # ./configure WARNING: "gcc" looks like gcc 4.x Looking for gcc 3.x gcc 3.x not found! QEMU is known to have problems when compiled with gcc 4.x It is recommended that you use gcc 3.x to build QEMU To use this compiler anyway, configure with --disable-gcc-check 因此可以先装一个gcc-3.4.6 # which gcc /usr/local/bin # gcc --version gcc (GCC) 3.4.6 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # cd /usr/local/qemu-0.9.0 # ./configure; make; make install
2. 编译kqemu 如果你还用gcc-3.4.6编译kqemu,在插入模块时会出现下面的问题 # modprobe kqemu FATAL: Error inserting kqemu (/lib/modules/2.6.13-15-smp/misc/kqemu.ko): Invalid module format 因此在编译kqemu时要用系统自带的gcc-4.0.2 # which gcc /usr/bin/gcc # gcc --version gcc (GCC) 4.0.2 20050901 (prerelease) (SUSE Linux) Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # cd /usr/local/qemu-0.9.0/kqemu-1.3.0pre11 # ./configure; make; make install # modprobe kqemu # lsmod | grep kqemu kqemu 128548 0 # modinfo kqemu filename: /lib/modules/2.6.13-15-smp/misc/kqemu.ko license: GPL vermagic: 2.6.13-15-smp SMP 586 REGPARM gcc-4.0 depends: parm: major:int
3. 网络设置 # qemu -cdrom slax-5.1.8.1.iso 用slax启动盘启动后,slax会得到一个10.0.2.15的ip,你的SuSE10.0会默认为10.0.2.2,域名服务器的ip是10.0.2.3。你可以通过ssh连接到SuSE10.0上 # ssh 10.0.2.2 如果虚拟的是windows,在地址栏中键入 //10.0.2.2 就可以通过samba和SuSE10.0交换文件了
4. 磁盘操作 # qemu-img create win.img 10G # qemu -hda win.img -cdrom TomatoWinXP_SP2_v3_0.iso -boot d -m 384 下面介绍通过回环设备将image文件挂载到本地,和本地文件系统直接交互。
# losetup /dev/loop0 win.img # fdisk /dev/loop0
The number of cylinders for this disk is set to 2610. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): x
Expert command (m for help): p
Disk /dev/loop0: 255 heads, 63 sectors, 2610 cylinders
Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID 1 80 1 1 0 254 63 568 63 9140922 0b 2 00 0 0 0 0 0 0 0 0 00 3 00 0 0 0 0 0 0 0 0 00 4 00 0 0 0 0 0 0 0 0 00
Expert command (m for help): q
# losetup -o 32256 /dev/loop1 win.img # mount -t vfat /dev/loop1 win # cd win # ls Documents and Settings autoexec.bat config.sys io.sys ntldr Program Files boot.ini found.000 msdos.sys pagefile.sys Recycled bootfont.bin hiberfil.sys ntdetect.com windows
32256是用start*512算出来的,在本例中start=63 拷贝完文件后最后别忘了进行清理 # losetup -a /dev/loop0: [0302]:241 (win.img) /dev/loop1: [0302]:241 (win.img) offset=32256 # umount win # losetup -d /dev/loop0 # losetup -d /dev/loop1
上面的操作在赵炯老师的《Linux内核完全注释》电子版中有更详细的讲解 摘自:http://blog.chinaunix.net/u/23177/showart_248414.html Linux联盟收集整理 |