Run Rackspace Cloud Server locally on Hyper-V

Here is how I ran a copy of my Rackspace cloud server locally on my Hyper-V 2008 R2 Server. Why would you want to do that you ask? Well, there are many reasons. For example, I want to run all my applications in a test/staging environment before I push them live. I want to test all updates to my servers before I push them out live, testing large processes out without wasting money on CPU/bandwidth before running them live, etc. It is very nice to have a near exact copy of what you are running on rackspace cloud servers locally.

Part of the problem was I didn’t have any spare servers laying around that I could install linux and Xen on but I already had a Hyper-V server. This would allow me to run a linux VM, but how do you get a Rackspace cloud server backup running in Hyper-V.

First, Download a copy of the OS you are running for your host machine. For example, my rackspace cloud server is running Centos 5.5. So I will download the install DVDs from CentOS 5.5 download

Second, download a copy of your server backup. To do that, you need to make sure you have Cloud Files backup turned on for you Cloud Servers.  There was no option to enable it when I was looking, so I had to write up a ticket requesting them to turn it on. It took about 3 days or so for them to enable it, but once it was enabled I could make backups of my cloud servers and they were copied to cloud files. Once you have backups to cloud files enabled, and you have a backup in there you can download, you can download the backup off of the cloud files admin website. Or if you have a program like jungle disk setup, I believe that would work as well.

This would probably work for other virtualization environments or linux distros as well, but you will have to piece together your own instructions in place of the Hyper-V and CentOS part.

Lets start setting up our Virtual Machine

Open Hyper-V, Select New-> Virtual Machine

  • Give it a name, save it where you want
  • Give it as much memory as you want
  • Leave networking set to “Not Connected” for now
  • Create a virtual hard disk, defaults are fine
  • Select “Install an operating system from a boot CD/DVD-ROM” and select the ISO for the OS you downloaded above.
  • and Finish

Next, Right click on your new VM and click settings

Select Network Adapter, then remove it.

At the top, select Add Hardware, choose Legacy Network Adapter and click add. Then select the network you wish to add it to. The Rackspace VMs are connected to 2 networks by default, one public and one private, if you wish to have the same setup, you will want to add 2 legacy network adapter. We removed the synthetic network adapters since linux would have some trouble loading the drivers by default. You could add the integration services to load them later on, but Legacy Network adapters will work just fine. Once done, click ok.

Start the new VM.

I’ll walk through the setup for CentOS 5.5, but if you used a different OS, you can follow along and the setup should be similar.

Once loaded, Hit enter for graphical mode

You can test the CD media if you want, but I’ll skip that part.

Ok, accepts all the defaults, if it asks to initialize this drive, erasing ALL DATA click yes.

For partitioning your hard drive select Create custom layout

First, figure out how large you want your swap partition to be. From what I can gather in Rackspace it is usually double the amount of RAM you have dedicated to the VM. I have a 2GB VM so I will create a 4GB (4096MB) swap partition.

Lets create the partitions:

  • Click New
  • Mount Point: /
  • for Size you will want to make it as large as you can but leaving room for your swap partition. So for me it is: 130046 (Free Space) – 4096 (Swap Partition) = 125950.
  • Click OK

Check how much free space you have left. Mine is just shy of 4096, it is 4094, so good enough.

  • Click New
  • For File System Type, Select swap
  • For Size, insert the free space you have left, 4094 is mine.
  • Click OK

Click Next

Choose the defaults, and continue through entering your root password.

For software, you want to uncheck everything. Select Customize now and continue unchecking everything. Go through all the sections and make sure nothing is installed, we want a completely plain nothing installed server.

Then click next twice to start the install. Once done, click reboot.

Ok, now once its back online, login using your root credentials. Assuming you setup the networking right in Hyper-V, you should be able to type ifconfig to see the ipaddress of your VM.

We are going to need to sftp and ssh into the VM. So grab yourself a copy of putty and Filezilla so you can login and make changes. Technically you don’t need putty, you could do this throught the Hyper-V console, but it will make things easier if you want to copy and paste stuff from the website.

Open putty, for Hostname type the IP address of your VM. Click open. It will probably pop up a Security Alert. Click yes. Login with your root credentials.

We need to make a folder for our backup to go. You can put yours in a different location, but if you do, just make sure you change that location in the rest of the tutorial.

mkdir /root/server

Leave the putty window open, since we will come back to it.

Open Filezilla and open the Site Manager

  • Click New Site, and give it a name.
  • Fill in Host with the IP address of your VM, and use Port 22.
  • Select Servertype: SFTP.
  • Select Logontype: normal
  • Select User: root
  • Password: whatever your root password is
  • Click Connect
  • It might ask you to trust the computer. Click OK.
  • On the right side browse to /root/server
  • On the left side browse to your Cloud Server (Cloud Files) backup that you downloaded from before. Then copy the backup to the VM.

Now back in putty.

ln -s / /root/server/image
cd /root/server
tar xvpzf Your-cloud-server-backup-name.tar.gz.0

That will put your backup over the top of the base linux installation. Depending on the size of your backup, this might take a while.

If you see anything like this:
tar: ./image/usr/local/bin/php-config: time stamp 2010-07-08 03:55:01 is 8677 s in the future
It’s probably because the computer clock in the VM is incorrect. You can reset the clock by typing:

date MMDDHHMMYYYY

(that is MonthDayHourMinuteYear)
for example, date 070806002010

Then you can run the tar command again if you like. There is no harm running it multiple times as it will just keep overwriting the files.

The VMs are currently setup for virtual SCSI disks, since we are using virtual IDE we need to change a few things
Edit these files:

vim /etc/fstab

replace all sda with hda

vim /etc/mtab

replace all sda with hda

Now, we need to fix the networking, for the first network adapter:

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0.bak
vim /etc/sysconfig/network-scripts/ifcfg-eth0

I’m using a DHCP network, so I will change the network to DHCP, if you needs statics, just change the static IP.

Change this
FROM:

DEVICE=eth0
BOOTPROTO=static
IPADDR=173.xxx.xxx.xxx
NETMASK=255.255.255.0
ONBOOT=yes

TO:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

For the second network adapter:

cp /etc/sysconfig/network-scripts/ifcfg-eth1 /root/ifcfg-eth1.bak
vim /etc/sysconfig/network-scripts/ifcfg-eth1

Change this
FROM:

DEVICE=eth1
BOOTPROTO=static
IPADDR=10.xxx.xxx.xxx
NETMASK=255.255.224.0
ONBOOT=yes

TO:

DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=no

If you want to enable the second network adapter on boot, just put a yes in there for ONBOOT.

Change the gateway:

vim /etc/sysconfig/network

Change this
FROM:

NETWORKING=YES
HOSTNAME=whatever-you-have-yours-set-to
GATEWAY=173.xxx.xxx.xxx

TO:

NETWORKING=YES
NETWORKING_IPV6=no
HOSTNAME=whatever-you-want-your-test-environment-set-to

Now reboot!

After reboot, you should have a functional copy of your rackspace server running locally on Hyper-V.

Note: If you have ip addresses set in your applications/firewall they will most likely be pointing to your live rackspace server, so you may want to edit those before playing around in this environment.

9 Responses to “Run Rackspace Cloud Server locally on Hyper-V”


  • Very Nice. You could probably P-to-V a CentOS box using the a similar procedure.

  • Thanks for this. I couldn’t find info about this anywhere but here.

    For the record, I was able to follow similar steps to run successfully run on VMWARE Fusion on Mac OS X.

    One thing to note is that in my case, the server image came in two files–something like image.tar.gz.0 and image.tar.gz.1. It took me a while to figure out, but I ended up having to cat them together like “cat image.tar.gz.0 image.tar.gz.1 > combined.tar.gz”.

  • Thanks. I really found this helpful during one of the restores at work. I had to do some changes to the steps in the article.

    For me the fstab and mtab changes did not work. The server was not bootable. Thankfully, I had a snapshot to revert to. Next I took a backup of the fstab and mtab files and after restore, simply copied these files over and followed rest of the steps. Worked like a charm for me.

    • Were you restoring from Rackspace to Hyper-V? or from something else to something else?

      • I was restoring a Rackspace backup to Hyper-V. After the first restore did not work I looked into the fstab entries and felt stupid.

        I noticed the Hyper-V CentOS server had Volume Groups instead of plain /dev/sda1. Restoring the fstab and mtab from original install helped.

        For me the fstab was like

        /dev/VolGroup00/LogVol00 / ext3 defaults 1 1
        LABEL=/boot /boot ext3 defaults 1 2
        tmpfs /dev/shm tmpfs defaults 0 0
        devpts /dev/pts devpts gid=5,mode=620 0 0
        sysfs /sys sysfs defaults 0 0
        proc /proc proc defaults 0 0
        /dev/VolGroup00/LogVol01 swap swap defaults 0 0

        • ahh yes, you must have selected the default partition layout during the base installation instead of a custom layout.

          But that’s helpful to know.
          I should add that to this post

          Before tar xvpzf:
          cp /etc/mtab /etc/mtab.bak
          cp /etc/fstab /etc/fstab.bak

          Then after:
          cp /etc/mtab /etc/mtab.bak-rackspace
          cp /etc/fstab /etc/fstab.bak-rackspace
          mv -f /etc/mtab.bak /etc/mtab
          mv -f /etc/fstab.bak /etc/fstab

  • Excellent article.
    Just downloaded my rackspace backup image, made some snapshots to make sure rollback if thing goes wrong and followed your tutorial.
    As i was restoring in a new machine (virtualbox), i created the disks im scsi controller. All was perfect! No changes in any file.

  • I have problem restoring Red Hat 6.1 image from Rackspace.
    I did not get any error msgs. Rebooted the server fine, checked few directories and they are not the same.What i’m doing wrong? Please help

  • I got a vhd backup file from Rackspace? How do I upload the files to the new local server I created?

Leave a Comment