storaged-project / blivet

A python module for configuration of block devices
GNU Lesser General Public License v2.1
100 stars 85 forks source link

blivet crashes if it cannot find partitions on a disk #288

Closed lantw44 closed 8 years ago

lantw44 commented 8 years ago

I run list_devices.py included in the examples directory, but it crashes:

Traceback (most recent call last):
  File "list_devices.py", line 8, in <module>
    b.reset()             # detect system storage configuration
  File "blivet/blivet.py", line 286, in reset
    self.devicetree.populate(cleanup_only=cleanup_only)
  File "blivet/devicetree.py", line 344, in populate
    self._populator.populate(cleanup_only=cleanup_only)
  File "blivet/populator.py", line 1630, in populate
    self._populate()
  File "blivet/populator.py", line 1693, in _populate
    self.add_udev_device(dev)
  File "blivet/populator.py", line 728, in add_udev_device
    device = self.add_udev_partition_device(info)
  File "blivet/populator.py", line 452, in add_udev_partition_device
    raise cls(msg)
blivet.errors.DiskLabelScanError: failed to scan disk sdb

blivet-gui also crashes with the same problem. I already reported it on Red Hat Bugzilla, but I don't get any response there: https://bugzilla.redhat.com/show_bug.cgi?id=1237284

I test this problem with git master branch of blivet on Fedora 23. It seems it is this problem that causes Fedora and CentOS installers crash on my machine. Fedora 23 is installed on /dev/sda and the disk that causes crash is /dev/sdb.

It seems that blivet uses parted, but parted is unable to recognize my disk:

# parted /dev/sdb print
Model: ATA Hitachi HDP72505 (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End    Size   File system  Flags
 1      0.00B  500GB  500GB  fat16

util-linux fdisk works fine:

fdisk -l /dev/sdb
Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa5b43cc2

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sdb1              63   4192964   4192902     2G  6 FAT16
/dev/sdb2         4192965   8385929   4192965     2G 16 Hidden FAT16
/dev/sdb3  *      8385930 113258249 104872320    50G 17 Hidden HPFS/NTFS
/dev/sdb4       113258250 976773167 863514918 411.8G  5 Extended
/dev/sdb5       113258313 742404095 629145783   300G  7 HPFS/NTFS/exFAT
/dev/sdb6       742406144 847268099 104861956    50G a5 FreeBSD
/dev/sdb7       847268163 976773119 129504957  61.8G 8e Linux LVM

Linux is able to recognize it:

[    3.445850] scsi 1:0:0:0: Direct-Access     ATA      Hitachi HDP72505 A5CA PQ: 0 ANSI: 5
[    3.454309] sd 1:0:0:0: Attached scsi generic sg1 type 0
[    3.454350] sd 1:0:0:0: [sdb] 976773168 512-byte logical blocks: (500 GB/465 GiB)
[    3.454473] sd 1:0:0:0: [sdb] Write Protect is off
[    3.454474] sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
[    3.454510] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    3.523217] usb 5-1.6: new high-speed USB device number 3 using ehci-pci
[    3.539450]  sdb: sdb1 sdb2 sdb3 sdb4 < sdb5 sdb6 sdb7 >
[    3.545237] sd 1:0:0:0: [sdb] Attached SCSI disk

lsblk also works fine:

$ lsblk /dev/sdb
NAME                   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb                      8:16   0 465.8G  0 disk 
├─sdb1                   8:17   0     2G  0 part 
├─sdb2                   8:18   0     2G  0 part 
├─sdb3                   8:19   0    50G  0 part 
├─sdb4                   8:20   0     1K  0 part 
├─sdb5                   8:21   0   300G  0 part /mnt/protected/DATA
├─sdb6                   8:22   0    50G  0 part 
└─sdb7                   8:23   0  61.8G  0 part 
  ├─wnnext-linuxrouter 253:0    0    10G  0 lvm  
  ├─wnnext-bsdrouter   253:1    0    10G  0 lvm  
  ├─wnnext-linuxserver 253:2    0     5G  0 lvm  
  ├─wnnext-bsdserver   253:3    0     5G  0 lvm  
  ├─wnnext-fedoraarm   253:4    0     7G  0 lvm  
  ├─wnnext-gentoo      253:5    0    16G  0 lvm  
  └─wnnext-fedoraaa64  253:6    0     7G  0 lvm  
lantw44 commented 8 years ago

I think blivet should not crash even if it finds a possibly invalid disk configuration. Crashing the installer means I am not able to install Fedora.

bcl commented 8 years ago

That's odd. parted says you don't have a partition table, it thinks the device is a loopback FAT16 filesystem.

Could you open a bug against parted at https://bugzilla.redhat.com and include the details you have here as well as the first 62 sectors of your disk? eg. output from:

dd if=/dev/sdb of=first62.bin count=62

lantw44 commented 8 years ago

I filed a bug here: https://bugzilla.redhat.com/show_bug.cgi?id=1288091

bcl commented 8 years ago

Explanation is here - https://bugzilla.redhat.com/show_bug.cgi?id=1288091#c1

Basically, parted can't handle this disk because of old FAT16 metadata on it.

vojtechtrefny commented 8 years ago

If think blivet should be still able to "work" even if it can't use/read one of the disks, we could hide it (or do the wipefs if user wants to) and allow changes on other disks.

vpodzime commented 8 years ago

Agreed.

dwlehman commented 8 years ago

This handling should be added to blivet-gui. It can catch UnusableConfigurationError and handle it however it wants. Blivet cannot make these decisions on its own and it does not have a user interface, so this is left to anaconda and blivet-gui.

If you want to ignore that disk completely, add it to ignored_disks before populating the DeviceTree.