Archive for the 'Linux' Category

Mounting disks by label; A cautionary tale

I was migrating some data to some new disks and since the drive letters would be changing once the old disks were removed, I partitioned them and then gave them label names so they could be mounted by label.

The original disks had labels like:
boot
srv
tmp

On the new disks I thought good names would be:
/boot
/srv
/tmp

(I think Redhat actually names things this way by default?)

Anyhow, to make a long story short, mount by label ignores the leading slash. When the system rebooted, as predicted the drives came up in a different order so a “mount LABEL=srv” will actually mount the first disk named either “/srv” or “srv”.

Moral of the story; it’s probably a good idea not to use any strange characters when naming disks.

UPS Monitoring with SUSE. Quick & Dirty

I recently had the need to query a bunch of UPSes to gather their current statistics using openSUSE. The Network UPS Tools packages (NUT for short) are available for openSUSE and that’s all you need (assuming your UPS is one of the supported ones).

# zypper install nut

Next you need to edit /etc/ups/ups.conf and make an entry for your UPS driver and serial port.

[myups]
driver = bcmxcp
port = /dev/ttyUSB0
desc = “Local UPS”

Next I started the UPS driver manually in debug mode so I could see what was going on. The nice thing about this driver is it will auto-discover the UPS serial port speed.

# /usr/lib/ups/driver/bcmxcp -a myups -D

In a separate terminal window, start upsd.

# upsd

Now you should be able to query the UPS:

# upsc myups@localhost

Because I was just collecting statistics, I wasn’t interested in using upsd to automatically shutdown servers or anything fancy but that is possible.

SUSE 11.2 Tweak – Show all tasks on Gnome Panel

The Gnome desktop in OpenSUSE 11.2 is beautiful (much nicer than the clunky KDE IMHO), but there are a few things that I don’t like about the default settings. I use 8 virtual desktops to keep my desktop organized but I like the taskbar to show all tasks. By default, the gnome panel’s task bar shows only the windows in the current workspace and for some reason you can’t just right-click the panel to change this setting.

Instead, it’s buried in the Gnome Configuration Editor which makes it really hard to find so here are the steps to fix this:

1) Computer -> More Applications

2) System -> Gnome Configuration Editor

The setting that needs to be changed is:

3) /apps/panel/applets/window_list_screen0/prefs/display_all_workspaces

You can navigate down the tree or use the “Find” function.

That’s it! Have a lot of fun!

Update: see the first comment for an equally obscure but perhaps easier method.

SUSE Studio – First impression… WOW!

Someone finally took pity on me and sent me an invite for  SUSE Studio. My first impression – Wow!

SUSE Studio lets you build your own custom linux distribution using SUSE as the starting point. The process requires only a few mouse clicks and is so fast and simple any Geeko can do it ;)

Step 1: choose a starting point for your build. Options range from bare-bones (Just Enough OS) OpenSUSE 11, to a full blown SUSE Enterprise Server.

Step 2: Add additional packages. Of course the full SUSE package list is available which includes everything you would normally find on the DVD. But, you can add any repository from the internet including your own custom ones either uploaded as an RPM or downloaded automatically from your own site.

But the goodness doesn’t end there… All of the respositories from the SUSE build service are also avaialble. You’ll be hard pressed to find a package that isn’t already available in Studio giving unprecidented flexability for building custom appliances.

Step 3: Next you configure some basic options such as Language, Timezone, Networking, and the default users and groups.

Step 4: Overylay files. If you need to add some files to your distro, just tar them up and they will be automatically un-tared in the directory specified.

Step 5: Create your applicance. You can pick one of 4 target formats. USB/Disk image, ISO, VMWare/VirtualBox, or XEN. Then click “Build”.

It typically takes less than 5 minutes to build the appliance and when you’re done you are presented with 2 options: Test Drive, or Download.

Test drive is really neat. Your appliance launches right in your browser window. You can watch it boot up, login, and test things out. The full desktop is there! Really cool! You can go back at any time and make changes.

Once you’re satisfied with your appliance click the download link and you’re done!

SUSE Studio is truly amazing.

I have only one small dissapointment; it only supports x86 archetectures and I had wanted to use it to build a PPC appliance that would run on the Sony PS3. I suspect they’ll add support for other CPUs in the future. Afterall, most small appliances don’t run full blown processors.

SUSE Broken? Don’t fear the chroot !

SUSE hasn’t let me down very often but recently I had a bad experience while applying some updates to an OpenSUSE laptop. There were quite a few updates so I undocked the laptop so I could relax while they downloaded.

For reasons that I have not yet resolved, the wirless networking became unstable and as a result, the updates had to be aborted.

Unfortunately, a new kernel was part of the updates and when the laptop rebooted it was in a bad state. X windows wouldn’t start and critically, there were no network drivers for the new kernel. To make matters worse, OpenSUSE does not keep the old kernels in /boot (why is that?) so there was nothing to fall back on.

With nothing left to do, it was time to try rescue mode and in a few short steps I had the system fully working again. Here is what I did:

Step 1: boot to rescue mode (duh).

Step 2: mount your hard disk partitions under /mnt in the same layout they would be normally. For example:

# mount /dev/sda2 /mnt
# mount /dev/sda1 /mnt/boot

… etc.

Step 3: Next we need to make sure we have acess to all the important system resources.

# mount --bind /proc /mnt/proc
# mount --bind /sys /mnt/sys
# mount --bind /dev /mnt/dev

Step 4: We’re ready to chroot into our new environment.

# chroot /mnt

Step 5: We are now running on our system just as if we had booted to it and we can perform repairs. In my case all I needed to do was complete the updates:

# zypper up

I rebooted and everything was back to normal.

Is Redhat giving Linux a bad name?

RedHat put out a new release this week. Redhat Enterprise 5.4. Here is a summary of the important changes:

- Nothing

About all they could muster in their press release was driver updates and something about KVM replacing XEN. Yawn… KVM is arguable a backwards step over XEN at this point so my guess is the change has more to do with Citrix buying XEN than any real technical advantage.

Setting aside the KVM vs. XEN argument; When is RedHat going to do a major update on its “look & feel” ? The biggest difference from RH4 to RH5? The background color changed from blue to red. wow.

In fact, RedHat has not changed in any significant way since before RHEL 4. It still has the same horrendous system admin tools and awful menu layout. It is now been way surpassed by its competition, SUSE Linux Enterprise Server 11 (which has improved leaps and bounds since SLES 9), and upstarts like Ubuntu.

On top of that, the anaconda installer is a dog and I’m fairly certain FEMA could come up with a better “rescue mode” than the one on the RH5 media.

And the desktop? Come on Redhat! You’ve got to step up! You’re giving Linux a bad name. As a Linux advocate, I’d be flat-out embarrassed to put RedHat beside Windows7 or Mac OSX.

Yes it’s still Linux and yes it’s still stable and great in many ways, but Redhat must do better. Much much better.

Rogers Rocket Stick on OpenSUSE 11.1

Yes it works! (I was as surprised as anyone)

It didn’t take me long to get it working but google returns a lot of posts with not so good information so here is the documentation on my experience.

Detecting Interactive shells in bash

I was recently tasked with writing a bash shell script that behaved differently depending on if it was invoked interactively (by a user at the command line), or non-interactively (cron).

There are surprisingly few useful results returned by Google. Both the “Advanced Bash-Scripting Guide” and GNU Bash manual mention testing to see if the prompt variable is set:

if [ -z $PS1 ]

but that will not work. For one thing, it’s perfectly reasonable for someone to have their prompt set to null, but aside from that, the prompt variables are not set when invoking a script so the test always returns the same result.

A coworker pointed out that that strangely, “man bash” has other ideas. In the Conditional Expressions section, it explains “-t fd True if file descriptor fd is open and refers to a terminal.” That sounds exactly like what we want:

if [[ -t 0 ]] ; then
  echo interactive
else
  echo non-interactive
fi

but there is still a problem. If you invoke the script remotely via an ssh call (e.g. ssh root@<remotehost> bashscript.sh”),  stdin will not be connected to a terminal. To make the command more reliable we need one more test:

if [[ -t 0 || -S /dev/stdin ]] ; then
  echo interactive
else
  echo non-interactive
fi

Be aware that detecting a socket is also no proof of “interactivity”, but at least we are getting closer.

Expanding Linux software RAID1 with an ext3 File System

Yes it is possible to expand a software RAID1 device without loosing data. As a proof of concept we will create a small RAID1 device, then expand it. [read more]

Diagnosing Linux disk space usage

Ever wonder where all your disk space has gone? On this new page I describe some useful tips to locate the offending files.

Next Page »