Página 1 de 1

Listar los dispositivos de almacenamiento: lsblk

Publicado: 21 Jun 2024, 11:10
por Guillermo
Comandos Linux para consultar hardware

- lsblk: list block devices
Los dispositivos de almacenamiento suelen leer y escribir datos como bloques de bytes. El comando lsblk puede utilizarse para listar los dispositivos de bloques disponibles en un sistema. Ejemplo:

Código: Seleccionar todo

guillermo@maquina:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 465,8G  0 disk
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0 464,3G  0 part /
└─sda3   8:3    0   976M  0 part [SWAP]
sr0     11:0    1  1024M  0 rom
Man page: (página del manual de lsblk)

Código: Seleccionar todo

guillermo@maquina:~$ man lsblk
lsblk - list block devices

SYNOPSIS
lsblk [options] [device...]

DESCRIPTION
lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and
udev db to gather information. If the udev db is not available or lsblk is compiled without udev support, then it tries to
read LABELs, UUIDs and filesystem types from the block device. In this case root permissions are necessary.

The command prints all block devices (except RAM disks) in a tree-like format by default. Use lsblk --help to get a list of
all available columns.

The default output, as well as the default output from options like --fs and --topology, is subject to change. So whenever
possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using --output
columns-list and --list in environments where a stable output is required.

Note that lsblk might be executed in time when udev does not have all information about recently added or modified devices
yet. In this case it is recommended to use udevadm settle before lsblk to synchronize with udev.

The relationship between block devices and filesystems is not always one-to-one. The filesystem may use more block devices,
or the same filesystem may be accessible by more paths. This is the reason why lsblk provides MOUNTPOINT and MOUNTPOINTS
(pl.) columns. The column MOUNTPOINT displays only one mount point (usually the last mounted instance of the filesystem), and
the column MOUNTPOINTS displays by multi-line cell all mount points associated with the device.

OPTIONS
-A, --noempty
Don’t print empty devices.

-a, --all
Disable all built-in filters and list all empty devices and RAM disk devices too.

-b, --bytes
Print the sizes in bytes rather than in a human-readable format.

By default, the unit, sizes are expressed in, is byte, and unit prefixes are in power of 2^10 (1024). Abbreviations of
symbols are exhibited truncated in order to reach a better readability, by exhibiting alone the first letter of them;
examples: "1 KiB" and "1 MiB" are respectively exhibited as "1 K" and "1 M", then omitting on purpose the mention "iB",
which is part of these abbreviations.

-D, --discard
Print information about the discarding capabilities (TRIM, UNMAP) for each device.

-d, --nodeps
Do not print holder devices or slaves. For example, lsblk --nodeps /dev/sda prints information about the sda device only.

-E, --dedup column
Use column as a de-duplication key to de-duplicate output tree. If the key is not available for the device, or the device
is a partition and parental whole-disk device provides the same key than the device is always printed.