• 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.

    This entry was posted on Tuesday, November 28th, 2006 at 3:54 pm and is filed under Data and Technology. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  • 2 Comments

    Take a look at some of the responses we've had to this article.

    1. [...] You can always simply change the disk label, but if you don’t care, you can just tell linux where the raw device is, bypassing the need to worry about the label. The easiest way to do this is simply to replace the “LABEL=/data” value to the “/dev” entry of the disk itself. Then, simply change “/data” to “/database” and you’re all set. [...]

    2. Bish
      Jun 22nd
      Reply

      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

    Let us know what you thought.

  • Name (required):

    Email (required):

    Website:

    Message:

Visitors have tagged this post: linux change disk label (48) - t (36) - change-disk-label linux (33) - linux disk label (28) - set disk label linux (21) - linux set disk label (19) - fstab label (18) - linux disk labels (16) - change partition label linux (13) - Linux change partition label (13) - ext3 disk label (12) - disk label linux (11) - RHEL fstab (9) - linux disklabel (9) - linux check disk label (9) - linux partition label (8) - rhel fstab label (8) - change partition label (8) - calvin (8) - linux change label disk (7) - linux change disklabel (7) - label (7) - set partition label linux (7) - linux set partition label (6) - all (6) - change Linux disk label (6) - label e2label (6) - linux set disklabel (6) - change label disk linux (6) - partition label linux (5) - linux change disk labels (5) - linux disk partition label (5) - change disk label (5) - set disk label (5) - linux disk label change (5) - RHEL label / (5) - fstab labels (5) - rhel4 partition (5) - change ext3 label (5) - disklabel linux (5) - rhel disk label (5) - linux disk label fstab (4) - linux label disk (4) - linux changing disk labels (4) - linux edit disk label (4) - fstab disk labels (4) - disk label fstab (3) - label ext3 disk (3) - change label on ext3 disk (3) - change linux partition label (3) - ext3 disklabel (3) - rhel disklabel (3) - Linux how to change disk label (3) - label disk linux (3) - check disk label linux (3) - linux change device label (3) - linux ext3 disk label (3) - linux set disc label (3) - changing disk label linux (3) - change disk LABEL ext3 linux (3) - RHEL /etc/fstab LABEL (3) - RHEL4 +fstab +LABEL (3) - how to set disk label linux (3) - "change disklabel" (3) - linux fstab label (3) - disk label ext3 (3) - create disk label linux (3) - linux partition labels (3) - "how to change disk label" (3) - change LABEL linux (3) - Disk label change linux (3) - how to change partition label (3) - fstab disk label (2) - linux delete disk label (2) - linux disk change label (2) - change RHEL labels (2) - "change disk name" + linux (2) - change label partition (2) - remove linux disk label (2) - fstab LABEL rhel (2) - set disklabel linux (2) - linux assign disk label (2) - rhel labels (2) - partition labelling in solaris (2) - disklabel linux ext3 (2) - RHEL device label (2) - changing linux disk labels (2) - fstab LABEL which device (2) - RHEL4 disk label (2) - linux change drive label (2) - editing disk labels linux (2) - "root=LABEL=/1" (2) - change drive label linux (2) - set ext3 label (2) - set disc label linux (2) - disk label mount (2) - linux change partion label (2) - fstab LABEL e2label (2) - mount disk label (2) - linux +change disk volume name (2) - linux set label disk (2) - How to change mount points in RHEL4 (2) - linux change disk (2) - linux disk label edit (2) - linux edit label (2) - set partition label (2) - change ext3 disk label (2) - disk label linux LABEL= (2) - rhel e2label (2) - linux disc label (2) - rhel set disk label (2) - linux change dos disk label (2) - partition label change (2) - partition LABEL fstab (2) - linux show disk label (2) - rhel check disk label (2) - change disk label on linux (2) - disk labels ext3 (2) - how to label disk in linux (2) - edit linux disk label (2) - rhel partition (2) - label a ext3 disk in linux (2) - check disk label in linux (2) - change disklabel linux (2) - long disk label (2) - set disklabel (2) - linux change disk name (2) - RHEL partition labels (2) - changing disk labels linux (2) - change (2) - linux "change partion (2) - "label Linux disk" (2) - change mount point linux rhel (2) - rhel disk labels (2) - change vfat disk label linux (2) - ext3 disk labels (2) - rhel label disk (2) - changing linux disk label (2) - rhel 4 label= fstab (1) - check disk label to device name mapping (1) - change linux disk label name (1) - change label mount (1) - set partition label ext3 (1) - RHEL4 mount disk (1) - setting disk labels linux (1) - linux changing labels ext3 disk (1) - how to change label in linux (1) - e2label disk label (1) - e2label change (1) - disk change linux label (1) -