Skip to content

Listing storage devices

lsblk

You can use the lsblk command to list all storage devices connected to your system. This command provides detailed information about each device, including the device name, size, type, and mount point.

Here's how you can use the lsblk command:

bash
lsblk

Example output:

bash
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   1TB   0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0   200G  0 part /
├─sda3   8:3    0   770G  0 part /home
└─sda4   8:4    0    32G  0 part [SWAP]
sdb      8:16   1  64GB   0 disk 
├─sdb1   8:17   1   1GB   0 part
└─sdb2   8:18   1  63GB   0 part /mnt/usb

In the example above:

  • NAME: The name of the storage device.
  • MAJ:MIN: The major and minor device numbers.
  • RM: Whether the device is removable (1) or not (0).
  • SIZE: The size of the device, displayed in MB, GB, or TB.
  • RO: Whether the device is read-only (1) or not (0).
  • TYPE: The type of device (disk or partition).
  • MOUNTPOINT: The mount point of the device (if mounted). The mount point is the location in the file system where the device is accessible.

fdisk

Another command you can use to list storage devices is fdisk. This command provides a more detailed view of the storage devices and partitions on your system.

Here's how you can use the fdisk command:

bash
sudo fdisk -l

Example output:

bash
Disk /dev/sda: 233.76 GiB, 251000193024 bytes, 490234752 sectors
Disk model: APPLE SSD SM0256
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: D34D7EET-D34D-B33F-B4B3-7EEF3D4D7EET

Device         Start       End   Sectors   Size Type
/dev/sda1         40    409639    409600   200M EFI System
/dev/sda2     409640 365039391 364629752 173.9G Apple APFS
/dev/sda3  481845248 490234718   8389471     4G Linux swap
/dev/sda4  365039616 366088191   1048576   512M EFI System
/dev/sda5  366088192 481845247 115757056  55.2G Linux filesystem

Partition table entries are not in disk order.