3 # Copyright (C) 2009 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 use Sys::Guestfs::Lib qw(open_guest);
26 use Locale::TextDomain 'libguestfs';
32 virt-rescue - Run a rescue shell on a virtual machine
36 virt-rescue [--options] domname
38 virt-rescue [--options] disk.img [disk.img ...]
42 You must I<not> use C<virt-rescue> on live virtual machines. Doing so
43 will probably result in disk corruption in the VM. C<virt-rescue>
44 tries to stop you from doing this, but doesn't catch all cases.
46 However if you use the I<--ro> (read only) option, then you can attach
47 a shell to a live virtual machine, but the results might be strange or
48 inconsistent at times (but you won't get disk corruption).
52 virt-rescue gives you a rescue shell and some simple recovery tools
53 which you can use on a virtual machine disk image.
55 After running virt-rescue, what you see under C</> is the recovery
58 You must mount the virtual machine's filesystems by hand. There
59 is a directory C</sysroot> where you can mount filesystems. For
63 LV VG Attr LSize Origin Snap% Move Log Copy% Convert
64 lv_root vg_f11x64 -wi-a- 8.83G
65 lv_swap vg_f11x64 -wi-a- 992.00M
66 ><rescue> mount /dev/vg_f11x64/lv_root /sysroot
69 This tool is just designed for quick interactive hacking on a virtual
70 machine. For more structured access to a virtual machine disk image,
71 you should use L<guestfs(3)>. To get a structured shell, use
92 Display version number and exit.
98 =item B<--connect URI> | B<-c URI>
100 If using libvirt, connect to the given I<URI>. If omitted, then we
101 connect to the default libvirt hypervisor.
103 If you specify guest block devices directly, then libvirt is not used
110 =item B<--ro> | B<-r>
112 Open the image read-only.
114 The option must always be used if the disk image or virtual machine
115 might be running, and is generally recommended in cases where you
116 don't need write access to the disk.
122 GetOptions ("help|?" => \$help,
123 "version" => \$version,
124 "connect|c=s" => \$uri,
125 "ro|r" => \$readonly,
127 pod2usage (1) if $help;
129 my $g = Sys::Guestfs->new ();
130 my %h = $g->version ();
131 print "$h{major}.$h{minor}.$h{release}$h{extra}\n";
135 pod2usage (__"virt-rescue: no image or VM names rescue given")
139 push @args, address => $uri if $uri;
140 push @args, rw => 1 unless $readonly;
141 my $g = open_guest (@args);
144 $g->set_append ("guestfs_rescue=1");
156 L<Sys::Guestfs::Lib(3)>,
158 L<http://libguestfs.org/>.
162 Richard W.M. Jones L<http://et.redhat.com/~rjones/>
166 Copyright (C) 2009 Red Hat Inc.
168 This program is free software; you can redistribute it and/or modify
169 it under the terms of the GNU General Public License as published by
170 the Free Software Foundation; either version 2 of the License, or
171 (at your option) any later version.
173 This program is distributed in the hope that it will be useful,
174 but WITHOUT ANY WARRANTY; without even the implied warranty of
175 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176 GNU General Public License for more details.
178 You should have received a copy of the GNU General Public License
179 along with this program; if not, write to the Free Software
180 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.