Bug 412575 - enlarging mounted btrfs partition with "Align" option checked leads to full loss of the partition.
Summary: enlarging mounted btrfs partition with "Align" option checked leads to full l...
Status: RESOLVED FIXED
Alias: None
Product: partitionmanager
Classification: Applications
Component: general (show other bugs)
Version: 4.0.0
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Andrius Štikonas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-03 19:22 UTC by bobafetthotmail
Modified: 2019-10-05 18:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 4.0.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bobafetthotmail 2019-10-03 19:22:22 UTC
SUMMARY
enlarging mounted btrfs partition with "Align" option checked leads to data loss.

I just wanted to enlarge the root partition, and I had the free space to do so.

Btrfs allows online resize so I used this tool to do it.

After I started the task, I noticed that the tool was also moving the whole partition to "align" it. I think the "align" checkbox is checked by default, and it's also hidden in the default interface behind an "advanced" button.

I did not realize that this would destroy the partition, so I didn't terminate the task.

The partition was lost and the system crashed. I had to reload a partition image from backups.

STEPS TO REPRODUCE
1. resize an unaligned and mounted btrfs partition that is in use (ideally a root partition of a test system), with the "Align" option checked.
2. Wait
3. profit

OBSERVED RESULT
The partition is trashed

EXPECTED RESULT
"Align" option is disabled for mounted resize of filesystems. I'm sure moving around a mounted ext4 or xfs partition to "align" it is equally bad, so just disable that if the filesystem is mounted.

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: OpenSuse Tumbleweed
(available in About System)
KDE Frameworks 5.62.0
Qt 5.13.1 (built against 5.13.1)
Comment 1 Andrius Štikonas 2019-10-03 19:34:26 UTC
Regarding disabling if it's mounted, that's not possible. Btrfs does not support offline resizing at all, to resize btrfs partition we mount it anyway.
Instead of disabling it, it's better to investigate whether it is reproducible and what causes this bug.
Comment 2 Andrius Štikonas 2019-10-05 10:38:36 UTC
Ok, I tested this on my system. I'll disable automatic realignment. I slightly misunderstood your initial comment, so ignore my first comment that it's not possible. (What's not possible is not mounting btrfs in order to resize but moving partitions can only be done when they are not mounted)
Comment 3 Andrius Štikonas 2019-10-05 10:54:13 UTC
Git commit 0b5e5040ebb3c172ea9c70af660e73957fc1334e by Andrius Štikonas.
Committed on 05/10/2019 at 10:52.
Pushed by stikonas into branch 'master'.

Do not align partitions if they are mounted.

Moving data when partitions are mounted is almost guaranteed to cause data loss.

M  +3    -1    src/gui/partresizerwidget.h

https://invent.kde.org/kde/kpmcore/commit/0b5e5040ebb3c172ea9c70af660e73957fc1334e
Comment 4 Andrius Štikonas 2019-10-05 10:56:03 UTC
I'll try to release a new bug fix version of kpmcore too.
Comment 5 Andrius Štikonas 2019-10-05 11:19:03 UTC
Git commit 40b65438f0608a1913cd5b6232232fed78d50bdc by Andrius Štikonas.
Committed on 05/10/2019 at 11:08.
Pushed by stikonas into branch '4.0'.

Do not align partitions if they are mounted.

Moving data when partitions are mounted is almost guaranteed to cause data loss.

M  +3    -1    src/gui/partresizerwidget.h

https://invent.kde.org/kde/kpmcore/commit/40b65438f0608a1913cd5b6232232fed78d50bdc
Comment 6 bobafetthotmail 2019-10-05 18:36:49 UTC
Thank you!