Bug #5211
closed
ceph-disk prepare: list_partitions() shouldn't return disks
Added by Alexandre Marangone almost 11 years ago.
Updated almost 11 years ago.
Description
# ceph-disk-prepare /dev/sda
ceph-disk: Error: Device is mounted: /dev/sdak1
list_partitions('/dev/sda') will on my server return:
/dev/sdaa
/dev/sdab
/dev/sdac
/dev/sdad
/dev/sdae
/dev/sdaf
/dev/sdag
/dev/sdai
/dev/sdah
/dev/sdaj
/dev/sdak
/dev/sdak1
- Subject changed from ceph-disk prepare: list_partitions doesn't take into account sdaa, sdab, etc. to ceph-disk prepare: list_partitions() shouldn't return disks
More info:
A customer has its OS installed on /dev/sdak.
When running ceph-disk prepare /dev/sda, ceph-disk-prepare will return an error stating that sdak is partitioned.
This is obviously not right.
After digging a bit it seems that the list_partitions() function get confused with disk named sdaa, sdab, etc.
This potentially impacts anyone with more than 26 disks and a OS installed on a disk above the 26th.
the python code that does this is pretty kludgey.. any suggestions for a more robust enumeration strategy should be pretty easy to implement
One way to do that would be to use lsblk /dev/<disk> and look for the word "part". I'm not sure lsblk is on every distribution though.
Another way that would probably work everywhere would be to list /sys/block/<disk>/ and look for <disk>N (N: partition number).
- Project changed from Ceph to devops
- Assignee set to Alexandre Marangone
Alexandre, please implement one of the suggestions you mentioned.
i think the right way to do this is to look to see if /sys/block/$disk/$part exist (e.g., /sys/block/sda/sda1) to tell if it is a child partition.
- Status changed from New to Fix Under Review
- Status changed from Fix Under Review to Pending Backport
- Status changed from Pending Backport to Resolved
Also available in: Atom
PDF