Cloud for Dummies - Installing a VM from CDROM
You already worked through the beginners example and got your first VM running. But now you want to use an operating system that we don't provide, e.g., Windows. In order to get a VM running Windows, you either have to make your own Windows-Image or download one from somewhere. In this tutorial we will make our own Windows Image in the Cloud, as this is a very versatile method that can easily be applied also to other operating systems. We will also point out possible stumbling blocks (look out for our hints). Here is how to do it.
This is a rough plan of what we are going to do:
- You have the Windows install medium (CDROM, DVD, Blue Ray) in your hands. And a valid license. In the first step you will create an image file on your laptop from that medium.
- You upload that CDROM image.
- You create a datablock image to later hold your Windows installation.
- You create a template for your Windows installation. This connects your CDROM and your empty hard drive.
- You generate a VM and boot it from your CDROM image.
- You install Windows onto your second disk.
- You shut down your VM. It is no longer needed.
- You copy (or change in place) your template to no longer boot from CDROM but instead from your Windows hard drive.
- You instantiate as many Windows-VMs from this template as you like.
This is quite a work program, so bring some time, as this won't be done in 5 minutes. The good thing: once your have made your Windows-image, you can quickly (in less than 2 minutes!) boot a new Windows-VM any time you want to. For a Windows-lover, this should be worth the effort. And instead of Windows, you can also install any other operating system for which you can get your hands on an install medium (aka CDROM).
1. Generating a Bootable Installation Image
Before we can do anything, you have to get your hands on an installation medium, e.g., a CDROM or DVD. From it you have to generate a bootable image that you can later use in the LRZ Cloud. For many free Linux systems you can already find (and download: http://cdimage.debian.org/debian-cd/7.8.0/amd64/iso-cd) such ready-to-use installation images from the internet. But for licensed software, like Windows, you probably have to buy a copy (and a license) first and then you will receive a CDROM-box via postal mail. Sometime you can download not fully functional demo versions or technical previews (e.g., http://windows.microsoft.com/de-de/windows/preview-iso).
So, let's assume you have a CDROM in your hand and a CDROM drive on your local computer. As example, I have a Windows95 CDROM and, because I am so nostalgic, I want to run a copy of Win95 in a VM. The CDROM is mounted as DEW95_FULL. How you actually get an image from a CDROM depends on which OS you are running on your local computer. I am running MacOS X, version 10.10.2, and this is how I do it on a Mac. You may have to use different software.
On the Mac you use DiskUtility.app, which already comes with MacOS X (it is in /Applications/Utilities/), so you don't have to install anything new. Change the image format to "DVD/CD master", which will give you an ISO image.
On the Mac the image has an ending of "cdr". Just rename it to "iso", so our file is now called "DEW95_FULL.iso".
Hint: whenever available, just choose a "netinstall", i.e., minimum, image as installation media to download and to start from. It doesn't make sense to download an entire Blue ray. You have to do the update at the end of the installation procedure anyway, so:
- you save time and space downloading a smaller image
- you save bandwidth avoiding to transfer things twice.
2. Upload of ISO Image
Next you have to upload this image to the LRZ Compute Cloud. You do this with Globus Online (the simple file upload via the web is notoriously unreliable and should be avoided). We already have a tutorial on this, called "Cloud for Dummies - Data Transfer". Please work your way through that tutorial. Now you have your CDROM in the Cloud!
Hint: Alternatively, you can save yourself some work if the ISO image is already available on the internet. In this case you can let ONE do the work of downloading the data for you. This comes in handy if you are on a slow internet line and the DVD image is several GB in size. No need to channel this large amount of data through your slow link. All you have to do is to specify the download URL (e.g., http://go.microsoft.com/fwlink/p/?LinkId=522100, build 9926 from January 2015) when you create the image.
Hint: while the data are being transferred the image is in the "LOCKED" state. You have to wait before you can use this image in a VM until the image becomes "READY".
3. Create a Datablock Image
You create a datablock image as empty datablock specifying "No Filesystem" as FS type (no need to format it, it'll be overwritten anyway). Specify the size in MB (I specified 25GB), this is important, and the "persistent" flag. This will be the new "hard drive" onto which you will install Windows in the next steps.
Hint: You make it persistent so that the fruits of your installation effort survive the runtime of the VM in which you install Windows.
4. Create a Template for Your Windows Installation
Now we have the CDROM image as source and the datablock image as target. We need to link the two through a template: in a real hardware computer we would now cable up the datablock image as hard drive inside the computer and put the CDROM image into the CDROM drive. In the Cloud, the cabeling is just a few clicks to generate a template.
I will now use the Windows-10 CDROM (not the old Win95 image we made ourselves) to install in the Cloud. After creating a new, empty template (green "+" sign), we go through all tabs of this template. You can add more RAM if you think it is needed. Adding more CPUs will probably not speed up the installation, so we don't waste any resources on that.
Since we need two disks attached, I add another disk.
The first disk (from which we will boot) will be the CDROM image of Windows-10, which we prepared earlier.
Hint: We have to specify "hda" here to make sure that this will be the first disk in the system, so that the VM will boot from it (and not from another disk). "hda" will use the IDE style disk driver, which is quite slow, but it turns out that Windows only reliably installs if we use this old IDE driver.
Hint: Don't confuse the
DEVICE_PREFIX settings! In TARGET you have to specify the exact location of the drive on the channel, e.g., hda, meaning first channel (the ‘a’ of ‘hda’) of the IDE bus (the ‘hd’ of ‘hda’). Specifing only ‘hd’ as TARGET will lead to an error. If you check here you see the difference between the two settings:
- TARGET: you have to specify the bus you want for your disk/cdrom (hd=IDE, sd=SCSI, vd=virtio) and the channel (a=1st, b=2nd, …).
- DEVICE_PREFIX: you only specify the bus (hd=IDE, sd=SCSI, vd=virtio), ONE will assign the channel automatically.
Now we specify our blank hard drive image as another IDE disk.
Hint: We specify "hd" here to make sure that it will use the IDE driver (for improved compatibility). We don't have to specify a target (ONE will choose one for us). If you are installing Linux, you can safely leave it blank or specify "vd" since the virtio driver is native.
Hint for Linux users: at this point you could also add a swap volatile disk, so that the installer does not complain about the lack of it. Please, do not add swap space to the main disk, it is just a waste of space and time (see the discussion here).
In the network section we disable the public internet, as we don't want all the hackers in the world to attack our relatively unprotected installation process. If we know that we can live without any network access during installation, then we can also disable the MWN interface, but often installation systems want to check an installation software key, etc., and thus want to contact their company server (e.g., at microsoft.com). The MWN network is good enough for this, as an LRZ NAT machine (Nat-o-mat) will let all outgoing traffic pass through.
Hint: We have to specify the rtl8139 driver to be compatible with Windows! Linux users can safely leave virtio.
For the installation, we specify that we want to boot from the (first) CDROM present.
Hint: We also specify the architecture we want to emulate (using the same as the underlying hardware will give us a speed improvement, so we use x86_64).
Our interaction with the installation process will be via the built-in VNC, so we activate it here. Also select the proper keyboard mapping (German is the default and fine for me).
Hint: Add the tablet USB driver! This should improve your mouse pointer accuracy in VNC.
This VM will not be protected by a password, so we don't need the contextualization. Finally we create the template.
Now our template is ready and we can start the installation.
5. Start the Installation
In order to start the installation we have to instantiate a VM from our template.
6. You Install Windows onto Your Second Disk.
You now see your VM running and by pressing the VNC symbol you can connect to it, so that you can guide the installation.
You have to work your way through the many installation screens of Windows.
Hint: On some keyboards it may be hard to reach the @ character on the VNC viewer and copy/paste may also not work. The VNC is good for basic work but not as a permanent solution. So you might want to activate Microsoft's Remote Desktop at this point. There is a nice Youtube video (not from LRZ) that explains how to do this: https://www.youtube.com/watch?v=pEXp8MUBa1A. Basically you have to open the Windows Firewall and activate Remote Desktop on your Win-10 machine.
Hint: The second hint concerns the IDE disk driver and the network driver. That one is very slow and should be replaced by the virtio driver. You can find a driver for Windows here: http://alt.fedoraproject.org/pub/alt/virtio-win/stable/. Download it to your Windows VM and install it there, using the Device Manager: you will find a PCI card with a yellow exclamation mark. Right-click it and update/install the driver from your unpacked ISO image. Just specify the drive (e.g., F:), Windows will then find the right drivers. When you now shut down your VM (next step) you should be all set to use virtio in your run-template.
Before we shut down our VM we will take a look at the drive assignment, because Windows expects the drives always in the same position (and won't boot if something changes here unexpectedly). So we open up the Virtual Machines display, click on our VM, select the Storage tab and note down that
- hda is our installation CDROM (just as we had specified in the TARGET field)
- hdc is the real Windows disk
We will need this information later on.
Hint for Linux users: the location of the swap disk needs to be fixed in /etc/fstab. Probably at the end of the installation procedure you can open a shell or customise your system. Otherwise just reboot, as asked by the installer, and start the OS on the hard drive, still in a persistent mode, and with the installation CDROM still attached. In fact Linux addresses disks by their unique id, which changes at every deployment for volatile disks, and the swap disk is one of them. The solution consists simply in removing the entry for the swap space inii /etc/fstab and replace it with /dev/vdb none swap sw 0 0. This also means that in the final template (see next steps) you have to specify vdb as TARGET of your swap volatile disk. If you prefer vdc or something else, there is no problem, just be consistent with that in /etc/fstab in the guest OS. If you wish to use the stage-in facility via the frontend, it is now time to add it to /etc/fstab. Again, the protocol used 9p, is native in Linux. Something like hostonly /mnt 9p trans=virtio,version=9p2000.L,ro,noauto 0 0 should do the trick. Please not the noauto option, preventing the OS to mount the shared folder at boot time, since in some cases the operation fails. Once the OS boots, it is possible to give at any time the command mount /mnt as root and access the shared folder. Of course the target mount point /mnt can be changed with anything else, just remember to be consistent in /etc/fstab.
7. Shut Down Your Installation VM
Once you are done and Windows has been installed, you can shut down the VM you used for installation. What you now have is a pristine installation of Windows. Because we made this hard disk "persistent", it will survive the shutdown.
8. Generate Your Run-Template
Since our installation-template served us well, I want to keep it – you never know when you will need it again. Thus, I make a copy of it, which is called cloning.
Now we can manipulate this copy. First we have to remove the CDROM, as this is no longer needed. We click on the little "x" next to the upper DISK. It will disappear. Second we have to assign the same drive letter to our hard drive that it had before. We have looked this up at the end of step 6: hdc! So we enter hdc as TARGET value for the remaining hard disk.
Hint: If we installed the virtio drivers in step 6, then we must now just delete any TARGET and DEV_PREFIX values. Then this drive will become vda and Windows will boot from it. Now is the time to also change the network driver to virtio.
Finally we have to specify that we want to boot from the hard drive now.
Hint for Linux users: Remember to add the swap volatile disk, as discussed at the end of section 6 of this tutorial. Please specify vdb as target, or whatever is addressed as swap partition in /etc/fstab in your VM.</span/
After this we can save (Update) the template. It is now ready.
We also might want to make our installed Windows disk non-persistent. This means that we will no longer change this disk, an instantiated VM will work on a copy of this disk. Thus, all mistakes that we make will not tarnish our pristine disk image. But all improvements that we make will be lost once the VM shuts down -- unless we preserve a copy of the disk as a new image (called a "Snapshot").
9. Boot Our Windows VM
Now we are ready to boot from our hard disk. We select the run-template from the templates, click on Instantiate, give a name to our new VM (or not, then ONE will select a name for you), and click on the green Instantiate button.
With this you should be ready to play with your Windows VM now. Have fun!
Hint: We had problems with a newer Windows-10 release (the one with Spartan, http://go.microsoft.com/fwlink/p/?LinkId=522144, build 10041), but I assume that this is a problem of the preview version.
Hint: For Linux systems you can basically use the same strategy. Hints have been added inline, where the procedure differs. Just look for the label Hint for Linux users.