Posts tagged ‘centos’

It’s a free alternative to RedHat Enterprise. When I say alternative, I mean it’s a copy of it, as the GPL allows that! These guys do a great job. My vote for best distro for commercial use.

So if you are installing 5.4 somewhere, you might want to wait a few days and get 5.5.
It seems that the 5.5 iso doesn’t fit on a normal DVD, so it’s being split into two!

adjust to matched your jre install:

mkdir -p ~/.mozilla/plugins
cd ~/.mozilla/plugins
ln -s /usr/java
ln -s /usr/java/jre1.6.0_18/lib/amd64/

and then restart firefox.

Fairly straight forward

yum install dhcp
chkconfig dhcpd on
Create /etc/dhcpd.conf from samples
/etc/rc.d/init.d/dhcpd on
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 53 -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p udp --dport 53 -j ACCEPT

The example below allocates in the range –

open up the ports on your machine (careful to only open it up on the internal side if the machine is dual facing).
You could use system-config-securitylevel and add port 53 for TCP and UDP. If you are having problems getting an IP address, check that it’s eth0 (and not say eth1), and if that fails, briefly turn off the firewall while testing.

/etc/dhcpd.conf: you’ll need to edit this to put in the address of your gateway (router), and the ip addresses of your dns servers, and add in any fixed ip address computers at the bottom.

ddns-update-style none;
ddns-updates off;
option T150 code 150 = string;
deny client-updates;
one-lease-per-client false;
allow bootp;
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample

ddns-update-style interim;
ignore client-updates;

subnet netmask {

# — default gateway
option routers;
option subnet-mask;

option nis-domain “”;
option domain-name “”;

#enter IP addresses of your dns servers (from /etc/resolv.conf)
option domain-name-servers changeme.dns.server.ip, xx.yy,zz.aa;

#option time-offset -18000; # Eastern Standard Time
# option ntp-servers;
# option netbios-name-servers;
# — Selects point-to-point node (default is hybrid). Don’t change this unless
# — you understand Netbios very well
# option netbios-node-type 2;

range dynamic-bootp;
default-lease-time 21600;
max-lease-time 43200;

hardware ethernet 00:26:44:72:e9:15;

Lucky me, I need to upgrade yet another machine, and it’s my email server. LVM (which I am not a big fan), takes all of the drive by default, and so now I want to resize the volume to be much smaller, then install the new operating system on the same drive (in some of the free space).

Quick Answer:
1. boot rescue cd, don’t mount drives
2. run:

lvm vgchange -a y
e2fsck -f /dev/VolGroup00/LogVol00
resize2fs -f /dev/VolGroup00/LogVol00 100G
lvm lvreduce -L100G /dev/VolGroup00/LogVol00

More Detail:
First I looked to see how much space I’m using.

[root@au1 c]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 297673144  49140752 233167480  18% /
/dev/sda1               101086     61896     33971  65% /boot
tmpfs                  3109444         0   3109444   0% /dev/shm

so around 50G, kid of a shame because I normally allocate 50G for the installed OS. No worries, I decide to go with 100G. (It’s a 250G drive I think) – hmm… TODO: check it’s not a 300G or 500G drive. Damn, I think it’s 500G…

Insert rescue CD into drive (eg the normal install disk (CentOS 5.4 64bit)).
At the prompt type: linux rescue
and then “Skip” the mounting of the drives.

lvm vgchange -a y
e2fsck -f /dev/VolGroup00/LogVol00
resize2fs -p -f /dev/VolGroup00/LogVol00 100G
lvm lvreduce -L100G /dev/VolGroup00/LogVol00

e2fsck and resize2fs will probably take a long time. For me e2fsck was probably around 5 minutes. resize2fs is certainly longer than that and I won’t know how long as I forgot to add in the -p and I’m about to head out for lunch (Happy Birthday Paul!).

If the Logical volume can be unmounted, then you can do these things without the rescue cd.

after reboot:
[root@au1 c]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 101573920 49124416 48255200 51% /
/dev/sda1 101086 61896 33971 65% /boot
tmpfs 3109444 0 3109444 0% /dev/shm

I recently upgraded a machine to 64bit CentOS, and now the drives are running crazy slow. hdparm -t /dev/hda showed result like this:

Timing buffered disk reads:   14 MB in  3.18 seconds =   4.40 MB/sec
Timing buffered disk reads:   12 MB in  3.23 seconds =   3.72 MB/sec

And that was on a striped drive! (very slow, should be ~100MB/sec for 1 drive, ~180MB/sec for 2 drive stripe).

I had a similar problem with an SSD, and thought it odd that the drives appeared as /dev/hd?? instead of /dev/sd??. The solution is not to probe the IDE interfaces and you do this by adding ide0=noprobe ide1=noprobe to the kernel params. So now my entry in /etc/grub.conf looks like:

title CentOS (2.6.18-164.11.1.el5) No Probe
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-164.11.1.el5 ro root=LABEL=/ ide0=noprobe ide1=noprobe
initrd /boot/initrd-2.6.18-164.11.1.el5.img

When making such a change, check your /etc/fstab to make sure that it’s not going to load /dev/hd?? since now the drives will change to /dev/sd??. And possibly they might get renumbered (probably thanks to the CD drive). So mine went from /dev/hda -> /dev/sda and /dev/hdc -> /dev/sdb

An earlier post will show that I setup a raid using /dev/hda3 and /dev/hdc1, so I recreated the strip with:

mdadm --stop /dev/md0
mdadm -A /dev/md0 /dev/sda3 /dev/sdb1
#add entry back into /etc/fstab
mount /dev/md0
echo 'DEVICES /dev/hda3 /dev/hdc1 /dev/sda3 /dev/sdb1'  > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf

reboot to test (consider commenting out /dev/md0 in /etc/fstab first).

so after all is fixed up hdparm shows much much better results.

hdparm -t /dev/sda

Timing buffered disk reads:  320 MB in  3.01 seconds = 106.16 MB/sec
Timing buffered disk reads:  320 MB in  3.00 seconds = 106.50 MB/sec

htparm -t /dev/md0

Timing buffered disk reads:  572 MB in  3.00 seconds = 190.41 MB/sec
Timing buffered disk reads:  592 MB in  3.01 seconds = 196.91 MB/sec

Certainly that is acceptable!

I wanted to upgrade my machine to 64bit CentOS at FastHosts. They said that it wasn’t supported, and they couldn’t upgrade my server until my contract runs out (in September – it’s now april). Wow. Okay, unbelievable as that sounds, I press on, send them a firm, but still polite email asking how to I get this upgraded to 64bit. They recommend using eRIC. The instructions are okay, but there are a few missing points, so hence this post.

My server is a “DS650” which is a dual core 2.4Ghz machine. First note all the settings on your box. IP address(es), netmask, gateway and nameservers is a good start. Backup your stuff, since this will blow your files away 🙂

1. Setup a windows share (samba) with a CentOS iso on it. I tried using windows, and forwarding the ports, but it didn’t work. the eRIC share wouldn’t pick it up (even though I could mount it over the internet on a mac and a remote windows box). Anyway, the samba worked first time.

2. Log in to fasthosts

3. Click on Dedicated Servers (tab)

4. Click on the server that you want to upgrade.

5. Click on Remote KVM Access

6. Click Enable KVM Access

7. Click on the IP address after “Login Address”. (you should also note the link below “View your server Login Details” page that has the user pass that you need.  It’s under “Remote KVM details” on that page.

9. So as long as you have java installed on your computer: Login

10. Click on Virtual Media -> CD-ROM

11. Share host is the ip address of your machine that has the mapped drive (must be accessible on the internet), share name is the share name of the cdrom (eg “D” or “cdrom”), I had to enter my user and pass for that machine to get access to the share (depends on your share config… I tested with another computer first to ease the pain)

Path to image /centosnet.iso

click set

(Just a note here that I’m almost certain it was /centosnet.iso, but it might be without the /). And of course I downloaded that centos netinstall, copied it to my share as centosnet.iso.

Click Remote Control on the left, click KVM Console.

Now log into the server using this console and reboot the server, as soon as it comes up, hit F2 to go into the bios (although for some servers, it will be “DEL”, or perhaps “F8”).

I had a lot of problems with eRIC and typing (repeat characters) .. and I’ve seen this before with other systems. So just type very slowly (wait for the character to appear on the screen before typing the next one). Perhaps there is an option to turn off keyboard repeat?

Arrow down to Boot Options, hit enter, then arrow down to Boot Sequence

Hit Enter, and now move the CD-Rom up above BootManage PXE, Slot 0B20 (by using ‘-‘ key)

Hit escape a few times, and then save and Exit.

Then you get this:

and now it should boot from the cdrom (the mounted drive!). This could be really slow (for me it was around 50k/sec, not too bad, but wouldn’t want to do the 4G CENTOS install using that!).
Here is the CentOS install just starting:

Save and exit, and now it should boot from the cdrom (which might be really slow.. depending on the connectivity back to your mounted drive).

Woo hoo .. CentOS install screen:

I used “linux text” to do the install. This is because the local mouse was out of sync with the remote mouse, and it was incredibly painful.

Manual IP address:

Configure network:

HTTP Setup:
Web site name:
CentOS Directory: centos/5.4/os/x86_64

Setup starting:

As I mentioned earlier, the mouse was out of sync when using eRIC, so I chose to use the text install. But how cool is this? The installer now has a VNC option. So I chose it:

and then choose a VNC password:

I sometimes use a mac, and so to then it was a simple as “Apple-K” when in the finder to connect to something remote, and then enter
vnc://217.xx.yy.zz:5901 and click “Connect”

hmm: no encryption… fine with me…

and sure enough up comes the normal CentOS graphical installer:

And the rest is your normal install from there.

I ran into a problem where the drives were going 2mb/s (crazy slow), so long story short, add ide0=noprobe ide1=noprobe to kernel settings: eg in /etc/grub.conf

title CentOS (2.6.18-164.11.1.el5) No Probe
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-164.11.1.el5 ro root=LABEL=/ ide0=noprobe ide1=noprobe
initrd /boot/initrd-2.6.18-164.11.1.el5.img


After some significant pain, I setup linux dual boot for the mac, but what I really want is to sometimes boot into linux, and sometimes just access the linux from my macos.  So you think no worries, Parallels supports Boot Camp, just use that. Wrong.  For Parallels to use a file system it needs to be mountable by the mac. CentOS uses ext3, and by default the mac doesn’t support ext2/ext3.  So

  • Step 1. Install CentOS using Boot Camp.  (see here…) TODO
  • Step 2. Reboot into MacOS, and install Mac Fuse
  • Step 3. Install fuse-ext2 (see Mount Ext2/Ext3 file system from a mac)
  • Step 4. Create a new Parallels install using the custom settings and boot camp partition. Here are the step-by-step screen shots.

Create New Virtual Machine

Choose Boot Camp Partition, click Continue

Select Version: More Linux -> CentOS Linux

Click Continue

Virutal Machine Type: Click Custom

CPU and Memory Options: I like 1G of main memory, click continue

Hard Disk Options: choose Boot Camp Partition, click Continue

I only have one disk, but pick the right one, click Continue

I like Shared Networking (Recommended), click Continue

Optimize for Virtual machine (Recommended) seems like a good choice, after all if you want to optimize for the mac, then don’t run the virtual machine.  You can always change this later.

Pick a name and a location for the Virtual machine, click Create.

When you start up the vm .. done

And soon enough you see the CentOS linux running inside my mac.


I thought I’d be brave and just go ahead and install CentOS 5.4 linux on my macbook pro (late 2009 edition). Part of the thinking was that if I have problems, I’ll get to learn more about the macbook. I backed up my drive, and I plan to replace the drive with an SSD anyway, so I was feeling pretty fearless.

After a few tiny hiccups, It was installed (I decided not to install grub figuring it might mess with the boot loader (and I had already installed refit).  But reboot .. nothing .. just a dreaded error

No bootable device insert boot disk and press any key

I tried a few keys to see if I could get any kind of bios settings. Nadda. So a little googling, and holding down the “option” key when booting gave me a nice looking icon with Macintosh HD, so clicked on that, and bingo. Back in mac land. And then the mac continued to reboot just fine after that.

I imagine other people might have the same problems when installing Windows XP, vista or windows 7.  I also imagine that I did something not quite right.

When I hit refresh on eclipse, it frequently (almost all the time) will crash. I’m using CentOS 5.4, 64 bit linux (and no doubt this appears in other linux distributions as well). I have subversion installed.

For my website, I don’t particularly use eclipse, but I do like the visual aspect of merging back into subversion. (perhaps someone can suggest a better, or at least lighter tool).

Anyway, the fix is quite easy (thanks to someone elses pain).

Add the following to your eclipse.ini file:


So now my eclipse.ini file looks like this: