Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all storage devices attached to a Linux machine [closed]

Tags:

linux

bash

shell

I have a need to find all of the writable storage devices attached to a given machine, whether or not they are mounted.

The dopey way to do this would be to try every entry in /dev that corresponds to a writable devices (hd* and sd*)......

Is there a better solution, or should I stick with this one?

like image 764
warren Avatar asked Oct 14 '08 12:10

warren


People also ask

Which command gives us details of connected storage devices?

The proper way to list block devices such as hard disks is using the command lsblk. Note: the -a flag forces lsblk to list also empty devices. In the first column you can see all the connected devices, in the image above you can see 3 devices: sda, sdc and sdd. Lets see some information on each.

Where are storage device files located on Linux systems?

All Linux device files are located in the /dev directory, which is an integral part of the root (/) filesystem because these device files must be available to the operating system during the boot process.


1 Answers

/proc/partitions will list all the block devices and partitions that the system recognizes. You can then try using file -s <device> to determine what kind of filesystem is present on the partition, if any.

like image 153
Steve Baker Avatar answered Oct 23 '22 04:10

Steve Baker