473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Easy way to detect hard drives and partitions in Linux

I need a way to detect hard drives and their partitions... labels would
be nice too... I did some googling but did not find anything all too
useful. This will strictly be on Linux / Unix so any help would be
greatly appreciated.

TIA

Jul 19 '05 #1
3 5392
RunLevelZero wrote:
I need a way to detect hard drives and their partitions... labels would
be nice too... I did some googling but did not find anything all too
useful. This will strictly be on Linux / Unix so any help would be
greatly appreciated.


os.popen('/sbin/sfdisk -l /dev/hda') etc... ?

Or reading from /proc/ide and friends?
Jul 19 '05 #2
You're not going to find a single portable "unix" way of doing this.
The format of /etc/fstab and /etc/mtab are pretty portable, but they
only list mountable/mounted partitions, not all partitions.

In addition to the linux possibilities mentioned in another reply, there
is also /proc/partitions. Finally, if you only want to recognize
FDISK.EXE-type partitions (used by many types of Linux, though that
seems to be changing in Fedora Core 4), it shouldn't be hard to write a
Python program to read the partition table directly from the disk. The
details will be readily available online.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCn0rcJd01MZaTXX0RAhVLAJ90DC3XyxTcgnweHqvHbq fQlBKZIgCfSpdl
O8X4WWSLBjcr6tJxIJUAiz4=
=evN/
-----END PGP SIGNATURE-----

Jul 19 '05 #3


Jeff Epler wrote:
You're not going to find a single portable "unix" way of doing this.
The format of /etc/fstab and /etc/mtab are pretty portable, but they
only list mountable/mounted partitions, not all partitions.

In addition to the linux possibilities mentioned in another reply, there
is also /proc/partitions. Finally, if you only want to recognize
FDISK.EXE-type partitions (used by many types of Linux, though that
seems to be changing in Fedora Core 4), it shouldn't be hard to write a
Python program to read the partition table directly from the disk. The
details will be readily available online.

Jeff


Well thanks for the responses and so quickly. I'm very new to
programming and am not afraid to say it. I'll see what I can come up
with. at least this is a good start.

Thanks.

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Steve | last post by:
This post has two parts. First is my feedback on sets. (Hello? Last summer called, they want their discussion thread back...) Second is some questions about my implementation of a partition...
6
by: cantabile | last post by:
Hi, I'd like to get drives and partitions (and their size too) with python under Linux. So far, I thought of reading /proc/partitions but maybe i could use fdsik also ? How would I do that in...
3
by: Ned Hart | last post by:
I'm formatting my mirrored drives and installing a third drive for raid 5 to add more space. I have backup exec. Can anyone tell me the best way to backup SQL so I can be sure it will restore...
8
by: Claudio Grondi | last post by:
It is maybe not a pure Python question, but I think it is the right newsgroup to ask for help, anyway. After connecting a drive to the system (via USB or IDE) I would like to be able to see...
3
by: Flix | last post by:
I need to detect the root directories of the installed hard disks (es: C:, D:, E:, etc.). I'm not interested in cd drives. I know that there is a way (a bit slow, if I remeber) to retrive all the...
7
by: jimdscudder | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location:...
2
by: systemresized | last post by:
Hello all good forum related to c++/c Me developing Cross Platform File Explorer. This application can displays all the drives whether it is of FAT32 or ext2 or ext3 or NTFS file sys. drive. Use...
3
AmberJain
by: AmberJain | last post by:
Hello, linux newbie here. PLZ HELP. I recently downloaded DSL (Damn Small Linux) ISO image from the internet and couldnot install it to hard disk. Live CD works fine on my PC. I have 2 partitions C:...
1
by: scotter86 | last post by:
Hey everyone, for the love of god i cannot get this straight. I have 2 hard drives, each runing windows xp home. I installed linux on my second hard drive and it over wrote the windows mbr. thats...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.