Bug 654436
| Summary: | anaconda list-harddrives command behaviour has changed in RHEL6 | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Gerardo Arceri <gea> |
| Component: | anaconda | Assignee: | Dave Cantrell <dcantrell> |
| Status: | CLOSED ERRATA | QA Contact: | Release Test Team <release-test-team-automation> |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 6.0 | CC: | atodorov, icomfort, jstodola, peter.sjoberg |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | anaconda-13.21.84-1 | Doc Type: | Bug Fix |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2011-05-19 12:34:56 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Gerardo Arceri
2010-11-17 21:05:24 UTC
For now, you could try sedding the following lines out of list-harddrives (may need to copy it to /tmp first so it'll be writeable):
for part in disk.partitions:
lst.add("%s %s" % (part.path, int(part.getSize())))
Or, perhaps you can try ignoring some of the results:
list-harddrives | grep -v '/dev/sd[a-z][0-9]'
Just as a temporary work around, you know.
The problem is that it's mostly used on (big surprise) brand new servers with no partitions at all and then the output is "" Then we would have better luck with using /proc/partitions but the code to do dynamic partitions goes from set -- $(list-harddisk) figure out partitions based on one or two disks + size of them to cat /proc/partitions|while read major minor blocks name name=loop && next name=lv && next name=disk partition && next name=other non disk things that may be here && next figure out partitions based on one or two disks + size of them Hm, that's definitely not intended behavior. Between RHEL5 and RHEL6, lots of storage things changed including the modules that list-harddrives uses to do its thing. We are now using pyparted (which uses parted) to find all the disks and then iterating over all those.
Here's the relevant part of the list-harddrives code:
import parted
import _ped
lst = set()
for dev in filter(lambda d: d.type != parted.DEVICE_DM, parted.getAllDevices()):
try:
disk = parted.Disk(dev)
except _ped.DiskLabelException:
continue
for part in disk.partitions:
lst.add("%s %s" % (part.path, int(part.getSize())))
print("%s %s" % (dev.path, int(dev.getSize())))
So you can see a couple places where things can go wrong here: parted.getAllDevices could be returning nothing for some reason, all your devices could fall under that parted.DEVICE_DM check, or parted.Disk() could be raising an exception for every device. But I think I'm going to have a relatively hard time figuring this out since I think it's likely to be a problem specific to your disks. At least, I sure hope it is.
Tested on HP blade, ESX Vmware guest and Virtualbox guest with bot IDE and Sata driver - all same thing, no drives listed when not partitioned.
I don't know anything about how the code works but I see "parted" there and can say that if I run "parted -l" I get "Error: /dev/sda unrecognized disk label" and nothing about the disk size - might be related ?
We are currently testing another workaround that looks promising
fdisk -l 2>/dev/null | grep ^Disk.*bytes|sed 's/:/ /;s~/dev/~~'|awk '{print $2,$5/1024}'
but we need one solution that covers as much as possible (rhel4-6, mixed hard ware, single or multiple disks, pre existing partitions or not) without any special cases anywhere (we have enough of them already)
This is an easy one to fix. The output of the RHEL-6 list-harddrives command is: /dev/sda 61057 /dev/sdb 476940 /dev/sdc 30524 /dev/sda1 300 /dev/sda2 60751 /dev/sdb1 476937 /dev/sdc1 30520 The output from the RHEL-5 list-harddrives command would have been: sda 61057.3359375 sdb 476940.023438 sdc 30524.0 The problem is the rewrite of the command added listing of partitions, which is not what the command does. Here's a patch to fix it up: diff --git a/data/command-stubs/list-harddrives-stub b/data/command-stubs/list-harddrives-stub index 2d9e225..4025186 100755 --- a/data/command-stubs/list-harddrives-stub +++ b/data/command-stubs/list-harddrives-stub @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +import os import sys import parted import _ped @@ -26,20 +27,12 @@ def main(argv): lst = set() for dev in filter(lambda d: d.type != parted.DEVICE_DM, parted.getAllDevices()): - try: - disk = parted.Disk(dev) - except _ped.DiskLabelException: - continue - - for part in disk.partitions: - lst.add("%s %s" % (part.path, int(part.getSize()))) - - print("%s %s" % (dev.path, int(dev.getSize()))) + lst.add((os.path.basename(dev.path), dev.getSize())) lst = list(lst) lst.sort() - for entry in lst: - print entry + for dev, size in lst: + print dev, size if __name__ == "__main__": main(sys.argv) This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release. With anaconda-13.21.97-1.el6.x86_64 before and after partitioning the output now is: # list-harddrives vda 8192.0 An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-0530.html |