472,961 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 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 5369
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.