caribpa / partgrator Goto Github PK
View Code? Open in Web Editor NEWCollection of scripts that automate migrating data from corrupted ext filesystems into freshly formatted ones
License: Artistic License 2.0
Collection of scripts that automate migrating data from corrupted ext filesystems into freshly formatted ones
License: Artistic License 2.0
To allow multiple main partgrator partitions, as well as multiple partgrator partitions, to support main partgrator partitions of different sizes in the same device, the main logic for processing partitions in partgrator-post
needs to change.
The reason for this is because the original design was built based on a somewhat wrong understanding regarding when the pre-mount
and post-mount
scripts are called when a partition is detected by the system, and, because of that, some unnecessary mechanisms were implemented. Basically, this misunderstanding comes from the fact that one can trigger the auto-mount mechanism of the system for all devices with the command udevtrigger --subsystem-match=block
from inside pre-mount
and/or post-mount
, resulting in two instances of these scripts being executed simultaneously with different partitions. The fact is that this behavior doesn't happen when a device is normally detected, for example: plugging a two-partition USB will result in pre-mount
being executed first (it is not guaranteed that partition one is the first partition to run the scripts), then in almost all cases post-mount
is executed but it also may happen that the other partition runs pre-mount
right after the first partition finished its pre-mount
instance but before it runs post-mount
. What cannot happen is that both partitions are running pre-mount
or post-mount
simultaneously.
As a result, the functions recover_partitions()
and migrate_partitions()
use mechanisms in their loops to try to process partitions that are being detected simultaneously (running pre-mount
), even though the original idea behind these loops was to read $partitions_status
once in memory and process its lines with the goal of minimizing reads to the file.
As partgrator grew, more abstractions were needed and now they can facilitate the changes below:
$partitions_status
file (partgrator-pre
), and also they instantly exit partgrator-pre
and partgrator-post
after checking that they don't contain a .partgrator
file in its root (otherwise start the recovery)recover_partitions()
and migrate_partitions()
no longer need to loop through the content of $partitions_status
partgrator-post
is:
.partgrator
file, exit if not (they are main non-partgrator partitions). This condition can be the same than the one depicted in the very first point about partgrator partitionsget_mountpoint_partition()
)$partitions_status
, exit if not found and issue a warning (according to the first step, they are main partgrator partitions)_partgrator
label (or whatever the variable $partgrator_label
is set to) using get_partition_label()
, and check that it is the same size of the current one (use blockdev --getsize64
). Except for the size check and duplicated labels, this is essentially what experimental_reprocess_partitions()
doesrecover_partitions()
and migrate_partitions()
functions to process and migrate the partition of the mountpoint passed as parameter, if neededIt still needs to be checked whether a migration is in process or not (and exit if so) to prevent another partition from migrating simultaneously if reload_disks()
is called from the first partgrator-post
before finishing.
This procedure also solves the limitation of mounting corrupted partitions because they need to wait until a partgrator partition is listed in the $partitions_status
to perform any procedure.
Unfortunately, the procedure cannot finish early if the error code found in $partitions_status
is clean because there's a chance the migration was interrupted and there are duplicated labels. The loop can break early when finding either a partgrator partition (same size as the one being processed) or a partition with duplicated label (no need to check for duplicates as there cannot be other partitions with the same label).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.