Using QEMU in Linux Debian 9 Stretch, another alternative to Virtual Machines (Part 2: Operating Virtual Machines in Monitor/Console mode))

in #utopian-io6 years ago


Hi! before reading this post, I advice you to read my first post about QEMU to understand what I am explaining there
Click Here To Go!!
👆 👆👆👆👆👆👆👆

Monitor/Console Mode

In this time i will talk about Monitor/Console Mode to interact with your new Virtual Machine, and connect some external peripherals from the host PC.

In the example shown in the previous post, I ran the VM that I had configured with this console command:

$ sudo qemu-system-i386 -hda slacko.img -m 1024

and then my new machine appeared in a new window

Once there you must make click inside the VM window, to enter and use it.

So, How about attaching some USB peripherals, shutting down, reboot and other operations with my new VM?

Everything can be made in console mode inside the virtual machine, All that you have to do, is running your virtual machine, and then use this mode.

To access this option and other more, you must enter into the VM and run the console mode by pressing:

[Ctrl+Alt+1]    Access to the Virtual Machine X Window (Graphic mode).
[Ctrl+Alt+2]    Access to the console/monitor mode
[Ctrl+Alt+3]    Access to the serial console mode
[Ctrl+Alt+4]    Access to the Parallell console mode

We are interested in the two former modes of the list: Graphic mode (to return to the graphic virtual machine) and Console /monitor mode. Now press [Ctrl+Alt+2] , and it will take you to the console mode.

Attaching USB devices from the host

If you want to access usb devices you must enable it when you start your VM, and running your machine in root mode. It can be made adding the option -usb:

$ sudo qemu-system-i386 -hda slacko.img -m 1024 -usb

From here you can attach any usb device to your machine, now you must know the host and vendor ID. This can be discovered opening a new console window in the host computer, then write:

$ lsusb 

And this command will show every USB device connected to the host machine.

In this example I am trying to attach the device 04e8:1f0a. The other way I can discover usb devices is using in the QEMU VM console mode this command:

(qemu) info usbhost

Now attach this device, writing and running in the VM console mode:

(qemu) usb_add host:04e8:1f0a

Now push [Ctrl+Alt+1] to return to the graphic mode, and you can notice that the device is attached.

If you want to detach this device just run in monitor:

(qemu) info usb

to get the usb device number, and then:

(qemu) usb_del [device_number]

in this example device_number = 0.3, now write:

(qemu) usb_del 0.3

Now you can notice that the device dissapear:

Other Features

You can attach any internal hard drive in your host PC running QEMU with this options:

$ sudo qemu-system-i386 -hda slacko.img -m 1024 -usb -drive file=/dev/sda1

Where /dev/sda1 is the sample drive that I mounted to the VM. You can prove with another drive that you wish.

Useful Commands in Monitor Mode

Here we are some commands that you would like to know in the monitor mode inside the VM:

system_powerdown           Turns off the VM.
system_reset               Makes a reset in the VM
stop                       Stops the VM emulation
cont                       Continue the VM emulation, previously stopped.
sendkey ctrl-alt-delete    Sends ctrl-alt-delete signal to the VM. 
                           You can use sendkey command to send any other  
                           combination of pressed keys. 
                           E.g: sendkey ctrl-alt-f1

Well this is the end of this article, those are the links that I used to make this tutorial:
This is where you can find QEMU: https://github.com/qemu/qemu
QEMU official page: https://www.qemu.org/
Every command taken for this tutorial, were taken from https://es.wikibooks.org/wiki/QEMU/Monitor

I hope you enjoyed this tutorial, now you can follow your path, and take a deep research!.

Sort:  

Thank you for your contribution @adolforivas42.
We suggest the following points:

  • The title of your tutorial is very long. We suggest you put shorter and key words from the content you are writing, such as QUEMU, Linux and Virtual Machine.
  • Try to improve your language in the text of the tutorial.
  • Improve the structure of your tutorial. Here's a good example link
  • Please follow the tutorials template link

Your tutorial is very interesting and we like to see more of your tutorials with our suggestions.
Thank you for your work.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @portugalcoin!

So far this week you've reviewed 15 contributions. Keep up the good work!

Hi @adolforivas42!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @adolforivas42!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63004.58
ETH 2548.62
USDT 1.00
SBD 2.81