FedoraQt / MediaWriter

Fedora Media Writer - Write Fedora Images to Portable Media
GNU General Public License v2.0
708 stars 154 forks source link

Drive restore no longer works on Fedora 39 #644

Closed kparal closed 11 months ago

kparal commented 11 months ago

The "restore" functionality no longer works on Fedora 39 Workstation. It displays an error:

image

In the background, it formats the drive with a clean MBR partition table (i.e. all partitions are gone), but it doesn't create a new exFAT partition over the whole drive, as expected.

Below is the journal from Fedora 39 Workstation during drive restoration. It happens in two parts (mostly, but sometimes there can be just one step, I don't know exactly why it differs sometimes).

The first time you try the restoration, FMW almost immediately returns back to its home screen, without showing any conclusion. But the drive gets flashed with a new MBR table, all partitions are gone. The journal is:

Sep 13 14:00:11 f39 systemd[1]: run-media-kparal-Fedora\x2dWS\x2dLive\x2d39_B\x2d1\x2d1.mount: Deactivated successfully.
Sep 13 14:00:11 f39 udisksd[824]: Cleaning up mount point /run/media/kparal/Fedora-WS-Live-39_B-1-1 (device 8:1 is not mounted)
Sep 13 14:00:11 f39 udisksd[824]: Unmounted /dev/sda1 on behalf of uid 1000
Sep 13 14:00:11 f39 systemd-homed[818]: block device /sys/devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb2/2-3/2-3:1.0/host6/target6:0:0/6:0:0:0/block/sda/sda2 has been removed.
Sep 13 14:00:11 f39 systemd-homed[818]: block device /sys/devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb2/2-3/2-3:1.0/host6/target6:0:0/6:0:0:0/block/sda/sda1 has been removed.
Sep 13 14:00:11 f39 systemd-homed[818]: block device /sys/devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb2/2-3/2-3:1.0/host6/target6:0:0/6:0:0:0/block/sda/sda3 has been removed.
Sep 13 14:00:11 f39 kernel:  sda:
Sep 13 14:00:12 f39 udisksd[824]: [fdisk] No free sectors available.
Sep 13 14:00:12 f39 org.fedoraproject.MediaWriter.desktop[6631]: W@10707ms: Drive restoration failed: "Error creating partition on /dev/sda: Failed to add new partition to the table: No space left on device"

If you select "Restore" in FMW again, this time FMW shows an error screen, as shown above. The log is:

Sep 13 14:00:20 f39 kernel:  sda:
Sep 13 14:00:20 f39 udisksd[824]: [fdisk] No free sectors available.
Sep 13 14:00:20 f39 org.fedoraproject.MediaWriter.desktop[6631]: W@19318ms: Drive restoration failed: "Error creating partition on /dev/sda: Failed to add new partition to the table: No space left on device"

Now the "Restore" option disappears from FMW. Users can no longer restore the drive using FMW.

For comparison, this is the journal from Fedora 38 Workstation during a successful drive restoration:

Sep 13 13:56:28 f38 systemd[1]: run-media-kparal-Fedora\x2dWS\x2dLive\x2d39_B\x2d1\x2d1.mount: Deactivated successfully.
Sep 13 13:56:28 f38 udisksd[731]: Cleaning up mount point /run/media/kparal/Fedora-WS-Live-39_B-1-1 (device 8:1 is not mounted)
Sep 13 13:56:28 f38 udisksd[731]: Unmounted /dev/sda1 on behalf of uid 1000
Sep 13 13:56:29 f38 kernel:  sda:
Sep 13 13:56:29 f38 udisksd[731]: Requested start of the logical partition overlaps with extended partition metadata. Start of the partition moved to 1.

Tested with mediawriter-5.0.7-1.fc39.x86_64 (and fc38) in a Fedora 39 (and 38) Workstation virtual machine.

grulja commented 11 months ago

Could be udisk2 issue, because we just call it over DBus, we don't do any partitioning ourself. I can see there is new udisk2 in F39 and when I check the release notes, it says partitioning was ported to libfdisk so might be related.

kparal commented 11 months ago

I tried to install udisks2-2.9.4-7.fc38 on F39, that fails because of dependencies. Then I tried to rebuild it to F39, that also fails because of some "configure" error.

If you think this is a problem in udisks2, can you please report a new bug against it, e.g. with some log of attempted operations? I don't know how to do that. But I'm happy to help with debugging, if you tell me how. Thanks.

grulja commented 11 months ago

CC: @tbzatek

Tome, the code for restoration is quite simple, we do everything over DBus, see restorejob.cpp. I can see that the new udisks2 use a new library for this and this works on Fedora 38 where we still have older udisks2. Do you know what's going on?

tbzatek commented 11 months ago

My first guess is that the "Failed to add new partition to the table: No space left on device" error message that is coming from libblockdev that has been rewritten to libfdisk is failing on slight alignment miscalculation (that has changed a little too).

Cc: @vojtechtrefny

tbzatek commented 11 months ago

As a quick fix you may try creating a new partition slighly smaller to accommondate a partition table (MBR is perhaps only 512 bytes). After all, old versions of udisks were complaining about overlapping partitions.

tbzatek commented 11 months ago

Another hint: if you call CreatePartition(size=0), it will create parition with maximum size. No need to calculate anything.

See http://storaged.org/doc/udisks2-api/latest/gdbus-org.freedesktop.UDisks2.PartitionTable.html#gdbus-method-org-freedesktop-UDisks2-PartitionTable.CreatePartition

kparal commented 11 months ago

With the fix tested in #650 this doesn't seem to work completely correctly yet. Sometimes I see screen flashing and it ends up on a wrong screen (not the "Finish" one), but without any error displayed. The drive is restored, though.

See here: restore-no-finish.webm

I think this happens more often when I clean-boot the machine and then restore the drive as the first thing action.

I also once saw that the drive was not restored at all (it returned to the home screen), but I couldn't replicate it again and I don't have logs.

grulja commented 11 months ago

Looks that change I did breaks it for some reason. I will investigate.