-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Linux] new API to list swap_partitions() #1681
Comments
swap is missing
did you try |
yes |
Mmm I am not sure. Partitions are retrieved via Line 228 in 05758f6
I assume that means /etc/mtab does not list swap partitions (I checked on my system: it's the same). |
It turns out swap partions are listed in |
First of all, thanks @giampaolo for the change. Unfortunately I still have a thought with your implementation. As I understand the documentation, all=False should filter on hardware. So USB sticks, hard drives and SSDs, but leave out virtual devices. I don't see the SWAP memory itself as such a virtual device, like a RAM disk. In my case it is not even a SWAP file, but a real partition. So I think it would be cool if this could be adjusted a bit more. I hope it is possible |
You got me thinking here so I investigated this topic a bit. The problem with swap partitions/files is that they are not like other regular partitions and most importantly they are not mounted (having
Since it's a block file, if you do To me this suggests that:
The problem with this is my ignorance: I have no idea how disk files/partitions work on Windows (what Windows API to use, what info we can extract) and also other UNIX systems. And knowing what info we can get is crucial to come up with an API which makes sense. Anyway, for now I think it's safer to revert 00a3398 (sorry). |
So you don't have to apologize for that. I was about to suggest that we reopen the ticket. You were quicker than I was. Maybe we should also think about the function name disk_partitions(). Maybe something where the mount approach comes across would be more understandable. In addition to the swap problem, I have found another problem that we might be able to improve by renaming the function.
As you saw above, I use BTRFS. With this I have merged two partitions. Only one of them is shown in the list. But both are in use as one. I think it's a similar problem to SWAP, but also a little different. With SWAP it is a separate partition after all. Maybe in the future it would be possible to switch to something like "lsblk" as backend. Please don't see this as a negative statement on your super tool, but I want to help you with my ideas to make it even better. |
Of course. When it comes to API decisions any feedback is very welcome (including name bikeshedding =)). Actually I even tweeted about this: As for the BTRFS issue, it seems unrelated to this one, but if you think psutil should work differently in that regard please open a new issue and we'll discuss it there. |
Platform
Bug description
As I understand it, the psutil.disk_partitions function should display all partitions. But my SWAP partitions are not listed.
The text was updated successfully, but these errors were encountered: