Virtualization the Linux/OSS Way
Listing 1. Script to Create Multiple VMs
#! /bin/bash
# A quick and dirty script to create multiple virtual machines,
# give them unique hostnames and IP addresses, and culminate in
# bringing them on-line.
# name of the directory where we'll mount our vdi's
dir=temp
rootdir=`pwd`/$dir
# the basename for the vms
basename=vbox-vm-
# the file that contains the basic disk image
basevdi=base.vdi
# how many images are we making
number=2
# what subnet will these guests be going on
IPnetwork='10.7.7.'
gateway='10.7.7.1'
# the start of the address range we will use
baseIP=10
# amount of memory these guests will get in Mbytes
memory=512
# base VRDP port
baseRDP=16001
counter=1
while [ $counter -le $number ]
do
echo $basename$counter $basename$counter.vdi \
$IPnetwork$baseIP $memory
VBoxManage clonehd `pwd`/base.vdi \
`pwd`/$basename$counter.vdi --variant Fixed
sudo mount_vdi/mount_vdi.sh $basename$counter.vdi $rootdir 1
sudo sed -i "s/basicsys/$basename$counter/g" $rootdir/etc/hosts
sudo sed -i "s/basicsys/$basename$counter/g" $rootdir/etc/hostname
sudo sed -i "s/1.1.1.2/$gateway/g" $rootdir/etc/network/interfaces
sudo sed -i "s/1.1.1.1/$IPnetwork$baseIP/g" \
$rootdir/etc/network/interfaces
sudo rm $rootdir/etc/udev/rules.d/70-persistent-net.rules
sudo touch $rootdir/etc/udev/rules.d/70-persistent-net.rules
sudo umount $rootdir
sudo losetup -d /dev/loop1
sudo losetup -d /dev/loop0
VBoxManage createvm --name $basename$counter --register
VBoxManage modifyvm $basename$counter --pae on --hwvirtex on
VBoxManage modifyvm $basename$counter --memory $memory --acpi on
VBoxManage modifyvm $basename$counter \
--hda `pwd`/$basename$counter.vdi
VBoxManage modifyvm $basename$counter \
--nic1 bridged --nictype1 82540EM --bridgeadapter1 eth0
VBoxHeadless --startvm $basename$counter -p $baseRDP &
sleep 5
baseRDP=$((baseRDP + 1))
baseIP=$((baseIP + 1))
counter=$((counter + 1))
done
If you get this script working, you are well on your way to having the infrastructure in place to support a manageable, flexible, cost-effective, robust virtualization environment. Personally, I'm looking forward to getting 3.2.x in place and being able to teleport running machines between hosts to manage workloads in real time—from the command line, of course. Stay tuned, my next article will deal with the back-end shared storage (based on open protocols and free, open-source software, while being redundant and performant). I intend to connect my virtualization hosts to support being able to:
VBoxManage controlvm vbox-vm-3 \
teleport --host vbox-host-2 --port 17001
Resources
Oracle's Virtualization Blog: blogs.oracle.com/virtualization
mount_vdi: www.mat.uniroma1.it/~caminati/mount_vdi.html
Bill Childers' “Virtualization Shootout: VMware Server vs. VirtualBox vs. KVM”, LJ, November 2009: www.linuxjournal.com/article/10528
Greg Bledsoe is the Manager of Technical Operations for a standout VoIP startup, Aptela (www.aptela.com), an author, husband, father to six children, wine enthusiast, amateur philosopher and general know-it-all who welcomes your comments and criticism at lj@bledsoehome.net.
-- I was cloud before cloud was cool. Not in the sense of being an amorphous collection of loosely related molecules with indeterminate borders -- or maybe I am. Holla @geek_king, http://twitter.com/geek_king
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Home, My Backup Data Center
- What's the tweeting protocol?
- Readers' Choice Awards
- New Products
- RSS Feeds
- Dart: a New Web Programming Experience




8 hours 51 min ago
11 hours 23 min ago
12 hours 41 min ago
13 hours 15 min ago
13 hours 38 min ago
18 hours 26 min ago
19 hours 13 min ago
20 hours 47 min ago
22 hours 24 min ago
1 day 21 min ago