マウントディレクトリをディレクトリに、ファイルをファイルにのみバインドできますか?

マウントディレクトリをディレクトリに、ファイルをファイルにのみバインドできますか?

~からhttp://man7.org/linux/man-pages/man2/mount.2.html

mount()は、ソースによって指定されたファイルシステム(通常はデバイスのパス名ですが、ディレクトリまたはファイルのパス名でもあります)を関連付けます。仮想文字列)をターゲットのパス名で指定された場所(ディレクトリまたはファイル)にコピーします。

私はテストしましたが、test.ext4はext4イメージファイル、mntは通常のファイルです。

何が起こる前に

 xtricman@archlinux  ~  ls mnt test.ext4 -ali
1093586 -rw-r--r-- 1 xtricman users        0 2月  27 10:13 mnt
1085615 -rw-r--r-- 1 xtricman users 16777216 2月  24 19:35 test.ext4

マウントディレクトリをファイルにバインドしましたが失敗しました。

 xtricman@archlinux  ~  sudo mount --bind /var mnt
mount: /home/xtricman/mnt: mount point is not a directory.

mountループデバイスを作成し、デバイスをファイルにマウント(バインドしない)できますが失敗します。

 xtricman@archlinux  ~  sudo mount test.ext4 mnt
mount: /home/xtricman/mnt: mount point is not a directory.

マウントされたファイルをディレクトリにバインドしましたが失敗しました。

 xtricman@archlinux  ~  sudo mount --bind test.ext4 /mnt
mount: /mnt: mount(2) system call failed: 不是目录.

マウントされたファイルをファイルにバインドすると成功します!

 xtricman@archlinux  ~  sudo mount --bind test.ext4 mnt
 xtricman@archlinux  ~  ls -ali mnt test.ext4
1085615 -rw-r--r-- 1 xtricman users 16777216 2月  27 10:16 mnt
1085615 -rw-r--r-- 1 xtricman users 16777216 2月  27 10:16 test.ext4
 xtricman@archlinux  ~  sudo umount mnt
 xtricman@archlinux  ~  echo "Trash" >  new_file
 xtricman@archlinux  ~  ls -ali new_file mnt test.ext4 
1093586 -rw-r--r-- 1 xtricman users        0 2月  27 10:13 mnt
1093810 -rw-r--r-- 1 xtricman users        6 2月  27 10:58 new_file
1085615 -rw-r--r-- 1 xtricman users 16777216 2月  27 10:16 test.ext4
 xtricman@archlinux  ~  sudo mount --bind new_file mnt
 xtricman@archlinux  ~  ls -ali new_file mnt test.ext4
1093810 -rw-r--r-- 1 xtricman users        6 2月  27 10:58 mnt
1093810 -rw-r--r-- 1 xtricman users        6 2月  27 10:58 new_file
1085615 -rw-r--r-- 1 xtricman users 16777216 2月  27 10:16 test.ext4

それでは、実際にマウントディレクトリをディレクトリに、ファイルをファイルにのみバインドできますか? 「ダミー文字列」とはどういう意味ですか?ソースまたはターゲットとして存在しないパスは単に失敗しませんか?

ベストアンサー1

おすすめ記事