Archive for the ‘Operating Systems’ Category

Restoring the contents of /dev

Sunday, July 18th, 2010

Have you ever deleted everything out of /dev by accident (or even on purpose)? Although it may seem that all is lost or that you have a lot of work ahead of you, it’s actually quite easy to restore on a modern Linux system such as CentOS 5 (or the RHEL equivalent).

The first thing you need to know is that CentOS and Red Hat use udevd, which means that the entries in /dev are dynamically created by the udev daemon and restarting this daemon will force it to re-create everything in /dev, just as it would when you start your computer up. This daemon isn’t controller in the normal way through the /etc/init.d scripts though, all you need to run is:

/sbin/start_udev

This will kill any copies of udev running and then start it back up, re-creating the /dev entries in the process. This seems to be quite safe to do on a production system, but it might be wise to only do this if you really have to, as if you haven’t damaged the contents of /dev, then some of your applications may not take kindly to the contents disappearing.

This will have re-created most of your device nodes in /dev, but there are still a couple of important ones missing, namely those used by device-mapper and LVM. You can get these back with the following two commands:

dmsetup mknodes
vgmknodes

The first of which will re-create entries under /dev/mapper and the second of which will re-create LVM volume group entries under /dev/ such as /dev/VolGroup00/ by default on CentOS or Red Hat.

Helpfully this will save someone a real headache or even rebuilding/restoring from backup unnecessarily. Just be more careful with rm next time! ;)

Re-open an accidentally closed tab in Safari 5.0

Saturday, July 3rd, 2010

Apple’s 5.0 release of the fantastic Safari web browser has introduced a feature I’ve been waiting for since discovering it several years ago in a somewhat unstable third party plugin who’s name escapes me and which has been in Firefox for some time – the ability to re-open an accidentally closed tab.

When combined with the “Reopen Last Closed Window” and “Reopen All Windows from Last Session” items under the history menu, Safari now has all the features that I miss from Firefox for when I accidentally hit the cross or on the rare occasions when it just locks up (usually thanks to bloody Adobe Flash Player!).

To use this awesome new feature, just use the normal undo/redo buttons under the Edit menu.

Safari 5.0 also brings back the nice old school progress meter in the background of the address bar. :)

Retrieve the Dell PowerEdge Service Tag remotely from Windows or Linux

Saturday, June 19th, 2010

Have you ever wanted to get the Dell Service Tag from a PowerEdge machine that you don’t have physical access to? Well it’s actually quite easy as Dell make this available through the standardised Desktop Management Interface (otherwise known as DMI) framework, so you don’t even have to install any of Dell’s OpenManage tools to view it!

On a Linux system, you just need to run the following as root:

/usr/sbin/dmidecode -s system-serial-number

On a Windows box, you can accomplish the same thing from the command prompt with:

wmic bios get serialnumber

Both of these tools should be installed by default on the respective operating system. If you have some kind of super stripped down installation, then they are available from the vendor’s original media.

Intel VT Virtualisation Technology on Dell PowerEdge servers

Saturday, June 19th, 2010

Somewhat annoyingly, Dell seem to like to disable Intel’s VT (Virtualisation Technology, sometimes called VMX) in the BIOS on their Dell PowerEdge servers, which means that you can’t use the Xen hypervisor to virtualise Microsoft Windows Server without changing this setting, which requires a reboot of the server to take effect.
You can use omreport from the Dell OpenManage Server Administrator software to check whether or not you have Intel Virtualisation Technology enabled.
If you haven’t got OpenManaged Server Administrator installed, then you can enable the Dell yum repository for CentOS/Red Hat systems and install it with:

wget -q -O – http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash
yum -y install srvadmin-base
/opt/dell/srvadmin/sbin/srvadmin-services.sh start

Once you’ve got the Dell OpenManage Server Administrator services running, you can take a look at what processor is installed in your system and what the current BIOS settings are with:

omreport chassis processors
omreport chassis biossetup

The two attributes that you’re looking for are Processor Virtualization Technology (which needs to be enabled) and Demand-Based Power Management (which needs to be disabled).

If you need to change them, then you can do this with:

omconfig chassis biossetup attribute=cpuvt setting=enabled
omconfig chassis biossetup attribute=dbs setting=disabled

Once that's done, then verify the new settings by running omreport chassis biossetup again and then once you’ve rebooted the server you can start taking advantage of the hardware virtualisation provided by Intel’s Virtualisation Technology.

Netcat saves the day!

Wednesday, June 2nd, 2010

During a botched upgrade taking an old CentOS box form 5.2 to 5.5, I ended up with a system in such a state that /lib/libselinux.so.1 and /lib64/libselinux.so.1 no longer existed. This is a major problem as it basically stops pretty much every program from working, you can’t even use cp or ls any more!

With yum and RPM unusable, SFTP/SCP/SSH clients and servers out of action and unable to use FTP or wget I thought this box was toast and was going to need a reboot and a live CD to bring it back to life.

After nosying around the system for a while to see what programs I could still run, I discovered that I could still run rsync, but this turned out to be little use as I couldn’t get RSH, SSH or RSYNC network connections in or out of the server.

The last thing I could think of was good old netcat, so I fired it up on another server with a known good copy of libselinux.so.1 and piped /lib64/libselinux.so.1 into it, then with everything crossed I piped it back out on the dying server, and lo and behold it worked and I was able to use ls again!

On the server (source) machine:

cat /lib64/libselinux.so.1 | nc -l 3333

On the client (destination) machine:

nc x.x.x.x 3333 > /lib64/libselinux.so.1

Where x.x.x.x is the IP address of the server.

Cancelled yum transactions

Saturday, May 22nd, 2010

If you’ve ever aborted a yum update for any reason, you’ve probably come across messages warning of transaction errors, such as the following example during an update from CentOS 5.4 to CentOS 5.5 that got cancelled part way through:

Transaction Check Error:
file /usr/include/libdevmapper.h from install of device-mapper-1.02.39-1.el5.i386 conflicts with file from package device-mapper-1.02.32-1.el5.x86_64
file /usr/share/man/man8/dmsetup.8.gz from install of device-mapper-1.02.39-1.el5.i386 conflicts with file from package device-mapper-1.02.32-1.el5.x86_64

Error Summary
————-

At the very start of the yum output, after “Resolving Dependencies” you should also see message saying

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
The program yum-complete-transaction is found in the yum-utils package..

This is nice and easy to resolve thankfully, you just need to use the suggested yum-complete-transaction utilit, which as the message suggests, can be found in the yum-utils package package.
This works just like the main yum program, except you don’t need to give it any arguments like install or update, you just run it and it will finish any incomplete transactions. hopefully this will fix any broken or cyclic dependancies where an update has been cancelled part way through.

I did find it somewhat ironic when I ran “yum install yum-utils” to gain access to the yum-complete-transaction command, I received the same message to install yum-complete-transaction via the yum-utils package, as that is exactly what I was trying to do!
Luckily, you can still install the yum-utils package from the normal system yum repositories whilst you have an outstanding transaction so you don’t have to mess around with downloading the RPM and installing it yourself.

ditto 100% CPU usage in Mac OS X

Saturday, May 22nd, 2010

My MacBook Pro was starting to really drag it’s heels last night and a quick trip to the Activity Monitor revealed two copies of a process called “ditto” taking up 100% of the processor time on both cores!

The ditto program is a command line tool for copying files and merging directories as well as extracting archives. Earlier in the evening I had been trying to extract what appears to be a corrupted .ZIP file from the finder which had failed a couple of times as it contained a directory structure but wasn’t creating the directories. In the end I made the directories by hand and then extracted it from the command line with “unzip”.

It seems that each of the failed extractions from the finder with the BOMArchiveHelper system utility left the ditto process running, even when I force quit the crashed BOMArchiveHelper instance. From looking at the process hierarchy, the ditto processes were running directly under launchd so it makes sense that they wouldn’t have been killed with BOMArchiveHelper as they aren’t children of it.

Killing each of the ditto processes from the Activity Monitor returned by MacBook Pro to it’s normal responsive self. Just remember that killing a crashed process might not always get rid of everything that it has spawned!

yum install and weird architecture behaviour

Friday, April 23rd, 2010

I was just trying to accomplish what you would think was a relatively easy task – installing the PHP-GD package from the Atomic Rocket Turtle repository for 64bit CentOS 5 and ran into a slightly cryptic problem.

Running yum install php-gd simply produced a dependancy error

php-gd-5.2.13-1.el5.art.i386 from atomic has depsolving problems
–> Missing Dependency: libt1.so.5 is needed by package php-gd-5.2.13-1.el5.art.i386 (atomic)
Error: Missing Dependency: libt1.so.5 is needed by package php-gd-5.2.13-1.el5.art.i386 (atomic)
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.

A quick check that I’m using an up to date mirror along with a yum clean all to make sure nothing weird is happening leaves me back where I started, but a bit of digging later reveals that this is an interesting problem with yum on 64bit systems where it is trying to install the 32bit package and looking for 32bit dependancies. Forcing the install to be 64bit with yum install php-gd.x86_64 works first time :)

Sharing one keyboard and mouse between several Macs

Thursday, April 8th, 2010

If you have multiple computers, each with it’s own monitor then it can get really confusing having multiple keyboards and mice in front of you, not to mention somewhat disrupting to your workflow every time you have to change between them and reposition your hands appropriately.

Having a KVM switch can help with this, but only lets you use a single monitor at once.
There is a great bit of software for Windows and Linux called Synergy2 that lets you share the keyboard and mouse from one computer between multiple machines. Synergy does have a Mac OS X port, but in the author’s own words it is “incomplete”.

Fortunately, there is a great bit of donation-ware software for Mac OS X called “Teleport”. This essentially does the same thing as Synergy, but in a nice easy to use Mac preference pane with full zeroconf auto-discovery of other Teleport equipped Macs, certificates for authentication and the option of encryption. It can also synchronise the clipboard between two Macs.
Take a look at http://abyssoft.com/software/teleport/ to download it, and if you like it as much as me then I would encourage you to donate.

DomU kernel panic under Xen with R1Soft CDP agent

Sunday, March 28th, 2010

I ran into a weird problem on a freshly installed server today where one of the DomU virtual machines kept locking up with a kernel panic message:

BUG: soft lockup – CPU#1 stuck for 10s!

All of the other Xen DomU virtual machines running on the box were fine, so I was pretty sure it wasn’t a hardware bug. The only possible solutions that I could come up with were

  1. My somewhat aggressive stripping down of the Dom0 host
  2. Zimbra (as the Java process was always the one referenced as being stuck
  3. The kernel module for the R1Soft CDP backup agent that I had installed a few hours ago.

I’ve run Zimbra on a CentOS 5 Xen VM before (although not 5.4 admittedly), so didn’t think that would be the problem (anyway, user land software should never be able to cause a kernel panic – in theory at least ;-) )
Again, the other Xen DomU virtual machines were fine, so hopefully the configuration on the Xen Dom0 host machine itself shouldn’t be causing the problem.

Just to be safe, I updated the kernel-xen package from the default 2.6.18-164.el5 to the latest 2.6.18-164.15.1 which was only released a few days ago and doesn’t appear to be on all of the mirrors yet!
With this done and the virtual machine restarted I had to run r1soft-cki to load an updated kernel module for the R1Soft CDP backup agent and the virtual machine has been stable for several hours now. Fingers crossed it stays that way!