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:
create a backup of the diskimage that you want to modify
shutdown domU
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)
boot domU
disable swap partitions by entering: swapoff /dev/xvda2 (or what corresponds to your setup)
fdisk /dev/xvda (or what corresponds to your setup)
press p + enter so see the whole disksetup
delete the second swap partition by entering d + enter and then 2 + enter
delete the system partion by entering d + enter and then 1+enter
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
recreate the swap partition (with n <enter> p <enter> 2 <enter> and appropriate values
chance the partition type of partition 2 to swap by pressing: t <enter> 2 <enter> 82 <enter>
exit fdisk by pressing w <enter>
execute: mkswap /dev/xvda2 to make the swap space ready
reboot domU
execute: resize2fs /dev/xvda1
Be aware that if you have a different partition schema this would not work!
after looking someusefullguides 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)
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
exclude=*-debuginfo
gpgcheck=0
obsoletes=1
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
reposdir=/dev/null
metadata_expire=1800
[base]
name=CentOS-5.3 – Base
baseurl=http://mirror.centos.org/centos/5.3/os/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
protect=1
#released updates
[update]
name=CentOS-5.3 – Updates
baseurl=http://mirror.centos.org/centos/5.3/updates/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
protect=1
#packages used/produced in the build but not released
[addons]
name=CentOS-5.3 – Addons
baseurl=http://mirror.centos.org/centos/5.3/addons/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
[extras]
name=CentOS 5.3 Extras $releasever – $basearch
baseurl=http://mirror.centos.org/centos/5.3/extras/i386/
enabled=1
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
turn on networking editing file /mnt/ec2-fs/etc/sysconfig/network
NETWORKING=yes
copy your resolv.conf, when boot from AWS DHCP was used
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 /root/.ssh/authorized_keys or read the following step if you prefer to use the AWS assigned key-pair
create the file /usr/local/sbin/get-aws-credentials.sh (have you installed curl? is needed for this script)
#!/bin/sh
if [ ! -d /root/.ssh ] ;
then mkdir -p /root/.ssh
chmod 700 /root/.ssh
fi
# Fetch public key using HTTP
curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/my-key
if [ $? -eq 0 ] ;
then
cat /tmp/my-key >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
rm -f /tmp/my-key
fi
make it executable
chmod +x /usr/local/sbin/get-aws-credentials.sh
add it to /etc/rc.local
# get AWS credentials
/usr/local/sbin/get-aws-credentials.sh
chroot into your image
chroot /mnt/ec2-fs /bin/bash
start your services at desired run level
chkconfig --level 345 sshd on
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?
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 .
Hi, Saturday 22 I’d had a crash with my motorbike. A man in a car changed his lane and I cannot was able to dodge it. The result was a fall to the ground without any serious damage for me and my girlfriend (a lot of contusions for both), thanks to our equip; but the bike was not well, probably the chassis is deformed and there are a lot of other issues (like front suspension, radiator and many parts). I’m sad for it but happy for our skin and bones .
Hi, as usual I don’t blog so much, so I’m here to write about some last news.
From Jan 14th I don’t work anymore with Sourcesense, now I work with Phiware, a young and funny company placed in Lugano. It was sad for me go away from Pronetics/Sourcesense after many years together, but this is the life…
My hosting (Aruba) sucks, I’m planning to move on Servage, if you want to suggest me another please add a comment.
Hi people,
in the last months I was very busy and the time for blogging was not so much, so now I force myself to write a little resume:
from May I work with HippoCMS, this is a Cocoon based CMS and use WebDAV (Slide) for content’s storage. After this time working on it I can say that the product is good and simple, optimal for a non-too-much-complex site and with a good and friendly user interface.
during August I work for a little project in RoR; I never wroted any ruby line before that and the curiosity for this framework was very high. After all my impression is that RoR is a really good framework for creating little site with many CRUDs, but the sintax not make me enthusiast and the not so strictly rules put a lot of confusion into my brain.
for my holiday I was in Sharm el Sheikh, the travel was not expansive (yeah, a really last minute on the web), I made many snorkeling sessions and it was really, really, really spectacular. I hope to came back there sooner or later.
this year the annual CocoonGT was made in Rome, the venue was the wonderful Bioparco, that was a funny week and many thanks go to the main promoters (Sourcesense, Semeru, Hippo). Here you can browse some photo.
in the last 3 weeks I cannot browse anymore my photo album, I receive a strange Fatal Error by php but I cannot see any error into the logs. My provider does not support me so much and I don’t have so much time to investigate furthermore.