fuse-archiveでいろいろなアーカイブをfuse mount

アドベントカレンダーの時期ですね.本来のクリスマスに向けカレンダーを日に日にめくりお菓子が出てくる感じのものとは別に近年技術者向けの記事をクリスマスまで公開してくアドベントカレンダーもあります.
その中のFreeBSDアドベントカレンダーを見ていて以下の記事が気になりました.

FreeBSD 14からtarアーカイブをファイルシステムにマウントするtarfs(4)が入ったそうです.Linuxでfuse-zipとかは使ったことがあるけど他にもないかなと探してfuse-archiveを試してみました.

fuse-zipはFilesystem in Userspace(FUSE) 🏛️経由でzipアーカイブをマウントできるものです.Debianパッケージもあるので導入や管理が楽です.

fuse-archiveはたくさんのアーカイブに対応した同じようなもののようです.

fuse-archiveのインストール

今回もDebian sid amd64環境に導入しました.
インストール方法は INSTALL.md に詳しいです.
ここではインストール時に DESTDIR を設定してホームディレクトリ以下にインストールしています.

$ sudo apt install libboost-container-dev libfuse-dev libarchive-dev \
                  g++ pkg-config make pandoc \
                  python3 (1)
$ git clone https://github.com/google/fuse-archive.git (2)
$ cd fuse-archive
$ make (3)
$ make check
$ DESTDIR=~/ make install (4)
install -D "out/fuse-archive" "/home/matoken//usr/bin/fuse-archive"
install -D -m 644 fuse-archive.1 "/home/matoken//usr/share/man/man1/fuse-archive.1"
$ which fuse-archive
/home/matoken/usr/bin/fuse-archive
  1. 関連パッケージの導入

  2. sourceのclone

  3. build

  4. DESTDIRを指定してインストール

fuse-archiveの利用

$ fuse-archive linux-6.8.2.tar.xz (1)
fuse-archive: Created mount point 'linux-6.8.2' (2)
$ mount | grep linux (3)
fuse-archive on /home/matoken/Downloads/linux-6.8.2 type fuse.fuse-archive (ro,nosuid,nodev,relatime,user_id=1000,group_id=1000)
$ grep linux /etc/mtab
fuse-archive /home/matoken/Downloads/linux-6.8.2 fuse.fuse-archive ro,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
$ ls linux-6.8.2/linux-6.8.2/ (4)
COPYING  Documentation  Kconfig   MAINTAINERS  README  block  crypto   fs       init      ipc     lib  net   samples  security  tools  virt
CREDITS  Kbuild         LICENSES  Makefile     arch    certs  drivers  include  io_uring  kernel  mm   rust  scripts  sound     usr
$ head linux-6.8.2/linux-6.8.2/README (5)
Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

$ touch linux-6.8.2/linux-6.8.2/Makefile (6)
touch: cannot touch 'linux-6.8.2/linux-6.8.2/Makefile': Read-only file system
$ fusermount -u linux-6.8.2 (7)
$ grep linux /etc/mtab
$ ls linux-6.8.2* (8)
linux-6.8.2.tar.xz
  1. fuse-archiveで適当なアーカイブをマウント(マウント時にはキャッシュに読み込むため少し時間がかかる)

  2. 拡張子を除いたファイル名のディレクトリがマウントポイントとして作成されマウントされた

  3. mountされているのを確認

  4. アーカイブ内のファイルにアクセス

  5. ファイルの中を確認

  6. 書き込みはできない

  7. unmount

  8. マウントポイントのディレクトリも消える

大きなアーカイブの利用
$ ls -s Qubes-R4.2.3-x86_64.iso
6748400 Qubes-R4.2.3-x86_64.iso
$ fuse-archive Qubes-R4.2.3-x86_64.iso (1)
fuse-archive: Cannot write to cache: No space left on device
$ fuse-archive -o nocache Qubes-R4.2.3-x86_64.iso (2)
fuse-archive: Created mount point 'Qubes-R4.2.3-x86_64'
$ ls Qubes-R4.2.3-x86_64
EFI  Packages  boot  images  repodata
  1. 大きなアーカイブだと容量不足で失敗することがある

  2. -o nocache オプションでキャッシュを無効にして舞うとすることが可能,ただし速度は大幅に低下する

アーカイブ内のアーカイブのマウント
$ mktemp -d
/tmp/tmp.ZJ1Sil9byy
$ fuse-archive Qubes-R4.2.3-x86_64/Packages/zlib-1.2.12-5.fc37.x86_64.rpm /tmp/tmp.ZJ1Sil9byy
fuse-archive: Using existing mount point '/tmp/tmp.ZJ1Sil9byy'
$ ls /tmp/tmp.ZJ1Sil9byy/
usr
パスワード付きzipファイル
$ find . -iname "*.txt" | zip -e -r -@ /tmp/test.zip
$ fuse-archive /tmp/test.zip
The archive is encrypted.
What is the passphrase that unlocks this archive?
> Got it!
fuse-archive: Created mount point '/tmp/test'

まとめ

fuse-archiveはこれまで試した類似ツールと比べて多くのファイル形式に対応していて高速です.アーカイブの中のファイルを確認するのにとても便利そうです.
ディストリビューションパッケージにあると便利ですが,DebianのWNPP 🏛️を見ると無さそうです.RFP 🏛️を投げるといいかもしれません.

環境

$ fuse-archive --version
fuse-archive version: 1.5
libarchive version: libarchive 3.7.4
bzlib version: 1.0.8, 13-Jul-2019
liblz4 version: 1.9.4
liblzma version: 5.6.3
libzstd version: 1.5.6
zlib version: 1.3.1
FUSE library version: 2.9.9
fusermount3 version: 3.14.0
using FUSE kernel interface version 7.19
$ dpkg-query -W libboost-container-dev libfuse-dev libarchive-dev g++ pkg-config make pandoc python3 git
g++     4:14.2.0-1
git     1:2.45.2-1.2
libarchive-dev:amd64    3.7.4-1.1
libboost-container-dev:amd64    1.83.0.2+b2
libfuse-dev:amd64       2.9.9-9
make    4.4.1-1
pandoc  3.1.11.1+ds-2
pkg-config:amd64        1.8.1-4
python3 3.12.7-1
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)