Recording a Virtual Machine
Recording your own desktop is a great quick-and-easy way to create a screencast. There are two issues with this however:-
- You can only record what you have installed already, or whatever can be installed on your platform of choice. If you wish to demonstrate something which is in another version of Ubuntu, or an older version of a program it may be difficult to reconcile the necessary dependancies.
- Your screencast may have a different look than a viewer sees on their desktop, especially if you have installed extra software or have modified your desktop look and feel. This can be offputing for a new user when their desktop doesn't look the same as those they see in the screencasts they watch.
Creating and then recording a virtual machine allows you to have an enclosed environment in which you control tightly the settings, and what applications are installed.
The virtual machine consists of some disk space which is used to create an disk image, some memory (whilst the VM is running) which is taken from the host and some CPU time for running the virtual CPU(s). It therefore isn't easy to emulate a computer which is more powerful than the host. So many people create virtual disk images which are relatively small (they often don't need to be large), and allocate only a portion of the hosts memory to the emulator. The amount of CPU time taken during execution depends on the emulator, with the good ones only taking a small portion of the host CPU to execute the virtual machine.
The disadvantage with this method is that the host computer has to run the recording software, the emulator and a full operating system and the application being recorded. This can be quite a bit for some computers to cope with and as such a preferable solution might be to use the VNC method described on the ScreenCasts/RecordingVNCSession page.
There are numerous tools for creating and running virtual machines under Ubuntu. The major ones are:-
- QEMU (with or without the closed-source kqemu kernel module)
- kvm (and QEMU)
- Parallels workstation
- Xen
- VMWare
This guide currently only details QEMU, however the principles apply to many of the others. Indeed kvm includes QEMU in the package, and as such much of this guide is identical when kvm is used.
Preparing a VM
Preparation is the key to great screencasts. Creating a disk image with all the necessary software takes a little time, but once created it can be backed up and reused for multiple screecasts.
Create a base disk image
The following command will create a 10GB qcow image called dappervm.qcow. A qcow image will start small and only grow as data is written to it. It will not be 10GB in size on disk initially, and probably never will be unless you absolutely fill the disk image up. So it makes sense to make a nice large image as the space won't be wasted.
qemu-img create -f qcow dapper.qcow 10G
Install Ubuntu into the disk image
If you have an ISO image of the Ubuntu installation CD (any of them) you can use the following method. It will start QEMU with 256MB of the host computer RAM (give it more if you can spare it), will mount the dapper.qcow image as /dev/hda, the iso image as /dev/hdc and boot off the CDROM drive with networking enabled. Of course you will need to change the name of the ISO image to whatever yours is called:-
qemu -m 256 -hda dapper.qcow -cdrom ./Ubuntucd.iso -boot d -net nic -net user
If you have a Ubuntu physical CD then you can use this method - which assumes the CDROM is in the CDROM/DVD drive known as /dev/hdc on the host computer:-
qemu -m 256 -hda dapper.qcow -cdrom /dev/hdc -boot d -net nic -net user
If all goes well a window should appear in which you should briefly see a standard BIOS splash screen in a which should quickly change to the standard Ubuntu splash screen. Follow the normal method you would use for installing Ubuntu. When you come to partition the disk you can use whatever layout of partitions you like, but note you "only" have 10GB to play with (assuming you followed the instructions above).
Depending on the speed of your computer the installation may take some time.
Note: If you are using the (non-free) kqemu module with QEMU or the (free) kvm module then you should see near native (host) performance. Without these modules the expected performance is lower.
Start the VM
Start QEMU
Shutdown the VM
Either closedown the operating system inside the VM cleanly or just kill QEMU.