LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-20-2005, 10:34 PM   #1
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
Determine physical disk size


Hi,

Is there any easy way to determine how many physical disks are attached to a Linux server and the size of each disk.

I have tried using sfdisk, fdisk, df and lspci to try and work this out but to no avail.

We have just noticed that there are two physical drives connected to this box from this command. Is there anyway of finding out the entire size of each drive.

This is the output from grep -i disk /var/log/*

dmesg:Attached scsi disk sda at scsi1, channel 0, id 0, lun 0
dmesg:Attached scsi disk sdb at scsi1, channel 0, id 1, lun 0

Cheers,
-Kristijan
 
Old 01-20-2005, 11:01 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
How about this:
Code:
fdisk -l | grep "^Disk" | cut -f 1 -d ',' | cut -f 3- -d '/'
 
Old 01-23-2005, 04:00 PM   #3
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Original Poster
Rep: Reputation: 30
Dark_Helmet,

Running that command on my box at home seems to work fine. Shows the exact disk size. I gave it a shot when I got into work this morning and this was the output.

Code:
[root@GEO1 root]# fdisk -l | grep "^Disk" | cut -f 1 -d ',' | cut -f 3- -d '/'
sda: 255 heads
sdb: 255 heads
This is the output of fdisk -l

Code:
[root@GEO1 root]# fdisk -l

Disk /dev/sda: 255 heads, 63 sectors, 4467 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   fd  Linux raid autodetect
/dev/sda2            14       140   1020127+  fd  Linux raid autodetect
/dev/sda3           141      4467  34756627+  fd  Linux raid autodetect

Disk /dev/sdb: 255 heads, 63 sectors, 4467 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1   *         1        13    104391   fd  Linux raid autodetect
/dev/sdb2            14       140   1020127+  fd  Linux raid autodetect
/dev/sdb3           141      4467  34756627+  fd  Linux raid autodetect
This is the output from df -h

Code:
[root@GEO1 root]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0               33G  720M   30G   3% /
/dev/md2               99M   15M   78M  16% /boot
none                 1008M     0 1008M   0% /dev/shm
Can someone clarify the output of df. Does Size show the total size of the disk, or does it just show the total of all the partitions.

For example, if I have a 80GB disk, and make 2 partitions, 30GB and a 20GB partition. Will df show the total size of the 2 partitions (50GB) or will it show the total disk size, including the empty space (80GB)

There is nothing there that exactly tells me /dev/sda = xxGB, or it is there and I can't see it =/

Cheers,
-Kristijan
 
Old 01-23-2005, 04:18 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
The command I gave was just highlighting a specifc portion ofthe fisk output (as you probably guessed).

You can calculate the size of the disk using its geometry listed. You might be able to incorporate this into a shell script to avoid whipping out the calculator, but it's reasonably quick.

Basically, it's just a lot of multiplication: heads * sectors per track * cylinders * bytes per sector = raw size of disk in bytes

In your case, both sda and sdb are identical since they're both in an array (and their numbers match). So, using my calculator:
(heads) * (sectors) * (cylinders) * (bytes) = 255 * 63 * 4467 * 512 = 36742325760

Or, in more familiar terms:
36742325760 / 1000000000 = 36.7 GB
36742325760 / (1024 * 1024 * 1024) = 34.2 GiB
 
Old 01-23-2005, 05:56 PM   #5
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Original Poster
Rep: Reputation: 30
Dark_Helmet,

Thanks for all the help. If I get some free time, I will throw together a small shell script to automate these calculations. I'll keep you posted if I do

Cheers,
-Kristijan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Size in superblock is different from the physical size of the partition cyberfishee Linux - Hardware 18 09-11-2016 08:48 AM
Determine Physical RAM size skistner Linux - Hardware 18 02-22-2010 12:57 PM
hping: physical layer header size unknown Ephracis Linux - Software 4 03-27-2009 06:57 PM
Size of physical RAM bkankur Linux - General 3 07-21-2006 05:27 AM
/proc/kcore size doesn't match with physical ram size cash_05 Linux - Newbie 2 06-01-2005 01:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:30 AM.

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