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.
Discuss This Article
Post Tags (user submitted): linux change disk label (48) - t (36) - change-disk-label linux (33) - linux disk label (27) - set disk label linux (21) - linux set disk label (19) - linux disk labels (16) - fstab label (16) - change partition label linux (13) - Linux change partition label (13) - ext3 disk label (12) - disk label linux (11) - RHEL fstab (9) - linux check disk label (9) - linux disklabel (9) - change partition label (8) - linux partition label (8) - rhel fstab label (8) - linux change disklabel (7) - linux change label disk (7) - set partition label linux (7) - all (6) - label e2label (6) - change label disk linux (6) - linux set disklabel (6) - linux set partition label (6) - change Linux disk label (5) - linux disk label change (5) - linux change disk labels (5) - change disk label (5) - partition label linux (5) - RHEL label / (5) - rhel4 partition (5) - set disk label (5) - disklabel linux (5) - linux disk partition label (5) - linux edit disk label (4) - fstab labels (4) - linux label disk (4) - change ext3 label (4) - linux disk label fstab (4) - linux changing disk labels (4) - fstab disk labels (4) - rhel disk label (4) - Disk label change linux (3) - linux ext3 disk label (3) - RHEL4 +fstab +LABEL (3) - linux change device label (3) - check disk label linux (3) - "change disklabel" (3) - linux partition labels (3) - change LABEL linux (3) - changing disk label linux (3) - label disk linux (3) - how to change partition label (3) - Linux how to change disk label (3) - change linux partition label (3) - change label on ext3 disk (3) - disk label fstab (3) - rhel disklabel (3) - change disk LABEL ext3 linux (3) - label ext3 disk (3) - create disk label linux (3) - ext3 disklabel (3) - how to set disk label linux (3) - linux fstab label (3) - linux set disc label (3) - "how to change disk label" (3) - RHEL /etc/fstab LABEL (3) - linux set label disk (2) - How to change mount points in RHEL4 (2) - set partition label (2) - disklabel linux ext3 (2) - linux change dos disk label (2) - linux disk change label (2) - change label partition (2) - partition LABEL fstab (2) - fstab LABEL e2label (2) - editing disk labels linux (2) - changing linux disk labels (2) - disk label linux LABEL= (2) - disk label ext3 (2) - fstab disk label (2) - change mount point linux rhel (2) - mount disk label (2) - linux disk label edit (2) - "root=LABEL=/1" (2) - change ext3 disk label (2) - set ext3 label (2) - set disklabel linux (2) - fstab LABEL rhel (2) - RHEL4 disk label (2) - linux +change disk volume name (2) - fstab LABEL which device (2) - "change disk name" + linux (2) - disk label mount (2) - linux change drive label (2) - rhel set disk label (2) - how to label disk in linux (2) - rhel e2label (2) - linux disc label (2) - set disc label linux (2) - linux "change partion (2) - linux change partion label (2) - linux change disk (2) - change drive label linux (2) - change RHEL labels (2) - partition label change (2) - RHEL device label (2) - change disklabel linux (2) - linux change disk name (2) - edit linux disk label (2) - partition labelling in solaris (2) - change (2) - linux show disk label (2) - RHEL partition labels (2) - check disk label in linux (2) - ext3 disk labels (2) - linux assign disk label (2) - changing disk labels linux (2) - change vfat disk label linux (2) - remove linux disk label (2) - disk labels ext3 (2) - rhel check disk label (2) - changing linux disk label (2) - set disklabel (2) - linux delete disk label (2) - change disk label on linux (2) - label a ext3 disk in linux (2) - calvin (2) - rhel disk labels (2) - "label Linux disk" (2) - linux edit label (2) - rhel label disk (2) - "how to label disk" (1) - how to change the label name of a drive in rhel linux (1) - check disk label linux rhel (1) - fstab labels linux (1) - ext3 "change label" (1) - "disk label" linux mount by-label (1) - rhel swap label (1) - how to mount disk on RHEL4 (1) - RHEL mount fstab (1) - change home disk linux fstab (1) - "how to set disk label" (1) - rhel mount (1) - rhel label fstab (1) - set label fstab (1) - ext3 change disk label (1) - how to change label of a partition in fstab (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. [...]
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!