[root@hoge ~]# fallocate --keep-size --length 1m /tmp/fuga fallocate: unrecognized option '--length' Usage: fallocate [options] <filename> Options: -h, --help this help -n, --keep-size don't modify the length of the file -p, --punch-hole punch holes in the file -o, --offsetおかしい、他のサーバでは、大丈夫なのに。。。offset of the allocation, in bytes -l, --length length of the allocation, in bytes For more information see fallocate(1).
CentOS 6 用の最新の util-linux-ng の .src.rpm を展開して、さぐってみたら、ありました typo バグ。
[root@hoge SOURCES]# cat util-linux-ng-2.17-opts-typos.patch
diff -up util-linux-ng-2.17.2/misc-utils/findmnt.c.kzak util-linux-ng-2.17.2/misc-utils/findmnt.c
--- util-linux-ng-2.17.2/misc-utils/findmnt.c.kzak 2016-03-08 11:39:00.996400246 +0100
+++ util-linux-ng-2.17.2/misc-utils/findmnt.c 2016-03-08 11:44:49.598921954 +0100
@@ -586,7 +586,10 @@ int main(int argc, char *argv[])
{ "output", 1, 0, 'o' },
{ "raw", 0, 0, 'r' },
{ "types", 1, 0, 't' },
- { "fsroot", 0, 0, 'v' },
+
+ { "nofsroot", 0, 0, 'v' },
+ { "fsroot", 0, 0, 'v' }, /* RHEL6: typo, backward compatibility */
+
{ "submounts", 0, 0, 'R' },
{ "source", 1, 0, 'S' },
{ "target", 1, 0, 'T' },
diff -up util-linux-ng-2.17.2/sys-utils/fallocate.c.kzak util-linux-ng-2.17.2/sys-utils/fallocate.c
--- util-linux-ng-2.17.2/sys-utils/fallocate.c.kzak 2016-03-08 11:39:01.028400021 +0100
+++ util-linux-ng-2.17.2/sys-utils/fallocate.c 2016-03-08 11:43:28.799496864 +0100
@@ -125,7 +125,10 @@ int main(int argc, char **argv)
{ "keep-size", 0, 0, 'n' },
{ "punch-hole", 0, 0, 'p' },
{ "offset", 1, 0, 'o' },
- { "lenght", 1, 0, 'l' },
+
+ { "length", 1, 0, 'l' },
+ { "lenght", 1, 0, 'l' }, /* RHEL6: typo, backward compatibility */
+
{ NULL, 0, 0, 0 }
};
[root@hoge SOURCES]# cat ../SPECS/util-linux-ng.spec
...
# 1122839 - fallocate and findmnt have wrong options according to man pages
Patch114: util-linux-ng-2.17-opts-typos.patch
...
* Mon Jan 11 2016 Karel Zakhttps://bugzilla.redhat.com/show_bug.cgi?id=11228392.17.2-12.19 ... - fix #1122839 - fallocate and findmnt have wrong options according to man pages
というわけで、エラーが出ていたサーバの util-linux-ng が古かったというオチでした。やはり、ほとんどの場合、常に最新を使うのが吉ですね。もちろんです。
今回、--keep-size オプションを使おうとして、なんとなくロングオプションを選んでしまいましたが、こういった間違いが起きてる可能性を考えると、ショートオプションを使ったほうが吉かもしれませんね。自作スクリプトは、古い環境も対象にしているので、ショートオプションに修正しました。

0 件のコメント:
コメントを投稿