1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
|
=head1 名前
guestmount - Mount a guest filesystem on the host using FUSE and libguestfs
=head1 書式
guestmount [--options] -a disk.img -m device [--ro] mountpoint
guestmount [--options] -a disk.img -i [--ro] mountpoint
guestmount [--options] -d Guest -i [--ro] mountpoint
=head1 説明
The guestmount program can be used to mount virtual machine filesystems and
other disk images on the host. It uses libguestfs for access to the guest
filesystem, and FUSE (the "filesystem in userspace") to make it appear as a
mountable device.
Along with other options, you have to give at least one device (I<-a>
option) or libvirt domain (I<-d> option), and at least one mountpoint (I<-m>
option) or use the I<-i> inspection option or the I<--live> option. How
this works is better explained in the L<guestfish(1)> manual page, or by
looking at the examples below.
FUSE lets you mount filesystems as non-root. The mountpoint must be owned
by you. The filesystem will not be visible to any other users unless you
make configuration changes, see L</NOTES> below.
To unmount the filesystem, use the L<guestunmount(1)> command.
=head1 例
For a typical Windows guest which has its main filesystem on the first
partition:
guestmount -a windows.img -m /dev/sda1 --ro /mnt
For a typical Linux guest which has a /boot filesystem on the first
partition, and the root filesystem on a logical volume:
guestmount -a linux.img -m /dev/VG/LV -m /dev/sda1:/boot --ro /mnt
To get libguestfs to detect guest mountpoints for you:
guestmount -a guest.img -i --ro /mnt
For a libvirt guest called "Guest" you could do:
guestmount -d Guest -i --ro /mnt
If you don’t know what filesystems are contained in a guest or disk image,
use L<virt-filesystems(1)> first:
virt-filesystems -d MyGuest
If you want to trace the libguestfs calls but without excessive debugging
information, we recommend:
guestmount [...] --trace /mnt
If you want to debug the program, we recommend:
guestmount [...] --trace --verbose /mnt
To unmount the filesystem after using it:
guestunmount /mnt
=head1 注記
=head2 他のユーザーは標準でファイルシステムを参照できません。
If you mount a filesystem as one user (eg. root), then other users will not
be able to see it by default. The fix is to add the FUSE C<allow_other>
option when mounting:
sudo guestmount [...] -o allow_other /mnt
B<and> to enable this option in F</etc/fuse.conf>.
=head2 Enabling FUSE
On some distros, you may need to add yourself to a special group
(eg. C<fuse>) before you can use any FUSE filesystem. This is necessary on
Debian and derivatives.
On other distros, no special group is required. It is not necessary on
Fedora or Red Hat Enterprise Linux.
=head2 fusermount エラー: "デバイスまたはリソースがビジーです"
You can see this error when another process on the system jumps into the
mountpoint you have just created, holding it open and preventing you from
unmounting it. The usual culprits are various GUI "indexing" programs.
The popular workaround for this problem is to retry the C<fusermount -u>
command a few times until it works (L<guestunmount(1)> does this for you).
Unfortunately this isn't a reliable fix if (for example) the mounted
filesystem is particularly large and the intruding program particularly
persistent.
A proper fix is to use a private mountpoint by creating a new mount
namespace using the Linux-specific L<clone(2)>/L<unshare(2)> flag
C<CLONE_NEWNS>. Unfortunately at the moment this requires root and we would
also probably need to add it as a feature to guestmount.
=head2 Race conditions possible when shutting down the connection
When L<guestunmount(1)>/L<fusermount(1)> exits, guestmount may still be
running and cleaning up the mountpoint. The disk image will not be fully
finalized.
This means that scripts like the following have a nasty race condition:
guestmount -a disk.img -i /mnt
# copy things into /mnt
guestunmount /mnt
# immediately try to use 'disk.img' ** UNSAFE **
The solution is to use the I<--pid-file> option to write the guestmount PID
to a file, then after guestunmount spin waiting for this PID to exit.
guestmount -a disk.img -i --pid-file guestmount.pid /mnt
# ...
# ...
# Save the PID of guestmount *before* calling guestunmount.
pid="$(cat guestmount.pid)"
# Unmount the filesystem.
guestunmount /mnt
timeout=10
count=$timeout
while kill -0 "$pid" 2>/dev/null && [ $count -gt 0 ]; do
sleep 1
((count--))
done
if [ $count -eq 0 ]; then
echo "$0: wait for guestmount to exit failed after $timeout seconds"
exit 1
fi
# Now it is safe to use the disk image.
Note that if you use the C<guestfs_mount_local> API directly (see
L<guestfs(3)/MOUNT LOCAL>) then it is much easier to write a safe, race-free
program.
=head1 オプション
=over 4
=item B<-a> IMAGE
=item B<--add> IMAGE
ブロックデバイスまたは仮想マシンイメージを追加します。
ディスクイメージの形式は自動検知されます。 これを上書きして強制的に特定の形式を使用する場合、 I<--format=..> オプションを使用します。
=item B<-a> URI
=item B<--add> URI
リモートディスクを追加します。 L<guestfish(1)/リモートストレージの追加> 参照。
=item B<-c> URI
=item B<--connect> URI
I<-d> オプションと同時に使用するとき、 これは使用する libvirt URI を指定します。 標準状態で標準の libvirt
接続を使用します。
=item B<-d> LIBVIRT-DOMAIN
=item B<--domain> LIBVIRT-DOMAIN
名前付き libvirt 仮想マシンからディスクを追加します。 I<--ro> オプションも使用されている場合、すべての libvirt
仮想マシンを使用できます。 しかしながら、書き込みモードでは、 停止状態の libvirt 仮想マシンのみ指定できます。
名前の代わりに仮想マシンの UUID を使用できます。
=item B<--dir-cache-timeout> N
Set the readdir cache timeout to I<N> seconds, the default being 60
seconds. The readdir cache [actually, there are several semi-independent
caches] is populated after a readdir(2) call with the stat and extended
attributes of the files in the directory, in anticipation that they will be
requested soon after.
There is also a different attribute cache implemented by FUSE (see the FUSE
option I<-o attr_timeout>), but the FUSE cache does not anticipate future
requests, only cache existing ones.
=item B<--echo-keys>
キーやパスフレーズを入力するとき、通常 guestfish はエコーを無効化します。 そのため、入力内容を確認できません。 テンペスト攻撃の心配がなく、
部屋に誰も居なければ、 入力内容を確認するためにこのフラグを指定できます。
=item B<--fd=>FD
Specify a pipe or eventfd file descriptor. When the mountpoint is ready to
be used, guestmount writes a single byte to this file descriptor. This can
be used in conjunction with I<--no-fork> in order to run guestmount captive
under another process.
=item B<--format=raw|qcow2|..>
=item B<--format>
I<-a> オプションは標準状態でディスクイメージの形式を自動検知します。 これを使用することにより、コマンドラインで後続の I<-a>
オプションのディスク形式を強制的に指定できます。 引数なしで I<--format> を使用することにより、 後続の I<-a>
オプションに対して自動検知に戻せます。
仮想マシンのディスクイメージが信頼できない raw 形式である場合、 ディスク形式を指定するためにこのオプションを使用すべきです。
これにより、悪意のある仮想マシンにより起こり得る セキュリティ問題を回避できます (CVE-2010-3851)。
L</guestfs(3)/guestfs_add_drive_opts> 参照。
=item B<--fuse-help>
Display help on special FUSE options (see I<-o> below).
=item B<--help>
簡単なヘルプを表示して、終了します。
=item B<-i>
=item B<--inspector>
L<virt-inspector(1)> コードを使用すると、 オペレーティングシステムを判定するためにディスクを検査します。
また、実際の仮想マシンにマウントすることと同じように ファイルシステムをマウントします。
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using the
inspection. C<SELECTOR> can be in one of the following formats:
=over 4
=item B<--key> C<DEVICE>:key:KEY_STRING
Use the specified C<KEY_STRING> as passphrase.
=item B<--key> C<DEVICE>:file:FILENAME
Read the passphrase from F<FILENAME>.
=back
=item B<--keys-from-stdin>
Read key or passphrase parameters from stdin. The default is to try to read
passphrases from the user by opening F</dev/tty>.
=item B<--live>
動作中の仮想マシンに接続します。 (実験的、L<guestfs(3)/ATTACHING TO RUNNING DAEMONS> 参照)。
=item B<-m> dev[:mountpoint[:options[:fstype]]
=item B<--mount> dev[:mountpoint[:options[:fstype]]]
Mount the named partition or logical volume on the given mountpoint B<in the
guest> (this has nothing to do with mountpoints in the host).
If the mountpoint is omitted, it defaults to F</>. You have to mount
something on F</>.
マウントパラメーターの三番目の (ほとんど使用されない) 項目は、 バックエンドのファイルシステムをマウントするために使用される
マウントオプションの一覧です。 これが指定されていない場合、 マウントオプションは空文字列または C<ro> (I<--ro>
フラグが使用されている場合) になります。
-m /dev/sda1:/:acl,user_xattr
パラメーターの四番目の項目は使用するファイルシステムドライバー (C<ext3> や C<ntfs> など) です。 これはほとんど必要ありません。
しかし、複数のドライバーがファイルシステムに対して有効である場合 (例: C<ext2> と C<ext3>)、 または libguestfs
がファイルシステムを誤検知している場合、 これは有用です。
=item B<--no-fork>
Don’t daemonize (or fork into the background).
=item B<-n>
=item B<--no-sync>
By default, we attempt to sync the guest disk when the FUSE mountpoint is
unmounted. If you specify this option, then we don't attempt to sync the
disk. See the discussion of autosync in the L<guestfs(3)> manpage.
=item B<-o> OPTION
=item B<--option> OPTION
追加オプションを FUSE に渡します。
To get a list of all the extra options supported by FUSE, use the command
below. Note that only the FUSE I<-o> options can be passed, and only some
of them are a good idea.
guestmount --fuse-help
Some potentially useful FUSE options:
=over 4
=item B<-o> B<allow_other>
Allow other users to see the filesystem. This option has no effect unless
you enable it globally in F</etc/fuse.conf>.
=item B<-o> B<attr_timeout=N>
Enable attribute caching by FUSE, and set the timeout to I<N> seconds.
=item B<-o> B<kernel_cache>
Allow the kernel to cache files (reduces the number of reads that have to go
through the L<guestfs(3)> API). This is generally a good idea if you can
afford the extra memory usage.
=item B<-o> B<uid=N> B<-o> B<gid=N>
Use these options to map all UIDs and GIDs inside the guest filesystem to
the chosen values.
=item B<-o> B<use_ino>
Preserve inode numbers from the underlying filesystem.
Without this option, FUSE makes up its own inode numbers. The inode numbers
you see in L<stat(2)>, C<ls -i> etc aren't the inode numbers of the
underlying filesystem.
B<Note> this option is potentially dangerous if the underlying filesystem
consists of multiple mountpoints, as you may see duplicate inode numbers
appearing through FUSE. Use of this option can confuse some software.
=back
=item B<--pid-file> FILENAME
C<filename> に guestmount ワーカープロセスの PID を書き込みます。
=item B<-r>
=item B<--ro>
Add devices and mount everything read-only. Also disallow writes and make
the disk appear read-only to FUSE.
This is highly recommended if you are not going to edit the guest disk. If
the guest is running and this option is I<not> supplied, then there is a
strong risk of disk corruption in the guest. We try to prevent this from
happening, but it is not always possible.
L<guestfish(1)/OPENING DISKS FOR READ AND WRITE> 参照。
=item B<--selinux>
This option is provided for backwards compatibility and does nothing.
=item B<-v>
=item B<--verbose>
libguestfs からの冗長なメッセージを有効にします。
=item B<-V>
=item B<--version>
プログラムのバージョンを表示して、終了します。
=item B<-w>
=item B<--rw>
ディスクが追加され、読み書き可能でマウントされるよう、 I<-a>, I<-d>, I<-m> オプションを変更します。
L<guestfish(1)/OPENING DISKS FOR READ AND WRITE> 参照。
=item B<-x>
=item B<--trace>
Trace libguestfs calls and entry into each FUSE function.
This also stops the daemon from forking into the background (see
I<--no-fork>).
=back
=head1 ファイル
=over 4
=item $XDG_CONFIG_HOME/libguestfs/libguestfs-tools.conf
=item $HOME/.libguestfs-tools.rc
=item $XDG_CONFIG_DIRS/libguestfs/libguestfs-tools.conf
=item /etc/libguestfs-tools.conf
This configuration file controls the default read-only or read-write mode
(I<--ro> or I<--rw>).
See L<libguestfs-tools.conf(5)>.
=back
=head1 終了ステータス
このプログラムは、成功すると 0 を、エラーがあると 0 以外を返します。
=head1 関連項目
L<guestunmount(1)>, L<fusermount(1)>, L<guestfish(1)>, L<virt-inspector(1)>,
L<virt-cat(1)>, L<virt-edit(1)>, L<virt-tar(1)>,
L<libguestfs-tools.conf(5)>, L<guestfs(3)/MOUNT LOCAL>,
L<http://libguestfs.org/>, L<http://fuse.sf.net/>.
=head1 著者
Richard W.M. Jones (C<rjones at redhat dot com>)
=head1 COPYRIGHT
Copyright (C) 2009-2019 Red Hat Inc.
|