Is there a list of a system's installed hard drives?
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there a list of a system's installed hard drives?
I'm thinking about writing a script that lists all of the hard drives that are installed on any given system and parsing through dmesg's output is a bit of a pain. lshw seems to work pretty good but it doesn't list the drives in my old Compaq DL360 so I don't know how much it can be relied on.
The closest thing I think that I can find is /proc/diskstats but does anyone know if there's any other way (via command line) to get a list of a system's hard drives? I would imagine that it's something fairly accessible since GUI tools like KDE's systemsettings seems to do a pretty good job of it.
That's true. I'm no scripting wizard, but I guess you could do a blind
for d in h s ; do
for i in a b c d ; do
echo "running fdisk -l ${d}d${i}"
fdisk -l /dev/${d}d${i}
done
done
But that doesn't take into account some devices like /dev/ida/cXdX the one on my old DL360 or who knows what else that's out there that don't fall into the standard /dev/sdX or /dev/hdX device file format. I was hoping that there'd be some "uber" system file that would have all of the disk info. Is there really not?
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25
Rep:
Quote:
Originally Posted by pwc101
1. Run it as root.
2. Don't resurrect a dead thread for a mostly unrelated problem: start a new one instead.
Thanks for the reply.
1.
If I run fdisk -l as non-root user i get: "Command not found"
If I run fdisk -l as root I get nothing. Just returns me to the prompt with no output.
2.
The people in this thread are using the same hardware as me, the same OS as me, and have fdisk working for them. I thought they might be in the best position to help me out.
1.
If I run fdisk -l as non-root user i get: "Command not found"
If I run fdisk -l as root I get nothing. Just returns me to the prompt with no output.
Weird. Try /sbin/fdisk -l.
What does locate fdisk turn up?
Quote:
Originally Posted by Stin
2.
The people in this thread are using the same hardware as me, the same OS as me, and have fdisk working for them. I thought they might be in the best position to help me out.
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25
Rep:
Quote:
Originally Posted by pwc101
Weird. Try /sbin/fdisk -l.
What does locate fdisk turn up?
It's still almost 2 years ago.
/sbin/fdisk does the same. No output and returns me to a prompt.
OOPS! I didn't see the age. I was just happy to see that people could do what I was trying to do on the hardware I have.
I haven't used locate before, and this is a live system so I dont want to risk it. I'll see if I can run it on the lab one.
man locate shows me about the slocate command. It sounds OK to use, but like I said, I'm currently connected in a production environment.
btw. Here is the output of df -k
[luser@host bin]$ cat /etc/redhat-release
Red Hat Linux release 6.2 (Zoot)
[linus@hmpc01 bin]$ df -k
Filesystem..............1k-blocks....Used.....Available...Use%.Mounted on
/dev/ida/c0d0p6.........130361.......62983....60647.......51%../
/dev/ida/c0d0p1.........130377.......2508.....121137......2%.../boot
/dev/ida/c0d0p8.........5944744......4456824..1187840.....79%../in
/dev/ida/c0d0p5.........2353640......1352648...879412.....61%../usr
Excuse the ...'s. I dont think these forums handle white space very well.
/sbin/fdisk does the same. No output and returns me to a prompt.
OOPS! I didn't see the age. I was just happy to see that people could do what I was trying to do on the hardware I have.
No biggie, we've all been there
Quote:
Originally Posted by Stin
I haven't used locate before, and this is a live system so I dont want to risk it. I'll see if I can run it on the lab one.
man locate shows me about the slocate command. It sounds OK to use, but like I said, I'm currently connected in a production environment.
Probaby a wise choice.
Quote:
Originally Posted by Stin
btw. Here is the output of df -k
[luser@host bin]$ cat /etc/redhat-release
Red Hat Linux release 6.2 (Zoot)
[linus@hmpc01 bin]$ df -k
Filesystem..............1k-blocks....Used.....Available...Use%.Mounted on
/dev/ida/c0d0p6.........130361.......62983....60647.......51%../
/dev/ida/c0d0p1.........130377.......2508.....121137......2%.../boot
/dev/ida/c0d0p8.........5944744......4456824..1187840.....79%../in
/dev/ida/c0d0p5.........2353640......1352648...879412.....61%../usr/
I've not seen that sort of /dev structure before - is this becuse it's a 6.2 install of RedHat?
Quote:
Originally Posted by Stin
Excuse the ...'s. I dont think these forums handle white space very well.
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25
Rep:
I tailed the /var/log/messages file and then tried the fdisk command in another window, and it had no effect on the log.
The ouput of dmesg wasnt very helpful, but this seems a step closer to what I need.
I just want to know how to translate this into what I need from fdisk -l
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.