--- page-title: "Find All Storage Devices Attached to a Linux Machine | Baeldung on Linux" url: https://www.baeldung.com/linux/find-all-storage-devices date: "2024-12-31 17:03:02" --- ## 1\. Introduction[](https://www.baeldung.com/linux/find-all-storage-devices#introduction) We often have to check the storage devices present on a machine. This is very useful when we have to check if all the hard disks and SSDs are recognized on the system and if any external storage devices are being handled correctly by the system. Linux offers multiple ways to list the storage devices attached to the system. In this tutorial, we shall look at them one by one. ## 2\. Reading */proc/partitions*[](https://www.baeldung.com/linux/find-all-storage-devices#reading-procpartitions) Every Linux distribution comes with a */proc* directory which contains different files that give different kinds of information about the current state of the system. However, this is a virtual file system. This means that these files don’t actually exist on the disk, but these file paths can be read by any application or command as if they were real files. */proc/partitions* is the file that contains details about the attached storage devices. So **running the [*cat*](https://man7.org/linux/man-pages/man1/cat.1.html) command on the */proc/partitions* will give us the required information**: ``` $ cat /proc/partitions major minor #blocks name 8 0 117220824 sda 8 1 524288 sda1 8 2 1 sda2 8 5 116694016 sda5 8 16 976762584 sdb 8 17 1024 sdb1 8 18 976758784 sdb2 ``` This method however shows output only in blocks, with the labels of each partition. ## 3\. *fdisk*[](https://www.baeldung.com/linux/find-all-storage-devices#fdisk) [*fdisk*](https://man7.org/linux/man-pages/man8/fdisk.8.html) is the Linux command used to perform operations on disks and partitions in Linux. We can **use *fdisk -l* to list all storage devices and their partitions.** This command may not work unless it is run as a root user or with [*sudo*](https://linux.die.net/man/8/sudo): ``` # fdisk -l Disk /dev/sda: 111.81 GiB, 120034123776 bytes, 234441648 sectors Disk model: SATA SSD Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x229714a0 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 1050623 1048576 512M b W95 FAT32 /dev/sda2 1052670 234440703 233388034 111.3G 5 Extended /dev/sda5 1052672 234440703 233388032 111.3G 83 Linux Disk /dev/sdb: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors Disk model: ST1000LM024 HN-M 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: 62FC8895-DF66-4DF6-9DAB-B193B64AA56B Device Start End Sectors Size Type /dev/sdb1 2048 4095 2048 1M Linux filesystem /dev/sdb2 4096 1953521663 1953517568 931.5G Linux filesystem ``` As we see above, the output is very detailed and neatly formatted. It describes all the storage devices attached to the system along with their total size, model, label, partitions and other useful data. ## 4\. *lsblk*[](https://www.baeldung.com/linux/find-all-storage-devices#lsblk) The [*lsblk*](https://man7.org/linux/man-pages/man8/lsblk.8.html) command stands for “list blocks” and **can be used to list all the block storage devices attached to the system:** ``` $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 111.8G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 111.3G 0 part / sdb 8:16 0 931.5G 0 disk ├─sdb1 8:17 0 1M 0 part └─sdb2 8:18 0 931.5G 0 part ``` As we see above, the hierarchy of partitions is clearly printed, and we can see which disks are attached and which partitions are present under them. However, only the device labels are printed and not the device names. ## 5\. *lshw*[](https://www.baeldung.com/linux/find-all-storage-devices#lshw) The [*lshw*](https://linux.die.net/man/1/lshw) command can also be used to list the storage devices attached to the system. It stands for “list hardware” and by default lists all the hardware devices connected to the system. However, we can **use the *class* argument to filter the list and display only the ‘disk’ devices**. As with *fdisk*, we may need to be root or use *sudo* to use this command: ``` # lshw -class disk *-disk description: ATA Disk product: SATA SSD physical id: 0.0.0 bus info: scsi@0:0.0.0 logical name: /dev/sda version: Sf10 serial: 00000000000000000552 size: 111GiB (120GB) capabilities: partitioned partitioned:dos configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=229714a0 *-disk description: ATA Disk product: ST1000LM024 HN-M physical id: 0.0.0 bus info: scsi@1:0.0.0 logical name: /dev/sdb version: 0003 serial: S314J90F791172 size: 931GiB (1TB) capabilities: gpt-1.00 partitioned partitioned:gpt configuration: ansiversion=5 guid=62fc8895-df66-4df6-9dab-b193b64aa56b logicalsectorsize=512 sectorsize=4096 ``` ## 6\. *parted*[](https://www.baeldung.com/linux/find-all-storage-devices#parted) The utility of the [*parted*](https://man7.org/linux/man-pages/man8/parted.8.html) command is very similar to that of the *fdisk* command. It can be used to manage disks and their partitions. We can **use the *\-l* argument to display the storage devices**: ``` # parted -l Model: ATA SATA SSD (scsi) Disk /dev/sda: 120GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 538MB 537MB primary fat32 boot 2 539MB 120GB 119GB extended 5 539MB 120GB 119GB logical ext4 Model: ATA ST1000LM024 HN-M (scsi) Disk /dev/sdb: 1000GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 2097kB 1049kB 2 2097kB 1000GB 1000GB ext4 ``` Very similar to *fdisk*, we can see all the storage devices attached, along with their names, labels, mount points, filesystem type, and partitions. ## 7\. *sfdisk*[](https://www.baeldung.com/linux/find-all-storage-devices#sfdisk) **[*sfdisk*](https://man7.org/linux/man-pages/man8/sfdisk.8.html) is an advanced version of the *fdisk* command**. Its output is very similar to the *parted* command, showing disk labels, disk model partitions, and filesystem type on each partition: ``` # sfdisk -l Disk /dev/sda: 111.81 GiB, 120034123776 bytes, 234441648 sectors Disk model: SATA SSD Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x229714a0 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 1050623 1048576 512M b W95 FAT32 /dev/sda2 1052670 234440703 233388034 111.3G 5 Extended /dev/sda5 1052672 234440703 233388032 111.3G 83 Linux Disk /dev/sdb: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors Disk model: ST1000LM024 HN-M 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: 62FC8895-DF66-4DF6-9DAB-B193B64AA56B Device Start End Sectors Size Type /dev/sdb1 2048 4095 2048 1M Linux filesystem /dev/sdb2 4096 1953521663 1953517568 931.5G Linux filesystem ``` ## 8\. Conclusion[](https://www.baeldung.com/linux/find-all-storage-devices#conclusion) In this article, we discussed six ways to list the storage devices attached to a Linux system, out of which *fdisk*, *sfdisk,* and *parted* give a very similar detailed output. The outputs from *cat /proc/partitions* and *lsblk* are very concise, and we could use them for further processing, such as in a bash script. The *lshw* command prints low-level information about storage devices such as serial and bus info that could be useful in debugging problems.