Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drive restore no longer works on Fedora 39 #644

Closed
kparal opened this issue Sep 13, 2023 · 8 comments · Fixed by #647
Closed

Drive restore no longer works on Fedora 39 #644

kparal opened this issue Sep 13, 2023 · 8 comments · Fixed by #647

Comments

@kparal
Copy link

kparal commented Sep 13, 2023

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
Copy link
Collaborator

grulja commented Sep 13, 2023

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
Copy link
Author

kparal commented Sep 14, 2023

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
Copy link
Collaborator

grulja commented Sep 14, 2023

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
Copy link

tbzatek commented Sep 14, 2023

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
Copy link

tbzatek commented Sep 14, 2023

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
Copy link

tbzatek commented Sep 15, 2023

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

vojtechtrefny added a commit to vojtechtrefny/MediaWriter that referenced this issue Sep 15, 2023
The newly created partition cannot start on offset 0, previously
UDisks was able to compensate for this, but there is a bug in the
latest UDisks/libblockdev and this no longer works. But in general
offset 0 for a new partition doesn't make sense. We can also use
0 for size to let UDisks calculate the maximal size instead of
passing the underlying device size.

Fixes: FedoraQt#644
grulja pushed a commit that referenced this issue Sep 15, 2023
The newly created partition cannot start on offset 0, previously
UDisks was able to compensate for this, but there is a bug in the
latest UDisks/libblockdev and this no longer works. But in general
offset 0 for a new partition doesn't make sense. We can also use
0 for size to let UDisks calculate the maximal size instead of
passing the underlying device size.

Fixes: #644
@kparal
Copy link
Author

kparal commented Sep 18, 2023

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
Copy link
Collaborator

grulja commented Sep 18, 2023

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

grulja pushed a commit that referenced this issue Sep 19, 2023
The newly created partition cannot start on offset 0, previously
UDisks was able to compensate for this, but there is a bug in the
latest UDisks/libblockdev and this no longer works. But in general
offset 0 for a new partition doesn't make sense. We can also use
0 for size to let UDisks calculate the maximal size instead of
passing the underlying device size.

Fixes: #644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants