Archive for August, 2009

Expanding a xen disk image’s space

Wednesday, August 12th, 2009

I documented this a while back and never posted it. Had to use it again today so I figured it would be fun to post it.

Compiled these steps using these urls:

http://www.mail-archive.com/centos@centos.org/msg08928.html

http://www.howtoforge.com/linux_resizing_ext3_partitions_p2

1. use dd to create a 1 GB file

[root@virtserver os]# cd /var/lib/xen/images/os
[root@virtserver os]# dd if=/dev/zero of=Tempfile bs=1024 count=1000000

3.  backup your disk image

[root@virtserver os]# cp somehost.example.com-disk0 somehost.example.com-disk0.bkup

4.  append the tmp file to virtual image file

cat Tempfile >> somehost.example.com-disk0

5. attach to the disk image

[root@virtserver os]# modprobe xenblk
[root@virtserver os]# pwd
/var/lib/xen/images/os
[root@virtserver os]# xm block-attach 0 ‘file:/var/lib/xen/images/os/somehost.example.com-disk0′ xvda w

if you try and mount a file that doesn’t exist you’ll get output like this:

Error: Device 51712 (vbd) could not be connected.
File /var/lib/xen/images/os/notreal.example.com-disk0 is read-only, and so I will not
mount it read-write in a guest domain.
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode>

Create a new virtual block device.

if you copy and paste you may have to fix your single quotes. when I copy and pasted this I got a weird ascii error.

6. fsck

[root@virtserver os]# e2fsck -f /dev/xvda1
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/boot: 42/524288 files (2.4% non-contiguous), 28805/524112 blocks

[root@virtserver os]# e2fsck -f /dev/xvda2
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/: 43523/2097152 files (0.9% non-contiguous), 487769/2096482 blocks

7. Strip out the ext3 fournal

[root@virtserver os]# tune2fs -O^has_journal /dev/xvda1
tune2fs 1.39 (29-May-2006)

[root@virtserver os]# tune2fs -O^has_journal /dev/xvda2
tune2fs 1.39 (29-May-2006)

8. delete and re-add the last partition on the disk using the new end cylinder

[root@virtserveros]# fdisk /dev/xvda

The number of cylinders for this disk is set to 1156.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/xvda: 9514 MB, 9514450944 bytes
255 heads, 63 sectors/track, 1156 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1         261     2096451   83  Linux
/dev/xvda2             262         783     4192965   83  Linux

Command (m for help): d
Partition number (1-4): 2

Command (m for help): p

Disk /dev/xvda: 9514 MB, 9514450944 bytes
255 heads, 63 sectors/track, 1156 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1         261     2096451   83  Linux

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (262-1156, default 262):
Using default value 262
Last cylinder or +size or +sizeM or +sizeK (262-1156, default 1156):
Using default value 1156

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

8. fsck and recreate the ext3 journals

[root@virtserver os]# e2fsck /dev/xvda2
e2fsck 1.39 (29-May-2006)
/: clean, 62190/1048576 files, 860683/1048241 blocks

[root@virtserver os]# tune2fs -j /dev/xvda2
tune2fs 1.39 (29-May-2006)
Creating journal inode: done
This filesystem will be automatically checked every -1 mounts or
0 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@virtserver os]# tune2fs -j /dev/xvda1
tune2fs 1.39 (29-May-2006)
Creating journal inode: done
This filesystem will be automatically checked every -1 mounts or
0 days, whichever comes first.  Use tune2fs -c or -i to override.

9. Resize the filesystem

[root@virtserver os]# resize2fs -f /dev/xvda2
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/xvda2 to 1797271 (4k) blocks.
The filesystem on /dev/xvda2 is now 1797271 blocks long.

10. detach the disk image and get on with your day with more space

[root@virtserver os]# xm block-detach 0 xvda

Google found JADDOG

Friday, August 7th, 2009

I was working on something for work that involved python and kerberos again. Very generic search looking for the docs I used last time I was implementing similar functionality. Something seemed familiar about the last result on the second page:

JaddogGoogle

I don’t feel so much like and island in nowhere land any more.

Experimenting with Railo

Thursday, August 6th, 2009

Coldfusion was the first programming language that actually did something with. I haven’t been writing it too much latley (yay django) but I still have code written in coldfusion that is faithfully running. I love open source and saw a while back that railo was going open source and being shipped with jboss. Went to the Railo site recently and found that Railo 3.1 had in fact been released so I thought I’d give it a spin. Rail 3.1 is downloadable with a copy of resin. I’d not ever heard of resin, seems like a lighter-weight java app server kind like jboss. Hope that’s not too far off base from what it really is. So here’s my experience getting Railo 3.1 to run on CentOS 5.3.

When you first download you need to compile… Found a post that said to download the railo-resin-no-jre and get sun’s jre, of course after I tried it with the jre and couldn’t get mod_coucho to compile. So in the root of what I unpacked (this assumes that you’ve installed things to build with):

$ ./configure –with-java-home=/usr/java/jre1.6.0_15

Got a warning on java JNI not existing. Couldn’t figure it out quicly but I think this is just performance related. Skipping it for now as I don’t need the performance yet. After configuring I ran make and make install. Going to use apache, the main compile didn’t seem to compile the apache module so did that. (this is the piece that failed when I tried to use the included jre) Also copied it to apache’s modules dir.

$ cd modules/c/src/apache2/
$ make all
$ cp .libs/mod_caucho.so /etc/httpd/modules

Now configure apache to use railo. I use virtual hosts heavily so went ahead a configured a couple to test with.

/etc/httpd/conf.d/railo.conf

LoadModule caucho_module modules/mod_caucho.so
DirectoryIndex index.cfm index.php index.htm index.html index.html.var
ResinConfigServer localhost 6800
<VirtualHost *>
ServerName site1.local
</VirtualHost>
<VirtualHost *>
ServerName site2.local
</VirtualHost>
<Location /caucho-status>
SetHandler caucho-status
</Location>

The resin config file had defaults that would use virtual hosting if you just create the proper directory structure. This is done in the root of what was unpacked.

$ mkdir -p hosts/site1.local/webapps/ROOT
$ mkdir -p hosts/site2.local/webapps/ROOT

I also stuck an index.cfm file in each root directory for testing… just a cfoutput with #now()# in it and a site identifier. The hosts/${domainname}/webapps/ROOT structure I think is the standard directory resin expects to do the virtual hosting. Finally start resin.

$ bin/httpd.sh start

I’ve used all the defaults here. There’s some docs on the virtual hosting stuff here. My next step is to integrate it with my existing server setup to see if I can customize this to the point I’d consider replacing AdobeCF with RailoCF. I’ve already tested a simple app written in CF7 on it. No problems.