how to detect size of IDE device
Hi. I am writing a script to detect the sizes of the IDE devices connected to my system. What is the most accuate way of doing it. Right now I am mouting the device on one of my directory adn then give the command df -h to check the size.
Is there any other way by which I can check the total size of device with mounting them?? Thanks |
Try the command: sfdisk -s /dev/hda
|
Quote:
hey that worked. Also, it gives the output in KBs. Is there any way(through a command) by which i can divide it with 1000(just corrected) so that I get the output in MB straightaway. Some thing like: sfdisk -s /dev/hdc | (divide operation here). Thank you once again. |
1mb is actually 1024kb not 100
of course this is file system size for a meg and not the hardware industry standard meg to make this more confusing blocks change size too with file system. as far as what command can be used mabye calc but im not sure at this very moment what the baisc program is for math operations with bash. |
If you don't care about the remainder, you can perform the division in bash.
mbsize=(( $kbsize/1024 )) |
Yeah I understand what you are saying . But in the first place how can I get the output of the command sfdisk -s /dev/hdc into the variable $kbsize?
Thanks |
I made a script a while back to show how much un-partitioned space was left on a drive.
Here is a snip for what you want.... Code:
#!/bin/bash Code:
#!/bin/bash |
That;sGreat!!! Thanks you so much. :)
|
To know the total size in MB you could also do :
Code:
sfdisk -s -uM /dev/hda |
All times are GMT -5. The time now is 06:57 AM. |