<div dir="ltr">Up front, I&#39;m going to say: you probably shouldn&#39;t do this.  If you need to remove a file, just rm it from a client and not directly on the brick.<div><br></div><div>If, however, you&#39;re like me, and you have garbage files generated during a gluster crash, you may need to do some cleanup to restore correct operation of your storage cluster.  </div>
<div><br></div><div>At first, I just removed files.  Mysteriously, even after removing a file from all bricks, it would come back after a few minutes!</div><div><br></div><div>Then I read <a href="http://joejulian.name/blog/what-is-this-new-glusterfs-directory-in-33/">http://joejulian.name/blog/what-is-this-new-glusterfs-directory-in-33/</a> -- that explains why this was happening.</div>
<div><br></div><div>Here&#39;s a quick and dirty script to remove a file directly on a brick.  YMMV, it&#39;s not my fault if your server catches fire while running this, caveat emptor, etc., etc.</div><div><br></div><div>
To run this, cd over to your brick top-level (the parent of the .glusterfs dir) and issue a command like:</div><div><br></div><div>~/glusterrm.sh &quot;path/to/my/<a href="http://file.name">file.name</a>&quot; --noop</div>
<div><br></div><div>The --noop (or, for that matter, any second parameter) will tell you what it would remove but not remove anything.</div><div><br></div><div>If you&#39;re satisfied with the result, run</div><div><br></div>
<div>~/glusterrm.sh &quot;path/to/my/<a href="http://file.name">file.name</a>&quot;</div><div><br></div><div>and the file will be deleted along with its shadow copy in the .glusterfs dir.  Make sure you run the same sequence on any replicas, and your file is gone, gone, gone. </div>
<div><br></div><div>#!/bin/bash</div><div><div>FILE=&quot;$1&quot;</div><div><br></div><div>hidden_file_path=$(getfattr -m gfid -d -e hex &quot;$FILE&quot; |\</div><div>sed -n &#39;2s/.*0x\(..\)\(..\)\(....\)\(....\)\(....\)\(....\)\(............\)/\1\/\2\/\1\2\3-\4-\5-\6-\7/p&#39;)</div>
<div><br></div><div>NOOP=$2</div><div><br></div><div>if [ &quot;x$NOOP&quot; = &quot;x&quot; ] ; then</div><div>  rm -v .glusterfs/$hidden_file_path &quot;$FILE&quot;</div><div>else</div><div>  echo &quot;Would remove the following:&quot;</div>
<div>  echo .glusterfs/$hidden_file_path</div><div>  echo &quot;$FILE&quot;</div><div>fi</div><div><br></div><div><br></div>-- <br>Justin Dossey<br>CTO, PodOmatic<div><br></div>
</div></div>