virt-rescue(1) | Virtualization Support | virt-rescue(1) |
virt-rescue - 仮想マシンにおいてレスキューシェルを実行します
virt-rescue [--options] -d domname virt-rescue [--options] -a disk.img [-a disk.img ...] [-i]
古い形式:
virt-rescue [--options] domname virt-rescue [--options] disk.img [disk.img ...]
virt-rescue is like a Rescue CD, but for virtual machines, and without the need for a CD. virt-rescue gives you a rescue shell and some simple recovery tools which you can use to examine or rescue a virtual machine or disk image.
You can run virt-rescue on any virtual machine known to libvirt, or directly on disk image(s):
virt-rescue -d GuestName -i virt-rescue --ro -a /path/to/disk.img -i virt-rescue -a /dev/sdc
For live VMs you must use the --ro option.
When you run virt-rescue on a virtual machine or disk image, you are placed in an interactive bash shell where you can use many ordinary Linux commands. What you see in / (/bin, /lib etc) is the rescue appliance. You must mount the virtual machine’s filesystems. There is an empty directory called /sysroot where you can mount filesystems.
To automatically mount the virtual machine’s filesystems under /sysroot use the -i option. This uses libguestfs inspection to find the filesystems and mount them in the right place. You can also mount filesystems individually using the -m option.
Another way is to list the logical volumes (with lvs(8)) and partitions (with parted(8)) and mount them by hand:
><rescue> lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert lv_root vg_f15x32 -wi-a- 8.83G lv_swap vg_f15x32 -wi-a- 992.00M ><rescue> mount /dev/vg_f15x32/lv_root /sysroot ><rescue> mount /dev/vda1 /sysroot/boot ><rescue> ls /sysroot
利用可能なファイルシステムを一覧表示するためのもう 1 つのコマンドは virt-filesystems(1) です。
Linux 仮想マシンにおいてコマンド(たとえば、grub)を実行するには、まず /sysroot ディレクトリーの中に chroot する必要があります:
><rescue> chroot /sysroot
Virt-rescue can be used on any disk image file or device, not just a virtual machine. For example you can use it on a blank file if you want to partition that file (although we would recommend using guestfish(1) instead as it is more suitable for this purpose). You can even use virt-rescue on things like USB drives, SD cards and hard disks.
You can get virt-rescue to give you scratch disk(s) to play with. This is useful for testing out Linux utilities (see --scratch).
Virt-rescue does not require root. You only need to run it as root if you need root to open the disk image.
This tool is just designed for quick interactive hacking on a virtual machine. For more structured access to a virtual machine disk image, you should use guestfs(3). To get a structured shell that you can use to make scripted changes to guests, use guestfish(1).
ディスクイメージの形式は自動検知されます。 これを上書きして強制的に特定の形式を使用する場合、 --format=.. オプションを使用します。
ゲストのブロックデバイスを直接指定していると((-a))、libvirt は何も使用されません。
See "ESCAPE KEY" below for further information.
例:
virt-rescue --format=raw -a disk.img
forces raw format (no auto-detection) for disk.img.
virt-rescue --format=raw -a disk.img --format -a another.img
forces raw format (no auto-detection) for disk.img and reverts to auto-detection for another.img.
仮想マシンのディスクイメージが信頼できない raw 形式である場合、 ディスク形式を指定するためにこのオプションを使用すべきです。 これにより、悪意のある仮想マシンにより起こり得る セキュリティ問題を回避できます (CVE-2010-3851)。
The filesystems are mounted on /sysroot in the rescue environment.
If the mountpoint is omitted, it defaults to /. You have to mount something on /.
The filesystems are mounted under /sysroot in the rescue environment.
マウントパラメーターの三番目の (ほとんど使用されない) 項目は、 バックエンドのファイルシステムをマウントするために使用される マウントオプションの一覧です。 これが指定されていない場合、 マウントオプションは空文字列または "ro" (--ro フラグが使用されている場合) になります。
-m /dev/sda1:/:acl,user_xattr
パラメーターの四番目の項目は使用するファイルシステムドライバー ("ext3" や "ntfs" など) です。 これはほとんど必要ありません。 しかし、複数のドライバーがファイルシステムに対して有効である場合 (例: "ext2" と "ext3")、 または libguestfs がファイルシステムを誤検知している場合、 これは有用です。
ディスクイメージまたは仮想マシンが使用中の場合、 必ずこのオプションを使用する必要があります。 また、ディスクへの書き込みアクセスが不要な場合、 このオプションが一般的に推奨されます。
"OPENING DISKS FOR READ AND WRITE" in guestfish(1) 参照。
-a, -d および --scratch オプションは混在できます。スクラッチディスクは、これらがコマンドラインに現れる順番で、アプライアンスに追加されます。
このオプションは --ro を意味します。仮想マシンが起動していたり、他の virt-rescue を実行しているときでも安全です。
"OPENING DISKS FOR READ AND WRITE" in guestfish(1) 参照。
Previous versions of virt-rescue allowed you to write either:
virt-rescue disk.img [disk.img ...]
または
virt-rescue guestname
whereas in this version you should use -a or -d respectively to avoid the confusing case where a disk image might have the same name as a guest.
互換性のため古い形式がまだサポートされています。
Adding the --network option enables QEMU user networking in the rescue appliance. There are some differences between user networking and ordinary networking:
exec 3<>/dev/tcp/redhat.com/80 echo "GET /" >&3 cat <&3
詳細は bash(1) 参照。
Virt-rescue supports various keyboard escape sequences which are entered by pressing "^]" (Control key + "]" key).
You can change the escape key using the -e option on the command line (see above), and you can disable escapes completely using -e none. The rest of this section assumes the default escape key.
The following escapes can be used:
If you are testing a tool inside virt-rescue and the tool (not virt-rescue) segfaults, it can be tricky to capture the core dump outside virt-rescue for later analysis. This section describes one way to do this.
truncate -s 4G /tmp/corefiles virt-format --partition=mbr --filesystem=ext2 -a /tmp/corefiles virt-filesystems -a /tmp/corefiles --all --long -h
virt-rescue --rw [-a ...] -a /tmp/corefiles
NB. If you use the --ro option, then virt-rescue will silently not write any core files to /tmp/corefiles.
><rescue> mkdir /tmp/mnt ><rescue> mount /dev/sdb1 /tmp/mnt
><rescue> echo '/tmp/mnt/core.%p' > /proc/sys/kernel/core_pattern ><rescue> ulimit -Hc unlimited ><rescue> ulimit -Sc unlimited
><rescue> ls -l /tmp/mnt total 1628 -rw------- 1 root root 1941504 Dec 7 13:13 core.130 drwx------ 2 root root 16384 Dec 7 13:00 lost+found
><rescue> umount /tmp/mnt ><rescue> exit
guestfish --ro -a /tmp/corefiles -m /dev/sda1 ><fs> ll / ><fs> download /core.NNN /tmp/core.NNN
Several environment variables affect virt-rescue. See "ENVIRONMENT VARIABLES" in guestfs(3) for the complete list.
See libguestfs-tools.conf(5).
guestfs(3), guestfish(1), virt-cat(1), virt-edit(1), virt-filesystems(1), libguestfs-tools.conf(5), http://libguestfs.org/.
Richard W.M. Jones http://people.redhat.com/~rjones/
Copyright (C) 2009-2023 Red Hat Inc.
To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
When reporting a bug, please supply:
2024-01-05 | libguestfs-1.52.0 |