C Shell Wiki
Posts (Latest 10 updated) :
Read all
Contents:
  1. [Linux] C Shell (csh) blkid用法: Retrieve block device attributes
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] C Shell (csh) blkid用法: Retrieve block device attributes

Overview

The blkid command is used to locate and print block device attributes, such as the filesystem type and UUID (Universally Unique Identifier). This command is particularly useful for identifying and managing storage devices on a Linux system.

Usage

The basic syntax of the blkid command is as follows:

blkid [options] [arguments]

Common Options

  • -o: Specify the output format (e.g., value, full, list).
  • -s: Specify which attributes to display (e.g., UUID, TYPE).
  • -p: Print the output in a parsable format.
  • -c: Use a specified cache file instead of the default.

Common Examples

  1. List all block devices with attributes:
    blkid
    
  2. Display only the UUIDs of the block devices:
    blkid -o value -s UUID
    
  3. Get the filesystem type of a specific device:
    blkid /dev/sda1 -o value -s TYPE
    
  4. Use a specific cache file:
    blkid -c /path/to/cachefile
    
  5. List all block devices in a full format:
    blkid -o full
    

Tips

  • Use blkid without any options to quickly get an overview of all block devices and their attributes.
  • When scripting, consider using the -o value option to make parsing the output easier.
  • Regularly check the UUIDs of your devices, especially before making changes to your filesystem, to avoid data loss.