Drush rpm for CentOS 5.5 (and probably others)

While looking at how to install drush for CentOS 5.5, I was amazed that there were no RPMs available. Luckily, someone did all the hard work and created a script to build the rpm here: http://www.workhabit.com/labs/drush-rpm-form

Using their script: http://www.workhabit.com/sites/default/files/rpm_build-drush.txt, which I am reproducing here:

view plain print about
1#!/usr/bin/perl
2# 20101012-1
3
4# This script packages Drush in binary .rpm form for easy installation. It
5# will automagically set up a proper environment for building RPMs in the
6# invoker's home directory. Note that the proper rpm building package
7# (rpm-build for RHEL or CentOS for example) must be installed. This script
8# also depends on basic utilities being available (tar, wget).
9#
10# Note that the resulting package has no actual dependencies; theoretically,
11# it should probably have dependencies on PHP. We're using non-standard PHP
12# packages and I'd like to make this script public, though. ;)
13#
14# Drush itself ends up in /usr/local/drush; a symlink for 'drush' is created
15# in /usr/bin. As per standard RPM building convention, this script should NOT
16# be run as the root user.
17#
18# Syntax is: rpm_build-drush (URL for drush version to package)
19#
20# Example: rpm_build-drush http://ftp.drupal.org/files/projects/drush-6.x-3.3.tar.gz
21
22### Global Variables
23# Change this to your organization/etc.
24my $packager = "Visible Systems Team";
25
26my $home = "$ENV{HOME}";
27my ($tarball, $version, $outrider);
28my @files;
29
30
31
32
33### Check for arguments
34if(@ARGV[0] eq "")
35{
36 print "Error: You must specify the URL of the drush package to download.\n";
37 exit 1;
38}
39
40
41
42
43### Grab pertinent version info
44# Get our actual package filename
45@ARGV[0] =~ m/(drush.+\.gz)$/;
46$tarball = $1;
47
48# Get our version
49$version = $tarball;
50$version =~ s/^drush-//;
51$version =~ s/\.tar\.gz$//;
52# - is invalid in RPM versioning; replace with _
53$version =~ s/-/_/g;
54
55
56
57
58### Set up our rpm building structure
59print "...Setting up build directories...\n";
60# Some of this is unnecessary given that we're creating a binary-only
61# package through unconventional means, but we might as well set up the
62# whole shebang.
63system("/bin/mkdir -p $home/rpmbuild/{BUILD,RPMS,S{OURCE,PEC,RPM}S}");
64# If .rpmmacros exists, back it up.
65if(-e "$home/.rpmmacros")
66{
67 system("cp $home/.rpmmacros $home/.rpmmacros.old");
68}
69system("echo -e \"\%_topdir\\t\$HOME/rpmbuild\" >
$home/.rpmmacros");
70if((system("mkdir -p /tmp/drush-$version/usr/local") >> 8) != 0)
71{
72 print "Error: Could not create temporary build root\n";
73 exit 2;
74}
75
76
77
78
79### Retrieve drush
80print "...Retrieving and unpacking drush...\n";
81# Retrieve
82if((system("wget -m -nd @ARGV[0] -P /tmp") >> 8) != 0)
83{
84 print "Error: Could not retrieve drush from @ARGV[0]\n";
85 exit 3;
86}
87# Unpackage
88if((system("tar -zxf /tmp/$tarball -C /tmp/drush-$version/usr/local/") >> 8) != 0)
89{
90 print "Error: Could not unpackage $tarball\n";
91 exit 4;
92}
93
94
95
96
97### Retrieve list of files included in the drush package
98@files = `find /tmp/drush-$version/usr/local/drush -type f`;
99
100
101
102
103### Write out our .spec file
104print "...Creating .spec file...\n";
105# Open the .spec file for writing
106open(SPEC, ">$home/rpmbuild/SPECS/drush-$version.spec") || die "Error: Could not open .spec file for writing.";
107print SPEC "Summary: drush\n";
108print SPEC "Name: drush\n";
109print SPEC "Version: $version\n";
110print SPEC "Release: 1\n";
111print SPEC "License: GPL v2\n";
112print SPEC "Vendor: http://drush.ws/about\n";
113print SPEC "Packager: $packager\n";
114print SPEC "Group: Development/Tools\n";
115print SPEC "BuildArch: noarch\n";
116print SPEC "BuildRoot: /tmp/drush-$version\n\n";
117print SPEC '%description' . "\n";
118print SPEC "drush - a command line shell and scripting interface for Drupal.\n\n";
119print SPEC '%prep' . "\n\n";
120print SPEC '%build' . "\n\n";
121print SPEC '%install' . "\n\n";
122print SPEC '%post' . "\n";
123print SPEC 'ln -s /usr/local/drush/drush /usr/bin/drush' . "\n\n";
124print SPEC '%postun' . "\n";
125print SPEC 'rm -f /usr/bin/drush' . "\n\n";
126print SPEC '%clean' . "\n\n";
127print SPEC '%files' . "\n";
128print SPEC '%defattr(-,root,root)' . "\n";
129# Now, drop our files in.
130for $outrider ( @files )
131{
132 $outrider =~ s/\/tmp\/drush-$version//;
133 print SPEC $outrider;
134}
135print SPEC "\n";
136print SPEC '%changelog' . "\n";
137close(SPEC);
138
139
140
141
142### Create our binary rpm.
143print "...Building binary RPM...\n";
144if((system("rpmbuild -bb $home/rpmbuild/SPECS/drush-$version.spec") >> 8) != 0)
145{
146 print "Error: Failed to create binary .rpm\n";
147 exit 5;
148}
149
150
151
152
153### Exit cleanly.
154print "\n\nBuild complete.\n";
155print "Your package should be available at $home/rpmbuild/RPMS/noarch/drush-$version-1.noarch.rpm\n\n";
156exit 0;

You will need perl and rpmbuild if you wish to build the packages:

view plain print about
1yum install perl rpm-build

Once you've got the right tools, you can build the latest ones from http://drupal.org/project/drush

view plain print about
1# perl rpm_build-drush.pl http://ftp.drupal.org/files/projects/drush-6.x-4.0-rc9.tar.gz
2...Setting up build directories...
3...Retrieving and unpacking drush...
4--2011-01-05 13:44:31-- http://ftp.drupal.org/files/projects/drush-6.x-4.0-rc9.tar.gz
5Resolving ftp.drupal.org... 140.211.166.134
6Connecting to ftp.drupal.org|140.211.166.134|:80... connected.
7HTTP request sent, awaiting response... 200 OK
8Length: 240870 (235K) [application/x-gzip]
9Server file no newer than local file `/tmp/drush-6.x-4.0-rc9.tar.gz' -- not retrieving.
10
11...Creating .spec file...
12...Building binary RPM...
13Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.56550
14+ umask 022
15+ cd /root/rpmbuild/BUILD
16+ exit 0
17Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.56550
18+ umask 022
19+ cd /root/rpmbuild/BUILD
20+ exit 0
21Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.56550
22+ umask 022
23+ cd /root/rpmbuild/BUILD
24+ /usr/lib/rpm/brp-compress
25+ /usr/lib/rpm/brp-strip
26+ /usr/lib/rpm/brp-strip-static-archive
27+ /usr/lib/rpm/brp-strip-comment-note
28Processing files: drush-6.x_4.0_rc9-1
29Requires(interp): /bin/sh /bin/sh
30Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
31Requires(post): /bin/sh
32Requires(postun): /bin/sh
33Requires: /usr/bin/env
34Checking for unpackaged file(s): /usr/lib/rpm/check-files /tmp/drush-6.x_4.0_rc9
35Wrote: /root/rpmbuild/RPMS/noarch/drush-6.x_4.0_rc9-1.noarch.rpm
36Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.38487
37+ umask 022
38+ cd /root/rpmbuild/BUILD
39+ exit 0
40
41
42Build complete.
43Your package should be available at /root/rpmbuild/RPMS/noarch/drush-6.x_4.0_rc9-1.noarch.rpm

Now we copy it to the current folder and install it

view plain print about
1cp /root/rpmbuild/RPMS/noarch/drush-6.x_4.0_rc9-1.noarch.rpm .
2yum --nogpgcheck localinstall drush-6.x_4.0_rc9-1.noarch.rpm

I built out the latest as of this writing 4.0 rpm, which is attached:
drush-6.x_4.0_rc9-1.noarch.rpm

Subversion svnserve "Could not obtain the list of SASL mechanisms"

I've decided to move our subversion repository to a new server. Put up a fresh install of CentOS 5.2 x32, updated and installed subversion on it.

Decided to set it up using svnserve with sasl, as 1.5 supports that. Following the SVN Book, I set up my svnserve.conf file as follows

view plain print about
1[general]
2anon-access = none
3auth-access = write
4realm = isf
5[sasl]
6use-sasl = true
7min-encryption = 128
8max-encryption = 256

I had set up the /etc/sasl/svn.conf file as follows

view plain print about
1pwcheck_method: auxprop
2auxprop_plugin: sasldb
3sasldb_path: /svn/sassl
4mech_list: DIGEST-MD5

Unfortunately, I kept getting the "Could not obtain the list of SASL mechanisms" error in TortoiseSVN and other clients. Nobody seemed to be able to help, until I finally figured it out - the DIGEST-MD5 plugin wasn't installed for cyrus by default on CentOS 5.2. All I had to do was run the following command and everything started working.

view plain print about
1yum install cyrus-sasl-md5

3ware 9690SA on CentOS 5.2 x86_64 with Xen

Apparently 9690SA support still didn't arrive in CentOS 5.2, so you still need some tricks to get it to work.

First download the driver disk from 3ware. If you are using a Xen kernel, you will need to get it from this knowledgebase article: http://www.3ware.com/KB/article.aspx?id=15399.

Extract the files and put them on a floppy. When installing linux you will need to type in 'linux dd' in the prompt when you boot off the CentOS 5.2 DVD/CD.

After installation, everything appears to be fine, but once you run yum update, and it updates the kernel, you will be unable to boot into the new kernel. We will need to do a few steps before it will work with a new kernel.

First, download the driver disk to your CentOS 5.2 box. (I couldn't get the URL off the page, so I FTPed the file over).

unzip the file:

view plain print about
1# unzip 208-3w-95xx-9650_9690_rhel5u2-kernel2.6.18-92.el5-installdisk-x86_64-9.5-GUID28bef5f421164b46ab5d859e5d957eea.zip
2Archive: 208-3w-95xx-9650_9690_rhel5u2-kernel2.6.18-92.el5-installdisk-x86_64-9.5-GUID28bef5f421164b46ab5d859e5d957eea.zip
3 inflating: modinfo
4 inflating: modules.alias
5 inflating: modules.cgz
6 inflating: modules.dep
7 inflating: modules.pcimap
8 inflating: pci.ids
9 inflating: pcitable
10 inflating: Readme
11 inflating: rhdd

Now we need to get the kernel modules out of modules.cgz.

view plain print about
1# zcat modules.cgz | cpio -ivd
22.6.18-92.el5
32.6.18-92.el5/x86_64
42.6.18-92.el5/x86_64/3w-9xxx.ko
52.6.18-92.el5xen
62.6.18-92.el5xen/x86_64
72.6.18-92.el5xen/x86_64/3w-9xxx.ko
81421 blocks

Since we are updating a regular kernel - not xen, we will use the 2.6.18-92.el5/x86_64/3w-9xxx.ko file.

view plain print about
1# cp 2.6.18-92.el5/x86_64/3w-9xxx.ko /lib/modules/2.6.18-92.1.6.el5/updates/

Now we need to make a new initrd

view plain print about
1# depmod 2.6.18-92.1.6.el5
2# cp /boot/initrd-2.6.18-92.1.6.el5.img /boot/initrd-2.6.18-92.1.6.el5.img.old
3# mkinitrd -v -f /boot/initrd-2.6.18-92.1.6.el5.img 2.6.18-92.1.6.el5
4Creating initramfs
5Looking for deps of module ehci-hcd
6Looking for deps of module ohci-hcd
7Looking for deps of module uhci-hcd
8Looking for deps of module ext3: jbd
9Looking for deps of module jbd
10Looking for driver for device sda2
11Looking for deps of module pci:v000013C1d00001005sv000013C1sd00001005bc01sc04i00: scsi_mod 3w-9xxx
12Looking for deps of module scsi_mod
13Looking for deps of module sd_mod: scsi_mod
14Looking for deps of module 3w-9xxx: scsi_mod
15Looking for deps of module ahci: scsi_mod libata
16Looking for deps of module libata: scsi_mod
17Looking for deps of module usb-storage: scsi_mod
18Looking for deps of module ide-disk
19Looking for deps of module dm-mod
20Looking for deps of module dm-mirror: dm-mod
21Looking for deps of module dm-zero: dm-mod
22Looking for deps of module dm-snapshot: dm-mod
23Using modules: /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/usb/host/ehci-hcd.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/usb/host/ohci-hcd.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/usb/host/uhci-hcd.ko /lib/modules/2.6.18-92.1.6.el5/kernel/fs/jbd/jbd.ko /lib/modules/2.6.18-92.1.6.el5/kernel/fs/ext3/ext3.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/scsi/scsi_mod.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/scsi/sd_mod.ko /lib/modules/2.6.18-92.1.6.el5/updates/3w-9xxx.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/ata/libata.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/ata/ahci.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/usb/storage/usb-storage.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/md/dm-mod.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/md/dm-mirror.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/md/dm-zero.ko /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/md/dm-snapshot.ko
24/sbin/nash ->
/tmp/initrd.RX6099/bin/nash
25/sbin/insmod.static -> /tmp/initrd.RX6099/bin/insmod
26`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/usb/host/ehci-hcd.ko' -> `/tmp/initrd.RX6099/lib/ehci-hcd.ko'
27`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/usb/host/ohci-hcd.ko' -> `/tmp/initrd.RX6099/lib/ohci-hcd.ko'
28`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/usb/host/uhci-hcd.ko' -> `/tmp/initrd.RX6099/lib/uhci-hcd.ko'
29`/lib/modules/2.6.18-92.1.6.el5/kernel/fs/jbd/jbd.ko' -> `/tmp/initrd.RX6099/lib/jbd.ko'
30`/lib/modules/2.6.18-92.1.6.el5/kernel/fs/ext3/ext3.ko' -> `/tmp/initrd.RX6099/lib/ext3.ko'
31`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/scsi/scsi_mod.ko' -> `/tmp/initrd.RX6099/lib/scsi_mod.ko'
32`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/scsi/sd_mod.ko' -> `/tmp/initrd.RX6099/lib/sd_mod.ko'
33`/lib/modules/2.6.18-92.1.6.el5/updates/3w-9xxx.ko' -> `/tmp/initrd.RX6099/lib/3w-9xxx.ko'
34`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/ata/libata.ko' -> `/tmp/initrd.RX6099/lib/libata.ko'
35`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/ata/ahci.ko' -> `/tmp/initrd.RX6099/lib/ahci.ko'
36`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/usb/storage/usb-storage.ko' -> `/tmp/initrd.RX6099/lib/usb-storage.ko'
37`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/md/dm-mod.ko' -> `/tmp/initrd.RX6099/lib/dm-mod.ko'
38`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/md/dm-mirror.ko' -> `/tmp/initrd.RX6099/lib/dm-mirror.ko'
39`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/md/dm-zero.ko' -> `/tmp/initrd.RX6099/lib/dm-zero.ko'
40`/lib/modules/2.6.18-92.1.6.el5/kernel/drivers/md/dm-snapshot.ko' -> `/tmp/initrd.RX6099/lib/dm-snapshot.ko'
41/sbin/lvm.static -> /tmp/initrd.RX6099/bin/lvm
42/etc/lvm -> /tmp/initrd.RX6099/etc/lvm
43`/etc/lvm/lvm.conf' -> `/tmp/initrd.RX6099/etc/lvm/lvm.conf'
44/sbin/dmraid.static -> /tmp/initrd.RX6099/bin/dmraid
45/sbin/kpartx.static -> /tmp/initrd.RX6099/bin/kpartx
46Adding module ehci-hcd
47Adding module ohci-hcd
48Adding module uhci-hcd
49Adding module jbd
50Adding module ext3
51Adding module scsi_mod
52Adding module sd_mod
53Adding module 3w-9xxx
54Adding module libata
55Adding module ahci
56Adding module usb-storage
57Adding module dm-mod
58Adding module dm-mirror
59Adding module dm-zero
60Adding module dm-snapshot

As you can see, it used our version of the 3w-9xxx.ko instead of the one that came with the kernel.

Now we reboot and see that it books successfully into the new kernel.

view plain print about
1# shutdown -r now

Now lets say that we have a xen kernel. Either by installing the stock xen or using the 3.2 version from my companion entry, now we need to update the 3w-9xxx.ko for that kernel as well, otherwise it won't boot. The steps are pretty similar, substituting the proper kernel version, we get:

view plain print about
1# cp 2.6.18-92.el5xen/x86_64/3w-9xxx.ko /lib/modules/2.6.18-92.1.6.el5xen/updates/

Now we need to make a new initrd

view plain print about
1# depmod 2.6.18-92.1.6.el5xen
2# cp /boot/initrd-2.6.18-92.1.6.el5xen.img /boot/initrd-2.6.18-92.1.6.el5xen.img.old
3# mkinitrd -v -f /boot/initrd-2.6.18-92.1.6.el5xen.img 2.6.18-92.1.6.el5xen
4Creating initramfs
5Looking for deps of module ehci-hcd
6Looking for deps of module ohci-hcd
7Looking for deps of module uhci-hcd
8Looking for deps of module ext3: jbd
9Looking for deps of module jbd
10Looking for driver for device sda2
11Looking for deps of module pci:v000013C1d00001005sv000013C1sd00001005bc01sc04i00: scsi_mod 3w-9xxx
12Looking for deps of module scsi_mod
13Looking for deps of module sd_mod: scsi_mod
14Looking for deps of module 3w-9xxx: scsi_mod
15Looking for deps of module ahci: scsi_mod libata
16Looking for deps of module libata: scsi_mod
17Looking for deps of module usb-storage: scsi_mod
18Looking for deps of module ide-disk
19Looking for deps of module dm-mod
20Looking for deps of module dm-mirror: dm-mod
21Looking for deps of module dm-zero: dm-mod
22Looking for deps of module dm-snapshot: dm-mod
23Using modules: /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/usb/host/ehci-hcd.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/usb/host/ohci-hcd.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/usb/host/uhci-hcd.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/fs/jbd/jbd.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/fs/ext3/ext3.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/scsi/scsi_mod.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/scsi/sd_mod.ko /lib/modules/2.6.18-92.1.6.el5xen/updates/3w-9xxx.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/ata/libata.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/ata/ahci.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/usb/storage/usb-storage.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/md/dm-mod.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/md/dm-mirror.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/md/dm-zero.ko /lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/md/dm-snapshot.ko
24/sbin/nash ->
/tmp/initrd.sW6636/bin/nash
25/sbin/insmod.static -> /tmp/initrd.sW6636/bin/insmod
26`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/usb/host/ehci-hcd.ko' -> `/tmp/initrd.sW6636/lib/ehci-hcd.ko'
27`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/usb/host/ohci-hcd.ko' -> `/tmp/initrd.sW6636/lib/ohci-hcd.ko'
28`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/usb/host/uhci-hcd.ko' -> `/tmp/initrd.sW6636/lib/uhci-hcd.ko'
29`/lib/modules/2.6.18-92.1.6.el5xen/kernel/fs/jbd/jbd.ko' -> `/tmp/initrd.sW6636/lib/jbd.ko'
30`/lib/modules/2.6.18-92.1.6.el5xen/kernel/fs/ext3/ext3.ko' -> `/tmp/initrd.sW6636/lib/ext3.ko'
31`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/scsi/scsi_mod.ko' -> `/tmp/initrd.sW6636/lib/scsi_mod.ko'
32`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/scsi/sd_mod.ko' -> `/tmp/initrd.sW6636/lib/sd_mod.ko'
33`/lib/modules/2.6.18-92.1.6.el5xen/updates/3w-9xxx.ko' -> `/tmp/initrd.sW6636/lib/3w-9xxx.ko'
34`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/ata/libata.ko' -> `/tmp/initrd.sW6636/lib/libata.ko'
35`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/ata/ahci.ko' -> `/tmp/initrd.sW6636/lib/ahci.ko'
36`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/usb/storage/usb-storage.ko' -> `/tmp/initrd.sW6636/lib/usb-storage.ko'
37`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/md/dm-mod.ko' -> `/tmp/initrd.sW6636/lib/dm-mod.ko'
38`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/md/dm-mirror.ko' -> `/tmp/initrd.sW6636/lib/dm-mirror.ko'
39`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/md/dm-zero.ko' -> `/tmp/initrd.sW6636/lib/dm-zero.ko'
40`/lib/modules/2.6.18-92.1.6.el5xen/kernel/drivers/md/dm-snapshot.ko' -> `/tmp/initrd.sW6636/lib/dm-snapshot.ko'
41/sbin/lvm.static -> /tmp/initrd.sW6636/bin/lvm
42/etc/lvm -> /tmp/initrd.sW6636/etc/lvm
43`/etc/lvm/lvm.conf' -> `/tmp/initrd.sW6636/etc/lvm/lvm.conf'
44/sbin/dmraid.static -> /tmp/initrd.sW6636/bin/dmraid
45/sbin/kpartx.static -> /tmp/initrd.sW6636/bin/kpartx
46Adding module ehci-hcd
47Adding module ohci-hcd
48Adding module uhci-hcd
49Adding module jbd
50Adding module ext3
51Adding module scsi_mod
52Adding module sd_mod
53Adding module 3w-9xxx
54Adding module libata
55Adding module ahci
56Adding module usb-storage
57Adding module dm-mod
58Adding module dm-mirror
59Adding module dm-zero
60Adding module dm-snapshot

Now we reboot, and it should boot sucessfully into xen.

3ware 9690SA on CentOS 5.1 x86_64 with Xen

9690SA Support doesn't come with the distribution until CentOS 5.2, so for 5.1 you will need some tricks to get it to work.

First download the driver disk from 3ware. If you are using a Xen kernel, you will need to get it from this knowledgebase article: http://www.3ware.com/KB/article.aspx?id=15257.

Extract the files and put them on a floppy. When installing linux you will need to type in 'linux dd' in the prompt when you boot off the CentOS 5.1 DVD/CD.

After installation, everything appears to be fine, but once you run yum update, and it updates the kernel, you will be unable to boot into the new kernel. We will need to do a few steps before it will work with a new kernel.

First, download the driver disk to your CentOS 5.1 box. (I couldn't get the URL off the page, so I FTPed the file over).

unzip the file:

view plain print about
1# unzip 191-3w-95xx-9650_9690_rhel5-kernel2.6.18-53.EL5-installdisk-x86_64-9.5-GUID083205f49ac341bc980c5c58ff4f1bc0.zip
2Archive: 191-3w-95xx-9650_9690_rhel5-kernel2.6.18-53.EL5-installdisk-x86_64-9.5-GUID083205f49ac341bc980c5c58ff4f1bc0.zip
3 inflating: modinfo
4 inflating: modules.alias
5 inflating: modules.cgz
6 inflating: modules.dep
7 inflating: modules.pcimap
8 inflating: pci.ids
9 inflating: pcitable
10 inflating: Readme
11 inflating: rhdd

Now we need to get the kernel modules out of modules.cgz.

view plain print about
1# zcat modules.cgz | cpio -ivd
22.6.18-53.el5
32.6.18-53.el5/x86_64
42.6.18-53.el5/x86_64/3w-9xxx.ko
52.6.18-53.el5xen
62.6.18-53.el5xen/x86_64
72.6.18-53.el5xen/x86_64/3w-9xxx.ko
81419 blocks

Since we are updating a regular kernel - not xen, we will use the 2.6.18-53.el5/x86_64/3w-9xxx.ko file.

view plain print about
1# cp 2.6.18-53.el5/x86_64/3w-9xxx.ko /lib/modules/2.6.18-53.1.21.el5/updates/

Now we need to make a new initrd

view plain print about
1# depmod 2.6.18-53.1.21.el5
2# cp /boot/initrd-2.6.18-53.1.21.el5.img /boot/initrd-2.6.18-53.1.21.el5.img.old
3# # mkinitrd -v -f /boot/initrd-2.6.18-53.1.21.el5.img 2.6.18-53.1.21.el5
4Creating initramfs
5Looking for deps of module uhci-hcd
6Looking for deps of module ohci-hcd
7Looking for deps of module ehci-hcd
8Looking for deps of module ext3: jbd
9Looking for deps of module jbd
10Looking for driver for device sda2
11Looking for deps of module pci:v000013C1d00001005sv000013C1sd00001005bc01sc04i00: scsi_mod 3w-9xxx
12Looking for deps of module scsi_mod
13Looking for deps of module sd_mod: scsi_mod
14Looking for deps of module 3w-9xxx: scsi_mod
15Looking for deps of module ahci: scsi_mod libata
16Looking for deps of module libata: scsi_mod
17Looking for deps of module usb-storage: scsi_mod
18Looking for deps of module ide-disk
19Looking for deps of module dm-mod
20Looking for deps of module dm-mirror: dm-mod
21Looking for deps of module dm-zero: dm-mod
22Looking for deps of module dm-snapshot: dm-mod
23Using modules: /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/usb/host/uhci-hcd.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/usb/host/ohci-hcd.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/usb/host/ehci-hcd.ko /lib/modules/2.6.18-53.1.21.el5/kernel/fs/jbd/jbd.ko /lib/modules/2.6.18-53.1.21.el5/kernel/fs/ext3/ext3.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/scsi/scsi_mod.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/scsi/sd_mod.ko /lib/modules/2.6.18-53.1.21.el5/updates/3w-9xxx.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/ata/libata.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/ata/ahci.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/usb/storage/usb-storage.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/md/dm-mod.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/md/dm-mirror.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/md/dm-zero.ko /lib/modules/2.6.18-53.1.21.el5/kernel/drivers/md/dm-snapshot.ko
24/sbin/nash ->
/tmp/initrd.fI5163/bin/nash
25/sbin/insmod.static -> /tmp/initrd.fI5163/bin/insmod
26copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/usb/host/uhci-hcd.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/uhci-hcd.ko' [elf64-x86-64]
27copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/usb/host/ohci-hcd.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/ohci-hcd.ko' [elf64-x86-64]
28copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/usb/host/ehci-hcd.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/ehci-hcd.ko' [elf64-x86-64]
29copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/fs/jbd/jbd.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/jbd.ko' [elf64-x86-64]
30copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/fs/ext3/ext3.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/ext3.ko' [elf64-x86-64]
31copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/scsi/scsi_mod.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/scsi_mod.ko' [elf64-x86-64]
32copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/scsi/sd_mod.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/sd_mod.ko' [elf64-x86-64]
33copy from `/lib/modules/2.6.18-53.1.21.el5/updates/3w-9xxx.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/3w-9xxx.ko' [elf64-x86-64]
34copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/ata/libata.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/libata.ko' [elf64-x86-64]
35copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/ata/ahci.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/ahci.ko' [elf64-x86-64]
36copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/usb/storage/usb-storage.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/usb-storage.ko' [elf64-x86-64]
37copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/md/dm-mod.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/dm-mod.ko' [elf64-x86-64]
38copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/md/dm-mirror.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/dm-mirror.ko' [elf64-x86-64]
39copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/md/dm-zero.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/dm-zero.ko' [elf64-x86-64]
40copy from `/lib/modules/2.6.18-53.1.21.el5/kernel/drivers/md/dm-snapshot.ko' [elf64-x86-64] to `/tmp/initrd.fI5163/lib/dm-snapshot.ko' [elf64-x86-64]
41/sbin/lvm.static -> /tmp/initrd.fI5163/bin/lvm
42/etc/lvm -> /tmp/initrd.fI5163/etc/lvm
43`/etc/lvm/lvm.conf' -> `/tmp/initrd.fI5163/etc/lvm/lvm.conf'
44/sbin/dmraid.static -> /tmp/initrd.fI5163/bin/dmraid
45/sbin/kpartx.static -> /tmp/initrd.fI5163/bin/kpartx
46Adding module uhci-hcd
47Adding module ohci-hcd
48Adding module ehci-hcd
49Adding module jbd
50Adding module ext3
51Adding module scsi_mod
52Adding module sd_mod
53Adding module 3w-9xxx
54Adding module libata
55Adding module ahci
56Adding module usb-storage
57Adding module dm-mod
58Adding module dm-mirror
59Adding module dm-zero
60Adding module dm-snapshot

As you can see, it used our version of the 3w-9xxx.ko instead of the one that came with the kernel.

Now we reboot and see that it books successfully into the new kernel.

view plain print about
1# shutdown -r now

Now lets say that we have a xen kernel. Either by installing the stock xen or using the 3.2 version from my companion entry, now we need to update the 3w-9xxx.ko for that kernel as well, otherwise it won't boot. The steps are pretty similar, substituting the proper kernel version, we get:

view plain print about
1# cp 2.6.18-53.el5xen/x86_64/3w-9xxx.ko /lib/modules/2.6.18-53.1.21.el5xen/updates/

Now we need to make a new initrd

view plain print about
1# depmod 2.6.18-53.1.21.el5xen
2# cp /boot/initrd-2.6.18-53.1.21.el5xen.img /boot/initrd-2.6.18-53.1.21.el5xen.img.old
3# mkinitrd -v -f /boot/initrd-2.6.18-53.1.21.el5xen.img 2.6.18-53.1.21.el5xen
4Creating initramfs
5Looking for deps of module uhci-hcd
6Looking for deps of module ohci-hcd
7Looking for deps of module ehci-hcd
8Looking for deps of module ext3: jbd
9Looking for deps of module jbd
10Looking for driver for device sda2
11Looking for deps of module pci:v000013C1d00001005sv000013C1sd00001005bc01sc04i00: scsi_mod 3w-9xxx
12Looking for deps of module scsi_mod
13Looking for deps of module sd_mod: scsi_mod
14Looking for deps of module 3w-9xxx: scsi_mod
15Looking for deps of module ahci: scsi_mod libata
16Looking for deps of module libata: scsi_mod
17Looking for deps of module usb-storage: scsi_mod
18Looking for deps of module ide-disk
19Looking for deps of module dm-mod
20Looking for deps of module dm-mirror: dm-mod
21Looking for deps of module dm-zero: dm-mod
22Looking for deps of module dm-snapshot: dm-mod
23Using modules: /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/usb/host/uhci-hcd.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/usb/host/ohci-hcd.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/usb/host/ehci-hcd.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/fs/jbd/jbd.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/fs/ext3/ext3.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/scsi/scsi_mod.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/scsi/sd_mod.ko /lib/modules/2.6.18-53.1.21.el5xen/updates/3w-9xxx.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/ata/libata.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/ata/ahci.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/usb/storage/usb-storage.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/md/dm-mod.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/md/dm-mirror.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/md/dm-zero.ko /lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/md/dm-snapshot.ko
24/sbin/nash ->
/tmp/initrd.Js4624/bin/nash
25/sbin/insmod.static -> /tmp/initrd.Js4624/bin/insmod
26copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/usb/host/uhci-hcd.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/uhci-hcd.ko' [elf64-x86-64]
27copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/usb/host/ohci-hcd.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/ohci-hcd.ko' [elf64-x86-64]
28copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/usb/host/ehci-hcd.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/ehci-hcd.ko' [elf64-x86-64]
29copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/fs/jbd/jbd.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/jbd.ko' [elf64-x86-64]
30copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/fs/ext3/ext3.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/ext3.ko' [elf64-x86-64]
31copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/scsi/scsi_mod.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/scsi_mod.ko' [elf64-x86-64]
32copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/scsi/sd_mod.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/sd_mod.ko' [elf64-x86-64]
33copy from `/lib/modules/2.6.18-53.1.21.el5xen/updates/3w-9xxx.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/3w-9xxx.ko' [elf64-x86-64]
34copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/ata/libata.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/libata.ko' [elf64-x86-64]
35copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/ata/ahci.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/ahci.ko' [elf64-x86-64]
36copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/usb/storage/usb-storage.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/usb-storage.ko' [elf64-x86-64]
37copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/md/dm-mod.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/dm-mod.ko' [elf64-x86-64]
38copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/md/dm-mirror.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/dm-mirror.ko' [elf64-x86-64]
39copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/md/dm-zero.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/dm-zero.ko' [elf64-x86-64]
40copy from `/lib/modules/2.6.18-53.1.21.el5xen/kernel/drivers/md/dm-snapshot.ko' [elf64-x86-64] to `/tmp/initrd.Js4624/lib/dm-snapshot.ko' [elf64-x86-64]
41/sbin/lvm.static -> /tmp/initrd.Js4624/bin/lvm
42/etc/lvm -> /tmp/initrd.Js4624/etc/lvm
43`/etc/lvm/lvm.conf' -> `/tmp/initrd.Js4624/etc/lvm/lvm.conf'
44/sbin/dmraid.static -> /tmp/initrd.Js4624/bin/dmraid
45/sbin/kpartx.static -> /tmp/initrd.Js4624/bin/kpartx
46Adding module uhci-hcd
47Adding module ohci-hcd
48Adding module ehci-hcd
49Adding module jbd
50Adding module ext3
51Adding module scsi_mod
52Adding module sd_mod
53Adding module 3w-9xxx
54Adding module libata
55Adding module ahci
56Adding module usb-storage
57Adding module dm-mod
58Adding module dm-mirror
59Adding module dm-zero
60Adding module dm-snapshot

Now we reboot, and it should boot sucessfully into xen.

Xen 3.2 on CentOS 5.1 x86_64 / RHEL 5.1 x86_64

Since my drivers are not signed, you will need to temporarily disable signature checking for yum.

view plain print about
1# vi /etc/yum.conf
Make sure it says gpgcheck=0

Download the file and untar it.

view plain print about
1# tar xvzf xen-3.2.0-CentOS5.1.tar.gz
2xen-3.2.0-CentOS5.1/
3xen-3.2.0-CentOS5.1/xen-devel-3.2.0-0xs.x86_64.rpm
4xen-3.2.0-CentOS5.1/xen-3.2.0-0xs.x86_64.rpm
5xen-3.2.0-CentOS5.1/xen-libs-3.2.0-0xs.x86_64.rpm
6
7# cd xen-3.2.0-CentOS5.1

Install the RPMs.

view plain print about
1# yum install -y xen-3.2.0-0xs.x86_64.rpm xen-libs-3.2.0-0xs.x86_64.rpm xen-devel-3.2.0-0xs.x86_64.rpm

It will download a bunch of dependencies and install them. Among them will be a new kernel - kernel-xen.

view plain print about
1# vi /etc/yum.conf
Set gpgcheck back to the old value: gpgcheck=1 if it was originally 1.

The only problem at this point is that yum for some reason doesn't update the boot entry, so we have to do this manually.

view plain print about
1# vi /boot/grub/menu.lst

view plain print about
1# grub.conf generated by anaconda
2#
3# Note that you do not have to rerun grub after making changes to this file
4# NOTICE: You have a /boot partition. This means that
5# all kernel and initrd paths are relative to /boot/, eg.
6# root (hd0,0)
7# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
8# initrd /initrd-version.img
9#boot=/dev/sda
10default=1
11timeout=5
12splashimage=(hd0,0)/grub/splash.xpm.gz
13hiddenmenu
14title CentOS (2.6.18-53.1.21.el5xen)
15 root (hd0,0)
16 kernel /xen.gz-2.6.18-53.1.21.el5
17 module /vmlinuz-2.6.18-53.1.21.el5xen ro root=/dev/VolGroup00/LogVol00
18 module /initrd-2.6.18-53.1.21.el5xen.img
19title CentOS (2.6.18-53.1.21.el5)
20 root (hd0,0)
21 kernel /vmlinuz-2.6.18-53.1.21.el5 ro root=/dev/VolGroup00/LogVol00
22 initrd /initrd-2.6.18-53.1.21.el5.img
23title CentOS (2.6.18-53.el5)
24 root (hd0,0)
25 kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00
26 initrd /initrd-2.6.18-53.el5.img

We want to update the CentOS (2.6.18-53.1.21.el5xen) entry, and set it to use the proper kernel - xen.gz-3.2

This is what my updated menu.lst looks like - yours may differ. I have also set the default to 0, so that it boots my xen kernel automatically.

view plain print about
1# grub.conf generated by anaconda
2#
3# Note that you do not have to rerun grub after making changes to this file
4# NOTICE: You have a /boot partition. This means that
5# all kernel and initrd paths are relative to /boot/, eg.
6# root (hd0,0)
7# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
8# initrd /initrd-version.img
9#boot=/dev/sda
10default=0
11timeout=5
12splashimage=(hd0,0)/grub/splash.xpm.gz
13hiddenmenu
14title CentOS (2.6.18-53.1.21.el5xen)
15 root (hd0,0)
16 kernel /xen.gz-3.2
17 module /vmlinuz-2.6.18-53.1.21.el5xen ro root=/dev/VolGroup00/LogVol00
18 module /initrd-2.6.18-53.1.21.el5xen.img
19title CentOS (2.6.18-53.1.21.el5)
20 root (hd0,0)
21 kernel /vmlinuz-2.6.18-53.1.21.el5 ro root=/dev/VolGroup00/LogVol00
22 initrd /initrd-2.6.18-53.1.21.el5.img
23title CentOS (2.6.18-53.el5)
24 root (hd0,0)
25 kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00
26 initrd /initrd-2.6.18-53.el5.img

Once you reboot you should automatically boot into the xen kernel and be able to create virtual machines.

Creating sparse files on Linux

Sometimes it's usefull to create sparse files on Linux. For example, when you're creating Xen hard disk images, creating a sparse file will take up much less space then creating a fully allocated file, and will only start taking up space as it fills up.

view plain print about
1dd if=/dev/zero of=filename.img bs=1k seek=128M count=1
This will create a sparse file of 128GB. Adjust the seek parameter to get the file size that you want.

If you need to find out the real space that the file is taking up, use du -lah

view plain print about
1# du -lah
220K ./filename.img
328K .

Using ls will only show you how big the file is supposed to be

view plain print about
1#ls -lah
2total 36K
3drwxr-xr-x 2 root root 4.0K Jun 5 13:59 .
4drwxr-xr-x 3 root root 4.0K Jun 5 13:59 ..
5-rw-r--r-- 1 root root 129G Jun 5 13:59 filename.img