geerlingguy / rpi-clone

A shell script to clone a booted disk on a Raspberry Pi.
https://rpi-clone.jeffgeerling.com/
BSD 3-Clause "New" or "Revised" License
172 stars 10 forks source link

Use temporary directories for mounting #17

Open matthijskooijman opened 3 months ago

matthijskooijman commented 3 months ago

This creates a temporary directory for src and dst mounts, rather than hardcoding /mnt/clone and /mnt/clone-src. This allows running the script twice in parallel, without conflicts.

To prevent littering tons of directories around, automatic cleanup of these directories is added (which has the added advantage of also unmounting and cleaning up when the script is somehow interrupted or fails in an unexpected way).

This also changes the interface to the rpi-clone-setup script slightly, since that also used to hardcode this directory name.

See commit messages for some more details.

These changes were previously submitted at https://github.com/billw2/rpi-clone/pull/102 and have been in use in my project since that PR was submitted four years ago. Now I've just rebased and reviewed them, the changes still applied without issue.

matthijskooijman commented 3 months ago

Thanks or your review! I've pushed a fixup commit (to be autosquashed manually before merging this commit) with the changes you suggested. I have not been able to test these changes yet, I expect I'll be able to next wednesday or thursday.