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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
01-20-2005, 10:34 PM
|
#1
|
Member
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394
Rep:
|
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
|
|
|
01-20-2005, 11:01 PM
|
#2
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
How about this:
Code:
fdisk -l | grep "^Disk" | cut -f 1 -d ',' | cut -f 3- -d '/'
|
|
|
01-23-2005, 04:00 PM
|
#3
|
Member
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394
Original Poster
Rep:
|
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
|
|
|
01-23-2005, 04:18 PM
|
#4
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
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
|
|
|
01-23-2005, 05:56 PM
|
#5
|
Member
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394
Original Poster
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 01:30 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|