Find block device details with the Linux blkid command

Source: Internet
Author: User

Today we'll show you how to use the lsblk and blkid tools to find information about block devices, and we're using a CentOS 7.0-equipped machine.

Lsblk

lsblk is a Linux tool that displays information about all the available block devices in your system. It obtains information from the Sysfs file system. By default, this tool will display all block devices in a tree-like format (except for memory virtual disks).

Lsblk Default Output

By default, LSBLK will export the block device to a tree format:

    • Name--Names of the devices

    • Each device in the maj:min --linux operating system is represented as a file, where the device is described by a primary and secondary device number for a block (disk) device.

    • RM --removable devices. If this is a removable device will display 1, otherwise display 0.

    • Type--Types of devices

    • mountpoint --Location of device mounts

    • RO -for read-only file systems, this will show 1, otherwise 0.

    • size --capacity of the device

Display the owner of the device

To display information about the owner of the device, including the user who owns the file, the group it belongs to, and the file system mount mode, you can use the-M option, like this:

    1. Lsblk -m

List device blocks

If you only want to list the devices and don't want them to be in a tree-like output, you can use the-l option:

    1. Lsblk -l
Using in Scripts

Advanced Tip: If you want to get rid of a table header if you wish to use it in a script, you can use the-N option:

    1. LSBLK -LN

Blkid

The blkid command is a command-line tool that can display information about the available block devices. It identifies the type of block device content (such as the file system, swap area), and gets attributes (such as tokens and key-value pairs) from the content's metadata, such as the volume label or UUID field. It has two main functions: to search for a device with a specified key value pair, or to display key-value pairs for one or more devices.

Blkid How to use

Running blkid without adding any parameters will output all available devices, their universal unique identifiers (UUID), the file system type, and the volume label (if one is set).

    1. # Blkid

List devices by name or UUID

If you only want to display information for a particular device, you can add the device's name as an option behind Blkid:

    1. # BLKID/DEV/SDA1

If you know the UUID of a device and want to know its device name, you can use the-u option, like this:

    1. # blkid-u d3b1dcc2-e3b0-45b0-b703-d6d0d360e524

More information

If you want to get more details, you can use the-p and-O udev options to display them in a neat format, like this:

    1. # Blkid-po UDEV/DEV/SDA1

Resetting the cache

Sometimes the list of devices may not be updated, and if this is the case, you can use the-G option to clean up the blkid cache, eliminating devices that do not already exist.

    1. # blkid-g

Via:http://linoxide.com/linux-command/linux-command-lsblk-blkid/

Adrian Dinu Translator: Felixonmars proofreading: Wxy

Find block device details with the Linux blkid command

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.