[Techtalk] disk labels and external drives

Miriam English mim at miriam-english.org
Mon Jun 28 22:24:07 UTC 2010


Thanks for the hint about UUID Joana. I couldn't get ls to display UUID, 
but your mention let me find the blkid command. I hadn't heard of it 
before, but it can inspect a specific device or list all devices if 
given no parameters.

Big problem with UUID values though, is that they have to be the most 
ugly things I've ever seen. For instance on my machine blkid /dev/sdb1 
displays this:
/dev/sdb1: UUID="f3683b08-4b9b-4dc2-8a7a-817f41ceedfe" SEC_TYPE="ext2" 
TYPE="ext3"

However reading about UUID led me to their use in fstab, and while I was 
reading about that I struck gold. Disk labels can be used in fstab too, 
so that is the answer.
It seems fstab uses the standard options but begins with
LABEL=label_of_disk

So I might label a disk "text" and set up an fstab line like this:
LABEL=text  /mnt/text  ext3  defaults  0 0

Then after that I can refer to it using /mnt/text in all linux commands. 
Whew!

Thanks for the hint that got me over the hump Joana.

Cheers,

- Miriam


Joana Botto wrote:
> Hi Miriam,
> 
> The UUID of a hard disk can be used to identify a device independent of 
> its device name or mount point and you can have a static entry on your 
> fstab. You can get the UUID with $ ls -l /dev/disk/by-uuid
> 
> I hope this helps.
> 
> Regards,
> Joana Botto
> 
> ||
> On Mon, Jun 28, 2010 at 9:53 PM, Miriam English <mim at miriam-english.org 
> <mailto:mim at miriam-english.org>> wrote:
> 
>     Nowadays I've begun using cheap external drives for archiving
>     material. This works well, but there is a problem. I have to be
>     extremely careful that I'm referring to the correct drive when
>     handling data. Internal drives are easy. I can refer to them as
>     /dev/something or /mnt/something but external drives are attached
>     via the USB port and can be any of several device names or mount
>     names based, it seems, on when they were plugged into the port.
> 
>     The command e2label lets you change the disk label on a device, so
>     I'm wondering if there is a way to use common shell commands to
>     access a drive based on its disklabel. For instance, instead of
>     cp -a /mnt/text/linux-howtos /mnt/usb1/text
>     I might be able to refer to the second (or first) drive by its label.
>     Is that possible?
> 
>     I've tried setting the disk label using gparted and it warned me
>     that it would delete the contents of the disk if I went ahead. Eeek!
>     That seems weird. I can't find anything about whether e2label
>     deletes data on a disk or partition, but backed up all the data on
>     one of my smallest internal drive partitions and tried it. It
>     doesn't hurt the data. (Whew!) That also answers whether it can be
>     used on partitions as well as just drives.
> 
>     I used to be able to refer to disks (even floppy disks) by their
>     labels all the time on the Amiga (once upon a time). It was a nicely
>     human-oriented way to do things. I've been okay with the human
>     having to think like a machine in linux because having access to all
>     the cool, new, powerful tools has been well worth the compromise,
>     but I've often wondered about being able to access disks via their
>     labels in linux. These days with flash drives and external hard
>     drives it would seem a logical thing to be able to do.
> 
>     Am I just overlooking something obvious?
> 
>     Cheers,
> 
>            - Miriam
> 
>     -- 
>     If you don't have any failures then you're not trying hard enough.
>      - Dr. Charles Elachi, director of NASA's Jet Propulsion Laboratory
>     -----
>     Website: http://miriam-english.org
>     Blog: http://miriam_e.livejournal.com
>     _______________________________________________
>     Techtalk mailing list
>     Techtalk at linuxchix.org <mailto:Techtalk at linuxchix.org>
>     http://mailman.linuxchix.org/mailman/listinfo/techtalk
> 
> 

-- 
If you don't have any failures then you're not trying hard enough.
  - Dr. Charles Elachi, director of NASA's Jet Propulsion Laboratory
-----
Website: http://miriam-english.org
Blog: http://miriam_e.livejournal.com


More information about the Techtalk mailing list