Archive for the ‘Work stuff’ Category

How to convert instance-store to EBS for boot

Tuesday, December 7th, 2010

In the last days I spent some time to take care of some AWS instances, and I ported one of this from instance-store to EBS, so the whole server is persistent and can be restarted without any data loosing.

  • Start ad instance-store machine, modify as you like.
  • Create a Volume with the size of 10GB and attach it to instance (suppose that it will be /dev/sdf).
  • format it as EXT3
    mkfs.ext3 /dev/sdf
  • mount it

    mkdir /mnt/ebs
    mount /dev/sdf /mnt/ebs
  • sync the instance with the volume

    rsync -avHx / /mnt/ebs
    rsync -avHx /dev /mnt/ebs
  • flush and umount

    umount /mnt/ebs
  • detach the volume and create a snapshot
  • register the AMI

    ec2-register --region $REGION -s $SNAP –name $NAME –description “$DESC” –architecture $ARCH --root-device-name /dev/sda1 --block-device-mapping '/dev/sda2=ephemeral0' --block-device-mapping '/dev/sda3=ephemeral1'

    change the appropriate parameter with your own

Now you have a fresh EBS AMI ready to boot into a new instance.


Missing modules.dep on EC2 Instance

Friday, October 22nd, 2010

If you are experiencing the following error in your /var/log/messages

... ... modprobe: FATAL: Could not load /lib/modules/2.6.16-xenU/modules.dep: No such file or directory

download, extract into / and the exec

$ depmod -a


Creating software RAID on living CentOS

Monday, May 17th, 2010

I need to add a software RAID 1 to our development server. Actually it is a used server so I cannot do it during installation phase. After searching a bit into the web I found a very nice guide here.


New web vocalization service

Monday, February 22nd, 2010

In the last months we released under our brand name the web vocalization service. This service is able to read your site only adding a link/form on your pages. In the next days you can find on our site the various pricing, initially only three version will be available: Free (with advertising), Basic and Plus.
We have in development some platforms integration too, for now WordPress (soon available on this blog obviously) and Drupal, in the next months some other platforms will be take in care (if you need some specific platform integration does not hesitate to ask).

Let me to know your feedback.


Increase disk size of Xen VM

Saturday, November 21st, 2009

Looking for a fast and safe mode to increase the size of a Xen VM I find this link that match exactly my situation: a image disk with only two partitions, the root partition and a swap partition.

So this is the steps that I followed to reach my goal:

  1. create a backup of the diskimage that you want to modify
  2. shutdown domU
  3. add extra space to the image by entering: dd if=/dev/zero bs=1M count=1024 >> /path/to/diskimage (this would add another 1024M to the DomU image)
  4. boot domU
  5. disable swap partitions by entering: swapoff /dev/xvda2 (or what corresponds to your setup)
  6. fdisk /dev/xvda (or what corresponds to your setup)
  7. press p + enter so see the whole disksetup
  8. delete the second swap partition by entering d + enter and then 2 + enter
  9. delete the system partion by entering d + enter and then 1+enter
  10. recreate the system partition with the same start cylinder than the older one but an end-cylinder bigger than the old cylinder value. press n <enter> p <enter> 1 <enter> and then enter the values
  11. recreate the swap partition (with n <enter> p <enter> 2 <enter> and appropriate values
  12. chance the partition type of partition 2 to swap by pressing: t <enter> 2 <enter> 82 <enter>
  13. exit fdisk by pressing w <enter>
  14. execute: mkswap /dev/xvda2 to make the swap space ready
  15. reboot domU
  16. execute: resize2fs /dev/xvda1

Be aware that if you have a different partition schema this would not work!


Force time to a AWS Instance

Friday, November 20th, 2009

echo 1 > /proc/sys/xen/independent_wallclock

Now you can force the host date.


How To create a CentOS 5.3 EC2 AMI

Sunday, October 25th, 2009


after looking some usefull guides to create Amazon Machine Image based on CentOS distribution, I decide to write the steps that i followed.

First of all we need of a CentOS machine, if you don’t have it use a virtual machine program (on my Kubuntu based laptop I use VirtualBox), once we have it login and start:

  • create image file (in this case about 1,1GB of space reserved), take in mind that this will be the size of your / mountpoint on AWS, so if you want to use the whole size use 10GB (count=10240)

    dd if=/dev/zero of=base-server.fs bs=1M count=1024
  • then create the file system

    mke2fs -F -j base-server.fs
  • create a mount point and mount the image file

    mkdir /mnt/ec2-fs
    mount -o loop base-server.fs /mnt/ec2-fs
  • prepare a base filesystem structure

    mkdir /mnt/ec2-fs/dev
    /sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x console
    /sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x null
    /sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x zero
    mkdir /mnt/ec2-fs/etc
    mkdir /mnt/ec2-fs/proc
    mount -t proc none /mnt/ec2-fs/proc
  • create a yum-xen.conf file with the repository info (in this case for i386 32bit architecture)

    name=CentOS-5.3 – Base
    #released updates
    name=CentOS-5.3 – Updates
    #packages used/produced in the build but not released
    name=CentOS-5.3 – Addons
    name=CentOS 5.3 Extras $releasever – $basearch
  • install all packages in “Core” group (optionally use “Base” or whatever you want)

    yum -c yum-xen.conf --installroot=/mnt/ec2-fs -y groupinstall Core
  • edit network interface configuration file /mnt/ec2-fs/etc/sysconfig/network-scripts/ifcfg-eth0

  • turn on networking editing file /mnt/ec2-fs/etc/sysconfig/network

  • create the file /mnt/ec2-fs/etc/hosts and add at least the localhost interface

    echo " localhost.localdomain localhost" > /mnt/ec2-fs/etc/hosts
  • copy your resolv.conf, when boot from AWS DHCP was changed

    cp /etc/resolv.conf /mnt/ec2-fs/etc/resolv.conf
  • edit the file /mnt/ec2-fs/etc/fstab (32 bit linux machine match only m1.small and c1.medium instance with this mount points)

    /dev/sda1 / ext3 defaults 1 1
    none /dev/pts devpts gid=5,mode=620 0 0
    none /dev/shm tmpfs defaults 0 0
    none /proc proc defaults 0 0
    none /sys sysfs defaults 0 0
    /dev/sda2 /mnt ext3 defaults 0 0
    /dev/sda3 swap swap defaults 0 0
  • if you need more packages install now with yum

    yum -c yum-xen.conf --installroot=/mnt/ec2-fs -y install wget
    yum -c yum-xen.conf --installroot=/mnt/ec2-fs -y install curl
  • disable selinux in /mnt/ec2-fs/etc/selinux/config by setting SELINUX=disabled
  • move TLS library out of the way (if you have it)

    mv /mnt/ec2-fs/lib/tls /mnt/ec2-fs/lib/tls.disabled
  • put your ssh public key for root user (if you want to use another user, create it) in /mnt/ec2-fs/root/.ssh/authorized_keys or read the following step if you prefer to use the AWS assigned key-pair
  • create the file /mnt/ec2-fs/usr/local/sbin/ (have you installed curl? is needed for this script)

    if [ ! -d /root/.ssh ] ;
    then mkdir -p /root/.ssh
    chmod 700 /root/.ssh
    # Fetch public key using HTTP
    curl -f > /tmp/my-key
    if [ $? -eq 0 ] ;
    cat /tmp/my-key >> /root/.ssh/authorized_keys
    chmod 600 /root/.ssh/authorized_keys
    rm -f /tmp/my-key

    make it executable

    chmod +x /mnt/ec2-fs/usr/local/sbin/

    add it to /mnt/ec2-fs/etc/rc.local

    # get AWS credentials
  • chroot into your image

    chroot /mnt/ec2-fs /bin/bash
  • start your services at desired run level and emtpy yum cache

    chkconfig --level 345 sshd on
    yum clean all

    then exit from chroot

  • umount image file

    umount /mnt/ec2-fs/proc
    umount -d /mnt/ec2-fs

Now your image file is ready, simply create bundle volume and upload to S3

  • install ruby, download ec2-ami-tools and install it

    yum install ruby
    rpm -Uvh ec2-ami-tools.noarch.rpm
  • create bundle volume (put file in /tmp)

    ec2-bundle-image -i base-server.fs -c my-cert.pem -k my-private-key.pem -u 1234-5678-9101 (amazon account id)
  • upload to Amazon S3

    ec2-upload-bundle -b base-server -m /tmp/base-server.fs.manifest.xml -a my-aws-access-key-id -s my-secret-key-id

Now you can register an AMI and launch your instance.



Distribute application with Ant

Wednesday, July 30th, 2008

Hi guys,

yesterday I spent some of my time looking for a tool to make a better distribution of our java application. No, I’m not talking about a java installer or something else, but only a way to distribute our internal tools in a single jar.

In the paste I’ve used Uberjar with maven but now I’m using ant and after a lot of try I choose One-Jar; but it works only with ant, probably the best solution is to try a way that work with maven too. Have you a suggest for me? :D


HOW TO… become an efficient coder

Friday, April 25th, 2008

Releasing Dixero…

Saturday, April 12th, 2008

Hola guy, in this days we are releasing another beta of Dixero, especially we have started to release public accounts.

“Dixero is a free and innovative Web-based tool which allows you to listen to your favorite RSS feeds directly online, on your computer as a Podcast, or using a portable device, like an iPod!
At last, with Dixero, you can aggregate your favorite feeds from the most recognized media companies and blogs, transforming posts into audio with different voices”

So, if you are interested to listen your preferred feeds on your iPod (or your mp3 portable player), or simple listen it also on the web with your browser don’t hesitate to join and enjoy ;) .

Thanks to Sketchin guys for the effort needed to reach this goal and for this promo :) .