Working With Disk Labels in RHEL

When you install RHEL, the filesystems are labeled for you. Usually you won’t have to mess with it anymore, but on occasion, you may want to change them to more accurately represent the data that is stored on that partition. If, for instance, you used to have all of your database files on a partition labeled “/database”, but you have now moved them somewhere else, and you now wish to house your user account data there, it would make sense to change the label to something like “/users”.

Labels are, of course, arbitrary, so there is no technical need to do this, and you could, instead simply change the mount point in the fstab file, mounting the partition by device name rather than label, but it is usually cleaner to change the label. Here is how you do it:

First, let’s figure out what the partition is currently labeled as:

[root@calvin /]# /sbin/e2label /dev/hda4
/database
[root@calvin /]#

It’s current label is “/database”, and, since we have moved the database data somewhere else, we now want to store our user account data here, we need to change it to “/users”.

[root@calvin /]# /sbin/e2label /dev/hda4 /users
[root@calvin /]#

That’s all there is to it, now we check to make sure we have done what we think we have done.

[root@calvin /]# /sbin/e2label /dev/hda4
/users
[root@calvin /]#

Sure enough, it’s now labeled “/users” and the data on the disk remains intact. Now all we have to do is change the appropriate entry in the “/etc/fstab” file to represent the change.

Change this:

LABEL=/database       /databases            ext3    defaults        1 2


To this:

LABEL=/users          /users                ext3    defaults        1 2


And you’re all set to go. Make sure you have unmounted “/databases” before making the change.

Now, just run:
[root@calvin /]# mount /users
[root@calvin /]#

And you’re all set to go. As always, change the values here to represent those in your environment.

2 thoughts on “Working With Disk Labels in RHEL

  1. Pingback: spiralbound.net » Changing Linux Mount Points

  2. The problem with the pingback comment above is that, if you add or remove a sata drive or FC Lun from your system, you alter the dev layout on the next reboot — usually in a manner you didn’t expect. Then you’re left with either assigning a 0-len LUN or re-jiggering all your /dev/foo entries in /etc/fstab by hand. If that happens at 2 in the morning after the machine rebooted (eg evicted from RACrap cluster) you’re working by hand AND sleepy as hell. This is nothing I wish on any fellow sysadmin.

    The alternative – ‘UUID=…’ – has its own benefits and drawbacks, but is a similar setup I’ve seen.

    Based on the dynamic re-assignment of /dev/ entries for adjusted SATA or FC disks(/luns), though, we’ve changed a long-standing “use the /dev/s in fstab or else!” policy in a place with many machines and many, many bureaucrats — something I add only so you can get an idea of how important an issue it became for us!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>