-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
Storage mangment API: disks infos #1953
base: dev
Are you sure you want to change the base?
Storage mangment API: disks infos #1953
Conversation
cb97422
to
6dbe2e1
Compare
6dbe2e1
to
a2b7e81
Compare
a2b7e81
to
a1a394f
Compare
Ok I think this is a good first step. Here is an exemple of the result this produces:
In a future PR, I'd like to add the device type (HDD, SSD, …) and RPM for HDDs. I don't really know how to do that. TrueNAS does it by using its own library. In the meantime, this is ready for review. |
src/disks.py
Outdated
encrypted_provider = glob(f"/sys/block/dm-*/slaves/{child_dev.sys_name}") | ||
if encrypted_provider: | ||
# retrive the dm-x part | ||
dm = encrypted_provider[0].split("/")[3] | ||
enc_dev = pyudev.Devices.from_name(device.context, "block", dm) | ||
# This work for LUKS, what about other partition mecanisms? | ||
partname = f"/dev/mapper/{enc_dev.properties['DM_NAME']}" | ||
encrypted = True | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method detects LUKS partitions but I'm not sure it does not detect other unecrypted partitions, like LVM. If someone with more system knowlege than me could check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could use pyparted
here but this needs sufficient rights. If I'm not mistaken, yunohost-api
is running as root, so this shouldn't be an issue, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this solution detects LVM (non-LUKS) partitions as encrypted. And I can't figure out how to retrieve FS with pyparted. I don't know how gparted and KDE partition manager detect the partition filesystem.
905eafa
to
81d9fa7
Compare
81d9fa7
to
e83e7b3
Compare
A few notes here: I rewrote this PR to use the udisks2 API which provides much more details about disks and is easier to use that udev + other sources of infos. But as a pure dbus API, the code is less self-explanatory. It's mainly about parsing dictionary. Maybe I can make use of something like Tell me if it's OK to add the udisk daemon to Ynh. I'm not aware of everything it entails. |
Naively udisk sounds fine to me 👍 |
Yes i think udisk is a good idea, also because it could help to automount external usb or disk... |
You can know if it's a HDD or SSD by checking directly the info inside /sys...
0 -> SSD /sys/block/sda/queue/removable to know if it's an usb removable disk i guess We could also imagine check for ssd how many written is made, in order to compute an end of life percentage. |
udisks2 provides the information so I don't need a solution anymore. Thanks. |
The problem
Rel: YunoHost/issues#1823.
Add API for getting infos on hard drives.