Bug 441161

Summary: operations order in KDE Partition Manager resize copy move
Product: [Applications] partitionmanager Reporter: empyreal <empyreal>
Component: generalAssignee: Andrius Štikonas <andrius>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description empyreal 2021-08-19 10:06:50 UTC
1. Made necessary unallocated space.
2. Copied boot partition.
3. Copied root partition.
4. Resized root partition.
5. Pressed Apply.
Result: could not move partition after resize. Error. Data on root partition destroyed. Why resize before moving if resize is last operation? Is it ok behaviour?

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Kernel Version: 5.8.0-63-generic
OS Type: 64-bit
Comment 1 Andrius Štikonas 2021-08-19 10:30:21 UTC
Can you be a bit more specific about what you were doing? I'm a bit confused what you mean by copied? Did you mean move or did you make a second copy of the whole root partition on the same disk?

Regarding order, again a lot depends on what exactly you were doing. In particular resizing to the left and to the right are not the same. Resizing partition to the right is just that, a simple resize operation. When you resize partition on the left boundary, it's a bit more complicated:
If partition is increased, then:
1) We move partition boundary further to the left
2) We move data in small chunks to the left starting from the leftmost part.
3) We move the right boundary of partition to the right place. (If right boundary of partition is resized to we need to resize filesystem too before resizing partition).

If you decrease partition on the right
1) File system is first shrunk
2) data is moved in small chunks to the right starting from rightmost chunk.
3) left partition boundary is moved.
And again a bit more complicated if there is also adjustment to the right boundary at the same time.
Comment 2 empyreal 2021-08-19 10:49:44 UTC
| left 1st partition | unallocated space | boot | root| swap|
Linux is on the right at the end of disk.
On the left from Linux I made an unallocated space enough for all Linux partitions.
Ctrl + C & Ctrl + V Linux partitions to  unallocated space on the left.
Then deleted original Linux partitions.
Then resize root partition.
Then Apply.
And error…
“could not move partition after resize” it was a message from system.
I know that I should had done operations one by one just for safety but tried batch.
Comment 3 Andrius Štikonas 2021-08-19 11:03:34 UTC
Hmm, I can't find error string "could not move partition after resize" at all.
The closest error string that I found is

"Checking partition <filename>%1</filename> after resize/move failed."

Looking at your operations, no other resize should have been done before that.

Also, if you still know exact partition boundaries before operations, you can try to create a partition with low-level tools (such as fdisk) on exactly the same place where your original Linux partition was (and make sure you are not formatting it) and I think you could recover your data. Well, at least left boundary has to be on exactly the same place, right boundary can be further right, but I guess it was end of disk anyway.

P.S. do you know when exactly the error happened in your steps. Was it after step "3. Copied root partition." ?
Comment 4 empyreal 2021-08-19 11:37:02 UTC
Kubuntu 21.04
KDE Partition Manager Version 20.12.3

Just booted from flash drive and tried all steps. 
Everything went smoothly.
Created unallocated space. Created partitions. Copied partitions. Deleted originals. Resized right partition to the end. Applied and all ok...
I can’t recollect exact text of error message unfortunately.
Sorry for false alarm.