Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As the title says, I regularly download my Rackspace images for backup of my VPS, however I'm wondering if it's possible to run them locally on KVM (for example) so I can run tests on my application without affection production.

share|improve this question
add comment

3 Answers 3

Yes, you can run them, the hypervisor they use is Xen IIRC. You are also able to download and install Openstack and have your own private cloud.

share|improve this answer
    
Do you know that this is the case, or do you just assume? I've tried to find more information about this, but it seems difficult. –  uvesten Apr 7 '13 at 16:28
    
From the Cloud FAQ: What hypervisor does Rackspace Cloud Servers use? We use Xen and XenServer hypervisors for Linux Cloud Servers and XenServer for Windows Cloud Servers - rackspace.com/cloud/cloud_hosting_faq -- Wow, just now noticed the date of the question. –  David Houde May 19 '13 at 4:24
    
@uvesten Sorry, I didnt notice your reply. I know this to be the case from installing openstack and building a private cloud. –  Sirch May 21 '13 at 9:12
    
Thanks! I might give it a shot then... –  uvesten May 21 '13 at 11:13
add comment

Almost a year to the day after the original question, I think I have a good procedure set up for downloading Rackspace images and running them locally, under Xen running on Ubuntu Precise.

I'll write down the steps here so there's an easy recipe for you to follow if you want to try it out. The steps work for linux/Ubuntu domU's at least, for others YMMV.

(These instructions are also posted on our blog at http://www.everichon.com/blog/2013/05/29/running-rackspace-images-locally/)

  1. Install Ubuntu precise (12.04 LTS), and follow the steps mentioned in http://blog.heidt.biz/blog/2012/09/17/setting-up-ubuntu-12-dot-04-precise-pangolin-as-xen-dom0/ to set up your server as a Xen Dom0. At least make sure to have a running 12.04 with xen and xe-tools installaed, and a LVM volume group to use for virtual disks for your DomU's.

  2. Go to your servers page on the rackspace cloud (manage.rackspacecloud.com -> Hosting -> Cloud servers) and select the one you want to run locally. Go to the Images tab for that server. Create an on-demand image. (Depending on the time the server was first created the on-demand image will either go directly to cloud files or be stored with the server. If the image is stored with the server, you have to move it to cloud files after creation.)

  3. Check the name of the image in cloud files. Go to Hosting -> Cloud Files and open the container cloudservers. There should be the file there named like myservername_YYYYMMDD_XXXXX_cloudserverZZZZZ.tar.gz.0, and that's the file you want.

  4. Download the image to your server. The easiest way to do this on Ubuntu 12.04 is to use swift. To install, just sudo apt-get install swift. Then run it like swift -A https://auth.api.rackspacecloud.com/v1.0 -U username -K API_key download cloudservers myservername_YYYYMMDD_XXXXX_cloudserverZZZZZ.tar.gz.0

  5. When the download is done, unpack the downloaded file (tar zxf myservername_YYYYMMDD_XXXXX_cloudserverZZZZZ.tar.gz.0). When it's done you'll have gotten the following files:

    image
        -> image.vhd
        -> manifest.ovf
        -> snap.vhd
    

    image.vhd is the one we're interested in, as it contains your root partition from the cloudserver.

  6. To make it easier to work with the image file, we'll convert it to a raw disk image. This is done using qemu-img (if it's not available on your system, do sudo apt-get install qemu-utils). To convert the image.vhd to something that's easier to work with, do qemu-img convert -p image.vhd disk.img

  7. Check the disk image using fdisk. (NOTE: I've only been working with 20 GB large images from rackspace, and my notes are about them. If you use another size, you'll have to adjust some steps accordingly!) fdisk -l disk.img should give something like the following:

    Disk sda1.img: 20.4 GB, 20400758784 bytes
    255 heads, 63 sectors/track, 2480 cylinders, total 39845232 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
       Device Boot      Start         End      Blocks   Id  System
    disk.img1   *        2048    39845887    19921920   83  Linux
    

    Note the start offset for the first partition, and the sector size.

  8. (Optional) Check that the disk image is ok. For this, we mount it loopback and simply see that it works.

    mkdir tmp
    mount -o loop,offset=1048576 disk.img tmp/
    ls -la tmp
    (The offset above is start for the first partition * sector size) 
    

    This gives you an indication that the disk is ok. Then unmount the image. umount tmp

  9. Create logical and swap volumes for your new DomU. lvcreate -L20G -n myservername-disk vg0 and lvcreate -L2G -Cy -n myservername-swap vg0. Also initialize the swap disk, mkswap /dev/vg0/myservername-swap.

  10. Copy your disk image to the new logical volume. dd if=disk.img of=/dev/vg0/myservername-disk bs=4096 skip=256. The bs and skip arguments are there to get the correct offset for your partition. I could go with bs=512 skip=2048, of course, but making the block size larger makes copying much faster. (And 512*2048 = 4096*256, so it does not matter for the offset.)

  11. Check the filesystem on your logical volume (and fix any errors), resize the fs to fit the lv, and check again.

    e2fsck -f /dev/vg0/myservername-disk
    resize2fs -p /dev/vg0/myservername-disk 
    e2fsck -f /dev/vg0/myservername-disk     
    
  12. Check the virtual disk settings in your virtual machine. This will be needed for your DomU config file. Mount the logical volume. mount /dev/vg0/myservername-disk tmp. Then check the fstab file, and (if it exists) the grub menu.lst file.

    more tmp/etc/fstab
    more tmp/boot/grub/menu.lst 
    

    Note the disk names for root and swap!

  13. Update the network settings for your DomU. With the virtual disk still mounted, edit the interfaces file to something that suits your local environment. vi tmp/etc/network/interfaces. I've usually changed mine from something like:

    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
        address 184.106.XXX.YYY
        netmask 255.255.XXX.YYY
        gateway 184.106.XXX.YYY
        dns-nameservers 173.203.XXX.YYY 173.203.XXX.YYY
    
    auto eth1
    iface eth1 inet static
        address 10.179.XXX.YYY
        netmask 255.255.XXX.YYY
    up route add -net 10.176.XXX.YYY0 netmask 255.240.XXX.YYY gw 10.179.XXX.YYY
    down route del -net 10.176.XXX.YYY netmask 255.240.XXX.YYY gw 10.179.XXX.YYY
    up route add -net 10.191.XXX.YYY netmask 255.255.XXX.YYY gw 10.179.XXX.YYY
    down route del -net 10.191.XXX.YYY netmask 255.255.XXX.YYY gw 10.179.XXX.YYY
    

    (for rackspace's environment) to:

    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto eth0
    iface eth0 inet dhcp
    

    for just using dhcp and one virtual network interface and my local server. After these changes, we should be done. Unmount the virtual disk, umount tmp.

  14. Create a xen config file for your imported DomU, vi /etc/xen/myservername.cfg, and put in something like this:

    name = "myservername"
    
    bootloader = '/usr/lib/xen-default/bin/pygrub'
    
    #uncomment the following if you want to boot into single user mode 
    #extra = " single"
    
    vcpus       = '2'
    memory      = '512'
    
    #
    #  Disk device(s). (Use the correct mappings from step 12.) 
    #
    disk        = [
                      'phy:/dev/vg0/myservername-disk,xvda1,w',
                      'phy:/dev/vg0/myservername-swap,xvda2,w',
                  ]
    #
    #  Networking
    #
    vif         = [ 'bridge=xenbr0' ]
    #
    #  Behaviour
    #
    on_poweroff = 'destroy'
    on_reboot   = 'restart'
    on_crash    = 'restart'
    

    Again, note that you should use the same device names for the virtual devices as the ones you discovered in step 12.

  15. Now everything should be ready! To verify, create the domU and attach a console by running xm create -c /etc/xen/myservername.cfg

share|improve this answer
add comment

Here is good link on "Run Rackspace Cloud Server locally on Hyper-V"

http://www.sudonym.com/375/run-rackspace-cloud-server-locally-on-hyper-v

share|improve this answer
3  
We really do prefer that answers have content, not pointers to content. This ensures that the answer will remain available even if the link goes dead. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Iain May 30 '12 at 16:40
    
Makes sense, my fault. Can I modify my answer ? –  Chakri May 30 '12 at 18:09
    
@Chakri just click the edit button and put in something good. –  ErnieTheGeek May 30 '12 at 18:20
    
@Chakri: Just edit the detail into your answer. –  Iain May 30 '12 at 21:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.