Notice: This process has been replaced by a script in pegasus/contrib/tutorial_vm

This page documents the steps required to create the Pegasus VM and deploy it using VirtualBox, Amazon EC2, and FutureGrid.

Creating the Base VM Image using VirtualBox

We will start out by creating a base CentOS 6 image using VirtualBox. Later I will show how to deploy this image on Amazon EC2 and FutureGrid.

First, if you don't already have it, download VirtualBox and install it.

Create a new Virtual Machine

Start VirtualBox and create new virtual machine. You can call it whatever you want, but I used "Pegasus". The OS should be "Linux" and the version should be "Red Hat (64 bit)". MAKE SURE YOU SELECT 64 BIT or your VM will have issues.

Give it 1024 MB of memory. This doesn't really matter that much.

Create a new virtual disk. Use VMDK format. Set it to be dynamically allocated. It is NOT necessary to split it into files of less than 2GB.

You can specify the location of the virtual disk and the name. I just left those at the defaults. I also used the default 8GB size. Since the virtual disk is dynamically allocated it won't really take up that much space.

Install CentOS 6 on the new VM

Start the new VM.

When the first run wizard pops up, attach a minimal CentOS ISO when it asks about media, I used the one from here:

http://mirrors.usc.edu/pub/linux/distributions/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-minimal.iso

Select install system with basic video driver.

When the system starts, skip the media test. I don't know what it does, but it didn't work for me.

At this point it will start the graphical installer. Just go through the first few steps selecting the obvious choices.

When it asks about the disk, Select "basic storage devices".

When the warning pops up select "Yes, discard any data"

I just left the hostname as "localhost.localdomain". Don't worry about the network configuration yet.

When it gets to asking about disk partitioning, use the "custom layout" option. Delete any existing partitions it sets up and create one large /dev/sda1 partition with ext4 mounted at / that is filled to the maximum size. This step is really important. You don't want to mess this up because it will make things really complicated when you try to move this to Amazon and FutureGrid. Create one partition (/dev/sda1), and that's all. No separate /boot partition, no LVM, no /home partition, no swap.

Ignore the warning about swap, write the changes, and format the disk.

Install the boot loader without a password.

At this point the installer will install all the packages. Reboot the VM when it is done.

Configuring the VM

Log in as root.

Edit /boot/grub/menu.lst:

  1. Set the GRUB option "timeout=0" so that it will start the default kernel immediately.
  2. Add "selinux=0" to the kernel options to disable SELinux.
  3. Add "vga=0x343" to the kernel options to get a more readable 800x600 terminal with 32bit color.
  4. Remove "rhgb" and "quiet" from the kernel options if you want more verbose logging when the VM starts.

Edit /etc/sysconfig/network-scripts/ifcfg-eth0:

  1. Set "onboot=yes" to enable the network interface.

If you want to disable the firewall, either:

  • Edit /etc/sysconfig/iptables and remove all the INPUT entries and replace them with a single line: "-A INPUT -j ACCEPT"
  • Or you can just chkconfig iptables off

If you want to add a 'pegasus' user:

  1. # useradd pegasus
  2. # passwd pegasus
    1. set password to "pegasus"
  3. # yum install sudo
  4. Edit /etc/sudoers
    1. allow users in wheel group to run sudo by uncommenting the %wheel line
  5. # usermod -G wheel pegasus

Since we aren't using LVM you can:

# chkconfig --level 12345 lvm2-monitor off

TODO: Add steps to install Condor, Pegasus, and the tutorial materials.

Deploying the Image on Amazon EC2

The next thing we will do is deploy the new VM we created with VirtualBox to Amazon EC2.

CentOS 6 has a Xen-compatible kernel, so no complex kernel stuff is required for this. I think CentOS 5.5 works too, but I haven't tried it.

I did all this through the EC2 Console. Later we can automate it, but for now the process is manual.

Copying the .vmdk to Amazon EC2

First, log into the EC2 Console and launch a Linux conversion VM. Any VM will do. I used an existing CentOS 6 VM.

In the volumes view, create and attach blank 8GB volume to the conversion VM you just started. The size of the volume must match the size of the virtual disk you created using VirtualBox. 

At this point you need to copy the .vmdk on your local machine to the conversion VM. Typically VirtualBox creates a directory in your home directory to store virtual machines. Look in that directory to find the .vmdk file. Mine was /Users/juve/VirtualBox VMs/Pegasus/Pegasus.vmdk.

Transfer the .vmdk to your conversion VM on EC2. You can use whatever technique you want. I used scp. The .vmdk shouldn't be too big (~1G), but you can gzip it first if you want. I transferred it to /tmp on the EC2 VM.

Next, log into the conversion VM via SSH.

The coversion instance should have a couple disks attached to it that you can see in the /dev directory. Depending on what OS and version you are using these may be /dev/sdX or /dev/xvdX where X is some letter. I used CentOS, so I got a /dev/xvde1, which is the root partition of the running VM, and /dev/xvdj, which is the blank volume.

Copy/convert the .vmdk to a disk image using:

# qemu-img convert -f vmdk Pegasus.vmdk -O raw /dev/xvdj

That operation is going to write a partition table to the blank volume, so you need to rescan the device to pick up the new partitions. You can do that with:

# partprobe /dev/xvdj

After running that command you should see a new device called '/dev/xvdj1'. Thats the partition you created when you installed CentOS using VirtualBox.

Mount the new partition with:

# mount /dev/xvdj1 /mnt

Reconfiguring the VM Image for EC2

We need to make a few changes to the image so that it will boot on EC2.

Copy the getsshkey script from the conversion VM to the new image:

# cp /etc/init.d/getsshkey /mnt/etc/init.d/

Chroot to the new image so that we can update it:

# chroot /mnt

Enable the getsshkey init script:

# chkconfig --add getsshkey

Edit /boot/grub/menu.lst to change the kernel options:

  1. remove "vga=0x343"
  2. add "console=hvc0"
  3. add "nomodeset"

Edit /etc/sysconfig/network-scripts/ifcfg-eth0 so that the OS can bring up the network interface:

  1. delete UUID and HWADDR

Exit from the chroot:

# exit

Unmount the new image:

# umount /mnt

Next, create a snapshot of the volume that contains the new image.

Finally, register the snapshot as a new AMI using the latest pv-grub hd00 kernel (not the hd0 kernel) and /dev/sda as the root device (not /dev/sda1).

Before terminating the conversion VM, launch an instance using the new AMI to test it.

 

  • No labels