Clone an OpenVZ system to run locally - virtualbox

I have a VPS on an ISP which is using OpenVZ. I want to run my own image locally to test some services, but I can only download a tar backup of the filesystem.
Can I create a image and run it locally using the tar backup ? I'm on Windows 7. Maybe VMWare Player or Oracle VirtualBox can run this files ?

Yes, you can. You can install centos 6 and OpenVZ in a virtuall machine and create a container from the backup there. http://openvz.org/Quick_installation

Related

Node.JS native addons on LINUX [duplicate]

I'm using AWS Lambda, which involves creating an archive of my node.js script, including the node_modules folder and uploading that to their infrastructure to run.
This works fine, except when it comes to node modules with native bindings (using node-gyp). Because the binding was complied and project archived on my local computer (OS X), it is not compatible with AWS's (Amazon Linux) servers.
How can I cross-compile/install a node module (specifically, node-sqlite3) so when I upload it to another server arch it runs?
While not really a solution to your problem, a very easy workaround could be to simply compile the native addons on a Linux machine.
For your particular situation, I would use Vagrant. Vagrant can create virtual machines and configure them within seconds.
Find an OS image that resembles Amazon's Linux distro (Fedora, CentOS, others that use yum as package manager - see Wiki)
Use a simple configuration script that, when run by Vagrant on machine startup, will run npm install (optionally it might also remove the node_modules folder before to ensure a clean installation)
For extra comfort, the script can also create the zip file for deployment
Once the installation finishes, the script will shutdown the VM to avoid unnecessary consumption of system resources
Deploy!
It might require some tuning if the linked libraries are not at the same place on the target machine but generally this seems to me like the best and quickest solution.
While installing the app using Vagrant might be sufficient in some cases, I have found it necessary to build the app on Linux which is as close to Lambda's Amazon Linux AMI as possible.
You can read the original answer here: https://stackoverflow.com/a/34019739/303184
Steps to make it work:
Spawn new EC2 instance. Make sure it is based on exactly the same image as your AWS Lambda runtime. You can review Lambda env details here: http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html. In our case, it was Amazon Linux AMI called amzn-ami-hvm-2015.03.0.x86_64-gp2.
Install nvm and use it to install the same version of Node.js as on the AWS Lambda. At the time of writing this, it was v0.10.36. You can refer to http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html again to find out.
You will probably need to install git & g++ compiler on the EC2. You can do this running
sudo yum install git gcc-c++
Finally, clone your app to your new EC2 and install your app's dependecies:
nvm use 0.10.36
npm install --production
You can then easily download the node_modules using scp or such.
Same lines as Robert's answer, when I had to work on my MAC in a different OS I use vm ware like Oracle's free virtualizer VirtualBox to get a linux on my mac, no cost to me. Or sign up for a new AWS account, you get a micro for a year free. Use that to get your linux box, do whatever you need there.
AWS has a page describing how to deal with native NPM modules: https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/

Datalab - how to install and keep packages

I decided to try and use Google Cloud Datalab for a small project that I'm working on rather than a Jupyter Notebook in an Anaconda environment on an AWS instance.
How can I install a package (for example OpenCV) onto the Datalab VM so that I don't have to reinstall it every time I restart my VM? Why do the packages disappear after every restart but the updated notebooks remain persistent? Any help answering these questions and clarifying how the Datalab VM works would be very helpful.
The notebooks are stored in a docker volume mount that represents a location on the persistent disk that is maintained across restarts of the VM.
The packages you install however are stored in the running container and hence lost on each restart.
You could create a custom docker image and use that instead. On the datalab create command, see the --image-name argument.
Here is an example of a Dockerfile you'll want to use:
FROM gcr.io/cloud-datalab/datalab:latest
RUN pip install opencv
Note that you'll need build the docker image using this docker file, and push the image to Google Container Registry. My memory is a bit fuzzy on this, but it is possible this image needs to be marked as public.
Hope that helps!

Clone a Cloud9 workspace into an SSH enabled setup

My question concerns migrating a web app built in Flask to a Droplet.
I have built the app in a private workspace, using the Flask template in C9. Now it's been developed, I want to set up the app in a Digital Ocean droplet. To connect a brand new C9 SSH workspace to a droplet is fine; however, the SSH workspace by default does not have many of the dependencies (mySQL; Flask) and this is a major pain. I'm using a droplet with Ubuntu NodeJS 6.9.5 on 14.04.
Is there a way to have my existing private dev workspace cloned to an SSH workspace? It would be even better to have a single workspace maintained that syncs to the other, should I wish to take down the droplet for any reason.
Thanks.
Why can't you just image the disk, a digital copy of a working c9 to your new workplace, then use rsync to do increment sync.
rsync -azHAXxP -e 'ssh -p22' username#your-droplet-IP \
"dd if=/dev/sda of=myworking-droplet.iso bs=512 conv=noerror,sync"
Now that you have a full copy of working droplet as an image (.iso) file,
you can copy this to any hard disk of your choice and boot into it.
Image your Cloud9 into USB
If your C9 filesize is less than 30G, you can copy this into usb drive and maintain a locally bootable copy, that is you can image this unto any larger USB
and make it bootable, to achieve this do :
Mount USB of bigger size than size of your iso.
Check your mounted flash drive localtion with df -h, or lsblk -a
Image your iso file to usb with :
dd if=myworking-droplet of=/dev/sdb bs=512k conv=noerror,sync
Once finished, remove your drive, plug it into another PC,
change the boot order to USB Drive
and boot into your C9 locally
Sync Your Cloud9 workspace directory to another box
It gets better if you just want to sync your C9 workspace directory
over SSH connection to another box, use:
`rsync -azHAXxP -e 'ssh -p22' username#your-droplet-IP:/path/to/your/workspace .`
The above will clone your workspace directory over to your current box.
NOTE: The dot at the end of the command is necessary.
Mount your Cloud9 workspace to your local machine
Also you can mount your remote workspace file system to your local computer so you can make changes on
the fly and treat your droplet as local storage, so you can work and
access the same workspace locally without the need to login into your Cloud9
everytime you want to make changes or work on your project, to achieve this use:
Install SSHFS if not already installed with :
sudo apt-get install sshfs
Create a local directory in which to mount the droplet's file system.
sudo mkdir /mnt/mydroplet
Mount your droplet with:
sudo sshfs -o allow_other,defer_permissions \
root#xxx.xxx.xxx.xxx:/ /mnt/mydroplet
If your droplet is configured for login via ssh key authorization, use this:
`sudo sshfs -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa \
root#xxx.xxx.xxx.xxx:/ /mnt/mydroplet`
Now you can work with files on your droplet as if it were a physical device attached to your local machine.
Testing your mount from your local machine:
`cd /mnt/mydroplet`
Creat a test file
touch TestFile.php
Now login into you Clound9 and verify that you can access and modify the newly created file i.e TestFile.php
Now you can code locally, it immediately appears on your C9, or upload files from your local machine to your Cloud9 by copy file to your locally mounted directory.

Why does vagrant use vmdk disk format as its standard package format?

I have a MacBook Air and space is a premium. I have a vagrant instance which has been growing in size from 2 GB to 8 GB.
I was looking at options for reducing the disk size found a few tutorials for VDI, but the actual file is a .vmdk file. Unfortunately, the tool to manage vmdk files is a commercially licensed tool from VMware.
Why does vagrant use the vmdk format as its default packaging format?
Is there a way to configure the vagrantfile and force it to use vdi instead of vmdk?
Simple answer is no.
VirtualBox only supports exporting images as OVF/OVA.
Vagrant 1.0.x base boxes are basically tar files of the VirtualBox exports. It changed a little bit in 1.1.x and 1.2+.
Anyway, technically you should still be able to convert the VMDK to VDI but you will have to re-attach it to the existing VM or create a new one using it, e.g.: VBoxManage clonehd in.vmdk out.vdi --format VDI
Refer to http://docs.vagrantup.com/v2/boxes/format.html
In the past, boxes were just tar files of VirtualBox exports. With Vagrant supporting multiple providers, box files are now tar files where the contents differ for each provider. They are still tar files, but they may now optionally be gzipped as well.
Box files made for Vagrant 1.0.x and VirtualBox continue to work with Vagrant 1.1+ and the VirtualBox provider.

how to integrate code with virtualbox?

i am doing project in virtualbox. i have a client and server code in c++. i want server code to be integrated with virtualbox source code. client is sending cd image to server and cd image is diaplayed as virtual cdrom in guest os. i am trying to integrate this cd image with virtual cdrom part of vbox. but i dont know where to integrate this such that while running guest os, cd appears in it. it should NOT BE DONE MANUALLY. dont know where to put this cd image such that it will apperas in guest os. it would be a great help if u sort out this problem .
Simplest, your server can run the shell command VBoxManage storageattach to eject or attach cdrom images to a virtualbox guest.