Friday, 13 August 2010

LVM VolGroup00 not found (CENTOS)

UPDATE: I've had a similar problem on Ubuntu recently, look here if you are trying to fix a "udevadm trigger is not permitted while udev is unconfigured" error.

-----------

Had to fix this on a server at work. Scenario was that I used Clonezilla to convert a server to an image and then created a virtual server from that image. Because the hard disk drivers had changed the virtual system failed to boot with the above error followed by the dreaded "Kernel Panic". The solution requires us to rebuild our initrd image to suit the new disk architecture.

To start we need to boot from the Centos CD/DVD and into "Rescue system" mode. Follow the prompts until you end up at a shell prompt.

Now, chroot to your system boot;

chroot /mnt/sysimage

Change to your boot directory;

cd /boot

We need to take note of the kernel version that we will be making an image for, it will usually be the latest version. In my case it was 2.6.18-53.el5PAE We will be using this info later. Just do an ls of the directory to see all the installed images.


Once you have identified the correct initrd image, we probably should back it up.

mv initrd-2.6.18-53.el5PAE.img initrd-2.6.18-53.el5PAE.img.backup

Now, we can build a new initrd;

mkinitrd /boot/initrd-2.6.18-92.el5.img 2.6.18-53.el5PAE

Once the image has been built we should rebuild grub just in case.

grub-install /dev/sda

If your drive is on /dev/hda or something else entirely then substitute the correct value in the command above.


Remove the disc from the drive and exit.

exit

And with that your system should boot up happily!

Tuesday, 27 July 2010

Virtualisation Is Fun . . . .

. . . . Well, mostly.

I've been a big fan of virtualisation since about 2002. I started with VMWare GSX 2 on Redhat 7.2 and have been using VMWare server on Ubuntu for several years since. For the most part I've found that VMWare offers the stability and usability that I wanted for the typically small installations that I need.

Lately, however, I find I'm losing my enthusiasm for the product a bit.

Firstly, there are all the compatiblity problems that require workarounds with later versions of the kernel and other software packages.

1) Firefox 3.6+ does not work with the console plugin at all. Access to machine consoles requires a workaround. There is no console plugin available for Google Chrome.

2) You can't install vmware server on the later versions of the linux kernel without manually applying 3rd party patches.

3) There are no downloadable updates for the vmware guest tools packages. You need to download the latest version of VMWare Workstation and manually extract the "latest" versions from that.

4) There are other small bugs and glitches to do with web interface and there is no longer a standalone client app as there was with previous versions. The web interface also leaves much to be desired.

So, I have long been mulling moving to a different platform. I even made a concerted effort with Virtualbox with some success.

The point is that VMWare Server is not the only "free" (as in beer) product available, there is also their "Type 1" hypervisor called ESXi, so I thought I'd take a look at that.

I had tried ESXi in the past, but met a stumbling block where it was not compatible with the hardware I was using at the time. I have new hardware now, so I thought I might take a look at ESXi again.

Currently, the version of ESXi that is on the VMWare website is version 4.1. After reading up a bit, I discovered that ESXi does not include the dreaded Web Management Console any more. It requires a standalone application called vSphere Client, which is also a "free" download. Yay! Unfortunately however, the vSphere Client app is Windows only, there is no Linux version at all. Boo! Apparently it was written in .NET so it is locked into the Microsoft platform. There are indications that you may possibly be able to run it in Wine, but I'm not interested in any more dodgy workarounds so that won't work for me.

So, it looks like I will need to be looking at my options yet again.

Basically, there are two types of hypervisors, Type 1 and Type 2. Type 1 is known as a "bare metal" hypervisor, meaning the hypervisor runs directly on the server hardware. Type 2's are called "hosted" which means the hypervisor runs as an application on a host OS. VMware Server is type 2 where as ESXi is type 1. KVM and Xen describe themselves as Type 1 hypervisors but personally, technical distinctions aside, I think the case for both Xen and KVM being type 1 is fairly weak. If I can boot it up and get an otherwise complete Linux desktop then to me that makes it a type 2. Esoteric arguments about the hypervisor being built into the Linux kernel and therefore qualifying it as "bare metal" aren't entirely convincing to me. No matter though, as I don't really care that much as long as things work.

So, let's do a quick and dirty comparison of the "free" (as in beer) virtualisation products currently available (in no particular order).

1) VMWare Server 2 (Type 2)
Has been a reliable workhorse since the old GSX days but it hasn't seen much love for quite some time. I guess VMWare/EMC are focusing their energies elsewhere. VMware server also has paravirtualisation support so a more modern CPU with VT extensions is not absolutely required. Licence = Proprietary

2) VMware ESXi (Type 1)
This I guess is where the VMWare action is these days as all the ESX related management tools and other gubbins is where EMC makes their money. Unfortunately the complete lack of *nix based tools means it's a no go zone for any self respecting Linux geek. VT extensions are required and hardware compatibility issues are not uncommon. Licence = Proprietary

3) MS Hyper-V (Type 1)
It's a Microsoft product which isn't a good start. Nevertheless, I have read a bit about it and apparently it's a fairly basic hypervisor which doesn't have much in the way of decent management tools. Considering Microsoft's history and their penchant for slipping in hidden user lock-in "features" wherever possible and the general crappiness of their products (not to mention the company itself) I am quite hesitant to consider using this. Hyper V also requires VT extensions. Licence = Proprietary

4) Citrix XenServer (Type 1)
Xen is installed as part of a Linux OS so it is easy to mistake it for a Type 2 hypervisor. I was confused about this for some time but apparently since the hypervisor is part of the kernel then this qualifies it as a Type 1. Whatever. Citrix XenServer itself is payware, but there is a "time unlimited trial version" available from their website. There are also open source implementations of Xen including one in the Ubuntu repositories. XenCenter is their version of vSphere and it is, you guessed it, also Windows only. Sigh. I haven't yet tried Xen but one thing I'm concerned about is that all the "energy" in the OSS world right now seems to be in the KVM camp so the long term future of Xen is somewhat cloudy. I don't like the Windows only management centre either.Xen also requires CPU VT extensions. Licence = XOSL

5) Redhat KVM (Type 1)
There is some debate as to whether KVM is type 1 or 2 on the interwebs. My understanding is that it runs in a similar fashion to Xen so I guess that makes it officially a type 1? I have seen it described as a "Type 1.5" before though. Anyway, KVM is part of the RHEL stack, but being open source is available for most distributions. As mentioned before it is where all the action is at the moment so I intend to try KVM next. KVM used to require VT extensions, but last time I looked at it it offered the option to use QEMU for paravirtualisation. I'm not sure what the performance hit is however, the old QEMU I knew was a full x86 emulator and was pretty slow. I believe that this new QEMU also does paravirtualisation though so it may be OK. Stay tuned for more details! Licence = GPL/LGPL

6) Virtualbox (Type 2)
Originally from Innotek, taken over by Sun and now part of the Oracle juggernaut, Virtualbox comes in two flavours. Oracle VirtualBox is free (beer) whereas VirtualBox OSE is Free (as in freedom). However, the OSE version does not work "headless" so it is of no interest to those who want to virtualise servers like I do. I spent a couple of months battling VB and did manage to get things to work (mostly) but it is simply too messy to really use in a production environment. There are zero management tools. EVERYTHING is done via the command line. Now, I'm in no way afraid of the command line but there are some areas where being able to have a visual representation of the state of all the servers you are managing can make things infinitely easier to deal with. Having to type VBoxManage list runningvms at a console just to see what is currently up is cumbersome, especially with the totally unnecessary capitalisation. Automatically starting and stopping machines at shutdown is a pain to setup and if a guest gets its state confused then you are in for an absolute world of pain trying to convince it to forget being suspended and just start up from scratch already. In the end I had a machine that simply refused to start because it insisted that it had been suspended and I could not for the life of me get it to restart. Not being able to remove a guest from the database because "a drive is attached" is simply stupid. I am trying to remove the machine goddamit, I don't CARE that there is a drive attached. But no, you have to find the drive uid by typing in a bunch of cryptic commands. Determine which virtual IDE adaptor it is connected to by using even more cryptic commands, remove the drive from the specific adaptor it is attached to and only THEN can you actually unregister the machine. Why does it have to be so difficult? By all accounts VirtualBox makes a decent alternative to VMWare Workstation as far as running on the desktop. Running it in headless mode is a recipe for frustration. Do I sound bitter? Well, maybe a little. There is also the ongoing uncertainty as to what Oracle intends to do with VirtualBox, they haven't been particularly open source friendly in the past. License = PUEL

So there we go. Now I'm off to play around with KVM!

Monday, 19 July 2010

On Tablets and the Death Of Windows

Tablets are coming and with it we will witness the slow and agonizing death of the Windows / Office hegemony.

There can be no doubt that a significant portion of people will purchase a tablet in the next decade. At first it will be as an adjunct to their "traditional" PC and not as a replacement.

However, as their traditional PC's get older and the tablets get better more than a few non tech people will actively consider making a decision to buy just one or the other. Increasingly they will choose to forgo on the traditional PC in favour of some form of small form factor touchscreen alternative, probably with a bluetooth, keyboard + mouse equipped dock for using it on a desk.

Microsoft on the other hand have lost any clue they may have once had. The only thing they have is their bullying relationship with their OEM "Partners", their various user lock in technologies and the existing Windows + Office monopoly.

Before we go any further we must remember Microsoft's Rule #1.

Rule#1 is to protect the Windows + Office monopoly. Everything else is secondary.

To do that Microsoft cannot afford to introduce products that will tempt their customers away from their overpriced and under performing flagship bloatware, therefore any "Tablet OS" will be either a poor second cousin to the desktop products or else they will continue to be what they are today, which is basically the same laptop/desktop OS crowbarred onto an overweight, over heating "touchscreen laptop" sporting the same old fashioned point and click UI that they have been pushing for decades.

This has failed for them for the last decade, there is no reason to believe that it will be any less of a fail in the future.

So, assuming that Ballmer has less success at bullying his OEM's into killing the tablet market like he did for netbooks that will leave most people choosing between various tablets sporting iOS or some form of Linux.

This is a huge problem for Microsoft. The main thing that keeps them in their position of dominance is the Windows monoculture. Most non techy people simply believe that if you want to type a letter you need Office and if you want to use the internet you click on the "Blue E". Various lockin "features" (docx files, .NET, Silverlight) help to reinforce this behaviour and serve to make developers lazy. Why develop open products that can be used cross platform when 95% of users will run IE6 with Active X on Windows" was the status quo for half a decade until Firefox came along. Eventually, the growing numbers of people who were NOT using IE6 on XP reached a tipping point where developers were forced to wake up and stop actively reinforcing Redmonds iron grip on the Industry. The internet is a better place for it now.

So it will be for tablets. Apple has already shown the way. Microsoft will totally fail to keep up as it continues to try and protect its existing monopoly while the Linux upstarts will take up the remainder of the market.

Eventually we will reach another tipping point as developers are forced by the market to wean themselves away from their Visual Studio plus .Net addiction and Joe Public comes to understand that the Microsoft way is not, in fact, the only way and they can write letters to their grandkids perfectly well without the need for a bloated, over featured and expensive PC that requires constant attention, vigilance and third party security products just to keep it functioning.

I fully expect that within 5 years Microsoft will be relegated to corporate desks, and even there their dominance will be waning.

Thursday, 15 July 2010

FIx: util-linux error doing dist-upgrade on Ubuntu

This bug was first "introduced" in 10.04 Lucid but appears to have carried over to Natty, Maverick and Oneiric.

If you get this error;

Could not perform immediate configuration on 'util-linux'

then you have struck a bug in the packaging of util-linux. The problem is that util-linux depends on the upstart-job but that is not correctly defined in the package.

Install upstart-job manually;

sudo apt-get install upstart-job

When that is done you should be able to do a apt-get dist-upgrade again without problems.

Moving your home directories to a separate partition.

I always have my user homes on a separate partition.

This has a couple of advantages.

1) Frees up space on your root (/) partition.

2) Separates user homes from the OS. If you ever have to re-install the OS you don't lose all your user data.

In general, the steps are as follows;


!!!!! BACKUP YOUR SYSTEM OR YOU COULD LOSE EVERYTHING !!!!!


First, lets take a look around and see how the system is currently configured

We want to know what drives are currently mounted and where.

df -h

The main one you are interested in is the device where / is mounted.

It will probably be /dev/sdan but it may be something different.

Here is an example using sda1;
brettg@earth:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 11G 4.2G 6.4G 40% /
none 1.5G 296K 1.5G 1% /dev
none 1.5G 608K 1.5G 1% /dev/shm
none 1.5G 132K 1.5G 1% /var/run
none 1.5G 0 1.5G 0% /var/lock
none 1.5G 0 1.5G 0% /lib/init/rw


Note: If your root is not on /dev/sda1 then ensure you make a note of where it is mounted.


You will notice that I currently have only a single file system mounted, and that is root on sda1. (You can ignore all the "none" mounts they are used by the kernel)

Next is to identify a suitable place to mount /home.

Note: I will assume that your system has a single hard disk with some free space or an existing EXT partition. If you have a second hard disk then you will need to modify this procedure to suit your configuration!


Let's take a look at all the drives on my system.

sudo fdisk -l

This will show you all the current disks and partitions on your system. Here is mine;
Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00090790

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1459 11717632 83 Linux
/dev/sda2 1459 4623 25410560 83 Linux
/dev/sda3 4623 4866 1952768 82 Linux swap / Solaris


In my case I already have a suitable unmounted partition /dev/sda2. The third partition is (obviously) my swap partition.
Note: If the unused space on your target disk is shown as free space or is partitioned as something else (ie NTFS or FAT) then you will need to use gparted or fdisk to remove it and create a suitable EXT partition (ID=83).

! For Dogs sake ensure you know what is on the partition you are messing with, all data on the partition will be LOST FOR EVER !


Once you have created a suitable partition, mount it to a temporary mount point. I will use the /dev/sda2 from now on as the target. Let's temporarily mount it to /tmp/sda2.


sudo mkdir /tmp/sda2
sudo mount /dev/sda2 /tmp/sda2
cd /tmp/sda2


At this point you should be now looking at the existing contents of the partition. If this is an old partition you probably want to ensure that you do in fact want to delete all the files located here because after the next command there is no going back.

Once you have determined that you do in fact want to trash the contents of the partition type;
sudo rm -rf /tmp/sda2

Next we want to copy our existing home directories over to the new partition. Use this command;

sudo cp -rfvp /home/* /tmp/sda2/

Depending on how much data is in your home directory this may take some time to complete.

When it is done do a quick visual check to see that everything looks OK.

brettg@earth:~$ ls -al /tmp/sda1
total 16
drwxr-xr-x 3 root root 4096 2010-07-14 14:58 .
drwxr-xr-x 22 root root 4096 2010-07-14 16:33 ..
drwxr-xr-x 12 brettg users 4096 2010-02-12 08:55 brettg
drwxr-xr-x 26 andy users 4096 2010-02-12 09:39 andy


Compare this with your existing homes;
brettg@earth:~$ ls -al /home
total 16
drwxr-xr-x 3 root root 4096 2010-07-14 14:58 .
drwxr-xr-x 22 root root 4096 2010-07-14 16:33 ..
drwxr-xr-x 12 brettg users 4096 2010-02-12 08:55 brettg
drwxr-xr-x 26 andy users 4096 2010-02-12 09:39 andy


Both should be the same.

If all is ok you can now do the final steps, which is adding the drive to fstab.

I like to use a disks uuid rather than the physical device. It makes things much easier down the track when you want to move or add drives to your system.

Let's find the uuid of our new partition;

sudo blkid /dev/sda2

This will return something like this;

/dev/sda2: UUID="ee88bfd6-1a7e-486f-85ff-2f2e4c81bd6d" TYPE="ext4"

You want to select and copy the uuid string without the quotes.

Now, edit /etc/fstab

sudo vi /etc/fstab

Add a line like this;

UUID=ee88bfd6-1a7e-486f-85ff-2f2e4c81bd6d /home ext4 errors=remount-ro 0 1

making sure you use your own uuid.

Let's test to see if you can mount the new home partition.

sudo mount /home

If all goes well there should be no error returned.

Let's see if it is mounted;

brettg@earth:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 11G 4.2G 6.4G 40% /
/dev/sda2 25G 2.2G 23.7G 9% /home
none 1.5G 300K 1.5G 1% /dev
none 1.5G 608K 1.5G 1% /dev/shm
none 1.5G 132K 1.5G 1% /var/run
none 1.5G 0 1.5G 0% /var/lock
none 1.5G 0 1.5G 0% /lib/init/rw


As we can see above, /dev/sda2 is now mounted to /home

And that's it. All we need to do is reboot and make sure everything is working OK.

Note: Be aware that the original data in /home on /dev/sda1 is still there and taking up the same space as it was before. It is hidden underneath the mounted drive. Once you have determined that everything is OK, you might want to login as root, manually umount /home to make the old data reappear and then rm -rf the old data. Of course the normal caveats apply and you should make triple sure you are really deleting what you think you are deleting before hitting Enter

Always remember when messing with partitions and rm -rf IRREVERSIBLE DATALOSS IS POSSIBLE !!!!!


Good luck and take care . . .

Friday, 9 July 2010

CPU, RAM and Process Monitoring with HTOP

Here's a nifty alternative to good old "top"







It's called "htop"

You can install it with

sudo apt-get install htop

and simply enter htop on the command line to invoke it.