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 virt-rescue gives you a rescue shell and some simple recovery tools
43 which you can use on a virtual machine disk image.
45 After running virt-rescue, what you see under C</> is the recovery
46 appliance. You must mount the virtual machine's filesystems by hand,
50 LV VG Attr LSize Origin Snap% Move Log Copy% Convert
51 lv_root vg_f11x64 -wi-a- 8.83G
52 lv_swap vg_f11x64 -wi-a- 992.00M
53 # mount /dev/vg_f11x64/lv_root /sysroot
56 B<Note> that the virtual machine must not be powered on when you use
57 this tool. Doing so will probably result in disk corruption in the
58 VM. However if you use the I<--ro> (read only) option, then you can
59 attach a shell to a running machine, but the results might be strange
62 This tool is just designed for quick interactive hacking on a virtual
63 machine. For more structured access to a virtual machine disk image,
64 you should use L<guestfs(3)>. To get a structured shell, use
85 Display version number and exit.
91 =item B<--connect URI> | B<-c URI>
93 If using libvirt, connect to the given I<URI>. If omitted, then we
94 connect to the default libvirt hypervisor.
96 If you specify guest block devices directly, then libvirt is not used
103 =item B<--ro> | B<-r>
105 Open the image read-only.
111 GetOptions ("help|?" => \$help,
112 "version" => \$version,
113 "connect|c=s" => \$uri,
114 "ro|r" => \$readonly,
116 pod2usage (1) if $help;
118 my $g = Sys::Guestfs->new ();
119 my %h = $g->version ();
120 print "$h{major}.$h{minor}.$h{release}$h{extra}\n";
124 pod2usage (__"virt-rescue: no image or VM names rescue given")
128 push @args, address => $uri if $uri;
129 push @args, rw => 1 unless $readonly;
130 my $g = open_guest (@args);
133 $g->set_append ("guestfs_rescue=1");
145 L<Sys::Guestfs::Lib(3)>,
147 L<http://libguestfs.org/>.
151 Richard W.M. Jones L<http://et.redhat.com/~rjones/>
155 Copyright (C) 2009 Red Hat Inc.
157 This program is free software; you can redistribute it and/or modify
158 it under the terms of the GNU General Public License as published by
159 the Free Software Foundation; either version 2 of the License, or
160 (at your option) any later version.
162 This program is distributed in the hope that it will be useful,
163 but WITHOUT ANY WARRANTY; without even the implied warranty of
164 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
165 GNU General Public License for more details.
167 You should have received a copy of the GNU General Public License
168 along with this program; if not, write to the Free Software
169 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.