vboxsfマウントポイントからLUKS暗号化ファイルを生成する方法は?

vboxsfマウントポイントからLUKS暗号化ファイルを生成する方法は?

VirtualBoxイメージにLUKS暗号化ファイルを生成しようとしています。暗号化されたファイルがVirtualBox共有フォルダにない場合は正常に動作します。

エラー出力は次のとおりです。

10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.945147 s, 11.1 MB/s

WARNING!
========
This will overwrite data on test.tomb irrevocably.

Are you sure? (Type uppercase yes): YES
Enter passphrase: 
Verify passphrase: 
Enter passphrase for test.tomb: 
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 8192 1k blocks and 2048 inodes

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

mount: /dev/mapper/tomb is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/mapper/tomb,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

Vagrantでは簡単に再現できます。

さまようファイル:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "debian/jessie64"

  config.vm.synced_folder 'tombs', '/tombs'

  config.vm.provision "shell", inline: <<-SHELL
    apt-get update
    apt-get install -y cryptsetup
    mkdir -p /media/tomb
    cat > /test.sh <<-EOF
#!/bin/bash

cd \$1
dd if=/dev/urandom of=test.tomb bs=1M count=10

cryptsetup -y luksFormat test.tomb
cryptsetup luksOpen test.tomb tomb
mkfs.ext4 -j /dev/mapper/tomb

mount /dev/mapper/tomb /media/tomb
ls /media/tomb

umount /media/tomb
cryptsetup luksClose tomb
EOF

  SHELL
end

放浪者の設定:

mkdir tombs
vagrant plugin install vagrant-vbguest
vagrant up
vagrant ssh

テストを受けてください:

sudo su -
bash /test.sh /root  # works fine
bash /test.sh /tombs # does not work

mount | grep tombs示す:

tombs on /tombs type vboxsf (rw,nodev,relatime)

dmesg示す:

[  267.574832] EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: (null)

LUKSファイルが共有フォルダにある場合、これは既知の制限ですか?そうでなければ、私が何を間違っているのでしょうか?

ベストアンサー1

説明した手順を使用して再現できました。共有フォルダはゲスト追加カーネルモジュールの特殊機能であり、機能的にローカルドライブと同じではない可能性があります。

また、ループバックデバイスの内部にLUKSファイルドライブを作成しようとしましたが(過去にLUKSファイルドライブを作成したため)、ファイルフォーマットもできず、事後確認で失敗します。

私はVagrantfileの共有所有者をrootに強制しようとしましたが、違いはないようです。また、グループにroot追加しようとしましたが、それも役に立ちませんでした。vagrantvboxsf

短い答えは「はい」です。これは、「簡単な」デフォルトのvirtualbox共有フォルダの制限のようです。私が試していなかったことの1つは、vagrantがnfsスタイルの共有フォルダをサポートしていることです。

おすすめ記事