Linux で HP の LTFS 使って LTO-5 テープを読み書きする

前回書いた記事では、 Linux 上で tar mt コマンドを使ったテープドライブの操作についてまとめました。

https://blog.yukirii.dev/linux-lto-tape-drive-management-commands/

今回は LTFS を使用する方法について確認してみたいと思います。現在所有している LTO ドライブは HP 製であるため、使用するソフトウェアは HP から提供されているものを使用します。

LTFS (Linear Tape File System)

LTFS は LTO-5 以降の世代からサポートされているテープ向けのファイルシステム。専用ソフトウェアやコマンドが必要だったテープへの読み書きの操作が、 HDD や USB メモリと同様の扱いで行えるようになる。

注意しなければならない点としては、テープの先頭から書き込みを行い追記は直前に記録したブロックの終点から行うという特性は、 tar フォーマットを使った場合と変わらない、ということ。ファイルの削除操作では該当の領域が利用不可とマークされるだけで、空き容量は増えないようです。同様に、記録済みのファイルに対する上書きでも、新たなファイルの追記として扱われます。

https://ja.wikipedia.org/wiki/LTFS

http://h50146.www5.hpe.com/products/storage/solution/ltfs/

実際に使ってみる

検証環境の OS は CentOS 7.2 です。

ソフトウェアのインストール

まずは HPE が配布している HPE StoreOpen Standalone for RHELx64 を入手する。 ダウンロードは以下のページから。

https://h20392.www2.hpe.com/portal/swdepot/displayProductInfo.do?productNumber=SOS_RHELx64

% tar zxvf HPE_StoreOpen_Standalone_3.2.0_RHELx64_Z7550-02154.tar.gz
COPYING.LIB
hpe-sos-3.2.0-67.x86_64.rpm
INSTALLING.linux
README

展開するとソフトウェアの rpm とドキュメント類が現れた。INSTALLING.linux によると、必要なパッケージは以下。

a. FUSE 2.8.5 or higher (http://fuse.sourceforge.net/) b. ICU v50.1.2 (http://site.icu-project.org/download) c. libxml2 v2.7 or higher d. e2fsprogs 1.41 or higher

## libxml2 と e2fprogs は既にインストールされているようだった
$ rpm -qa e2fsprogs
e2fsprogs-1.42.9-7.el7.x86_64
$ rpm -qa libxml2
libxml2-2.9.1-6.el7_2.2.x86_64

## icu 及び fuse 関連パッケージをインストールする
% sudo yum install icu fuse fuse-devel

## lsmod で fuse が一覧に含まれることを確認
## modprobe でカーネルモジュールをロードする
% lsmod | grep fuse
fuse                   87741  1
% sudo modprobe fuse

## HPE StoreOpen Standalone のインストール
% sudo rpm -ivh hpe-sos-3.2.0-67.x86_64.rpm

テープのフォーマット

mkfs のように mkltfs というコマンドが使用できるようになる。ドライブのデバイスファイルを指定しフォーマットする。

$ sudo /usr/local/bin/mkltfs -d /dev/nst0
LTFS15000I Starting mkltfs, HPE StoreOpen Standalone version 3.2.0, log level 2
LTFS15041I Launched by "/usr/local/bin/mkltfs -d /dev/nst0"
LTFS15042I This binary is built for Linux (x86_64)
LTFS15043I GCC version is 4.4.4 20100726 (Red Hat 4.4.4-13)
LTFS17087I Kernel version: Linux version 3.10.0-327.10.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Tue Feb 16 17:03:50 UTC 2016 i386
LTFS17089I Distribution: CentOS Linux release 7.2.1511 (Core)
LTFS17089I Distribution: NAME="CentOS Linux"
LTFS17089I Distribution: CentOS Linux release 7.2.1511 (Core)
LTFS17089I Distribution: CentOS Linux release 7.2.1511 (Core)
LTFS15003I Formatting device '/dev/nst0'
LTFS15004I LTFS volume blocksize: 524288
LTFS15005I Index partition placement policy: None

LTFS17085I Plugin: Loading "ltotape" driver
LTFS20013I Drive type is HP LTO5, serial number is HU1202LFNR
LTFS17160I Maximum device block size is 524288
LTFS15049I Checking the medium (mount)
LTFS11175E Cannot read ANSI label: expected 80 bytes, but received 4096
LTFS11009E Cannot read volume: failed to read partition labels.
LTFS15010I Creating data partition b on SCSI partition 1
LTFS15011I Creating index partition a on SCSI partition 0
LTFS17165I Resetting the medium's capacity proportion
LTFS11097I Partitioning the medium
LTFS20075E Failed to write attribute (-1)
LTFS20076I Triggering drive diagnostic dump
LTFS20096I Diagnostic dump complete
LTFS20024W Cannot store attribute 0x820 (-1)
LTFS11100I Writing label to partition b
LTFS11278I Writing index to partition b
LTFS11100I Writing label to partition a
LTFS11278I Writing index to partition a
LTFS15013I Volume UUID is: 1ce2ff2f-196a-4fb1-939a-a07a3d0b7559

LTFS15019I Volume capacity is 1335 GB
LTFS20076I Triggering drive diagnostic dump
LTFS20096I Diagnostic dump complete
LTFS15024I Medium formatted successfully

テープのマウント

マウントポイントを作成し、 ltfs コマンドでマウントする。

## マウントポイントの作成
$ sudo mkdir /mnt/lto

## ltfs コマンドにマウント先を渡してマウントする
$ sudo /usr/local/bin/ltfs /mnt/lto
5d28 LTFS14000I LTFS starting, HPE StoreOpen Standalone version 3.2.0, log level 2
5d28 LTFS14058I LTFS Format Specification version 2.2.0
5d28 LTFS14104I Launched by "/usr/local/bin/ltfs /mnt/lto"
5d28 LTFS14105I This binary is built for Linux (x86_64)
5d28 LTFS14106I GCC version is 4.4.4 20100726 (Red Hat 4.4.4-13)
5d28 LTFS17087I Kernel version: Linux version 3.10.0-327.10.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Tue Feb 16 17:03:50 UTC 2016 i386
5d28 LTFS17089I Distribution: CentOS Linux release 7.2.1511 (Core)
5d28 LTFS17089I Distribution: NAME="CentOS Linux"
5d28 LTFS17089I Distribution: CentOS Linux release 7.2.1511 (Core)
5d28 LTFS17089I Distribution: CentOS Linux release 7.2.1511 (Core)
5d28 LTFS14063I Sync type is "time", Sync time is 300 sec
5d28 LTFS17085I Plugin: Loading "ltotape" driver
5d28 LTFS17085I Plugin: Loading "unified" iosched
5d28 LTFS20013I Drive type is HP LTO5, serial number is HU1202LFNR
5d28 LTFS17160I Maximum device block size is 524288
5d28 LTFS11005I Mounting the volume
5d28 LTFS17302W Cannot retrieve attribute (Barcode=0x806)
5d28 LTFS14111I Initial setup completed successfully
5d28 LTFS14112I Invoke 'mount' command to check the result of final setup
5d28 LTFS14113I Specified mount point is listed if succeeded

## df コマンドで容量を確認してみる
$ df
ファイルシス                       サイズ  使用  残り 使用% マウント位置
  〜 省略 〜
ltfs:/dev/nst0                      1400693760          0 1400693760    0% /mnt/lto

df の結果をみると 1.4TB の領域が使用可能であることがわかる。

データの読み書き

マウント後は通常のローカルディスクのようにファイルアクセスを行うことができる。テープへのファイルの書き込み&読み込みには cp コマンドが使えるし、 ls コマンドで格納されているファイルの確認もできる。

## 15GB のファイルを 10 ファイル分コピーしてみた。
$ cp file10 /mnt/lto
$ ls -lh /mnt/lto
合計 144G
-rwxrwxrwx 1 user 15G  9月  3 19:19 file01*
-rwxrwxrwx 1 user 15G  9月  3 19:21 file02*
-rwxrwxrwx 1 user 15G  9月  3 19:24 file03*
-rwxrwxrwx 1 user 15G  9月  3 19:26 file04*
-rwxrwxrwx 1 user 15G  9月  3 19:29 file05*
-rwxrwxrwx 1 user 15G  9月  3 19:32 file06*
-rwxrwxrwx 1 user 15G  9月  3 19:34 file07*
-rwxrwxrwx 1 user 15G  9月  3 19:37 file08*
-rwxrwxrwx 1 user 15G  9月  3 19:39 file09*
-rwxrwxrwx 1 user 15G  9月  3 19:42 file10*

LTFS では、ファイルを削除した場合は、ファイルの存在する領域が利用不可にマークされるだけで、その領域の再利用はされない。実際に挙動を確認してみる。

# ファイル削除前の使用量
$ df -h
ファイルシス                       サイズ  使用  残り 使用% マウント位置
ltfs:/dev/nst0                       1.4T  161G  1.2T   12% /mnt/lto

# メタデータ操作だけなので一瞬で終わる
$ rm -f /mnt/lto/file{05..10}

# ファイルは見えなくなった
$ ls -l /mnt/lto
合計 58G
-rwxrwxrwx 1 user 15G  9月  3 19:19 file01*
-rwxrwxrwx 1 user 15G  9月  3 19:21 file02*
-rwxrwxrwx 1 user 15G  9月  3 19:24 file03*
-rwxrwxrwx 1 user 15G  9月  3 19:26 file04*

# テープ自体の使用量は削除前と変わらない
$ df -h
ファイルシス                       サイズ  使用  残り 使用% マウント位置
ltfs:/dev/nst0                       1.4T  161G  1.2T   12% /mnt/lto

LTFS の使用をやめるには

ドライブに挿入したテープカートリッジでの LTFS の使用をやめる場合は unltfs コマンドでアンフォーマットできる。

$ sudo /usr/local/bin/unltfs -d /dev/nst0
LTFS15495I LTFS Unformat Utility

LTFS15492I This operation will result in irrecoverable loss of data on the tape (Data or LTFS formatted).
Enter 'Y' if you agree or any other key to abort.
Y
LTFS17085I Plugin: Loading "ltotape" driver
LTFS20013I Drive type is HP LTO5, serial number is HU1202LFNR
LTFS17160I Maximum device block size is 524288
LTFS15064I Cartridge in device /dev/nst0 will be unformatted
LTFS15065I Removing LTFS format...
LTFS15497I Operation succeeded. Cartridge no longer contains a valid LTFS volume.

comments powered by Disqus