I have several file systems mounted on /mnt/hdd0, /mnt/hdd1, /mnt/hdd2, etc. on my Manjaro Linux system. Let’s call these file systems fs0, fs1, fs2, and so on. Currently, all of these file systems have the same directory structure and contain files.

My goal is to reorganize and redistribute all the files across the drives based on the alphabetical ordering of their relative file paths, following these rules:

  1. The files with the earliest alphabetical relative paths should be moved to the first mounted file system in alphabetical order (e.g. /mnt/hdd0) which contains the appropriate folder structure.
  2. The files with the latest alphabetical relative paths should be moved to the last mounted file system in alphabetical order (e.g. /mnt/hddN) which contains the appropriate folder structure.
  3. The remaining files should be distributed across the remaining mounted file systems (/mnt/hdd1, /mnt/hdd2, etc.) in alphabetical order based on their relative paths.

The process should fill up each file system in alphabetical order (/mnt/hdd0, /mnt/hdd1, etc.) until the given free space threshold is reached before moving on. While reorganizing, I want to ensure each file system maintains a specified amount of free space remaining. If a file system does not have enough free space for the files being moved to it, I want to move enough existing files from that file system to another file system with the most available space to make room.

I need step-by-step instructions, including commands, scripts, or tools in Manjaro Linux, to automate this entire process of reorganizing and redistributing the files while following the rules mentioned above.

  • @The_Lemmington_PostOPM
    link
    1
    edit-2
    3 months ago

    This wouldn’t work because of the way it deletes everything when making space on a filesystem. It should just move enough files to make space for the ones it’s moving there. Even if this script worked, I would need a lot of testing before I were confident using it to reorganize my actual data.

    Also, to copy the directory structure I use:

    rsync -av -f"+ */" -f"- *" "/mnt/hdd1" "/mnt/hdd2" &