How to get files into a Qemu VM

Picture the scene, you have created a Windows VM for use in UNetLab. You loaded it with all your go-to applications, and are good to go. A week or so down the line you have a new requirement, that demands a certain application to be loaded onto the Qemu VM.

What do you do? Delete the VM and recreate it? That would be a waste of a license. VNC doesn’t handle cut and paste, and you can’t get it connected to your internal network in order to download it.

I had this issue today. For a post on how to run Barracuda NG Firewall in UNetLab, I needed to run the NGAdmin program. But the pnet0 interface wouldn’t play ball, and I can’t cut and paste from my Mac into the VNC.

So, I mulled over my options for a moment, then realized that I could copy the files I needed to the /tmp/ directory on the UNetLab box and make an ISO of that folder. This can then be used by the Qemu guest as a standard CDRom!

UNetLab does not come with the mkisofs program by default, so you’ll need to install this:

root@unl01:~# sudo apt-get install mkisofs
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'genisoimage' instead of 'mkisofs'
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-61 linux-headers-3.13.0-61-generic
  linux-headers-3.13.0-62 linux-headers-3.13.0-62-generic
  linux-image-3.13.0-61-generic linux-image-3.13.0-62-generic
Use 'apt-get autoremove' to remove them.
Suggested packages:
  wodim cdrkit-doc
The following NEW packages will be installed:
  genisoimage
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 587 kB of archives.
After this operation, 1,580 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main genisoimage amd64 9:1.1.11-2ubuntu3 [587 kB]
Fetched 587 kB in 0s (840 kB/s)
Selecting previously unselected package genisoimage.
(Reading database ... 129086 files and directories currently installed.)
Preparing to unpack .../genisoimage_9%3a1.1.11-2ubuntu3_amd64.deb ...
Unpacking genisoimage (9:1.1.11-2ubuntu3) ...
Setting up genisoimage (9:1.1.11-2ubuntu3) ...
root@unl01:~#

You will need to make sure that the exe file is on your UNetLab machine:

root@unl01:~# ls /tmp/
netio32768  ngadmin_6-1-0-150 (1).exe  vmware-root
root@unl01:~# cd /tmp/

It’s there, so let’s make a folder and copy it into it:

root@unl01:/tmp# mkdir Barracuda
root@unl01:/tmp# mv ngadmin_6-1-0-150 (1).exe Barracuda/

Now we can create a CD-ROM image in the win-7-pro directory, called cdrom.iso (do not name it anything other than this), using the folder /tmp/Barracuda as the source:

root@unl01:/tmp# mkisofs -o /opt/unetlab/addons/qemu/win-7-Pro/cdrom.iso /tmp/Barracuda/
I: -input-charset not specified, using utf-8 (detected in locale settings)
 47.84% done, estimate finish Tue Sep  8 10:42:26 2015
 95.75% done, estimate finish Tue Sep  8 10:42:26 2015
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 116
Path table size(bytes): 10
Max brk space used 0
10452 extents written (20 MB)
root@unl01:/tmp#

Now we can turn on the Windows VM and access the CDRom drive. If the VM was turned on before the cdrom.iso file was copied to the directory then shut it down and start it up again.
Qemu CD ROM, how to get files into Qemu guest
Bingo, the CD Rom is there in the Qemu VM. And so are my much-needed files:
Qemu - working CDrom

3 Comments

  1. Orkhan Allahverdiyev October 7, 2015
  2. Stuart Fordham October 7, 2015
  3. Orkhan Allahverdiyev October 7, 2015

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.