1 =head2 add-cdrom | cdrom
5 This function adds a virtual CD-ROM disk image to the guest.
7 This is equivalent to the qemu parameter C<-cdrom filename>.
9 Note that this call checks for the existence of C<filename>. This
10 stops you from specifying other types of drive which are supported
11 by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
12 the general C<config> call instead.
14 =head2 add-drive | add
18 This function adds a virtual machine disk image C<filename> to the
19 guest. The first time you call this function, the disk appears as IDE
20 disk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and
23 You don't necessarily need to be root when using libguestfs. However
24 you obviously do need sufficient permissions to access the filename
25 for whatever operations you want to perform (ie. read access if you
26 just want to read the image or write access if you want to modify the
29 This is equivalent to the qemu parameter C<-drive file=filename,cache=off>.
31 Note that this call checks for the existence of C<filename>. This
32 stops you from specifying other types of drive which are supported
33 by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
34 the general C<config> call instead.
36 =head2 add-drive-ro | add-ro
40 This adds a drive in snapshot mode, making it effectively
43 Note that writes to the device are allowed, and will be seen for
44 the duration of the guestfs handle, but they are written
45 to a temporary file which is discarded as soon as the guestfs
46 handle is closed. We don't currently have any method to enable
47 changes to be committed, although qemu can support this.
49 This is equivalent to the qemu parameter
50 C<-drive file=filename,snapshot=on>.
52 Note that this call checks for the existence of C<filename>. This
53 stops you from specifying other types of drive which are supported
54 by qemu such as C<nbd:> and C<http:> URLs. To specify those, use
55 the general C<config> call instead.
61 Close the current Augeas handle and free up any resources
62 used by it. After calling this, you have to call
63 C<aug-init> again before you can use any other
68 aug-defnode name expr val
70 Defines a variable C<name> whose value is the result of
73 If C<expr> evaluates to an empty nodeset, a node is created,
74 equivalent to calling C<aug-set> C<expr>, C<value>.
75 C<name> will be the nodeset containing that single node.
77 On success this returns a pair containing the
78 number of nodes in the nodeset, and a boolean flag
79 if a node was created.
85 Defines an Augeas variable C<name> whose value is the result
86 of evaluating C<expr>. If C<expr> is NULL, then C<name> is
89 On success this returns the number of nodes in C<expr>, or
90 C<0> if C<expr> evaluates to something which is not a nodeset.
96 Look up the value associated with C<path>. If C<path>
97 matches exactly one node, the C<value> is returned.
103 Create a new Augeas handle for editing configuration files.
104 If there was any previous Augeas handle associated with this
105 guestfs session, then it is closed.
107 You must call this before using any other C<aug-*>
110 C<root> is the filesystem root. C<root> must not be NULL,
113 The flags are the same as the flags defined in
114 E<lt>augeas.hE<gt>, the logical I<or> of the following
119 =item C<AUG_SAVE_BACKUP> = 1
121 Keep the original file with a C<.augsave> extension.
123 =item C<AUG_SAVE_NEWFILE> = 2
125 Save changes into a file with extension C<.augnew>, and
126 do not overwrite original. Overrides C<AUG_SAVE_BACKUP>.
128 =item C<AUG_TYPE_CHECK> = 4
130 Typecheck lenses (can be expensive).
132 =item C<AUG_NO_STDINC> = 8
134 Do not use standard load path for modules.
136 =item C<AUG_SAVE_NOOP> = 16
138 Make save a no-op, just record what would have been changed.
140 =item C<AUG_NO_LOAD> = 32
142 Do not load the tree in C<aug-init>.
146 To close the handle, you can call C<aug-close>.
148 To find out more about Augeas, see L<http://augeas.net/>.
152 aug-insert path label true|false
154 Create a new sibling C<label> for C<path>, inserting it into
155 the tree before or after C<path> (depending on the boolean
158 C<path> must match exactly one existing node in the tree, and
159 C<label> must be a label, ie. not contain C</>, C<*> or end
160 with a bracketed index C<[N]>.
166 Load files into the tree.
168 See C<aug_load> in the Augeas documentation for the full gory
175 This is just a shortcut for listing C<aug-match>
176 C<path/*> and sorting the resulting nodes into alphabetical order.
182 Returns a list of paths which match the path expression C<path>.
183 The returned paths are sufficiently qualified so that they match
184 exactly one node in the current tree.
190 Move the node C<src> to C<dest>. C<src> must match exactly
191 one node. C<dest> is overwritten if it exists.
197 Remove C<path> and all of its children.
199 On success this returns the number of entries which were removed.
205 This writes all pending changes to disk.
207 The flags which were passed to C<aug-init> affect exactly
214 Set the value associated with C<path> to C<value>.
216 =head2 blockdev-flushbufs
218 blockdev-flushbufs device
220 This tells the kernel to flush internal buffers associated
223 This uses the L<blockdev(8)> command.
225 =head2 blockdev-getbsz
227 blockdev-getbsz device
229 This returns the block size of a device.
231 (Note this is different from both I<size in blocks> and
232 I<filesystem block size>).
234 This uses the L<blockdev(8)> command.
236 =head2 blockdev-getro
238 blockdev-getro device
240 Returns a boolean indicating if the block device is read-only
241 (true if read-only, false if not).
243 This uses the L<blockdev(8)> command.
245 =head2 blockdev-getsize64
247 blockdev-getsize64 device
249 This returns the size of the device in bytes.
251 See also C<blockdev-getsz>.
253 This uses the L<blockdev(8)> command.
255 =head2 blockdev-getss
257 blockdev-getss device
259 This returns the size of sectors on a block device.
260 Usually 512, but can be larger for modern devices.
262 (Note, this is not the size in sectors, use C<blockdev-getsz>
265 This uses the L<blockdev(8)> command.
267 =head2 blockdev-getsz
269 blockdev-getsz device
271 This returns the size of the device in units of 512-byte sectors
272 (even if the sectorsize isn't 512 bytes ... weird).
274 See also C<blockdev-getss> for the real sector size of
275 the device, and C<blockdev-getsize64> for the more
276 useful I<size in bytes>.
278 This uses the L<blockdev(8)> command.
280 =head2 blockdev-rereadpt
282 blockdev-rereadpt device
284 Reread the partition table on C<device>.
286 This uses the L<blockdev(8)> command.
288 =head2 blockdev-setbsz
290 blockdev-setbsz device blocksize
292 This sets the block size of a device.
294 (Note this is different from both I<size in blocks> and
295 I<filesystem block size>).
297 This uses the L<blockdev(8)> command.
299 =head2 blockdev-setro
301 blockdev-setro device
303 Sets the block device named C<device> to read-only.
305 This uses the L<blockdev(8)> command.
307 =head2 blockdev-setrw
309 blockdev-setrw device
311 Sets the block device named C<device> to read-write.
313 This uses the L<blockdev(8)> command.
319 Return the contents of the file named C<path>.
321 Note that this function cannot correctly handle binary files
322 (specifically, files containing C<\0> character which is treated
323 as end of string). For those you need to use the C<download>
324 function which has a more complex interface.
326 Because of the message protocol, there is a transfer limit
327 of somewhere between 2MB and 4MB. To transfer large files you should use
332 checksum csumtype path
334 This call computes the MD5, SHAx or CRC checksum of the
337 The type of checksum to compute is given by the C<csumtype>
338 parameter which must have one of the following values:
344 Compute the cyclic redundancy check (CRC) specified by POSIX
345 for the C<cksum> command.
349 Compute the MD5 hash (using the C<md5sum> program).
353 Compute the SHA1 hash (using the C<sha1sum> program).
357 Compute the SHA224 hash (using the C<sha224sum> program).
361 Compute the SHA256 hash (using the C<sha256sum> program).
365 Compute the SHA384 hash (using the C<sha384sum> program).
369 Compute the SHA512 hash (using the C<sha512sum> program).
373 The checksum is returned as a printable string.
379 Change the mode (permissions) of C<path> to C<mode>. Only
380 numeric modes are supported.
384 chown owner group path
386 Change the file owner to C<owner> and group to C<group>.
388 Only numeric uid and gid are supported. If you want to use
389 names, you will need to locate and parse the password file
390 yourself (Augeas support makes this relatively easy).
394 command 'arguments ...'
396 This call runs a command from the guest filesystem. The
397 filesystem must be mounted, and must contain a compatible
398 operating system (ie. something Linux, with the same
399 or compatible processor architecture).
401 The single parameter is an argv-style list of arguments.
402 The first element is the name of the program to run.
403 Subsequent elements are parameters. The list must be
404 non-empty (ie. must contain a program name). Note that
405 the command runs directly, and is I<not> invoked via
406 the shell (see C<sh>).
408 The return value is anything printed to I<stdout> by
411 If the command returns a non-zero exit status, then
412 this function returns an error message. The error message
413 string is the content of I<stderr> from the command.
415 The C<$PATH> environment variable will contain at least
416 C</usr/bin> and C</bin>. If you require a program from
417 another location, you should provide the full path in the
420 Shared libraries and data files required by the program
421 must be available on filesystems which are mounted in the
422 correct places. It is the caller's responsibility to ensure
423 all filesystems that are needed are mounted at the right
426 Because of the message protocol, there is a transfer limit
427 of somewhere between 2MB and 4MB. To transfer large files you should use
432 command-lines 'arguments ...'
434 This is the same as C<command>, but splits the
435 result into a list of lines.
437 See also: C<sh-lines>
439 Because of the message protocol, there is a transfer limit
440 of somewhere between 2MB and 4MB. To transfer large files you should use
445 config qemuparam qemuvalue
447 This can be used to add arbitrary qemu command line parameters
448 of the form C<-param value>. Actually it's not quite arbitrary - we
449 prevent you from setting some parameters which would interfere with
450 parameters that we use.
452 The first character of C<param> string must be a C<-> (dash).
454 C<value> can be NULL.
460 This copies a file from C<src> to C<dest> where C<dest> is
461 either a destination filename or destination directory.
467 This copies a file or directory from C<src> to C<dest>
468 recursively using the C<cp -a> command.
472 debug subcmd 'extraargs ...'
474 The C<debug> command exposes some internals of
475 C<guestfsd> (the guestfs daemon) that runs inside the
478 There is no comprehensive help for this command. You have
479 to look at the file C<daemon/debug.c> in the libguestfs source
480 to find out what you can do.
486 This returns the kernel messages (C<dmesg> output) from
487 the guest kernel. This is sometimes useful for extended
488 debugging of problems.
490 Another way to get the same information is to enable
491 verbose messages with C<set-verbose> or by setting
492 the environment variable C<LIBGUESTFS_DEBUG=1> before
497 download remotefilename (filename|-)
499 Download file C<remotefilename> and save it as C<filename>
500 on the local machine.
502 C<filename> can also be a named pipe.
504 See also C<upload>, C<cat>.
506 Use C<-> instead of a filename to read/write from stdin/stdout.
510 drop-caches whattodrop
512 This instructs the guest kernel to drop its page cache,
513 and/or dentries and inode caches. The parameter C<whattodrop>
514 tells the kernel what precisely to drop, see
515 L<http://linux-mm.org/Drop_Caches>
517 Setting C<whattodrop> to 3 should drop everything.
519 This automatically calls L<sync(2)> before the operation,
520 so that the maximum guest memory is freed.
526 This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
527 filesystem checker on C<device>, noninteractively (C<-p>),
528 even if the filesystem appears to be clean (C<-f>).
530 This command is only needed because of C<resize2fs>
531 (q.v.). Normally you should use C<fsck>.
537 This compares the two files C<file1> and C<file2> and returns
538 true if their content is exactly equal, or false otherwise.
540 The external L<cmp(1)> program is used for the comparison.
546 This returns C<true> if and only if there is a file, directory
547 (or anything) with the given C<path> name.
549 See also C<is-file>, C<is-dir>, C<stat>.
555 This call uses the standard L<file(1)> command to determine
556 the type or contents of the file. This also works on devices,
557 for example to find out whether a partition contains a filesystem.
559 The exact command which runs is C<file -bsL path>. Note in
560 particular that the filename is not prepended to the output
567 This command lists out all files and directories, recursively,
568 starting at C<directory>. It is essentially equivalent to
569 running the shell command C<find directory -print> but some
570 post-processing happens on the output, described below.
572 This returns a list of strings I<without any prefix>. Thus
573 if the directory structure was:
579 then the returned list from C<find> C</tmp> would be
587 If C<directory> is not a directory, then this command returns
590 The returned list is sorted.
596 This runs the filesystem checker (fsck) on C<device> which
597 should have filesystem type C<fstype>.
599 The returned integer is the status. See L<fsck(8)> for the
600 list of status codes from C<fsck>.
608 Multiple status codes can be summed together.
612 A non-zero return code can mean "success", for example if
613 errors have been corrected on the filesystem.
617 Checking or repairing NTFS volumes is not supported
622 This command is entirely equivalent to running C<fsck -a -t fstype device>.
628 Return the additional kernel options which are added to the
629 guest kernel command line.
631 If C<NULL> then no options are added.
637 Get the autosync flag.
643 This returns the ext2/3/4 filesystem label of the filesystem on
650 This returns the ext2/3/4 filesystem UUID of the filesystem on
657 Return the current search path.
659 This is always non-NULL. If it wasn't set already, then this will
660 return the default path.
666 Return the current qemu binary.
668 This is always non-NULL. If it wasn't set already, then this will
669 return the default qemu binary name.
675 This returns the current state as an opaque integer. This is
676 only useful for printing debug and internal error messages.
678 For more information on states, see L<guestfs(3)>.
684 This returns the verbose messages flag.
690 This command searches for all the pathnames matching
691 C<pattern> according to the wildcard expansion rules
694 If no paths match, then this returns an empty list
695 (note: not an error).
697 It is just a wrapper around the C L<glob(3)> function
698 with flags C<GLOB_MARK|GLOB_BRACE>.
699 See that manual page for more details.
703 grub-install root device
705 This command installs GRUB (the Grand Unified Bootloader) on
706 C<device>, with the root directory being C<root>.
712 This command returns up to the first 10 lines of a file as
715 Because of the message protocol, there is a transfer limit
716 of somewhere between 2MB and 4MB. To transfer large files you should use
723 If the parameter C<nrlines> is a positive number, this returns the first
724 C<nrlines> lines of the file C<path>.
726 If the parameter C<nrlines> is a negative number, this returns lines
727 from the file C<path>, excluding the last C<nrlines> lines.
729 If the parameter C<nrlines> is zero, this returns an empty list.
731 Because of the message protocol, there is a transfer limit
732 of somewhere between 2MB and 4MB. To transfer large files you should use
739 This runs C<hexdump -C> on the given C<path>. The result is
740 the human-readable, canonical hex dump of the file.
742 Because of the message protocol, there is a transfer limit
743 of somewhere between 2MB and 4MB. To transfer large files you should use
750 This returns true iff this handle is busy processing a command
751 (in the C<BUSY> state).
753 For more information on states, see L<guestfs(3)>.
759 This returns true iff this handle is being configured
760 (in the C<CONFIG> state).
762 For more information on states, see L<guestfs(3)>.
768 This returns C<true> if and only if there is a directory
769 with the given C<path> name. Note that it returns false for
770 other objects like files.
778 This returns C<true> if and only if there is a file
779 with the given C<path> name. Note that it returns false for
780 other objects like directories.
788 This returns true iff this handle is launching the subprocess
789 (in the C<LAUNCHING> state).
791 For more information on states, see L<guestfs(3)>.
797 This returns true iff this handle is ready to accept commands
798 (in the C<READY> state).
800 For more information on states, see L<guestfs(3)>.
802 =head2 kill-subprocess
806 This kills the qemu subprocess. You should never need to call this.
812 Internally libguestfs is implemented by running a virtual machine
815 You should call this after configuring the handle
816 (eg. adding drives) but before performing any actions.
822 List all the block devices.
824 The full block device names are returned, eg. C</dev/sda>
826 =head2 list-partitions
830 List all the partitions detected on all block devices.
832 The full partition device names are returned, eg. C</dev/sda1>
834 This does not return logical volumes. For that you will need to
841 List the files in C<directory> (relative to the root directory,
842 there is no cwd) in the format of 'ls -la'.
844 This command is mostly useful for interactive sessions. It
845 is I<not> intended that you try to parse the output string.
851 List the files in C<directory> (relative to the root directory,
852 there is no cwd). The '.' and '..' entries are not returned, but
853 hidden files are shown.
855 This command is mostly useful for interactive sessions. Programs
856 should probably use C<readdir> instead.
862 Returns file information for the given C<path>.
864 This is the same as C<stat> except that if C<path>
865 is a symbolic link, then the link is stat-ed, not the file it
868 This is the same as the C<lstat(2)> system call.
872 lvcreate logvol volgroup mbytes
874 This creates an LVM volume group called C<logvol>
875 on the volume group C<volgroup>, with C<size> megabytes.
877 =head2 lvm-remove-all
881 This command removes all LVM logical volumes, volume groups
882 and physical volumes.
884 B<This command is dangerous. Without careful use you
885 can easily destroy all your data>.
891 Remove an LVM logical volume C<device>, where C<device> is
892 the path to the LV, such as C</dev/VG/LV>.
894 You can also remove all LVs in a volume group by specifying
895 the VG name, C</dev/VG>.
899 lvresize device mbytes
901 This resizes (expands or shrinks) an existing LVM logical
902 volume to C<mbytes>. When reducing, data in the reduced part
909 List all the logical volumes detected. This is the equivalent
910 of the L<lvs(8)> command.
912 This returns a list of the logical volume device names
913 (eg. C</dev/VolGroup00/LogVol00>).
915 See also C<lvs-full>.
921 List all the logical volumes detected. This is the equivalent
922 of the L<lvs(8)> command. The "full" version includes all fields.
928 Create a directory named C<path>.
934 Create a directory named C<path>, creating any parent directories
935 as necessary. This is like the C<mkdir -p> shell command.
941 This command creates a temporary directory. The
942 C<template> parameter should be a full pathname for the
943 temporary directory name with the final six characters being
946 For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX",
947 the second one being suitable for Windows filesystems.
949 The name of the temporary directory that was created
952 The temporary directory is created with mode 0700
953 and is owned by root.
955 The caller is responsible for deleting the temporary
956 directory and its contents after use.
958 See also: L<mkdtemp(3)>
964 This creates a filesystem on C<device> (usually a partition
965 or LVM logical volume). The filesystem type is C<fstype>, for
970 mount device mountpoint
972 Mount a guest disk at a position in the filesystem. Block devices
973 are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
974 the guest. If those block devices contain partitions, they will have
975 the usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style
978 The rules are the same as for L<mount(2)>: A filesystem must
979 first be mounted on C</> before others can be mounted. Other
980 filesystems can only be mounted on directories which already
983 The mounted filesystem is writable, if we have sufficient permissions
984 on the underlying device.
986 The filesystem options C<sync> and C<noatime> are set with this
987 call, in order to improve reliability.
991 mount-options options device mountpoint
993 This is the same as the C<mount> command, but it
994 allows you to set the mount options as for the
995 L<mount(8)> I<-o> flag.
999 mount-ro device mountpoint
1001 This is the same as the C<mount> command, but it
1002 mounts the filesystem with the read-only (I<-o ro>) flag.
1006 mount-vfs options vfstype device mountpoint
1008 This is the same as the C<mount> command, but it
1009 allows you to set both the mount options and the vfstype
1010 as for the L<mount(8)> I<-o> and I<-t> flags.
1016 This returns the list of currently mounted filesystems. It returns
1017 the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
1019 Some internal mounts are not shown.
1025 This moves a file from C<src> to C<dest> where C<dest> is
1026 either a destination filename or destination directory.
1028 =head2 ntfs-3g-probe
1030 ntfs-3g-probe true|false device
1032 This command runs the L<ntfs-3g.probe(8)> command which probes
1033 an NTFS C<device> for mountability. (Not all NTFS volumes can
1034 be mounted read-write, and some cannot be mounted at all).
1036 C<rw> is a boolean flag. Set it to true if you want to test
1037 if the volume can be mounted read-write. Set it to false if
1038 you want to test if the volume can be mounted read-only.
1040 The return value is an integer which C<0> if the operation
1041 would succeed, or some non-zero value documented in the
1042 L<ntfs-3g.probe(8)> manual page.
1048 This is a test probe into the guestfs daemon running inside
1049 the qemu subprocess. Calling this function checks that the
1050 daemon responds to the ping message, without affecting the daemon
1051 or attached block device(s) in any other way.
1057 This creates an LVM physical volume on the named C<device>,
1058 where C<device> should usually be a partition name such
1065 This wipes a physical volume C<device> so that LVM will no longer
1068 The implementation uses the C<pvremove> command which refuses to
1069 wipe physical volumes that contain any volume groups, so you have
1070 to remove those first.
1076 This resizes (expands or shrinks) an existing LVM physical
1077 volume to match the new size of the underlying device.
1083 List all the physical volumes detected. This is the equivalent
1084 of the L<pvs(8)> command.
1086 This returns a list of just the device names that contain
1087 PVs (eg. C</dev/sda2>).
1089 See also C<pvs-full>.
1095 List all the physical volumes detected. This is the equivalent
1096 of the L<pvs(8)> command. The "full" version includes all fields.
1102 Return the contents of the file named C<path>.
1104 The file contents are returned as a list of lines. Trailing
1105 C<LF> and C<CRLF> character sequences are I<not> returned.
1107 Note that this function cannot correctly handle binary files
1108 (specifically, files containing C<\0> character which is treated
1109 as end of line). For those you need to use the C<read-file>
1110 function which has a more complex interface.
1116 This resizes an ext2 or ext3 filesystem to match the size of
1117 the underlying device.
1119 I<Note:> It is sometimes required that you run C<e2fsck-f>
1120 on the C<device> before calling this command. For unknown reasons
1121 C<resize2fs> sometimes gives an error about this and sometimes not.
1122 In any case, it is always safe to call C<e2fsck-f> before
1123 calling this function.
1129 Remove the single file C<path>.
1135 Remove the file or directory C<path>, recursively removing the
1136 contents if its a directory. This is like the C<rm -rf> shell
1143 Remove the single directory C<path>.
1149 This command writes patterns over C<device> to make data retrieval
1152 It is an interface to the L<scrub(1)> program. See that
1153 manual page for more details.
1155 B<This command is dangerous. Without careful use you
1156 can easily destroy all your data>.
1162 This command writes patterns over a file to make data retrieval
1165 The file is I<removed> after scrubbing.
1167 It is an interface to the L<scrub(1)> program. See that
1168 manual page for more details.
1170 =head2 scrub-freespace
1174 This command creates the directory C<dir> and then fills it
1175 with files until the filesystem is full, and scrubs the files
1176 as for C<scrub-file>, and deletes them.
1177 The intention is to scrub any free space on the partition
1180 It is an interface to the L<scrub(1)> program. See that
1181 manual page for more details.
1183 =head2 set-append | append
1187 This function is used to add additional options to the
1188 guest kernel command line.
1190 The default is C<NULL> unless overridden by setting
1191 C<LIBGUESTFS_APPEND> environment variable.
1193 Setting C<append> to C<NULL> means I<no> additional options
1194 are passed (libguestfs always adds a few of its own).
1196 =head2 set-autosync | autosync
1198 set-autosync true|false
1200 If C<autosync> is true, this enables autosync. Libguestfs will make a
1201 best effort attempt to run C<umount-all> followed by
1202 C<sync> when the handle is closed
1203 (also if the program exits without closing handles).
1205 This is disabled by default (except in guestfish where it is
1206 enabled by default).
1210 set-e2label device label
1212 This sets the ext2/3/4 filesystem label of the filesystem on
1213 C<device> to C<label>. Filesystem labels are limited to
1216 You can use either C<tune2fs-l> or C<get-e2label>
1217 to return the existing label on a filesystem.
1221 set-e2uuid device uuid
1223 This sets the ext2/3/4 filesystem UUID of the filesystem on
1224 C<device> to C<uuid>. The format of the UUID and alternatives
1225 such as C<clear>, C<random> and C<time> are described in the
1226 L<tune2fs(8)> manpage.
1228 You can use either C<tune2fs-l> or C<get-e2uuid>
1229 to return the existing UUID of a filesystem.
1231 =head2 set-path | path
1235 Set the path that libguestfs searches for kernel and initrd.img.
1237 The default is C<$libdir/guestfs> unless overridden by setting
1238 C<LIBGUESTFS_PATH> environment variable.
1240 Setting C<path> to C<NULL> restores the default path.
1242 =head2 set-qemu | qemu
1246 Set the qemu binary that we will use.
1248 The default is chosen when the library was compiled by the
1251 You can also override this by setting the C<LIBGUESTFS_QEMU>
1252 environment variable.
1254 Setting C<qemu> to C<NULL> restores the default qemu binary.
1256 =head2 set-verbose | verbose
1258 set-verbose true|false
1260 If C<verbose> is true, this turns on verbose messages (to C<stderr>).
1262 Verbose messages are disabled unless the environment variable
1263 C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
1267 sfdisk device cyls heads sectors 'lines ...'
1269 This is a direct interface to the L<sfdisk(8)> program for creating
1270 partitions on block devices.
1272 C<device> should be a block device, for example C</dev/sda>.
1274 C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
1275 and sectors on the device, which are passed directly to sfdisk as
1276 the I<-C>, I<-H> and I<-S> parameters. If you pass C<0> for any
1277 of these, then the corresponding parameter is omitted. Usually for
1278 'large' disks, you can just pass C<0> for these, but for small
1279 (floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
1280 out the right geometry and you will need to tell it.
1282 C<lines> is a list of lines that we feed to C<sfdisk>. For more
1283 information refer to the L<sfdisk(8)> manpage.
1285 To create a single partition occupying the whole disk, you would
1286 pass C<lines> as a single element list, when the single element being
1287 the string C<,> (comma).
1289 See also: C<sfdisk-l>, C<sfdisk-N>
1291 B<This command is dangerous. Without careful use you
1292 can easily destroy all your data>.
1296 sfdisk-N device partnum cyls heads sectors line
1298 This runs L<sfdisk(8)> option to modify just the single
1299 partition C<n> (note: C<n> counts from 1).
1301 For other parameters, see C<sfdisk>. You should usually
1302 pass C<0> for the cyls/heads/sectors parameters.
1304 B<This command is dangerous. Without careful use you
1305 can easily destroy all your data>.
1307 =head2 sfdisk-disk-geometry
1309 sfdisk-disk-geometry device
1311 This displays the disk geometry of C<device> read from the
1312 partition table. Especially in the case where the underlying
1313 block device has been resized, this can be different from the
1314 kernel's idea of the geometry (see C<sfdisk-kernel-geometry>).
1316 The result is in human-readable format, and not designed to
1319 =head2 sfdisk-kernel-geometry
1321 sfdisk-kernel-geometry device
1323 This displays the kernel's idea of the geometry of C<device>.
1325 The result is in human-readable format, and not designed to
1332 This displays the partition table on C<device>, in the
1333 human-readable output of the L<sfdisk(8)> command. It is
1334 not intended to be parsed.
1340 This call runs a command from the guest filesystem via the
1343 This is like C<command>, but passes the command to:
1345 /bin/sh -c "command"
1347 Depending on the guest's shell, this usually results in
1348 wildcards being expanded, shell expressions being interpolated
1351 All the provisos about C<command> apply to this call.
1357 This is the same as C<sh>, but splits the result
1358 into a list of lines.
1360 See also: C<command-lines>
1366 Sleep for C<secs> seconds.
1372 Returns file information for the given C<path>.
1374 This is the same as the C<stat(2)> system call.
1380 Returns file system statistics for any mounted file system.
1381 C<path> should be a file or directory in the mounted file system
1382 (typically it is the mount point itself, but it doesn't need to be).
1384 This is the same as the C<statvfs(2)> system call.
1390 This runs the L<strings(1)> command on a file and returns
1391 the list of printable strings found.
1393 Because of the message protocol, there is a transfer limit
1394 of somewhere between 2MB and 4MB. To transfer large files you should use
1399 strings-e encoding path
1401 This is like the C<strings> command, but allows you to
1402 specify the encoding.
1404 See the L<strings(1)> manpage for the full list of encodings.
1406 Commonly useful encodings are C<l> (lower case L) which will
1407 show strings inside Windows/x86 files.
1409 The returned strings are transcoded to UTF-8.
1411 Because of the message protocol, there is a transfer limit
1412 of somewhere between 2MB and 4MB. To transfer large files you should use
1419 This syncs the disk, so that any writes are flushed through to the
1420 underlying disk image.
1422 You should always call this if you have modified a disk image, before
1429 This command returns up to the last 10 lines of a file as
1432 Because of the message protocol, there is a transfer limit
1433 of somewhere between 2MB and 4MB. To transfer large files you should use
1440 If the parameter C<nrlines> is a positive number, this returns the last
1441 C<nrlines> lines of the file C<path>.
1443 If the parameter C<nrlines> is a negative number, this returns lines
1444 from the file C<path>, starting with the C<-nrlines>th line.
1446 If the parameter C<nrlines> is zero, this returns an empty list.
1448 Because of the message protocol, there is a transfer limit
1449 of somewhere between 2MB and 4MB. To transfer large files you should use
1454 tar-in (tarfile|-) directory
1456 This command uploads and unpacks local file C<tarfile> (an
1457 I<uncompressed> tar file) into C<directory>.
1459 To upload a compressed tarball, use C<tgz-in>.
1461 Use C<-> instead of a filename to read/write from stdin/stdout.
1465 tar-out directory (tarfile|-)
1467 This command packs the contents of C<directory> and downloads
1468 it to local file C<tarfile>.
1470 To download a compressed tarball, use C<tgz-out>.
1472 Use C<-> instead of a filename to read/write from stdin/stdout.
1476 tgz-in (tarball|-) directory
1478 This command uploads and unpacks local file C<tarball> (a
1479 I<gzip compressed> tar file) into C<directory>.
1481 To upload an uncompressed tarball, use C<tar-in>.
1483 Use C<-> instead of a filename to read/write from stdin/stdout.
1487 tgz-out directory (tarball|-)
1489 This command packs the contents of C<directory> and downloads
1490 it to local file C<tarball>.
1492 To download an uncompressed tarball, use C<tar-out>.
1494 Use C<-> instead of a filename to read/write from stdin/stdout.
1500 Touch acts like the L<touch(1)> command. It can be used to
1501 update the timestamps on a file, or, if the file does not exist,
1502 to create a new zero-length file.
1508 This returns the contents of the ext2, ext3 or ext4 filesystem
1509 superblock on C<device>.
1511 It is the same as running C<tune2fs -l device>. See L<tune2fs(8)>
1512 manpage for more details. The list of fields returned isn't
1513 clearly defined, and depends on both the version of C<tune2fs>
1514 that libguestfs was built against, and the filesystem itself.
1516 =head2 umount | unmount
1520 This unmounts the given filesystem. The filesystem may be
1521 specified either by its mountpoint (path) or the device which
1522 contains the filesystem.
1524 =head2 umount-all | unmount-all
1528 This unmounts all mounted filesystems.
1530 Some internal mounts are not unmounted by this call.
1534 upload (filename|-) remotefilename
1536 Upload local file C<filename> to C<remotefilename> on the
1539 C<filename> can also be a named pipe.
1541 See also C<download>.
1543 Use C<-> instead of a filename to read/write from stdin/stdout.
1547 vg-activate true|false 'volgroups ...'
1549 This command activates or (if C<activate> is false) deactivates
1550 all logical volumes in the listed volume groups C<volgroups>.
1551 If activated, then they are made known to the
1552 kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
1553 then those devices disappear.
1555 This command is the same as running C<vgchange -a y|n volgroups...>
1557 Note that if C<volgroups> is an empty list then B<all> volume groups
1558 are activated or deactivated.
1560 =head2 vg-activate-all
1562 vg-activate-all true|false
1564 This command activates or (if C<activate> is false) deactivates
1565 all logical volumes in all volume groups.
1566 If activated, then they are made known to the
1567 kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
1568 then those devices disappear.
1570 This command is the same as running C<vgchange -a y|n>
1574 vgcreate volgroup 'physvols ...'
1576 This creates an LVM volume group called C<volgroup>
1577 from the non-empty list of physical volumes C<physvols>.
1583 Remove an LVM volume group C<vgname>, (for example C<VG>).
1585 This also forcibly removes all logical volumes in the volume
1592 List all the volumes groups detected. This is the equivalent
1593 of the L<vgs(8)> command.
1595 This returns a list of just the volume group names that were
1596 detected (eg. C<VolGroup00>).
1598 See also C<vgs-full>.
1604 List all the volumes groups detected. This is the equivalent
1605 of the L<vgs(8)> command. The "full" version includes all fields.
1611 This command counts the characters in a file, using the
1612 C<wc -c> external command.
1618 This command counts the lines in a file, using the
1619 C<wc -l> external command.
1625 This command counts the words in a file, using the
1626 C<wc -w> external command.
1630 write-file path content size
1632 This call creates a file called C<path>. The contents of the
1633 file is the string C<content> (which can contain any 8 bit data),
1634 with length C<size>.
1636 As a special case, if C<size> is C<0>
1637 then the length is calculated using C<strlen> (so in this case
1638 the content cannot contain embedded ASCII NULs).
1640 I<NB.> Owing to a bug, writing content containing ASCII NUL
1641 characters does I<not> work, even if the length is specified.
1642 We hope to resolve this bug in a future version. In the meantime
1645 Because of the message protocol, there is a transfer limit
1646 of somewhere between 2MB and 4MB. To transfer large files you should use
1653 This command writes zeroes over the first few blocks of C<device>.
1655 How many blocks are zeroed isn't specified (but it's I<not> enough
1656 to securely wipe the device). It should be sufficient to remove
1657 any partition tables, filesystem superblocks and so on.
1659 See also: C<scrub-device>.
1665 This runs the I<zerofree> program on C<device>. This program
1666 claims to zero unused inodes and disk blocks on an ext2/3
1667 filesystem, thus making it possible to compress the filesystem
1670 You should B<not> run this program if the filesystem is
1673 It is possible that using this program can damage the filesystem
1674 or data on the filesystem.