# lsblk — List Block Devices as a Tree

> Practical guide to lsblk — show disks, partitions and mount points as a readable tree and pick the right device before running dd, fdisk or mount.

Source: https://www.jpkc.com/db/en/cheatsheets/shell-system/lsblk/

<!-- PROSE:intro -->
lsblk lists every block device on your system – hard disks, SSDs, partitions, loop devices and USB sticks – as a readable tree with name, size, type and mount point. It reads its information straight from the kernel (sysfs/udev) and is a pure read-only command: it changes nothing and is safe to run as often as you like. That makes lsblk the ideal sanity check before you operate on a device with `dd`, `fdisk` or `mount` – you confirm exactly which `/dev/…` you are dealing with and avoid grabbing the wrong disk by accident.
<!-- PROSE:intro:end -->

## Basic Usage

`lsblk` — List all block devices in tree format.

```bash
lsblk
```

`lsblk -a` — Show all devices including empty ones.

```bash
lsblk -a
```

`lsblk <device>` — Show info for a specific device.

```bash
lsblk /dev/sda
```

`lsblk -l` — List format (flat, no tree).

```bash
lsblk -l
```

## Output Columns

`lsblk -f` — Show filesystem type, label, UUID, and mount point.

```bash
lsblk -f
```

`lsblk -o <columns>` — Show specific columns.

```bash
lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT,UUID
```

`lsblk -o NAME,SIZE,TYPE,TRAN,MODEL` — Show device model and transport type.

```bash
lsblk -o NAME,SIZE,TYPE,TRAN,MODEL
```

`lsblk -O` — Show all available columns.

```bash
lsblk -O
```

`lsblk --help` — Show help, including the list of all available column names.

```bash
lsblk --help
```

## Output Formats

`lsblk -J` — Output in JSON format.

```bash
lsblk -J
```

`lsblk -P` — Output in key=value pairs format.

```bash
lsblk -P
```

`lsblk -r` — Raw output (for scripting).

```bash
lsblk -r -o NAME,SIZE,MOUNTPOINT
```

`lsblk -b` — Show sizes in bytes instead of human-readable.

```bash
lsblk -b
```

## Filtering

`lsblk -d` — Show only whole disks (no partitions).

```bash
lsblk -d
```

`lsblk -n` — Suppress the header line.

```bash
lsblk -n -o NAME,SIZE
```

`lsblk -e <major>` — Exclude devices by major number (7=loop).

```bash
lsblk -e 7
```

`lsblk -I <major>` — Include only devices with a specific major number (8=SCSI/SATA).

```bash
lsblk -I 8
```

## Common Patterns

`lsblk -d -o NAME,SIZE,MODEL,TRAN` — List physical disks with model and interface type.

```bash
lsblk -d -o NAME,SIZE,MODEL,TRAN
```

`lsblk -f -o NAME,FSTYPE,SIZE,MOUNTPOINT,FSUSE%` — Show filesystem usage per partition.

```bash
lsblk -f -o NAME,FSTYPE,SIZE,MOUNTPOINT,FSUSE%
```

`lsblk -o NAME,UUID -n -l | grep -v '^$'` — List all partition UUIDs (for fstab).

```bash
lsblk -o NAME,UUID -n -l | grep -v '^$'
```

`lsblk -S` — Show SCSI/SATA device information.

```bash
lsblk -S
```

<!-- PROSE:outro -->
## Conclusion

lsblk is one of those commands worth picking up early: a single call gives you a clear overview of every disk, its partitions and where they are mounted. Day to day you mostly need plain `lsblk` for the tree and `lsblk -f` to see filesystems, labels and UUIDs; with `-o` and `-J` you tailor the output for reports or scripts. Its biggest value is as a safe sanity check: always confirm with lsblk which `/dev/…` device you are looking at before you touch it with `dd`, `fdisk` or `mount`. lsblk itself writes nothing and does no harm – the danger only arises when you hand the wrong device to a destructive command.

## Further Reading

- [lsblk(8) — man page](https://man7.org/linux/man-pages/man8/lsblk.8.html) – complete reference of all options and output columns
- [Arch Wiki: Persistent block device naming](https://wiki.archlinux.org/title/Persistent_block_device_naming) – how UUIDs and labels from lsblk map to stable device names in fstab
<!-- PROSE:outro:end -->

## Related Commands

- [fdisk](https://www.jpkc.com/db/en/cheatsheets/shell-system/fdisk/) – view and edit disk partition tables
- [mount](https://www.jpkc.com/db/en/cheatsheets/shell-system/mount/) – attach filesystems to the directory tree
- [df-du](https://www.jpkc.com/db/en/cheatsheets/shell-system/df-du/) – check used and free disk space

