The blkid command obtains the file system type, UUID

Source: Internet
Author: User

In Linux, you can use the blkid command to query the file system type used on the query device. Blkid is used to query information such as the file system type, label, and UUID used by system Block devices (including swap partitions. To use this command, you must install the e2fsprogs package.

You can directly use blkid to list the types of mounted file systems in the current system.

Lijilin @ lijilin-TH55B-HD :~ $ Sudo blkid

/Dev/sda1: Label = "win7" UUID = "40305e93305e9030" type = "NTFS"

/Dev/sda5: Label = "software" UUID = "823e2d6213af89bd" type = "NTFS"

/Dev/sda6: Label = "Learning" UUID = "ccbc9a082598c349" type = "NTFS"

/Dev/sda7: Label = "Entertainment" UUID = "0979a05bd10f9410" type = "NTFS"

/Dev/sda8: UUID = "7350922f-c69c-4f33-84e0-befd8b42d2f6" type = "Swap"

/Dev/sda9: UUID = "3002feb1-dceb-441d-bfd2-31243e336d39" type = "ext4"

Lijilin @ lijilin-TH55B-HD :~ $

 

You can view the file system types used by the specified device (such as/dev/sda1 ).

Lijilin @ lijilin-TH55B-HD :~ $ Blkid/dev/sda1

/Dev/sda1: Label = "win7" UUID = "40305e93305e9030" type = "NTFS"

 

View labels in the system

Lijilin @ lijilin-TH55B-HD :~ $ Sudo blkid-s label

/Dev/sda1: Label = "win7"

/Dev/sda5: Label = "Software"

/Dev/sda6: Label = "Learning"

/Dev/sda7: Label = "Entertainment"

 

View UUID IN THE SYSTEM

Lijilin @ lijilin-TH55B-HD :~ $ Sudo blkid-s UUID

[Sudo] password for lijilin:

/Dev/sda1: UUID = "40305e93305e9030"

/Dev/sda5: UUID = "823e2d6213af89bd"

/Dev/sda6: UUID = "ccbc9a082598c349"

/Dev/sda7: UUID = "0979a05bd10f9410"

/Dev/sda8: UUID = "7350922f-c69c-4f33-84e0-befd8b42d2f6"

/Dev/sda9: UUID = "3002feb1-dceb-441d-bfd2-31243e336d39"

Lijilin @ lijilin-TH55B-HD :~ $

========================================================== ================================

How to obtain the uuid of a device (in Linux ):

1) # blkid/dev/sda1

/Dev/sda1: Label = "/axs3" UUID = "298d198d-aa60-48af-a9f4-638f8f274afa" sec_type = "ext2" type = "ext3"
2) # tune2fs-L/dev/sda1 | grep 'uuid'
298d198d-aa60-48af-a9f4-638f8f274afa
3) # ls-L/dev/Disk/by-UUID/| grep sda1 | awk '{print $8 }'
298d198d-aa60-48af-a9f4-638f8f274afa
4) # scsi_id-P 0x80/0x83-S/block/sda1 should only be valid for SCSI devices.
5) # dumpe2fs/dev/sda1 | grep 'uuid'
Dumpe2fs 1.39 (29-may-2006)
Filesystem UUID: 298d198d-aa60-48af-a9f4-638f8f274afa

This command is not recommended. If the partition is large, it takes a long time.
6) # vol_id/dev/sda1 | grep 'uuid'
Id_fs_uuid = 298d198d-aa60-48af-a9f4-638f8f274afa
Id_fs_uuid_enc = 298d198d-aa60-48af-a9f4-638f8f274afa
 

========================================================== ==============================

If you try to install or upgrade Ubuntu to the latest version, you may find that all storage devices are represented by a uuid string. UUID-universally unique identifiers ".

What is UUID?

UUID is a string that identifies the storage devices in your system. Its purpose is to help users uniquely identify all storage devices in the system, regardless of their type. It identifies a DVD drive, a USB storage device, and a hard disk device in your system. A typical UUID looks like this:

C73a37c8-ef7f-40e4-b9de-8b2f8103844

Why UUID?

Cause 1: it is the only identifier.

UUID provides a unique identifier string for the storage device in the system, regardless of the type of the device. If you add a new storage device, such as a hard disk, to the system, it may cause some trouble. For example, the device fails to be found during startup, however, using UUID will not cause such problems.

Cause 2: The device name is not always the same

The automatically assigned device names are not always the same. They depend on the kernel loading module sequence at startup. If you start the system when you insert a USB disk and unplug it the next time, the device name distribution may be inconsistent.

Using UUID is also very helpful for mounting mobile devices-for example, I have a 24-in-One Card Reader that supports a variety of cards, UUID can always mount the same card in the same place.

Cause 3: many key features in Ubuntu are dependent on UUID now

For example, grub-the system boot program can now recognize UUID and open your/boot/GRUB/menu. lst. You can see statements similar to the following:
Title Ubuntu hard (Development Branch), kernel 2.6.24-16-generic
Root (hd2, 0)
Kernel/boot/vmlinuz-2.6.24-16-generic root = UUID = c73a37c8-ef7f-40e4-b9de-8b2f81038441 Ro quiet splash
Initrd/boot/initrd. img-2.6.24-16-generic
Quiet

List UUID of devices in the system

If you use the latest Ubuntu, you can use the blkid command to list the uuid of all storage devices in the system.

# Blkid
/Dev/sda1: UUID = "2220cf8220cf5b83" type = "NTFS"
/Dev/sda2: UUID = "48e81f29e81f14b2" label = "DRIVE-D" type = "NTFS"
/Dev/sdb1: UUID = "c73a37c8-ef7f-40e4-b9de-8b2f81038441" sec_type = "ext2" type = "ext3 ″
/Dev/sdb5: TYPE = "Swap" UUID = "abe7529e-dcd5-4afc-b714-05569dbcd30b"
/Dev/sdb6: UUID = "f34c8c7c-a020-4a14-8c97-257180240250" sec_type = "ext2" type = "ext3 ″
/Dev/sdb7: UUID = "8fa274ca-5b22-411f-b51277469c1f276da" sec_type = "ext2" type = "ext3 ″
/Dev/sdc1: UUID = "1e36f323-c4e5-4f55-ba0a-838643550bf9" type = "ext3" sec_type = "ext2 ″
/Dev/sdc2: UUID = "83aa92e4-4df4-4aab-80f3-9bbb447e0459" type = "ext3" sec_type = "ext2 ″

 

Obtain the uuid of the specified device:

If you know a device name and want to confirm its UUID, for example, if you want to confirm that your/etc/fstab UUID is correct, you can use the vol_id command:

# Vol_id-U/dev/sdb1
C73a37c8-ef7f-40e4-b9de-8b2f81038441
Refer:
Http://www.unixtutorial.org/2008/05/ubuntu-uuid-how-to/
Article Source: feino Network (www.diybl.com): http://www.diybl.com/course/6_system/linux/linuxjs/2008930/147029.html

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.