A question about fstab

My fstab file contains lines such as these:

/dev/disk/by-path/pci-0000:00:11.0-scsi-2:0:0:0-part2 /tmp                 ext4       acl,user_xattr        1 2
/dev/disk/by-path/pci-0000:00:11.0-scsi-2:0:0:0-part3 /var                 ext4       acl,user_xattr        1 2
/dev/disk/by-path/pci-0000:00:11.0-scsi-2:0:0:0-part4 /home                ext4       acl,user_xattr        1 2
/dev/disk/by-path/pci-0000:00:11.0-scsi-2:0:0:0-part1 swap                 swap       defaults              0 0
/dev/disk/by-path/pci-0000:00:11.0-scsi-1:0:0:0-part1 /boot/efi            vfat       umask=0002,utf8=true  0 0

Looks a little messy. I was looking at the man page and came across this under device identification:

The recommended setup is to use tags (e.g. LABEL=<label>) rather
than /dev/disk/by-{label,uuid,partuuid,partlabel} udev  symlinks
in  the  /etc/fstab file. The tags are more readable, robust and
portable. The mount(8) command internally uses udev symlinks, so
use  the  symlinks in /etc/fstab has no advantage over the tags.
For more details see libblkid(3).

I don’t understand that ststement. It would seem that I can replace the “/dev/disk/by-path/pci-0000:00:11.0-scsi-2:0:0:0-part4” portion of the line with a label such as “DRIVE-2-4” but I don’t see where to define the label. Or, perhaps I misunderstand the whole thing. Can anyone explain this to me?

And, where is (can I get) documentation for libblkid?
Bart

You can use “e2label” to define a label for each “ext4” partition (or “ext2” or “ext3”).

You should be able to label your vfat partition with “dosfslabel”, or you could give it a label when running Windows. And “swaplabel” should be able to set a label to your swap partition.

Alternatively, you can use UUID= in “fstab”. You can find the UUID with the “blkid” command.

Also I think you can set labels in Yast

You mean the actual disk label? Do I replace

/dev/disk/by-path/pci-0000:00:11.0-scsi-2:0:0:0-part2 /tmp                 ext4       acl,user_xattr        1 2

With

LABEL=suse131-tmp  /tmp ext4 <parameters> 1 2

Assuming suse131-tmp is the disk label of the partition connected to pci-0000:00:11.0-scsi-2:0:0:0-part2 ?

I don’t like using the UUID because it makes changing out a hard drive harder.

Bart

On 2015-02-06 03:26, montana suse user wrote:

> You mean the actual disk label? Do I replace

Yes.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

… Partitioner.

Edit partition, choose mount by label, fill in the label (but make certain Format is not checked!).:wink:

For some reason, I had in mind that the label mentioned was in the file itself kinda like in a source.c file.

#define LABEL=<whatever>

I’m glad I checked.

I already have all my partitions labeled.

Thanks guys! I’m gonna make my file look nice and neat.

Bart

You can see all possibilities in /dev/disk/

henk@boven:~> ls -l /dev/disk
totaal 0
drwxr-xr-x 2 root root 700  6 feb 09:16 by-id
drwxr-xr-x 2 root root 140  6 feb 09:16 by-label
drwxr-xr-x 2 root root 280  6 feb 09:16 by-path
drwxr-xr-x 2 root root 140  6 feb 09:16 by-uuid
henk@boven:~> 

E.g. to check which possibilities I have at this moment in time for the partition /dev/sda5:

henk@boven:~> ls -l /dev/disk/by* | grep sda5
lrwxrwxrwx 1 root root 10  6 feb 09:16 ata-Hitachi_HDT725032VLA380_VFJ201R23XUEXW-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10  6 feb 09:16 scsi-1ATA_Hitachi_HDT725032VLA380_VFJ201R23XUEXW-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10  6 feb 09:16 scsi-SATA_Hitachi_HDT72503_VFJ201R23XUEXW-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10  6 feb 09:16 wwn-0x5000cca311f7606f-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10  6 feb 09:16 System_B -> ../../sda5
lrwxrwxrwx 1 root root 10  6 feb 09:16 pci-0000:00:1f.2-scsi-0:0:0:0-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10  6 feb 09:16 67aabbdc-41c8-4c4c-a965-4ff46768c4cf -> ../../sda5
henk@boven:~>

These are all the symlinks created by udev for this partitions. You see there is a by-label in my case (System_B).

While many terms are used for these labels, I think the term “Volume Lable” is the correct one. They label the Volume, which in this case is the file system (not the partition) They are in the file system and that explaines why they are set using file system dependent tools (mentioned above) and not partition tools ¹).

¹) The term “Partitioner” is often used wrongly. Often, “Partitioners” (like YaST > System > Partitioner), combine the partitioning (working on the partition table) with actions on file systems (creating, maybe enlarging, etc. of certain file system types). And YaST Partitioner also can do other tasks like Volume labeling, maintaining fstab entries. All very usefull, but it blurs the meaning of “partitioning”. A strict partitioning tool is e.g. fdisk.

BTW, you can use the LABEL= feature, or mount by using /dev/disk/by-label/… symlink (that is the same method the /dev/disk/by-path/… you seem to use now and the /dev/disk/by-id/… that is openSUSEE’s default.

I do not understand why the one method is more “nice and neat” (but that ii of course at least partly personal taste) then the other. All variations on the by-… theme have their advantages and disadvantages and one should contemplate about those before deviating from the openSUSE deafult IMHO. And when you decide for by-label for one or more of them, you then can decide if you think it more “nice and clean” to use the specific fstab feature above the symlink way.

Labels must be unique to the system ie you can’t mount a partition with the same label as an exiting one. So if you clone the drive those cloned partitions can not be mounted in the running system. When you use labels you take full charge ie you are the captain of the ship. Not a bad thing just that you must be aware and control all the mounts appropriately

When I read the man page, I misunderstood and obviously became fixated on a different definition then the correct one. How nice it was to have a bunch of people reply so quickly. And with such professionalism and restraint. All I can say is “Well DUH!”

As for neatness, witness how nice it now looks:

LABEL=suse131-root /                 ext4  noatime,discard,acl,user_xattr                                                      1 1
LABEL=suse131-tmp  /tmp              ext4  acl,user_xattr                                                                      1 2
LABEL=suse131-var  /var              ext4  acl,user_xattr                                                                      1 2
LABEL=suse131-home /home             ext4  acl,user_xattr                                                                      1 2
LABEL=swap          swap             swap  defaults                                                                            0 0
LABEL=EFI          /boot/efi         vfat  umask=0002,utf8=true                                                                0 0
//RT-AC66R/root    /home/bart/router cifs  nofail,credentials=/home/bart/.fstab/.creds,_netdev                                 0 0
//Ls420dc48/share  /home/bart/Server cifs  nofail,credentials=/home/bart/.fstab/.creds,_netdev,file_mode=0777,dir_mode=0777,rw 0 0 

Thanks all!
Bart