在测试glusterfs的时候创建存储组老是提示volume create: testvol: failed: /test/brk0 or a prefix of it is already part of a volume , 这是由于文件的扩展属性造成的, 你所创建的节点目录比如/test/brk0被之前建存储卷使用过, 使用【getfattr -d -m . 目录名或文件名 -e hex 】 可以查看该目录或文件的扩展属性,
如果存在则需要使用【setfattr -x 扩展属性名 】 删除目录或文件的扩展属性, 然后再次创建存储卷的时候就会成功了。
如果目录比较多可以使用以下脚本递归遍历目录或文件,然后选择删除文件的扩展属性【仅作参考】
#!/bin/bash tmplogfile=tmp.log shfilelog=log.log getAndSetfattrFun() { getfattr -d -m . $1 | sed -e '/^#/d' -e '/^$/d' | awk -F"=" '{print $1 }' > $tmplogfile while read LINE do echo $LINE | grep -q "linkto" if [ $? -eq 0 ] ;then echo "$1 is T file " >> $shfilelog rm -f $1 return #file delete fi setfattr -x $LINE $1 if [ $? -eq 0 ] ;then echo "setfattr -x [$LINE] [$1] success!" >>$shfilelog else echo "setfattr -x [$LINE] [$1] faild! " >> $shfilelog fi done<$tmplogfile rm -f $tmplogfile } foreachd(){ for file in $1/* do if [ -d $file ]; then #echo $file "is directory !" >> $shfilelog getAndSetfattrFun $file foreachd $file elif [ -f $file ]; then #echo $file "is file !" >> $shfilelog getAndSetfattrFun $file fi done } #CURRENTPATH=${PWD} foreachd $1 |
转载于:https://blog.51cto.com/huangfu3342/1609169