Skip to content
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] psutil.disk_partitions('/dev/sda') with luks will hide one partition #1488

Open
Torxed opened this issue Apr 14, 2019 · 0 comments
Open
Assignees

Comments

@Torxed
Copy link

Torxed commented Apr 14, 2019

Platform

  • Arch Linux (latest)
  • psutil v5.6.1

Bug description
If having a partition "hidden" behind a luks2 encryption, psutil won't be able to show the actual partition list of said luks volume. Instead, psutil will show the resulting mapper-device instead.

I'm sure this is fine for most use cases, but if you want to use psutil in order to find/target a parition for formatting, this won't cut it. Surely, umount:ing the device will probably solve the problem - but it's still a slightly strange behavior.

Here's the disk setup shown with lsblk:

[anton@Arcinstall ~]$ lsblk -o name -n
sda
├─sda1
└─sda2
  └─luksdev
import psutil
x = psutil.disk_partitions('/dev/sda')
for i in x:
    print(i)

Test results

sdiskpart(device='efivarfs', mountpoint='/sys/firmware/efi/efivars', fstype='efivarfs', opts='rw,nosuid,nodev,noexec,relatime')
sdiskpart(device='/dev/mapper/luksdev', mountpoint='/', fstype='btrfs', opts='rw,relatime,ssd,space_cache,subvolid=5,subvol=/')
sdiskpart(device='securityfs', mountpoint='/sys/kernel/security', fstype='securityfs', opts='rw,nosuid,nodev,noexec,relatime')
sdiskpart(device='tmpfs', mountpoint='/tmp', fstype='tmpfs', opts='rw,noatime')
sdiskpart(device='/dev/sda1', mountpoint='/boot', fstype='vfat', opts='rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro')

/dev/mapper/luksdev is there, but /dev/sda2 is not (where as /dev/mapper/luksdev is a sub-resource of /dev/sda2. Maybe I'm just confused and this is exactly how Linux intended it to behave, and psutil follows suit.

But perhaps list_partitions(all=True) could show the /dev/sda2 device as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants