Linux Comm Blkid π
2026-06-23 | π Linux
[ Linux Command Manual](#)\n\n* * *\n\n## What is the blkid Command\n\n`blkid` is a utility in Linux systems used to identify block device attributes. It can display the filesystem type, UUID (Universal Unique Identifier), label (LABEL), and other related information of block devices (such as hard disks, partitions, USB devices, etc.).\n\n### Main Features\n\n* Identify the filesystem type of storage devices\n* Get unique identifiers (UUID) of devices\n* View partition labels (LABEL) of devices\n* Display the size and other attributes of block devices\n\n* * *\n\n## Basic Syntax\n\nblkid [device...]\n\n### Common Options and Parameters\n\n| Option | Description |\n| --- | --- |\n| `-c ` | Specify cache file (default is /etc/blkid.tab) |\n| `-g` | Collect garbage data to cache file |\n| `-o ` | Specify output format (full, value, list, device, udev) |\n| `-p` | Low-level superblock probing (bypass cache) |\n| `-s ` | Display information for specified tag (such as UUID, TYPE, LABEL, etc.) |\n| `-U ` | Find device by UUID |\n| `-L ` | Find device by LABEL |\n| `-i` | Display I/O limitation information |\n| `-h` | Display help information |\n| `-V` | Display version information |\n\n* * *\n\n## Usage Examples\n\n### 1. View All Block Device Information\n\n## Example\n\nsudo blkid\n\nOutput Example:\n\n/dev/sda1: UUID="5a3a1e7b-1a2b-4c3d-8e9f-0a1b2c3d4e5f" TYPE="ext4" /dev/sda2: UUID="6b4c5d6e-7f8g-9h0i-1j2k-3l4m5n6o7p8q" TYPE="swap" /dev/sdb1: LABEL="DATA" UUID="9a8b7c6d-5e4f-3g2h-1i0j-9k8l7m6n5o4p" TYPE="xfs"\n\n### 2. View Specific Device Information\n\n## Example\n\nsudo blkid /dev/sda1\n\nOutput Example:\n\n/dev/sda1: UUID="5a3a1e7b-1a2b-4c3d-8e9f-0a1b2c3d4e5f" TYPE="ext4"\n\n### 3. Display Only UUID Information\n\n## Example\n\nsudo blkid -s UUID -o value /dev/sda1\n\nOutput Example:\n\n5a3a1e7b-1a2b-4c3d-8e9f-0a1b2c3d4e5f\n\n### 4. Find Device by UUID\n\n## Example\n\nsudo blkid -U 5a3a1e7b-1a2b-4c3d-8e9f-0a1b2c3d4e5f\n\nOutput Example:\n\n/dev/sda1\n\n### 5. Use List Format Output\n\n## Example\n\nsudo blkid -o list\n\nOutput Example:\n\ndevice fs_type label mount point UUID -------------------------------------------------------------------------------/dev/sda1 ext4 / 5a3a1e7b-1a2b-4c3d-8e9f-0a1b2c3d4e5f/dev/sda2 swap 6b4c5d6e-7f8g-9h0i-1j2k-3l4m5n6o7p8q/dev/sdb1 xfs DATA /mnt/data 9a8b7c6d-5e4f-3g2h-1i0j-9k8l7m6n5o4p\n\n* * *\n\n## Practical Application Scenarios\n\n### 1. Using UUID in fstab for Mounting\n\nWhen editing the `/etc/fstab` file, using UUID is more reliable than using device names, as device names may change:\n\n## Example\n\nUUID=5a3a1e7b-1a2b-4c3d-8e9f-0a1b2c3d4e5f / ext4 defaults 0 1\n\n### 2. Identifying Devices in Automation Scripts\n\nIn scripts, you can use blkid to identify specific devices:\n\n## Example\n\n#!/bin/bash\n\nDATA_PARTITION=$(sudo blkid -L"DATA")\n\nif[-n"$DATA_PARTITION"]; then\n\necho"Found data partition: $DATA_PARTITION"\n\nmount$DATA_PARTITION/mnt/data\n\nelse\n\necho"Data partition not found"\n\nfi\n\n### 3. Detecting Unmounted Filesystems\n\n## Example\n\nsudo blkid |grep-v"$(mount | awk '{print $1}')"\n\n* * *\n\n## Frequently Asked Questions\n\n### Q1: Why do I need to use sudo to execute blkid?\n\nA: Regular users may not have permission to access certain device information. Using sudo ensures you get complete device information.\n\n### Q2: What is the difference between blkid and lsblk?\n\nA:\n\n* `lsblk` mainly displays the hierarchy and basic information of block devices (name, size, mount point, etc.)\n* `blkid` focuses on displaying filesystem-related detailed information (UUID, TYPE, LABEL, etc.)\n\n### Q3: How to update blkid's cache?\n\nA: You can use the following command to update the cache:\n\n## Example\n\nsudo blkid -g\n\nOr bypass the cache completely using low-level probing:\n\n## Example\n\nsudo blkid -p\n\n* * *\n\n## Summary\n\nThe `blkid` command is a very useful tool in Linux system administration, especially when dealing with storage devices and filesystems. Through this tutorial, you should be able to:\n\n1. Understand the basic functions and syntax of blkid\n2. Use various options to obtain specific device information\n3. Apply the blkid command in real-world scenarios\n4. Solve common problems related to device identification\n\nMastering the blkid command will help you manage storage devices in Linux systems more effectively.\n\n[ Linux Command Manual](#)