Thursday, November 5, 2015

AWS: Amazon Web Services


EC2 stands for "Elastic Compute Cloud". This allows running a remote virtual machine instance in the AWS cloud. The remote machine can choose to have OS windows or Linux(redhat, suse, ubuntu or amazon's linux). The remote machine instance can be-
1. General Purpose
2. Compute optimized
3. GPU instance
4. Memory optimized
5. Storage optimized

AWS basics:

For launching an existing EC2 instance, 
1. Click on EC2
2. Click the instances link @left panel.
        -> This shows the list of instances
3. Select the instance and click on the "Actions" drop down at the top
4. To start/stop the instance, select the "instance state" and change the state.

After launching a remote instance, you will get a public IP address.


Connect to EC2 from Linux:

 Run the following command to login to the remote machine instance-

ssh -i "ec2-keypair.pem" ubuntu@
            Where ec2-keypair.pem is the private key file


Troubleshooting:

1. Error:
 ssh: connect to host port 22: Connection timed out

    a. Click the "security group" link @left panel.
        -> This shows the list of security groups
    b. Right click on your security group and select "Edit inbound rules"
    c. Make sure that your public IP is added as "custom IP" and give IP address as xx.xx.xx.xx/32

Connect to EC2 from Windows:

Setting up EC2 with nodejs:

Follow this link for setting up the EC2 instance for node.js-
http://therightchoyce.tumblr.com/post/37209565860/installing-nodejs-on-an-ec2-ubuntu-instance-for

Test out the node.js with the following hello world program:


         var http = require('http');



         var server = http.createServer(function (request, response) {
                response.writeHead(200, {"Content-Type":"text/plain"});
                response.end("Hello world");
         });
        
         server.listen(8000);
        console.log("Server running on 8000");


Save the file to example.js and run with 
nodejs example.js

On the browser, you should see "Hello world" printed on :8000

Creating a project repository in Github


1. Create an account in github and verify your email
2. Click on the dropdown on top right side with a + sign. It takes you to the url https://github.com/new
3. Give a repository name and click on create repository.


Working with github:
In order to clone the repository, you need-
1. Create an ssh key by following this link
https://help.github.com/articles/generating-ssh-keys/

2. Add the ssh public key to the github page at this location
https://github.com/settings/ssh

3. Run the following command-
 git clone git@github.com:/.git

4. Do the following to set your username/password

git config --global user.name "your name"
git config --global user.email "your@email.com"

5. Pushing your change to github:
git push origin  localbranch:master

Thursday, January 10, 2008

Titbits on Cygwin :)

The following are small tidbits of information that I can comeback to refer... and hopefully helpful to others too...

Cygwin:
Cygwin is an interesting tool for those who are familiar with linux and wants to do something similar in windows. It gives a bash shell in a windows system and permits compilation of most linux programs.

Well one interesting thing to keep in mind while installing cygwin is to remember that you need to choose the components that you may want to install. The default installation of cygwin does NOT install the gcc compilers and most of the libraries which might interest a developer.

The installation takes quite sometime as it downloads stuffs from internet. Maybe a wiser choice is to download it locally and then install it as the internet installation fails often.

waiting... waiting... for the downloading to finish. Probably I am downloading more stuffs that I really need...

Finally cygwin is installed with compiler on my PC!!!

My aim is to compile squashfs tools in windows so that I will have the utility available to make a squash fs image in windows AND Linux.

SquashFS:
The following are some leads on squashfs filesystem-
http://www.roseindia.net/linux/tutorial/linux-howto/SquashFS-HOWTO/creatingandusing.html

The source code for the tools can be found at the following link-
http://sourceforge.net/projects/squashfs

It compiles cleanly in Linux. I am trying to see whether its the same case with windows cygwin compilation too.

SquashFS tools Compilation on Cygwin:

In cygwin, squashFS tools does not compile cleanly. Its to be expected as the squashFS providers does not claim to support windows platform.

Compilation fails because it references system header files. Looking a bit closely in the code, it looks like the mksquashfs.c is trying to get the number of processors in the system.

My aim is to compile the code in a Windows PC with one processor. So thats it. #ifdef away the code thats trying to get the number of processors and #else to processors=1..

Summerising the changes required to compile squashFS(version3.1r2) in cygwin-
-Define linux macro in the Makefile to make the compilation work similar to linux
-#ifdef away a few calls done to get the number of processors and include files

Bingo it works!!! I have mksquashfs that work on windows. I am able to mount the squashFS image made in windows in the target Linux!!!!

If this tool is to be invoked without cygwin, we will have to copy the following cygwin DLLs to the same directory as the executable mksquashfs.exe is.
-cygwin1.dll
-cygz.dll