Bug 487650 - Partition Manager fails to read MS-DOS partition tables
Summary: Partition Manager fails to read MS-DOS partition tables
Status: RESOLVED FIXED
Alias: None
Product: partitionmanager
Classification: Applications
Component: general (show other bugs)
Version: 24.05.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Andrius Štikonas
URL:
Keywords: regression
: 488387 489567 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-05-27 21:37 UTC by AF
Modified: 2024-09-14 05:22 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 24.05.1
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description AF 2024-05-27 21:37:58 UTC
SUMMARY

I have a few old systems running old versions of Windows and MS-DOS, so I am regularly interacting with disks with MS-DOS partition tables. I frequently connect drives to my system via USB to copy files over to these drives. I never had any problems with this until today, so something must have changed very recently.

If I connect a disk to my system via USB (either a USB flash drive or a SATA drive with a USB adapter) that has an MS-DOs partition table, and then click refresh devices in Partition Manager, the drive is detected but an error appears when that drive is selected which says "No valid partition table was found on this device". If I choose to add a new partition table to this device and select an MS-DOS partition table, the operation completes successfully but after the devices refresh, the same error is displayed. If I choose to add a new partition table and select GPT, everything works as expected. I have tried this with multiple drives, with multiple adapters, and with different USB ports, but I always get the same results. I also get the same results on both the LTS kernel and the mainline kernel.

STEPS TO REPRODUCE
1. Connect a disk via USB that has a valid MS-DOS partition table.
2. Open Partition Manager and refresh devices.
3. Look at the device in the UI.

OBSERVED RESULT
You will see a "No valid partition table was found on this device" error.

EXPECTED RESULT
The drive should be able to be read.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.1
Kernel Version: 6.6.32-1-lts (64-bit)
Graphics Platform: Wayland
Processors: 16 × 12th Gen Intel® Core™ i5-12600K
Memory: 31.2 GiB of RAM
Graphics Processor: Mesa Intel® Arc
Manufacturer: Gigabyte Technology Co., Ltd.
Product Name: B760M C
System Version: -CF

ADDITIONAL INFORMATION
Comment 1 AF 2024-05-28 04:45:32 UTC
Here is an example while running Partition manager in debug mode (KPMCORE_DEBUG=1 partitionmanager). I have connected a CF disk to the computer with a USB adapter (/dev/sda). The CF disk has an existing MS-DOS partition table and a FAT16 formatted partition on it. The UI displays "No valid partition table was found on this device" when looking at this device. I select to format the drive with a new MS-DOS partition table, add a FAT16 partition, and apply my changes. After the action completes and the UI refreshes, the same disk displays the "No valid partition table was found on this device" error again.

> KPMCORE_DEBUG=1 partitionmanager
Loaded backend plugin:  "pmsfdiskbackendplugin"
"Command: /usr/bin/dumpe2fs "
"Command: /usr/bin/e2label "
"Command: /usr/bin/mkfs.ext2 "
"Command: /usr/bin/e2fsck -V"
"Command: /usr/bin/tune2fs "
"Command: /usr/bin/resize2fs "
"Command: /usr/bin/dumpe2fs "
"Command: /usr/bin/e2label "
"Command: /usr/bin/mkfs.ext2 "
"Command: /usr/bin/e2fsck -V"
"Command: /usr/bin/tune2fs "
"Command: /usr/bin/resize2fs "
"Command: /usr/bin/dumpe2fs "
"Command: /usr/bin/e2label "
"Command: /usr/bin/mkfs.ext2 "
"Command: /usr/bin/e2fsck -V"
"Command: /usr/bin/tune2fs "
"Command: /usr/bin/resize2fs "
"Command: /usr/bin/mkswap "
"Command: /usr/bin/mkfs.fat "
"Command: /usr/bin/fatlabel "
"Command: /usr/bin/mkfs.fat "
"Command: /usr/bin/fatlabel "
"Command: /usr/bin/ntfsresize "
"Command: /usr/bin/ntfsinfo "
"Command: /usr/bin/ntfslabel "
"Command: /usr/bin/mkfs.ntfs "
"Command: /usr/bin/ntfsclone "
"Command: /usr/bin/xfs_db "
"Command: /usr/bin/mkfs.xfs "
"Command: /usr/bin/xfs_repair "
"Command: /usr/bin/xfs_growfs -V"
"Command: /usr/bin/xfs_copy "
"Command: /usr/bin/mkfs.btrfs "
"Command: /usr/bin/btrfs "
"Command: /usr/bin/btrfstune "
"Command: mkfs.btrfs -O list-all"
"Command: /usr/bin/cryptsetup "
"Command: /usr/bin/lvm "
"Command: /usr/bin/cryptsetup "
"Command: /usr/bin/mkfs.fat "
"Command: /usr/bin/fatlabel "
"Command: /usr/bin/fsck.minix "
"Command: /usr/bin/mkfs.minix "
"Using backend plugin: pmsfdiskbackendplugin (1)"
"Scanning devices..."
"Command: lsblk --nodeps --paths --sort name --json --output type,name"
"Command: blockdev --getsize64 /dev/nvme0n1"
"Command: blockdev --getss /dev/nvme0n1"
"Command: sfdisk --json /dev/nvme0n1"
"Command: lsblk --nodeps --noheadings --output model /dev/nvme0n1"
"Command: lsblk --nodeps --noheadings --output tran /dev/nvme0n1"
"Command: smartctl --all --json /dev/nvme0n1"
"Device found: INTEL SSDPE21D960GA"
getting temp failed for  "/dev/nvme0n1" :  No such file or directory
getting powered on time failed for  "/dev/nvme0n1" :  No such file or directory
getting power cycles failed for  "/dev/nvme0n1" :  No such file or directory
"Command: udevadm info --query=property /dev/nvme0n1p1"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/nvme0n1p1"
"Command: udevadm info --query=property /dev/nvme0n1p1"
"Command: udevadm info --query=property /dev/nvme0n1p1"
"Command: udevadm info --query=property /dev/nvme0n1p2"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/nvme0n1p2"
"Command: udevadm info --query=property /dev/nvme0n1p2"
"Command: udevadm info --query=property /dev/nvme0n1p2"
"Command: dumpe2fs -h /dev/nvme0n1p2"
"Command: udevadm info --query=property /dev/nvme0n1p3"
"Command: lsblk --list --noheadings --paths --json --output type,name /dev/nvme0n1p3"
"Command: cryptsetup luksDump /dev/nvme0n1p3"
"Command: dmsetup table /dev/mapper/cryptroot"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: btrfs filesystem show --raw /dev/mapper/cryptroot"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/mapper/cryptroot"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/mapper/cryptroot"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: cryptsetup luksUUID /dev/nvme0n1p3"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: blockdev --getsize64 /dev/sda"
"Command: blockdev --getss /dev/sda"
"Command: sfdisk --json /dev/sda"
"Command: lsblk --nodeps --noheadings --output model /dev/sda"
"Command: lsblk --nodeps --noheadings --output tran /dev/sda"
"Command: smartctl --all --json /dev/sda"
"Device found: MassStorageClass"
smartctl initialization failed for  "/dev/sda" :  No such file or directory
error during smart output parsing for  "/dev/sda" :  No such file or directory
"Command: udevadm info --query=property /dev/sda"
"Command: blkid /dev/sda"
unknown file system type  "dos"  on  "/dev/sda"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/sda"
"Command: blockdev --getsize64 /dev/sdb"
"Command: lvm vgdisplay /dev/sdb"
"Command: blockdev --getsize64 /dev/sdc"
"Command: lvm vgdisplay /dev/sdc"
"Command: blockdev --getsize64 /dev/sdd"
"Command: lvm vgdisplay /dev/sdd"
"Command: lvm vgs --foreign --readonly --noheadings --units B --nosuffix --options vg_name"
"Scan finished."
"Add operation: Create a new partition table (type: msdos) on ‘/dev/sda’"
"Add operation: Create a new partition (485.00 MiB, fat16) on ‘/dev/sda’"
"Applying operations..."
Command input: "label: dos\nwrite\n"
"Command: sfdisk --wipe=always /dev/sda"
"Command: udevadm settle --timeout=10"
"Command: partx --update /dev/sda"
"Command: udevadm trigger --subsystem-match=block"
"Command: udevadm settle --timeout=10"
Command input: "start=2048 size=993280\nwrite\n"
"Command: sfdisk --force --append /dev/sda"
"Command: udevadm settle --timeout=10"
"Command: partx --update /dev/sda"
"Command: udevadm trigger --subsystem-match=block"
"Command: udevadm settle --timeout=10"
"Command: udevadm settle --timeout=10"
"Command: partx --update /dev/sda"
"Command: udevadm trigger --subsystem-match=block"
"Command: udevadm settle --timeout=10"
"Command: mkfs.fat -F16 -I -v /dev/sda1"
"Command: sfdisk --part-type /dev/sda 1 6"
"Command: udevadm settle --timeout=10"
"Command: partx --update /dev/sda"
"Command: udevadm trigger --subsystem-match=block"
"Command: udevadm settle --timeout=10"
"Command: udevadm settle --timeout=10"
"Command: partx --update /dev/sda"
"Command: udevadm trigger --subsystem-match=block"
"Command: udevadm settle --timeout=10"
"Command: fatlabel /dev/sda1 -r"
"Command: udevadm settle --timeout=10"
"Command: partx --update "
"Command: udevadm trigger --subsystem-match=block"
"Command: udevadm settle --timeout=10"
"Command: udevadm settle --timeout=10"
"Command: partx --update "
"Command: udevadm trigger --subsystem-match=block"
"Command: udevadm settle --timeout=10"
"Command: fsck.fat -a -w -v /dev/sda1"
"Using backend plugin: pmsfdiskbackendplugin (1)"
"Scanning devices..."
"Command: lsblk --nodeps --paths --sort name --json --output type,name"
"Command: blockdev --getsize64 /dev/nvme0n1"
"Command: blockdev --getss /dev/nvme0n1"
"Command: sfdisk --json /dev/nvme0n1"
"Command: lsblk --nodeps --noheadings --output model /dev/nvme0n1"
"Command: lsblk --nodeps --noheadings --output tran /dev/nvme0n1"
"Command: smartctl --all --json /dev/nvme0n1"
"Device found: INTEL SSDPE21D960GA"
getting temp failed for  "/dev/nvme0n1" :  No such file or directory
getting powered on time failed for  "/dev/nvme0n1" :  No such file or directory
getting power cycles failed for  "/dev/nvme0n1" :  No such file or directory
"Command: udevadm info --query=property /dev/nvme0n1p1"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/nvme0n1p1"
"Command: udevadm info --query=property /dev/nvme0n1p1"
"Command: udevadm info --query=property /dev/nvme0n1p1"
"Command: udevadm info --query=property /dev/nvme0n1p2"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/nvme0n1p2"
"Command: udevadm info --query=property /dev/nvme0n1p2"
"Command: udevadm info --query=property /dev/nvme0n1p2"
"Command: dumpe2fs -h /dev/nvme0n1p2"
"Command: udevadm info --query=property /dev/nvme0n1p3"
"Command: lsblk --list --noheadings --paths --json --output type,name /dev/nvme0n1p3"
"Command: cryptsetup luksDump /dev/nvme0n1p3"
"Command: dmsetup table /dev/mapper/cryptroot"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: btrfs filesystem show --raw /dev/mapper/cryptroot"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/mapper/cryptroot"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/mapper/cryptroot"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: cryptsetup luksUUID /dev/nvme0n1p3"
"Command: udevadm info --query=property /dev/mapper/cryptroot"
"Command: blockdev --getsize64 /dev/sda"
"Command: blockdev --getss /dev/sda"
"Command: sfdisk --json /dev/sda"
"Command: lsblk --nodeps --noheadings --output model /dev/sda"
"Command: lsblk --nodeps --noheadings --output tran /dev/sda"
"Command: smartctl --all --json /dev/sda"
"Device found: MassStorageClass"
smartctl initialization failed for  "/dev/sda" :  No such file or directory
error during smart output parsing for  "/dev/sda" :  No such file or directory
"Command: udevadm info --query=property /dev/sda"
"Command: blkid /dev/sda"
unknown file system type  "dos"  on  "/dev/sda"
"Command: lsblk --noheadings --nodeps --output mountpoint /dev/sda"
"Command: blockdev --getsize64 /dev/sdb"
"Command: lvm vgdisplay /dev/sdb"
"Command: blockdev --getsize64 /dev/sdc"
"Command: lvm vgdisplay /dev/sdc"
"Command: blockdev --getsize64 /dev/sdd"
"Command: lvm vgdisplay /dev/sdd"
"Command: lvm vgs --foreign --readonly --noheadings --units B --nosuffix --options vg_name"
"Scan finished."
Comment 2 AF 2024-05-28 05:55:00 UTC
If I take that CF card and USB adapter that was partitioned in my previous comment and plug it into a separate system which hasn't been updated in ~1-2 weeks, I do see the partition table and partitions showing up as expected. This confirms that whatever caused this regression has happened recently. The specs of the not recently updated system where Partition Manager is working correctly with MS-DOS partition tables:

Operating System: Arch Linux
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0
Kernel Version: 6.8.9-arch1-2 (64-bit)
Graphics Platform: Wayland
Processors: 6 × Intel® Core™ i5-8500 CPU @ 3.00GHz
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 630
Manufacturer: Dell Inc.
Product Name: OptiPlex 5060
Comment 3 Andrius Štikonas 2024-05-28 19:19:52 UTC
Hmm, possibly https://invent.kde.org/system/kpmcore/-/commit/801b291a7f537cb137aa7a64f23424dca840030a causes  this
Comment 4 Andrius Štikonas 2024-05-28 19:24:56 UTC
Could you paste output of
sudo sfdisk --json /dev/sda
to confirm whether it's the regression from the commit above.
Comment 5 AF 2024-05-28 20:04:10 UTC
Sure thing:

> sudo sfdisk --json /dev/sda

{
   "partitiontable": {
      "label": "dos",
      "id": "0x00000000",
      "device": "/dev/sda",
      "unit": "sectors",
      "sectorsize": 512,
      "partitions": [
         {
            "node": "/dev/sda1",
            "start": 63,
            "size": 1012977,
            "type": "6",
            "bootable": true
         }
      ]
   }
}
Comment 6 Andrius Štikonas 2024-05-28 21:11:36 UTC
(In reply to AF from comment #5)
>       "id": "0x00000000",

Hmm, that's definitely regression due to that commit. We need some other way of distinguishing between MBR partition table and FAT file systems...

Looks like sfdisk for partition tables reports exactly the same output as for FAT file systems :(

E.g. this is exFAT whole device partition:

 sudo sfdisk --json /dev/sdb
{
   "partitiontable": {
      "label": "dos",
      "id": "0x00000000",
      "device": "/dev/sdb",
      "unit": "sectors",
      "sectorsize": 512
  }

and this is MBR that I just created
sudo sfdisk --json /dev/sdb
{
   "partitiontable": {
      "label": "dos",
      "id": "0x69badb1c",
      "device": "/dev/sdb",
      "unit": "sectors",
      "sectorsize": 512
   }
}

Unfortunately, it looks like you can still have MBR with id that is 0x0...
Comment 7 Andrius Štikonas 2024-05-28 21:33:47 UTC
Git commit 2acc26ca582f6556a682881e624a7ae5deb1711d by Andrius Štikonas.
Committed on 28/05/2024 at 21:32.
Pushed by stikonas into branch 'release/24.05'.

Fix detection of MBR partition table with zeroed signature.

M  +4    -3    src/plugins/sfdisk/sfdiskbackend.cpp

https://invent.kde.org/system/kpmcore/-/commit/2acc26ca582f6556a682881e624a7ae5deb1711d
Comment 8 Andrius Štikonas 2024-05-28 21:34:19 UTC
Git commit 98e11080b1398c44ecc05ec77c25b731775508e1 by Andrius Štikonas.
Committed on 28/05/2024 at 21:34.
Pushed by stikonas into branch 'master'.

Fix detection of MBR partition table with zeroed signature.

M  +4    -3    src/plugins/sfdisk/sfdiskbackend.cpp

https://invent.kde.org/system/kpmcore/-/commit/98e11080b1398c44ecc05ec77c25b731775508e1
Comment 9 Andrius Štikonas 2024-05-28 21:35:11 UTC
Any chance you could test the patch on your system too?

It seems to work here and no longer relies on "id" to be "0x00000000"
Comment 10 AF 2024-05-29 04:48:53 UTC
I cloned the master branch, built, and installed and now everything seems to be working correctly on my end as well! I tested with disks that had their partition table and partitions created by KDE Partition Manager as well as by MS-DOS 6.22, both are working as expected. Thank you for your help with this!
Comment 11 Andrius Štikonas 2024-06-11 21:23:34 UTC
*** Bug 488387 has been marked as a duplicate of this bug. ***
Comment 12 Andrius Štikonas 2024-07-01 20:52:04 UTC
*** Bug 489567 has been marked as a duplicate of this bug. ***