linuxblkid命令介绍

韵味老鸟 2024-08-21 14:02:35

linux blkid 命令介绍

blkid 命令简介

Linux 中的 blkid 命令用于定位或打印块设备属性。块设备可以是硬盘、固态硬盘 (SSD) 或可移动存储设备,如 USB 驱动器。它可以确定块设备包含的内容类型(例如文件系统或交换分区),并从内容元数据(例如 LABEL 或 UUID 字段)中提取属性(标记、NAME=value 对)。

一:命令介绍

常用选项-d、--no-encoding:不对非打印字符进行编码。-g、--garbage-collect:删除不再存在的设备。-h、--help:显示使用消息并退出。-k、--list-filesystems:列出所有已知的文件系统和 RAID,然后退出。-o、--output FORMAT:使用指定的输出格式。FORMAT 可以是: full:打印所有标签 value:打印标签的值 list:以用户友好的格式打印设备 device:仅打印设备名称-t、--match-token NAME=VALUE:搜索具有名为 NAME 且值为 VALUE 的属性的块设备。NAME 可以是 TYPE、LABEL 或 UUID。-U、--uuid [UUID]...:查找使用此文件系统 UUID 的设备。blkid [选项] [设备名称]选项:修改 blkid 命令行为的各种命令选项。设备名称:要搜索的设备名称。可以省略。

root@meng:~# which blkid

/usr/sbin/blkid

root@meng:~# blkid --help

Usage:

blkid --label <label> | --uuid <uuid>

blkid [--cache-file <file>] [-ghlLv] [--output <format>] [--match-tag <tag>]

[--match-token <token>] [<dev> ...]

blkid -p [--match-tag <tag>] [--offset <offset>] [--size <size>]

[--output <format>] <dev> ...

blkid -i [--match-tag <tag>] [--output <format>] <dev> ...

Options:

-c, --cache-file <file> read from <file> instead of reading from the default

cache file (-c /dev/null means no cache)

-d, --no-encoding don't encode non-printing characters

-g, --garbage-collect garbage collect the blkid cache

-o, --output <format> output format; can be one of:

value, device, export or full; (default: full)

-k, --list-filesystems list all known filesystems/RAIDs and exit

-s, --match-tag <tag> show specified tag(s) (default show all tags)

-t, --match-token <token> find device with a specific token (NAME=value pair)

-l, --list-one look up only first device with token specified by -t

-L, --label <label> convert LABEL to device name

-U, --uuid <uuid> convert UUID to device name

Low-level probing options:

-p, --probe low-level superblocks probing (bypass cache)

-i, --info gather information about I/O limits

-H, --hint <value> set hint for probing function

-S, --size <size> overwrite device size

-O, --offset <offset> probe at the given offset

-u, --usages <list> filter by "usage" (e.g. -u filesystem,raid)

-n, --match-types <list> filter by filesystem type (e.g. -n vfat,ext3)

-D, --no-part-details don't print info from partition table

-h, --help display this help

-V, --version display version

Arguments:

<size> and <offset> arguments may be followed by the suffixes for

GiB, TiB, PiB, EiB, ZiB, and YiB (the "iB" is optional)

<dev> specify device(s) to probe (default: all devices)

For more details see blkid(8).

二:案例

root@meng:~# blkid

/dev/mapper/ubuntu--vg-ubuntu--lv: UUID="66ea190c-3f56-425b-961c-ffe622ebf98c" BLOCK_SIZE="4096" TYPE="ext4"

/dev/sda2: UUID="9f85f04d-eef5-4538-b062-caf325262174" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="57221264-a978-4def-b378-30e797a61a7a"

/dev/sda3: UUID="a61MiJ-taH2-6XD6-W1ug-wdfM-TvTu-nzQG0D" TYPE="LVM2_member" PARTUUID="ea6fe76e-c5d2-498c-b6ef-a1bffb1aed9d"

/dev/loop1: TYPE="squashfs"

/dev/loop6: TYPE="squashfs"

/dev/loop4: TYPE="squashfs"

/dev/loop0: TYPE="squashfs"

/dev/loop5: TYPE="squashfs"

/dev/loop3: TYPE="squashfs"

/dev/sda1: PARTUUID="94a876d5-73f1-4ddb-8575-a5c17410489d"

root@meng:~# blkid -o list

device fs_type label mount point UUID

-----------------------------------------------------------------------------------------------------------------------------------------------------------

/dev/mapper/ubuntu--vg-ubuntu--lv ext4 / 66ea190c-3f56-425b-961c-ffe622ebf98c

/dev/sda2 ext4 /boot 9f85f04d-eef5-4538-b062-caf325262174

/dev/sda3 LVM2_member (in use) a61MiJ-taH2-6XD6-W1ug-wdfM-TvTu-nzQG0D

/dev/loop1 squashfs /snap/core20/2318

/dev/loop6 squashfs /snap/lxd/29351

/dev/loop4 squashfs /snap/snapd/21465

/dev/loop0 squashfs /snap/core20/2264

/dev/loop5 squashfs /snap/snapd/21759

/dev/loop3 squashfs /snap/lxd/28373

/dev/sda1 (not mounted)

root@meng:~# blkid -t TYPE=ext4

/dev/mapper/ubuntu--vg-ubuntu--lv: UUID="66ea190c-3f56-425b-961c-ffe622ebf98c" BLOCK_SIZE="4096" TYPE="ext4"

/dev/sda2: UUID="9f85f04d-eef5-4538-b062-caf325262174" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="57221264-a978-4def-b378-30e797a61a7a"

0 阅读:1