Tuesday, June 19, 2007

Fun with Linux Filesystem Labels

Most things in life involve a little Give and Take, and filesystems in Linux are certainly no exception.

On the Give side of the equation Linux offers the ability to identify a filesystem not only by its traditional device file name, such as /dev/sde1, but also by a unique label that you can apply to the filesystem.

On the Take side, if you've ever supported a Linux system attached to SAN storage you know that a simple act such as adding or removing a LUN can cause Linux to remap your /dev/sd entries, causing what used to be /dev/sde1 to become /dev/sdd1.

The problem is readily apparent when you reboot the server. Your server is no longer able to locate the /dev/sde1 device in order to mount it at /oracle!

This problem can be solved by using filesystem labels, which are entries in the header structure of an EXT3 filesystem. By using the following command (logged in as root of course)
tune2fs -L oracle /dev/sde1

you can set the label for the filesystem "/dev/sde1" to the keyword "oracle".

While labels allow the use of some special characters like / and _ in their names, I recommend keeping the label simple and indicative of where the fileystem belongs.

To see the results of your change, use
tune2fs -l /dev/sde1   (note the lowercase "L")

Then to make this change effective alter the /etc/fstab entry for /oracle and replace the device file with a special label keyword as shown here:

LABEL=oracle /oracle ext3 noatime 1 1

This approach works for the native Linux EXT3 filesystem as well as for Oracle's OCFS and OCFS2 filesystems.


neelu said...

I unquestionably understand what you have said. In fact, I browsed throughout your other articles and I think that you’re certainly right. Congrats with this site.
Hotels In Bilbao

vishus said...

I really agree with the facts that you have shared on this post. An interesting topic like this really enhances reader's mind to have more effective decisions over a certain issue.
Pisa hotels