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
56 appliance. You must mount the virtual machine's filesystems by hand,
60 LV VG Attr LSize Origin Snap% Move Log Copy% Convert
61 lv_root vg_f11x64 -wi-a- 8.83G
62 lv_swap vg_f11x64 -wi-a- 992.00M
63 # mount /dev/vg_f11x64/lv_root /sysroot
66 This tool is just designed for quick interactive hacking on a virtual
67 machine. For more structured access to a virtual machine disk image,
68 you should use L<guestfs(3)>. To get a structured shell, use
89 Display version number and exit.
95 =item B<--connect URI> | B<-c URI>
97 If using libvirt, connect to the given I<URI>. If omitted, then we
98 connect to the default libvirt hypervisor.
100 If you specify guest block devices directly, then libvirt is not used
107 =item B<--ro> | B<-r>
109 Open the image read-only.
115 GetOptions ("help|?" => \$help,
116 "version" => \$version,
117 "connect|c=s" => \$uri,
118 "ro|r" => \$readonly,
120 pod2usage (1) if $help;
122 my $g = Sys::Guestfs->new ();
123 my %h = $g->version ();
124 print "$h{major}.$h{minor}.$h{release}$h{extra}\n";
128 pod2usage (__"virt-rescue: no image or VM names rescue given")
132 push @args, address => $uri if $uri;
133 push @args, rw => 1 unless $readonly;
134 my $g = open_guest (@args);
137 $g->set_append ("guestfs_rescue=1");
149 L<Sys::Guestfs::Lib(3)>,
151 L<http://libguestfs.org/>.
155 Richard W.M. Jones L<http://et.redhat.com/~rjones/>
159 Copyright (C) 2009 Red Hat Inc.
161 This program is free software; you can redistribute it and/or modify
162 it under the terms of the GNU General Public License as published by
163 the Free Software Foundation; either version 2 of the License, or
164 (at your option) any later version.
166 This program is distributed in the hope that it will be useful,
167 but WITHOUT ANY WARRANTY; without even the implied warranty of
168 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
169 GNU General Public License for more details.
171 You should have received a copy of the GNU General Public License
172 along with this program; if not, write to the Free Software
173 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.