高速で透過的な圧縮機能を提供するLZOlayerFS
LZOlayer FileSystemは、FUSEを使用した、書き込みもできる圧縮ファイルシステム。圧縮には、LZOの他、zlibを使用することもできる。
(2014/9/26)既にこのソフトウェアの開発は終了している。
インストール
安定しているとのことではあるが、マイナーなため、パッケージにはなっていないことがほとんど。直接ソースを落としてインストールする。ビルドには、FUSEとzlibのライブラリの他、lzoライブラリ(バージョン2。DebianやUbuntuでは「liblzo2-dev」)が必要。$ tar xzf LZOlayer_fs-20060306.tar.gz $ cd LZOlayer_fs-20060306 $ make gcc -o lzo_fs LZOlayer_fs.c -g -Wall -g -D_FILE_OFFSET_BITS=64 -I/usr/include/lzo/ -O2 -s -fomit-frame-pointer -lfuse -lz -llzo2 LZOlayer_fs.c: In function 'LZOlayer_getattr': LZOlayer_fs.c:127: error: 'O_LARGEFILE' undeclared (first use in this function) LZOlayer_fs.c:127: error: (Each undeclared identifier is reported only once LZOlayer_fs.c:127: error: for each function it appears in.) LZOlayer_fs.c: In function 'LZOlayer_open': LZOlayer_fs.c:169: error: 'O_LARGEFILE' undeclared (first use in this function) LZOlayer_fs.c:184: warning: cast from pointer to integer of different size LZOlayer_fs.c: In function 'LZOlayer_read': LZOlayer_fs.c:196: error: 'O_LARGEFILE' undeclared (first use in this function) LZOlayer_fs.c: In function 'LZOlayer_packet_sync': LZOlayer_fs.c:252: error: 'O_LARGEFILE' undeclared (first use in this function) LZOlayer_fs.c:288: warning: integer overflow in expression LZOlayer_fs.c:288: warning: integer overflow in expression LZOlayer_fs.c: In function 'LZOlayer_release': LZOlayer_fs.c:318: error: 'O_LARGEFILE' undeclared (first use in this function) LZOlayer_fs.c: In function 'LZOlayer_mknod': LZOlayer_fs.c:368: error: 'O_LARGEFILE' undeclared (first use in this function) LZOlayer_fs.c: In function 'LZOlayer_truncate': LZOlayer_fs.c:386: error: 'O_LARGEFILE' undeclared (first use in this function) make: *** [lzo_fs] Error 1
ビルドしてみたところ、見慣れないエラーが出た。
[引用]MANPAGE of OPENより
O_LARGEFILE
(LFS) off_t ではサイズを表せない (だだし off64_t ではサイズを表せる) ファイルをオープン可能にする。この定義を有効にするためには、 _LARGEFILE64_SOURCE マクロを定義しなければならない。 (以下略)
ということらしいが、これを参考にして、以下の修正でビルドが通るようになった。ビルドエラーの他、バージョン情報の誤りも修正した。
--- LZOlayer_fs.c.orig +++ LZOlayer_fs.c @@ -7,13 +7,13 @@ Use it at your OWN RISK Absolutely NO WARANTY */ +#define _LARGEFILE64_SOURCE #define FUSE_USE_VERSION 22 #include <fuse.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> -#define __USE_LARGEFILE64 #include <fcntl.h> #include <dirent.h> #include <sys/types.h> @@ -31,7 +31,7 @@ #define max_packets 2048 off_t block_size = 131072; #define __LZOlayer_DEBUG 0 -#define VERSION "20060202-2" +#define VERSION "20060306" static char *srcPath; static int zlibCompression = 0;
下の警告の内容は多少気になるが...
$ make gcc -o lzo_fs LZOlayer_fs.c -g -Wall -g -D_FILE_OFFSET_BITS=64 -I/usr/include/lzo/ -O2 -s -fomit-frame-pointer -lfuse -lz -llzo2 LZOlayer_fs.c: In function 'LZOlayer_open': LZOlayer_fs.c:184: warning: cast from pointer to integer of different size LZOlayer_fs.c: In function 'LZOlayer_packet_sync': LZOlayer_fs.c:288: warning: integer overflow in expression LZOlayer_fs.c:288: warning: integer overflow in expression
ビルドが終わったら、生成されたlzo_fsを/usr/local/bin/や${HOME}/bin/などにコピーする。
$ sudo cp lzo_fs /usr/local/bin/ もしくは $ cp lzo_fs ~/bin/
動作方式
Squashfsなどの読み取り専用圧縮ファイルシステムと違い、事前にファイルシステムイメージを作るものではない。マウントポイント以下にファイルが作成されると、それが圧縮されて、マウント時に指定する「ソースパス」のディレクトリに格納されるという形になっている。読み出す場合は、逆に、「ソースパス」の圧縮済ファイルを伸長して、無圧縮時のように扱える。マウント
事前に、ソースパス(ここでは${HOME}/lzo_compressed)とマウントポイント(ここでは${HOME}/lzo)を作成して、$ mkdir ~/lzo_compressed ~/lzo
下のようにすると、${HOME}/lzo/以下に作成されたファイルは、LZO圧縮されて${HOME}/lzo-compressed/以下に同名のファイル名で保存される。
$ lzo_fs ~/lzo_compressed ~/lzo -s
-sオプションは、現状では事実上必須。-o allow_otherを付けると、別のユーザがアクセスできるようにもできる。
zlibを使用する場合は-zlibオプションを付ける。
$ lzo_fs ~/lzo_compressed ~/lzo -zlib -s zlibCompression Enabled
当然のことながら、LZOを使用してマウントしたときに作成したファイルは読めず、逆に、zlibを使用してマウントしたときに作成したファイルはLZOでマウントしたときには読めない。両方を使い分けるのなら、ソースパスとマウントポイントはそれぞれLZO用とzlib用を用意して、個別にマウントする。
圧縮の動作を確認
試しに、VirtualBoxのマニュアルを入れてみると、$ stat -c %s ~/lzo/VirtualBox-manual-1.5.0.pdf 3286240 $ stat -c %s ~/lzo_compressed/VirtualBox-manual-1.5.0.pdf 3055918
のように、縮んでディスク上に保存されていることが分かる。PDFファイルは縮みにくいが、
$ stat -c %s ~/lzo/hibernate.log 2678725 $ stat -c %s ~/lzo_compressed/hibernate.log 123669
テキストファイルには効果的。
マウント解除
アンマウントは、FUSEのファイルシステム共通の形で$ fusermount -u ~/lzo
のように、マウントポイントを指定する。
使用したバージョン:
- LZOlayerFS 20060306