Related Items  

Linux and Windows IT Support  

dedicated-technology-experts

Windows, Apple and Linux IT support and services.

For Software and Web Development.

Mount disks with UUID or LABEL

PrintE-mail

Q: I have a new disk and I would like to mount it on my existing linux install. I can't use the device name (eg. /dev/sda1, /dev/sdb3, etc) because every time I reboot the partitions shuffle around.

A: There are various ways to mount. You can use LABEL or UUID to mount your disks.

Method 1: UUID

A Universally Unique Identifier (UUID) is an identifier standard used in software construction, standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE). The intent of UUIDs is to enable distributed systems to uniquely identify information without significant central coordination.

Finding out UUID for your hard drive:

sudo vol_id -u /dev/hda1

replace hda1 with the partition for which you wish to find the UUID

Should give you something like this:

651a8088-be20-4894-ad93-408881274996

(You can also list UUIDs for all devices using blkid commmand)

Then, all you have to do is edit your /etc/fstab file:

UUID=42aacc5e-2271-4444-aeb2-e6b88a935fb2 /m1 ext3 defaults 0 0

Type sudo mount -a and you should see your new partition. (Note that the hard drive has to be formatted and partitioned before you can mount it)

Method 2: LABELs

Volume labels make it possible for partitions to retain a consistent name regardless of where they are connected, and regardless of whatever else is connected. Labels are not mandatory for a linux volume. Each can be a maximum of 16 characters long.

Note: don't try this on the disks that have data. Labelling them can destroy it.

e2label /dev/hdb1 newlabel


tune2fs -L newlabel /dev/hdb1


mke2fs -L newlabel /dev/hdb1

Once that's done, you can add the disk to your /etc/fstab:

LABEL=newlabel /m2 ext3 defaults 0 0

Comments (1)
list all devices
1 Monday, 11 January 2010 14:23
Ant
For UUID, to list all devices, run:
sudo blkid

Add your comment

Your name:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
yvComment v.1.24.0
   
Copyright © 1999 - 2024 Virtual Helpme | Managed IT Solutions Specialized for Your Business | Original Template: Allrounder