Linux system Introduction Using UUID to mount partitions in fstab

Source: Internet
Author: User

Fstab files are familiar to everyone. During Linux Startup, each partition is mounted through the information in fstab. A typical partition entry is like this:

 

/Dev/sdb5/mnt/USB vfat utf8, umask = 0 0 0

 

/Dev/sda4 is the partition to be mounted, and sda4 is a Linux
The name of the partition in sequence when detecting the hard disk. Generally, this name will not change, but if you have multiple hard disks and the hard disk changes in the order on your computer, the same name may indicate different hard disk scores.
If you are starting from a USB device, the insertion sequence with other USB devices will also lead to difficulty in partition identification.

 

UUID can be used in this case. UUID is the full name of universally unique identifier. That is to say, each partition has a unique UUID value, so that there will be no confusion in partition recognition.

 

Mount the partition with UUID in fstab. It looks like this:

 

UUID = 1234-5678/mnt/USB vfat utf8, umask = 0 0 0

 

Enter the uuid value corresponding to the partition after UUID = to mount the partition correctly.

 

So, how do we know the uuid of a partition?

 

There are three methods:

 

1. view the device file information under/dev/Disk/by-UUID.

 

# Ls-L/dev/Disk/by-UUID/

------

Lrwxrwxrwx 1 Root 10 10-13 0909-090b->.../sdb5

Lrwxrwxrwx 1 Root 10 10-13 09:13 7c627a81-7a6b-4806-987b-b5a8a0a93645->.../SDA

.....

 

2. Run the vol_id command.

 

# Vol_id/dev/sdb5

Id_fs_usage = filesystem

Id_fs_type = vfat

Id_fs_version = FAT32

Id_fs_uuid = 0909-090b

Id_fs_uuid_enc = 0909-090b

Id_fs_label = swap

Id_fs_label_enc = swap

Id_fs_label_safe = swap

 

3. Use the blkid command

 

# Blkid/dev/sdb5

/Dev/sdb5: Label = "Swap" UUID = "0909-090b" type = "vfat"

 

The UUID of the partition can be obtained through these three methods. The UUID varies according to the partition, and the length and format are different.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.