Today we'll show you how to use lsblk and blkid tool to find information about the block device, we are using a computer with CentOS 7.0 machine.
lsblk Linux is a tool that displays information about your system of all available block devices. It gets information from the sysfs file system. By default, this tool will be displayed in a tree format (in addition to the virtual memory disk) all block devices.
lsblk default output
By default lsblk will block device output in a tree format:
NAME - name of the device
MAJ: MIN - Linux operating system, each device to a file representation of the block (disk) devices, the major and minor device numbers used here to describe the device.
RM - removable devices. If this is a mobile device will display 1, 0 otherwise.
TYPE - the type of device
MOUNTPOINT - equipment mounted position
RO - For read-only file system will be displayed here 1, 0 otherwise.
SIZE - capacity of the device
The owner of the display device
To display the owner of the device-related information, including their user file, group, and file system mount mode, you can use the -m option, like this:
Lists devices block
If you only want to list the devices, rather than want them to output a tree, you can use the -l option:
Use in scripts
Advanced tip: If you want to use in the script and want to exclude the header, so you can use the -n option:
blkid command is a command-line tool that displays information about the available block devices. It can identify a block device type of content (such as file systems, swap) and acquired from the content metadata (such as a label, or UUID fields) properties (such as tokens and key-value pairs). It mainly has two types of effects: with the specified key to search for a device, or display one or more device pairs.
Do not add any parameters directly blkid will run all available output devices, their universally unique identifier (UUID), file system type and volume label (if set).
Equipment listed by name or UUID
If you want to display information about a particular device, you can name the device as an option added after blkid:
# Blkid / dev / sda1
If you know the UUID of a device and want to know the device name, you can use the -U option, like this:
# Blkid -U d3b1dcc2-e3b0-45b0-b703-d6d0d360e524
If you want to get more detailed information, you can use the -p option and -o udev to use them neatly displayed format, like this:
# Blkid -po udev / dev / sda1
Sometimes the device list may not be updated, if this is the case you can use the -g option to clean blkid cache, thereby removing the device does not already exist.
# Blkid -g