21

I am trying to use Qemu 1.3 for windows to run lubuntu on a USB stick with Windows 7. After downloading and unpacking Qemu on my usb stick, if I click on qemu.io.exe, I get

qemu-io.exe>

How do I start my downloaded linux .iso file? It sounds basic but its not clear to me from the Qemu website.

2 Answers 2

2

The Qemu manual would be a good place to start. It'll help you work out what you're supposed to do next, which is to tell qemu what to do, and exactly how to do that.

4
  • 3
    I'll take that as an answer, although the manual doesn't seem to be very specific for what I am trying to do. I'm not blown away by the docs here, unless I'm missing something. Commented Jan 28, 2013 at 15:38
  • 1
    There's nothing worse than SO answers that just point you to the docs. Like, why else do you think we came here in the first place? Most Unix / systems-y tools have the worst documentation imaginable.
    – iono
    Commented Jul 29, 2022 at 16:56
  • 1
    People commenting complaints in reply to answers from 9 years ago is worse, I'd say.
    – Xyon
    Commented Jul 30, 2022 at 18:02
  • @Xyon Not when it's true regardless of how old the statement is. It's no different than a person trying to be a photographer back in the 60s and took nothing but shitty photos and hearing someone complain about it today. The truth can and does hurt. It just sucks that people can't be real and honest enough to and except that. A shitty response is a shitty response. Commented Jun 2 at 18:38
38

Here is how I run a minimal version of CentOS 7 on a Windows 7 Enterprise, 64 bits, without being a member of the administrator group (non-admin).

The basic idea is:

  1. Download qemu for windows and unzip it anywhere
  2. Download an ISO image of the Linux distribution you want to run
  3. Create a file that will be your virtual machine hard disk
  4. Run qemu, booting from the CD image
  5. Install the OS
  6. Reboot the virtual machine, this time without the CD image

Networking and fancy graphics are hard to get right. Still struggling, actually...

1. Download QEMU

Use a precompiled binary found on QEMU links page. I used version 2.8.0 for this.

To "install" this version as a non-admin, open a command prompt, issue the command set __COMPAT_LAYER=RunAsInvoker and run qemu-w64-setup-20170131.exe from that prompt. Install in a folder where you have write permissions, like "My Documents" or something.

2. Download an ISO image of Linux

Again, help yourself. I used the Minimal distribution of CentOS 7, the file is called CentOS-7-x86_64-Minimal-1611.iso.

3. Create a virtual hard disk

I used a batch file for this. Copy the following to a file named createvm.bat and adjust the variables to suit your environment:

@echo off
rem ==================================
rem Replace with your values
rem ==================================
set "QEMUDIR=%USERPROFILE%\Documents\Warez\qemu-2.8.0-win64"

rem ==================================
rem Safety net
rem ==================================
if not exist hda.img (
    rem CREATE a virtual hard disk 
    "%QEMUDIR%\qemu-img.exe" create hda.img 40G
) else (
    echo file hda.img already exist. Delete or move and try again.
    goto:eof
)

4. Run QEMU, booting from the virtual CD

Use a batch for this one, as you might use it often. Copy the follwing into installvm.bat:

@echo off

rem ==================================
rem Replace with your values
rem ==================================
set "QEMUDIR=%USERPROFILE%\Documents\Warez\qemu-2.8.0-win64"
set "ISOFILE=CentOS-7-x86_64-Minimal-1611.iso"

rem ==================================
rem You can add a w suffix to this if 
rem you don't want a console
rem ==================================
set "QEMUBIN=qemu-system-x86_64.exe"

rem ==================================
rem Run the virtual machine
rem ==================================
start "QEMU" "%QEMUDIR%\%QEMUBIN%" -drive file=hda.img,index=0,media=disk,format=raw -cdrom %ISOFILE% -m 2G -L Bios -usbdevice mouse -usbdevice keyboard -boot menu=on -rtc base=localtime,clock=host -parallel none -serial none -name centos -no-acpi -no-hpet -no-reboot 

5. Install the OS

I had trouble with the GUI installer. When prompted to install CentOS, hit the TAB key and replace the word quiet at the end of that line with the word text.

Follow the installation instructions on screen. When the installation is finished, the virtual machine will exit. It can take quite a while, especially when running as a non-admin user.

6. Run your Linux image in QEMU

This step is what you will do over and over again to run the VM each time you need it. Copy the follwing into runvm.bat:

@echo off

rem ==================================
rem Replace with your values
rem ==================================
set "QEMUDIR=%USERPROFILE%\Documents\Warez\qemu-2.8.0-win64"

rem ==================================
rem You can add a w suffix to this if 
rem you don't want a console
rem ==================================
set "QEMUBIN=qemu-system-x86_64.exe"

rem ==================================
rem Run the virtual machine
rem ==================================
start "QEMU" "%QEMUDIR%\%QEMUBIN%" -drive file=hda.img,index=0,media=disk,format=raw -m 2G -L Bios -usbdevice mouse -usbdevice keyboard -boot menu=on -rtc base=localtime,clock=host -parallel none -serial none -name centos -no-acpi -no-hpet -no-reboot -device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::2222-:22

I added a local portforward : if you ssh/putty to localhost:2222, you will reach the SSH daemon of your VM. Beware that firewalld or iptables might block traffic, depending on the way you installed Linux.

5
  • 2
    Much appreciated! Commented Feb 1, 2017 at 1:21
  • can this be managed with qtemu ? Commented Oct 16, 2023 at 7:58
  • Not sure what you mean by "Managed with qemu"... I suggest you ask a new question (and maybe link to this one).
    – ixe013
    Commented Oct 17, 2023 at 14:15
  • Nice answer, I'm not 100% certain but instead of writing a batch file to create a virtual hard disk, there's a very nice tool for windows called Virtual Clone Drive by Elaborate Bytes. After installing this, you can easily create virtual CD/DVD drives and you can create multiple drives as well. Then all you have to do is go to your *.iso *.bin files, etc... or any file that is mountable right click and mount to desired drive, and you're good to go. From there it would just be a matter of getting QEMU to recognize your virtual disks. Commented Jun 2 at 18:46
  • Unfortunately, Virtual Clone Drive requires Administrator Rights. If you have admin rights, might as well use them to install your favorite hypervisor. The batch files here serve two purpose : 1) works everywhere, no install or rights required 2) clearly and deterministically show the commands to run.
    – ixe013
    Commented Jun 3 at 1:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .