Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 654436

Summary: anaconda list-harddrives command behaviour has changed in RHEL6
Product: Red Hat Enterprise Linux 6 Reporter: Gerardo Arceri <gea>
Component: anacondaAssignee: Dave Cantrell <dcantrell>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: low Docs Contact:
Priority: low    
Version: 6.0CC: 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
Description of problem:
list-harddrives command behaviour has changed between RHEL5.5 and 6, Previous to RHEL6 release its output listed only the harddrives on the system and not the partitions.



Version-Release number of selected component (if applicable):
13.21.82

How reproducible:
Always

Steps to Reproduce:
1. Boot system into kickstart environment
2. switch to tty2 and type list-harddrives
3. examine output
  
Actual results:
e.g for a system with two unformatted disks 10G (sda/sdb)
RHEL5.5 list-harddrives used to report
#list-harddrives
sda 10G
sdb 10G

RHEL6 on the same system reports empty output

If the disks were partitioned RH5.5 would report only the drives and not the partitions, RHEL6 would report both which is IMHO incorrect.


Expected results:
See above

Additional info:
This breaks our current kickstart environment as we relied on list-harddrives to identify the hard drives present on the system

Comment 2 Chris Lumens 2010-11-18 15:14:47 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.

Comment 3 peter.sjoberg 2010-11-18 17:55:08 UTC
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

Comment 4 Chris Lumens 2010-11-18 18:16:35 UTC
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.

Comment 5 peter.sjoberg 2010-11-18 18:32:03 UTC
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)

Comment 6 Dave Cantrell 2010-11-18 18:56:47 UTC
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)

Comment 7 RHEL Program Management 2010-11-18 18:59:38 UTC
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.

Comment 10 Alexander Todorov 2011-02-16 13:47:52 UTC
With anaconda-13.21.97-1.el6.x86_64 before and after partitioning the output now is:

# list-harddrives 
vda 8192.0

Comment 11 errata-xmlrpc 2011-05-19 12:34:56 UTC
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