Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to find storage devices attached to computer

📅 2015-Jan-23 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ disk, fdisk, lshw, storage ⬩ 📚 Archive

Two storage devices found attached to computer

Storage devices like hard disks, SSD drives, CD/DVD disks, SD cards and USB thumbdrives can be plugged into a Linux computer. For many operations, we need to know the device name of the storage device. For example, /dev/sda. Partitions created on this device to store data will have characters suffixed to this device name. For example, /dev/sda7 might be a partition on the /dev/sda hard disk.

Using fdisk

I like to find out the device name of storage devices by listing them out using fdisk:

$ sudo fdisk -l

For each storage device, this lists the device name (named after Disk) followed by information about it and its partitions.

Using df

The df command lists the mounted partitions on the computer:

$ df -h

You will have to guess the name of the storage device from the partition name by removing a few characters of suffix. For example, partitions on a SD card named /dev/mmcblk0 might be named as /dev/mmcblk0p1 and /dev/mmcblk0p2.

Using GNOME Disk

The GNOME Disk utility is typically pre-installed on Ubuntu. It can be invoked from the Dash using its name Disks or from the shell as gnome-disks. It shows all the attached storage devices and their name is listed under Device.

Using lshw

Some people suggest listing the disk class of devices from the lshw command:

$ sudo lshw -class disk

I do not prefer this since it does not list SD cards and many such storage devices.

Tried with: Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧