Linux - How to figure out what harddrives are attached?
Solution 1
fdisk -l
Solution 2
For those coming here from a search - this is (currently) an old question with old answers, but there are other newer posts that answer this question better.
The solution I prefer is:
root# lsblk -io NAME,TYPE,SIZE,MOUNTPOINT,FSTYPE,MODEL
NAME TYPE SIZE MOUNTPOINT FSTYPE MODEL
sdb disk 2.7T WDC WD30EZRX-00D
`-sdb1 part 2.7T linux_raid_member
`-md0 raid1 2.7T /home xfs
sda disk 1.8T ST2000DL003-9VT1
|-sda1 part 196.1M /boot ext3
|-sda2 part 980.5M [SWAP] swap
|-sda3 part 8.8G / ext3
|-sda4 part 1K
`-sda5 part 1.8T /samba xfs
sdc disk 2.7T WDC WD30EZRX-00D
`-sdc1 part 2.7T linux_raid_member
`-md0 raid1 2.7T /home xfs
sr0 rom 1024M CDRWDVD DH-48C2S
References:
- https://unix.stackexchange.com/q/4561
- https://askubuntu.com/q/182446
- https://serverfault.com/a/5081/109417
Solution 3
The sg_* utilities might also be useful:
$ sudo sg_map -i
/dev/sg0 /dev/sda ATA WDC WD5000BEVT-2 01.0
/dev/sg1 /dev/scd0 Optiarc BD ROM BC-5500S 1.83
/dev/sg2 /dev/sdb ATA WDC WD5000BEVT-0 01.0
/dev/sg3 /dev/sdc WD PP III Studio II 0817
There are lots of other commands in the sg utilities such as sg_scan, sg_readcap and so on.
Also if you are booted from a redhat/centos cd you can switch to an alternate console and use the "list-harddrives" command to show disks attached to the system.
Solution 4
fdisk -l
dmesg
/var/log/message..
Solution 5
Depends on how the drive is attached.
ATA/SATA drives should normally be detected on bootup. Look into the boot log (/var/log/syslog, /var/log/messages
, output of dmesg
).
There should also be a list of recognized partitions for all partitioned drives under /proc/partitions
.
For hotplugged drives (e.g. USB) it depends on how the distribution manages them. Usually modern distros use udev (older might use hotplug or hald). The log is configurable, either a separate log under /var/log
, or in the general log messages
or syslog
).
Related videos on Youtube
Araejay
Updated on September 17, 2022Comments
-
Araejay almost 2 years
So I have a server that has a few harddrives in it, all formatted and mounted. However I'm told there is another drive attached to it. How do I find out what drives are attached? How do I find out the device filename for this new drive (that's not mounted)
-
sleske over 14 yearsWhat "mandatory extra characters"? Just
fdisk -l
will list all devices mentioned in/proc/partitions
, which is just what's needed in this case. -
Chopper3 over 14 yearssorry, serverfault.com doesn't accept answers with less that 15 characters, so sometimes, when you have a very short but appropriate answer you have to add padding before you can click ok :)
-
Skaperen over 9 yearssay it like: the best way I have found is: fdisk -l