From a615aa49b8d7016377bf5192136d62d679715126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Payet?= Date: Wed, 10 Dec 2025 16:57:27 +0100 Subject: [PATCH 1/3] Do not balance files with hardlinks With this change, files with hardlinks are not considered for balance, so they are not broken --- src/mergerfs.balance | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mergerfs.balance b/src/mergerfs.balance index 5ceab6e..7cc950f 100755 --- a/src/mergerfs.balance +++ b/src/mergerfs.balance @@ -92,6 +92,11 @@ def exclude_by_size(filepath,exclude_lt,exclude_gt): except: return False +def exclude_by_nlink_count(filepath): + info = os.stat(filepath) + if info.st_nlink > 1: + return True + return False def find_a_file(src, relpath, @@ -112,6 +117,8 @@ def find_a_file(src, continue if exclude_by_size(filepath,exclude_lt,exclude_gt): continue + if exclude_by_nlink_count(filepath): + continue return os.path.relpath(filepath,src) return None From fd1737dfdb0553c84a38afd9f1dc61b92b115e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Payet?= Date: Wed, 10 Dec 2025 18:48:52 +0100 Subject: [PATCH 2/3] Add to the docs that files with hardlinks won't be moved --- src/mergerfs.balance | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mergerfs.balance b/src/mergerfs.balance index 7cc950f..3fce1c4 100755 --- a/src/mergerfs.balance +++ b/src/mergerfs.balance @@ -179,7 +179,7 @@ def human_to_bytes(s): def buildargparser(): - parser = argparse.ArgumentParser(description='balance files on a mergerfs mount based on percentage drive filled') + parser = argparse.ArgumentParser(description='balance files on a mergerfs mount based on percentage drive filled. files with hardlinks will not be moved') parser.add_argument('dir', type=str, help='starting directory') From 5566825b57364f17221d1d059cda86fd4683fa26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Payet?= Date: Wed, 10 Dec 2025 18:49:55 +0100 Subject: [PATCH 3/3] Fix typo in argparse description for mergerfs.balance --- src/mergerfs.balance | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mergerfs.balance b/src/mergerfs.balance index 3fce1c4..e3a4b85 100755 --- a/src/mergerfs.balance +++ b/src/mergerfs.balance @@ -179,7 +179,7 @@ def human_to_bytes(s): def buildargparser(): - parser = argparse.ArgumentParser(description='balance files on a mergerfs mount based on percentage drive filled. files with hardlinks will not be moved') + parser = argparse.ArgumentParser(description='balance files on a mergerfs mount based on percentage drive filled. files with hardlinks won't be moved') parser.add_argument('dir', type=str, help='starting directory')