Quantcast
Channel: Adam Young's Web Log
Viewing all articles
Browse latest Browse all 467

Making a Virtual Machine image from a Live CD

0
0

The Live CD shipped with Fedora 18 is a perfectly serviceable virtual machine image, provided you give it some writeable disk space. It even ships with a tool to make this happen. All it needs is a block device.

First, lets give it a block device:

cd /home/ayoung/vms
qemu-img create -f raw f18root.img 8G
sudo mke2fs f18root.img
sudo losetup --find --show f18root.img

I realize vms was a very popular computer system, and the VMs would be a better name for the directory, but I eschew capitalization in directory naming. The vms directory contains my VM image files. Here is what each line above affects:

  1. qemu-create generates a new
    raw image file
    That will be the actual backing store.
  2. mke2fs initializes the ext2 (or later) file system.
  3. losetup creates a block device that maps to the raw file. the Live CD creator requires a block device. In this case, the device is /dev/loop1 but the actual value will vary per host, see the output of the losetup command to get the actual value.

Download the appropriate Live CD from: http://fedoraproject.org/get-fedora to your local filesystem. In my case, I have it in ~/Downloads/Fedora-18-Alpha-x86_64-Live-Desktop.iso.

sudo mount -o loop ~/Downloads/Fedora-18-Alpha-x86_64-Live-Desktop.iso /mnt/
sudo yum install livecd-tools
sudo /mnt/LiveOS/livecd-iso-to-disk /home/ayoung/Downloads/Fedora-18-Alpha-x86_64-Live-Desktop.iso /dev/loop1
  1. Mount the ISO to get access to the files
  2. livecd-tools has the applications required by the script
  3. Run the Live CD creator against the loopback device created above.

To deploy the VM:

sudo virt-install --vcpus=1  --name F18Alpha  --ram 1024  --import  --disk f18root.img

Viewing all articles
Browse latest Browse all 467

Latest Images

Trending Articles





Latest Images