Archive for the ‘Linux’ Category

The best WordPress performance tip, ever.

Sunday, June 12th, 2011

If you’ve ever used WordPress to host a blog than you know that it is a very powerful platform. With a lot of power comes a lot of complexity. This complexity combined with the mandate that WordPress be easy to use/install/run combines to make for some interesting choices as it pertains to performance.

Recently I was tasked with building a high performance WordPress system for a user. I won’t bore you with all of the details but I will give you 1 tip that saved the day for me.

(more…)

How to: Install APF (advanced policy firewall) for Linux

Wednesday, March 9th, 2011

 

This article explains how to quickly install and configure APF (Advanced Policy Firewall) for Linux.

(more…)

Intel DH55TC – Linux/Virtualization tests

Thursday, January 14th, 2010

I recently had the chance to test out the brand spanking new Intel DH55TC motherboard with various Linux (and virtualization) operating systems for the purposes of network installation and compatibility actually surprised me.

(more…)

Plesk – SSL: Private key does not match the certificate public key

Thursday, January 14th, 2010

After enabling SSO, Plesk will not start with the error:

(network.c.377) SSL: Private key does not match the certificate public key, reason: error:0906D06C:PEM routines:PEM_read_bio:no start line /etc/sso/sso.pem

(more…)

Split a LVM2 Volume Group into two or more!

Friday, February 15th, 2008

We’ve all had that sinking feeling in our gut. The feeling when you realize that in a rush someone let CentOS, Fedora, or Redhat Linux auto-partition disks into one huge LVM2 mess. Until recently my answer would always simply be that its faster to reformat it and restore than try and reduce the volume group. That was until I had no choice.

I was absolutely horrified at the quality of information which was available to carry out what seems like a fairly mundane task. I am sure there are 300 different ways to do this exact same process but I needed a way that would work every time. (That is how I roll)

So about 10 or 15 completely destroyed file systems later, I share with you the fruit of my labor.

What this guide covers:

This guide covers shrinking a logical volume so that you can create more logical volumes, partitions and file systems.

What this guide does not cover:

Removing physical volumes from a Volume Group so that you can separate physical disks.

Warning: I would recommend following the guide below on a test machine prior to carrying it out on a production machine. Either way systemadminihater.com takes no responsibility for any damages caused by anything you do as a result of the instructions on this page, or any drinking games described on the other pages of this site.

Requirements:

–A Linux Rescue CD with LVM2 support (I used CentOS 5.1)

Steps:

Boot your system from your rescue CD.

I will assume that your current volume group is VolGroup00 and your current logical volume is VolGroup00. I will be creating a new logical volume LogVol02 for the sake of example.

#Activate the Logical Volume so that it becomes available.

lvm lvchange -ay /dev/VolGroup00/LogVol00

#Retrieve information about the file system you wish to shrink.

tune2fs -l /dev/mapper/VolGroup00-LogVol00

Make note of the:

Block Count: 60252160
Block Size: 4096 (4K)

My disk is a 250GB RAID-1 (60252160 4K Blocks) I am going to slice my logical volume in half because it is an easy example.

#Force FSCK to run on the logical volume you want to shrink

e2fsck -f /dev/VolGroup00/LogVol00

Resize the logical volume keep in mind that the number on the end represents 4K blocks! 30126080 x 4 = 120504320K / 1048576 = ~115GB

#Notice we give resize2fs its size in 4K blocks.

resize2fs /dev/VolGroup00/LogVol00 30126080

Multiply the number you used above by 4 (30126080 * 4) = 120504320 we give lvreduce its value in K so we can get exactly what we want.

#resize the file system.

lvm lvreduce –size 120504320K /dev/VolGroup00/LogVol00

#use vgdisplay to figure out available space

lvm vgdisplay

#below you see      extents /  space free

Free  PE / Size       3677 / 114.91 GB

#Create a new Logical Volume: LogVol02
#You can create a LV using many different options:
#–size 114G would’ve created a 114GB LV
#–extents 3677
#I used extents because it seems more exact.

lvm lvcreate –extents 3677 -n LogVol02 VolGroup00

#Create a new ext3 file system on LogVol02

mkfs.ext3 /dev/VolGroup00/LogVol02

Conclusion:

You now have two logical volumes where there used to be one!

Impress your friends, your co-workers, or maybe just yourself. Either way if you ever need to get your hands in LVM I hope this makes it easier.

-Drew

Boot Ghost via PXE/LAN

Tuesday, August 8th, 2006

Anyone with a large number of Windows hosts (or a small number of hosts and a small number of incompetent users) in their network should be familiar with Norton Ghost. If you are like me, and use Ghost anywhere from 3-6 times in a single day, breaking out floppy disks or CD-ROMs every time a box needs to be imaged can be tedious. This article describes how to create a network bootable Ghost environment. 

Norton Ghost is a product that I have had a love/hate relationship with ever since I began using the corporate edition of Ghost 8.0. It handles the imaging and restoration of Windows based PCs and servers perfectly, whilst the Linux support leaves entirely too much to be desired. Other commercial products such as Acronis TrueImage handle Linux much better from what I’ve seen, but is also prone to destroying the occasional boot loader or two (or all?).

If you’ve never used Norton Ghost, here is a little background on the process involved. First you configure a PC or Server to be your “master client”, then you use Ghost (I always used GhostCast) to create an “Image” of the hard drive (or drives) that system is based on. What this does for you is allows you to quickly restore to a consistent baseline without having to re-install Windows, download patches, re-secure everything, and et cetera. In essence, it saves a huge amount of time.

At my current place of employment we spin-up maybe 10 boxes in a single day, which means that we had to swap sets of ghost floppies (or CD-ROMs) each time we did this, and although it was not that big of a deal, occasionally having bad media at a critical point in a system rebuild is entirely unacceptable. This is where PXE comes in.

PXE, or Pre-eXcution Environment, (assuming you have a NIC created before 2001) allows your server or workstation to boot without any disk media what so ever, and you can boot just about anything you can imagine via PXE. Here is a brief synopsis of how PXE interacts with your system and network as a whole.

The workstation boots, if PXE is selected as a boot option the workstation attempts to obtain an IP address from a DHCP or BOOTP server on your network. If the server does obtain a DHCP or BOOTP IP address, it will then look for a certain flag that your DHCP server sends out saying “I want you to boot from this image”. The workstation then looks for another DHCP flag which tells it where to find the image in question, the workstation downloads the image, and attempts (you hope) to execute it.

I am a big proponent of open source technology, I wanted to use as many open source tools as I could to complete this project. The software that I used for this particular project is: ISC DHCP 3, pxelinux, Peter Anvin’s TFTPd-hpa, there are multiple open source TFTP daemons available, but this is the best one I could find. I must admit I did steer away from open source for one component of this project, as I used WinImage to create the single image from both of the Ghost boot floppies.

I installed all of these daemons on Centos 4.2, I ran Winimage on a Windows 2003 Server, and I also used the same Windows Server to create my Ghost media. I like CentOS because of the long support cycles for patches, the fact that it works 100X better than Fedora, and the fact that it had all of the daemons I needed compiled as RPMs.

You will need:
A Linux Server (Redhat, Fedora, Debian, CentOs, Enter favorite distribution here)
ISC DHCP 3.0
Syslinux (if you have linux, you likely have this already)
tftp-hpa
WinImage or another tool to create bootable images.
A Windows PC or Server from which to generate your boot image.
An old crappy workstation to test everything on.

Since I used CentOs 4.2 to construct my setup, I will assume everyone is using CentOS 4.2, and give commands related to that particular distribution; however the configuration files for all of the server related items mentioned should be distribution independant.

First lets install the daemons we need.

yum install dhcp
yum install tftp-server
yum install syslinux

You may or may not notice that by installing tftp-server a directory named tftpboot was placed in your root. This directory is where we will be storing most of our pertinent PXE files. Now we will finish setting up your PXE server.

cp /usr/lib/syslinux/pxelinux.0 /tftpboot
mkdir pxelinux.cfg

This moves the PXE loader to the appropriate location, and creates the configuration directory. We will come back to the PXE configuration later. Now we must configure ISC DHCP. DHCPD’s configuration file is /etc/dhcpd.conf on CentOS 4.2 and other Redhat Derivitives.

Here is an example /etc/dhcpd.conf

authoritative;
allow booting;
ddns-update-style none;
next-server 10.1.5.1;
default-lease-time -1;
filename “pxelinux.0″;
subnet 10.1.5.0 netmask 255.255.255.0 {
range 10.1.5.128 10.1.5.254;
}

Caution: You do NOT want to install ISC DHCP on a server that is in a network already running another DHCP server, funky results will occur.

The last thing to do (for now) is to ensure that tftpd, and DHCPd will start at boot time. You can achieve this a number of ways. I just use the command ntsysv which is included with all RedHat Derivitive distributions of Linux.

NOTE: I will assume you are using MS-DOS bootable media, and not PC-DOS, FreeDOS or any other kind of DOS.

Now onto WinImage; our specific example of Norton Ghost 8.0 creates either 2 1.44MB floppy disks, or a CD-ROM ISO for you to boot off of. Create a folder on your Windows machine called “Ghost” or whatever else you prefer, and copy the contents of both floppy disks into this folder. You need to edit the AUTOEXEC.BAT file in your “Ghost” folder. It should look like this:

@echo off
SET TZ=GHO+05:00
prompt $p$g
\net\netbind.com
MOUSE.COM
cd \ghost
GHOST.EXE -RB -SURE -QUIET
goto END
:END

I will note that you may want to modify your GHOST.EXE command-line as mine is set to automatically reboot, and not bother me about every little detail in the GhostCast Client.

NOTE: In order to do the next step, WinImage must be running in professional mode.

At this point you should have a Ghost folder which is roughly 1.7MB in size. Load up WinImage and tell it to create a 2.88MB floppy image. Insert the contents of the “Ghost” folder into this image and click on Image > Boot Sector Properties; Click on Windows 95/98 to ensure that this image is bootable. Save the image as whatever you prefer to call it, and exit WinImage. Copy the newly created image into the /tftpboot folder on your PXE server.

Now we must create a pxelinux configuration file. For now, we will just setup a default configuration file (which means that every DHCP client will recieve the same image from pxelinux).

cd /tftpboot/pxelinux.cfg

Create a file called default, mine looks like this:

label Ghost
kernel memdisk
append initrd=ghost.img

I am assuming that you have created a file called ghost.img in your /tftpboot folder, you will also need to copy the memdisk binary. Memdisk is software that allows you to boot just about any sort of disk image (as long as it is valid, and bootable).

cp /usr/lib/syslinux/memdisk /tftpboot

Ensure that dhcpd and tftp-server are running on your server machine.

service restart dhcpd

Note: Generally TFTP daemons run under inetd, or xinetd; so you will need to make sure that those helper daemons are allowing tftpd to run on your server. The configuration file for inetd is /etc/inetd.conf, and the configuration directory for xinetd is generally /etc/xinetd.d I wont spend too much time worrying about the configuration of inetd.conf, as most modern linux systems use xinetd.

The xinetd.d folder holds multiple configuration files; all of which you can enable or disable services with. You may need to edit /etc/xinetd.d/tftp to look something like this:

service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot -r blksize

Now comes the fun part, testing this bad boy out. Get that old Pentium 3 1GHz out of your garage, and set it up for network booting. Then Fire it up, if Norton Ghost’s DOS client or whatever else you want to network boot pops up on your screen you’ve done it. If not, post in the forums, and we’ll get you straightened out.

Enjoy your Network Booting Ghost machine!