Category Archives: linux

Logical Volume, wherefore art thou?

So you have a RedHat/CentOS host that has just been handed off to you.  The host has been configured by the previous admin to mount some storage from a SAN. How do you find out what is mapped where?

Normally to determine what is mapped where and the relevant usage you could use:

# df -h

This would give you something like the following output:

Filesystem Size Used Avail Use% Mounted on
/dev/sda3 233G 98G 124G 45% /
/dev/sda1 251M 46M 193M 20% /boot
tmpfs 48G 0 48G 0% /dev/shm
/dev/mapper/datasan_vg-datasan_lv 1.0T 218G 807G 22% /datasan
/dev/mapper/pglog_vg-pglog_lv 300G 193G 108G 65% /pglog
10.30.197.250:/vol/onesc_pglog/pg_dumps 238G 223G 15G 94% /backups/pg_dumps
10.30.197.250:/vol/onesc_pglog/pitr_backup 238G 223G 15G 94% /backups/pitr_backup

That’s all well and good. It shows you that you have two logical volumes datasan and pglog that are mounted on the root, but what if you needed to know more about those volumes?

To get more info on the volume groups, use the vgdisplay command:

# vgdisplay pglog_vg

— Volume group —
VG Name pglog_vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 11
VG Access read/write
VG Status resizable
Clustered yes
Shared no
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.99 GB
PE Size 4.00 MB
Total PE 76798
Alloc PE / Size 76797 / 299.99 GB
Free PE / Size 1 / 4.00 MB
VG UUID SrVfEk-e5fx-0x0i-WhXb-uqsM-Uh5S-FDcNeP

If you want more information on the logical volume(s) in that particular volume group:

# lvdisplay -m pglog_vg

— Logical volume —
LV Name /dev/pglog_vg/pglog_lv
VG Name pglog_vg
LV UUID wZBCcO-jGWW-LdkQ-Mbhl-Et8a-1sqC-5Ednj5
LV Write Access read/write
LV Status available
# open 1
LV Size 299.99 GB
Current LE 76797
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4

— Segments —
Logical extent 0 to 76796:
Type linear
Physical volume /dev/mpath/pglogp1
Physical extents 0 to 76796

Now that you know the physical volume(s) in the logical volume you can find out some details on the physical volume itself:

# pvdisplay /dev/mpath/pglogp1

— Physical volume —
PV Name /dev/mpath/pglogp1
VG Name pglog_vg
PV Size 300.00 GB / not usable 4.03 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 76798
Free PE 1
Allocated PE 76797
PV UUID CwxWYc-SjKX-KvPj-vJoq-i4dZ-2jzm-rHGNd1

Automating VMWare Tools reconfiguration

One of the pains that come with kernel updates in Linux is the necessity to rebuild vendor kernel modules or custom written kernel modules.

As time goes by many vendors are adding support for the Dynamic Kernel Module Support (DKMS) framework.  Recent releases of both the ATI Catalyst and the NVIDIA drivers support DKMS at some level.  VMWare is currently exploring this and you can turn it on (if you have DKMS support installed) however, it is still marked as experimental.

On my production servers we don’t encourage widespread use of experimental features so this has not been enabled with the VMWare Tools installation.  Unfortunately this means that during the patching process it is possible to lose network connectivity due to the need to rebuild the VMWare Tools configuration after a kernel update.

I found one solution to this on the LinuxDynasty site.  The problem with this particular method is that the file that is being checked for “not_configured” only gets written in a small set of circumstances.  In my case, the VM was partially configured, so this file wasn’t written.

Here is my alteration of the solution linked to above.

Update the code in the vmware-tools startup script

In the following file:

/etc/init.d/vmware-tools

Add the following line after the vmblockfusemntpt variable declaration

rebuild_tools="/etc/vmware-tools/rebuild_needed"

Then add the following line in the end of the start case for the service (around line 1370)

touch $rebuild_tools

Add the check code to the rc.local startup script

In the file

/etc/rc.local

Add the following to the end of the file

 rkernel=`uname -r`
if [ -e /etc/vmware-tools/rebuild_needed ]; then
echo "vmware-tools not configured for running kernel $rkernel"
echo "running vmware-config-tools.pl"
/usr/bin/vmware-config-tools.pl -d
echo "vmware-tools now compiled for running kernel $rkernel"
echo "restarting vmware-tools"
/etc/init.d/vmware-tools restart
echo "vmware-tools restarted"
echo "restarting networking"
/etc/init.d/network restart
echo "network restarted"
rm /etc/vmware-tools/rebuild_needed
exit 0
fi

Now the next time you reboot your Linux box after updating the kernel, the vmware tools will be properly reconfigured and the appropriate services restarted automatically.

Copy from an eLinks browser session

Like many system admins, I don’t want to install any applications that I don’t absolutely have to have on a regular basis.  In many cases this includes the graphical internet application group.

Today I found a need to copy and paste from an eLinks browser session.  It turns out that in the regular terminal in CentOS GNOME, you can’t just select and copy because of the way that eLinks renders the page content.

In order to copy and paste from an eLinks browser into, say, gEdit, you have to hold down the SHIFT key while using the mouse to select the text.

This also applies in a text-only (no X11) setup, assuming that you have gdm installed and running.  Unfortunately, eLinks doesn’t support selecting content with only the keyboard.

Trim the whitespace in vi

Today when I needed to copy some text on my CentOS server, I ended up grabbing a bunch of whitespace at the end of each line.  Normally this wouldn’t be a problem, since I would have copied from a regular browser.  In this case I was copying from with eLinks since I don’t have a graphical browser installed yet.

Sure, I could have just navigated to the end of each line and then used shift + C to delete, but I this was a 25 line block of text and that would have been too tedious.

Here’s the quick search and replace syntax to handle this for you:

:%s/\s\+$//

Java and Google Chrome

Google Chrome logoToday while working on the AASU Blackboard VISTA custom login page, I ran into an issue loading Java applets.

Apparently, Google Chrome checks your browser plug-ins to determine if they are out of date when you attempt to load content requiring them.  Here’s a snippet from the Google Support Site about the bug feature:

To make sure you’re protected, whenever Google Chrome detects that a common plug-in on a page is out of date with a security vulnerability, a message will appear beneath the address bar notifying you that the plug-in has been blocked.

While this is a great feature, since it is an attempt to protect your computer from nefarious code, there are times that it just doesn’t work properly.

The situation I ran into is described on a chromium issue report.  Basically, the Linux version of Oracle Java 7 is being seen as out-of-date, even though it is the most recent version available.  When going into the Google Chrome plug-in preferences you may see the Java plug-in marked as disabled and showing the version number in red as well as a link to java.com to download a security update.

While Chrome does give you ability to run the plug-in each time it is used, this can rapidly become a pain in the rear.  The checkbox labeled Always Allow also doesn’t seem to work.

So what to do?  Well, you can either painstakingly click the Run this time button or you can run Google Chrome with a command line switch that turns off the plugin checking mechanism.

Being an intrepid sort that likes to live on the edge and dance where angels fear to tread, I chose to run with the checking mechanism turned off.  To update the Ubuntu application launcher to make this easier, I edited the following file:

/usr/share/applications/google-chrome.desktop
sudo vi /usr/share/applications/google-chrome.desktop

Look for the first instance of a line starting with Exec and alter it to read as follows:

Exec=/opt/google/chrome/google-chrome --allow-outdated-plugins %U

After saving the file and restarting Google Chrome you will no longer be bothered by the annoying Java plug-in error warning.  To verify this is working, you can enter the following on the command line:

ps ux | grep -v grep | grep allow-outdated-plugins

You should get back at least one result.

As a bonus, you can ensure that you are running the most recent version of Java (1.7.0_05 as of this writing) by doing the following on a command line:

java -version
javac -version

You should see something like the following:

foreandy@foreandy-iMac:~$ java -version
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
foreandy@foreandy-iMac:~$ javac -version
javac 1.7.0_05