Sunday, June 01, 2008

Concept of Volume Label in Linux

Initially when I bought my first PC 4 years back I started off with Windows XP. Assigning volume label or renaming a partition in windows was indeed very easy. It was just a "right click" stuff. After a year or so I then switched over to Linux and have never looked back since then.

In Linux I never felt the need to rename a partition because Linux treats partitions by device files or mount points. However if you are still interested in assigning a volume label to a partition from Linux, here is what you should:

# umount /dev/sdmn
# tune2fs -L /dev/sdmn
# mount -a

e.g.
# umount /dev/sdb3
# tunefs -L DEBIAN /dev/sdb3
# mount -a

The best of this is that same volume-label which is assigned to the partition under concern is also visible in Windows as well and rightly so.

The million dollar question is how can you use volume-label in Linux. I will explain it using my own example. I have many disk-drives (more than 5 hard-disks in my home pc) each disk-drive having some or the other Linux installed on it. Every now & then I take my disk-drives out of the box for data-exchange or for maintenance. In that process sometimes a disk drive is attached to a new slot or interchanged with some other slot as a result of which position of disk-drives (hda, hdb, sda, sdb, sdc) gets changed and eventually it leads to mismatch between disk-drive position and it's entry in "/etc/fstab". This makes the system non-bootable or partition having it's entry in "/etc/fstab" doesn't gets mounted.

To avoid this it's always advisable to assign a volume label to the partitions and refer the partitions in "/etc/fstab" by it's volume label. A typical example of an entry referred by it's volume label in "/etc/fstab" is shown below:

# cat /etc/fstab | grep -i label
LABEL=/ / ext3 defaults 1 1
LABEL=DEBIAN /debian ext3 defaults 0 0

The 1st & 2nd entry in above example could also have been:
/dev/sda1 / ext3 defaults 1 1
/dev/sdb3 /debian ext3 defaults 0 0

But if the disk-drive /dev/sda or /dev/sdb are removed for some reason or if their positions are interchanged then they won't get mounted.

However if the partitions are referred by volume labels then this situation of crisis will never arise. Thats amazing. Kindly share your views and don't hesitate to shoot in your queries if any.

© COSEC
Wanna Learn and Know more about Linux, log on to
http://discoverlinux.blogspot.com/

Labels: , , , ,