HOWTO: LINUX, VIRT-MANAGER & VIRTUAL MACHINES.

Share your own howto's etc. Not for support questions!

HOWTO: LINUX, VIRT-MANAGER & VIRTUAL MACHINES.

Postby john123son » 2020-03-12 09:28

Linux, Virt-manager & Virtual Machines.

But my goal was to investigate virtual machines, so I needed to install virt-manager, libvirt, and qemu. Installing virt-manager pulled in the other two as dependencies. I used synaptic to do this. The apt-get command used by synaptic would have been

apt-get install virt-manager

Notice that qemu is qemu-system-x86 (which includes the program qemu-system-x86_64).

Being desperate to try out virt-manager I fired it up with the command:

virt-manager

Virt-manager asked for the root password and would clearly run the virtual machine as the root user. I had been told that running a GUI application as the root user was a security risk, but ran it anyway. Of course, I installed Debian 10. Virt-manager has a default configuration for the virtual machine that will run a particular operating system. I chose the Debian 10 default.

After this I tried to find out how to run virtual machines as an ordinary user. This was surprisingly difficult to discover. One internet article said that you had to uncomment (remove the initial # sign) from the following lines

#unix_sock_ro_perms = "0777"
#unix_sock_rw_perms = "0770"
#unix_sock_admin_perms = "0700"

of the file /etc/libvirt/libvirtd.conf. This I did. Later I changed the last line to

unix_sock_admin_perms = "0770"

At this point I am unsure how much of this was necessary. To register the changes I then restarted the libvirt daemon with

service libvirtd restart

but still couldn't run virt-manager as an ordinary user. I rechecked the group permissions, still no luck. Eventually, I found that this can be done with the command:

virt-manager --connect=qemu:///session

Image

We will now create a virtual machine called, debian10, running under Debian 10.

..............................................

Moving on, let's install Windows 10 on a virtual machine. If you have a Windows 10 installation disc use that. If not you can download Win10_1909_English_x64.iso from

https://www.microsoft.com/en-us/software-download/windows10ISO

Fire up virt-manager with

virt-manager --connect=qemu:///session

Now, do as you did for the Debian 10 install except use the Windows 10 ISO, and make sure that Windows 10 is detected as the operating system you are installing. Telling virt-manager the operating system enables things to be tailored to it. However, by comparing the Windows 10 hardware with the Debian 10 hardware, it also appears to cause certain channels to be missing.

Image

Choose Customize configuration before install and add the missing channels.

Image

Click Finish.
Click Add Hardware > Channel.

Image

Click Finish.
Click Add Hardware > Channel.

Image

Click Finish.

Image

Click Begin Installation.

Image

The Windows 10 installation is fairly straightforward.

Image

If you don't have a product key, click I don't have a product key.

Image

May as well choose the best.

Image

You will have to decline options involving the internet.

And eventually,...

Image

At this point, both the internet (user-mode networking) and audio work.

You will probably want to adjust the screen resolution by right-clicking on the desktop > Display settings > Display resolution. You should also turn off automatic upgrades.

Type services.msc in the textbox and press Enter. It'll open Services Manager.
Scroll down to bottom and you'll see a service "Windows Update" in the list.
Double-click on the service and change its Startup type to Disabled.

This will be enough for many users but you can also add a shared clipboard, and a shared directory. In doing this you also get dynamic resolution, and a few drivers that are especially tailored to virtual machines.

Till this point, the graphics connection to the virtual machine has been handled by the version of virt-viewer bundled with virt-manager. This is the connection (window) you get when you click on "Open" in virt-manager. The ability to establish a shared directory is not compiled into the bundled version. So, if you want a shared directory you will always have to use the non-bundled version. Clipboard sharing works with both versions.

So, let's establish our shared clipboard and directory.

First, shut down windows10.

Download the following two files from https://www.spice-space.org/

https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-0.141/spice-guest-tools-0.141.exe
https://www.spice-space.org/download/windows/spice-webdavd/spice-webdavd-x64-2.2.msi

Check that your system has ntfs-3g installed. It provides support for the NTFS filesystem.

modprobe nbd
qemu-nbd -c /dev/nbd0 /path/to/the/file/windows10.qcow2
mount /dev/nbd0p2 /mnt


Notice the second partition has been mounted. The first partition is the EFI system partition.

cp spice-guest-tools-0.141.exe /mnt/Users/John/Downloads/
cp spice-webdavd-x64-2.2.msi /mnt/Users/John/Downloads/


The guest has a user called John.

umount /mnt
qemu-nbd -d /dev/nbd0


Open virt-manager with

virt-manager --connect=qemu:///session

Right click on the "windows10" entry and choose "Run".

Image

Now fire up the non-bundled version of virt-viewer with

virt-viewer --connect=qemu:///session --domain-name windows10 &

This will establish a graphical connection with the virtual machine "windows10". When it has finished booting, navigate to John's downloads directory

Image

Double click on "spice-guest-tools-0.141" and install the Spice guest tools.
Double click on "spice-webdavd-x64-2.2" and install the Spice WebDAV daemon.

Now choose File > Preferences

Image

Choose the directory you wish to share.

Image

Click the "Share" button and then close the dialog.

Image

Now you have to Reboot.

Once windows10 has rebooted open "File Explorer" to the folder "This PC".

Image

You should see your shared directory as the network drive Z:

Copied from: http://www.preearth.net/phpBB3/viewtopi ... =18&t=1183

preearth.net/phpBB3/viewtopic.php?f=18&t=1183

which also includes a guide to installing Debian 10.
john123son
 
Posts: 12
Joined: 2020-03-12 09:20

Re: HOWTO: LINUX, VIRT-MANAGER & VIRTUAL MACHINES.

Postby sunrat » 2020-03-12 11:36

Interesting first post. Directly copying a post, presumably not yours, from another forum but leaving out the Debian bit. There's some bad advice there - in the other forum it's recommended to set up the deb-multimedia repo which is well known to cause regular breakage in a stock Debian. And both posts say to "install the best" Windows 10 Pro - useless unless you need corporate features like Group Policy, Azure, Active Directory etc. Use Win 10 Home if you're at home.
I actually just started the reply to ask you to remove the shouting in the title, but soon realised there may be inaccuracies and disingenuousness.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!
User avatar
sunrat
 
Posts: 3073
Joined: 2006-08-29 09:12
Location: Melbourne, Australia


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable