LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 07-26-2006, 09:21 PM   #1
ojaiguy
LQ Newbie
 
Registered: Jul 2006
Posts: 5

Rep: Reputation: 0
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.

Thanks!
 
Old 07-26-2006, 09:35 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
I like 'fdisk -l'. It'll actually show all the partitions, but it'd be trivial to parse out whatever you need.
 
Old 07-26-2006, 10:18 PM   #3
ojaiguy
LQ Newbie
 
Registered: Jul 2006
Posts: 5

Original Poster
Rep: Reputation: 0
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?
 
Old 07-26-2006, 10:22 PM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Actually, fdisk -l with no arguments displays information for ALL known drives. You can also look in /proc/partitions.
 
Old 07-26-2006, 10:26 PM   #5
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
for fdisk -l you can do:
Code:
fdisk -l | grep -o "^/dev/.[^ ]*"
 
Old 06-16-2008, 03:46 AM   #6
Stin
LQ Newbie
 
Registered: Feb 2008
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25

Rep: Reputation: 15
Hi guys,

I'm working on some DL360's running Redhat, and fdisk -l doesn't output anything.

I need that output in case I need to replace and restore the disks.

Do you guys know how I can get it working or how I can get around this not working?

Thanks in anticipation.

Stin
 
Old 06-16-2008, 04:01 AM   #7
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
1. Run it as root.
2. Don't resurrect a dead thread for a mostly unrelated problem: start a new one instead.
 
Old 06-16-2008, 04:12 AM   #8
Stin
LQ Newbie
 
Registered: Feb 2008
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25

Rep: Reputation: 15
Quote:
Originally Posted by pwc101 View Post
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.
 
Old 06-16-2008, 04:16 AM   #9
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by Stin View Post
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.
Weird. Try /sbin/fdisk -l.

What does locate fdisk turn up?
Quote:
Originally Posted by Stin View Post
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.
It's still almost 2 years ago.
 
Old 06-16-2008, 04:24 AM   #10
Stin
LQ Newbie
 
Registered: Feb 2008
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25

Rep: Reputation: 15
Quote:
Originally Posted by pwc101 View Post
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.

Last edited by Stin; 06-16-2008 at 04:30 AM.
 
Old 06-16-2008, 04:28 AM   #11
Stin
LQ Newbie
 
Registered: Feb 2008
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25

Rep: Reputation: 15
Sorry double post.

Last edited by Stin; 06-16-2008 at 04:29 AM.
 
Old 06-16-2008, 04:37 AM   #12
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by Stin View Post
/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 View Post
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 View Post
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 View Post
Excuse the ...'s. I dont think these forums handle white space very well.
Use [code][/code] tags to preserve formatting.
 
Old 06-16-2008, 04:49 AM   #13
Stin
LQ Newbie
 
Registered: Feb 2008
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25

Rep: Reputation: 15
Thank you very much for your time and patience.

I think it is like that because it is compaq scsi.

I've found this thread but its a bit above my ability right now:

http://www.knoppix.net/forum/viewtopic.php?t=24895

I think they are saying it could be a kernel bug.
 
Old 06-16-2008, 04:55 AM   #14
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Yeah, doesn't look promising.

Do you see any of the messages they mention in either /var/log/messages or the output of dmesg? Things like:
Code:
cpqarray: Finding drives on ida0
cpqarray: ida0: idaSendPciCmd Timeout out, No command List address returned.
cpqarray: error sending ID Controller
 
Old 06-16-2008, 05:58 AM   #15
Stin
LQ Newbie
 
Registered: Feb 2008
Distribution: Redhat 7.3 Valhalla, Solaris 8, HP Tru64
Posts: 25

Rep: Reputation: 15
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


[root@rpc1 /proc]# more partitions
Code:
major minor  #blocks  name

  72     0    8878080 ida/c0d0
  72     1     134640 ida/c0d0p1
  72     2          1 ida/c0d0p2
  72     3      36704 ida/c0d0p3
  72     5    2431664 ida/c0d0p5
  72     6     134624 ida/c0d0p6
  72     7     134624 ida/c0d0p7
  72     8    6001664 ida/c0d0p8
  22     0 1073741823 hdc
[root@rpc1 /proc]# exit
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
2 hard drives, XP on my main sata drives, 10.2 on my IDE LILO doesnt show on boot up Dachy Slackware 14 01-03-2008 07:01 AM
How can I get konqueror's media:/ to list hard drives by label instead of size? DaneM Linux - Software 1 06-03-2006 02:57 PM
I have two 35 GB hard-drives with Ubuntu installed. How to set up RAID? Mateo1041 Linux - Hardware 31 01-19-2006 01:32 PM
System's locks when running games installed via apt JackieBrown Debian 7 09-01-2005 08:42 PM
Upgrading hard drives on Software raid 1 boot drives. linuxboy123 Linux - General 0 12-11-2003 03:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 10:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration