Generated code for 'initrd-list'.
[libguestfs.git] / guestfish-actions.pod
1 =head2 add-cdrom | cdrom
2
3  add-cdrom filename
4
5 This function adds a virtual CD-ROM disk image to the guest.
6
7 This is equivalent to the qemu parameter C<-cdrom filename>.
8
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.
13
14 =head2 add-drive | add
15
16  add-drive filename
17
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
21 so on.
22
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
27 image).
28
29 This is equivalent to the qemu parameter C<-drive file=filename,cache=off>.
30
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.
35
36 =head2 add-drive-ro | add-ro
37
38  add-drive-ro filename
39
40 This adds a drive in snapshot mode, making it effectively
41 read-only.
42
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.
48
49 This is equivalent to the qemu parameter
50 C<-drive file=filename,snapshot=on>.
51
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.
56
57 =head2 aug-close
58
59  aug-close
60
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
64 Augeas functions.
65
66 =head2 aug-defnode
67
68  aug-defnode name expr val
69
70 Defines a variable C<name> whose value is the result of
71 evaluating C<expr>.
72
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.
76
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.
80
81 =head2 aug-defvar
82
83  aug-defvar name expr
84
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
87 undefined.
88
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.
91
92 =head2 aug-get
93
94  aug-get path
95
96 Look up the value associated with C<path>.  If C<path>
97 matches exactly one node, the C<value> is returned.
98
99 =head2 aug-init
100
101  aug-init root flags
102
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.
106
107 You must call this before using any other C<aug-*>
108 commands.
109
110 C<root> is the filesystem root.  C<root> must not be NULL,
111 use C</> instead.
112
113 The flags are the same as the flags defined in
114 E<lt>augeas.hE<gt>, the logical I<or> of the following
115 integers:
116
117 =over 4
118
119 =item C<AUG_SAVE_BACKUP> = 1
120
121 Keep the original file with a C<.augsave> extension.
122
123 =item C<AUG_SAVE_NEWFILE> = 2
124
125 Save changes into a file with extension C<.augnew>, and
126 do not overwrite original.  Overrides C<AUG_SAVE_BACKUP>.
127
128 =item C<AUG_TYPE_CHECK> = 4
129
130 Typecheck lenses (can be expensive).
131
132 =item C<AUG_NO_STDINC> = 8
133
134 Do not use standard load path for modules.
135
136 =item C<AUG_SAVE_NOOP> = 16
137
138 Make save a no-op, just record what would have been changed.
139
140 =item C<AUG_NO_LOAD> = 32
141
142 Do not load the tree in C<aug-init>.
143
144 =back
145
146 To close the handle, you can call C<aug-close>.
147
148 To find out more about Augeas, see L<http://augeas.net/>.
149
150 =head2 aug-insert
151
152  aug-insert path label true|false
153
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
156 flag C<before>).
157
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]>.
161
162 =head2 aug-load
163
164  aug-load
165
166 Load files into the tree.
167
168 See C<aug_load> in the Augeas documentation for the full gory
169 details.
170
171 =head2 aug-ls
172
173  aug-ls path
174
175 This is just a shortcut for listing C<aug-match>
176 C<path/*> and sorting the resulting nodes into alphabetical order.
177
178 =head2 aug-match
179
180  aug-match path
181
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.
185
186 =head2 aug-mv
187
188  aug-mv src dest
189
190 Move the node C<src> to C<dest>.  C<src> must match exactly
191 one node.  C<dest> is overwritten if it exists.
192
193 =head2 aug-rm
194
195  aug-rm path
196
197 Remove C<path> and all of its children.
198
199 On success this returns the number of entries which were removed.
200
201 =head2 aug-save
202
203  aug-save
204
205 This writes all pending changes to disk.
206
207 The flags which were passed to C<aug-init> affect exactly
208 how files are saved.
209
210 =head2 aug-set
211
212  aug-set path val
213
214 Set the value associated with C<path> to C<value>.
215
216 =head2 blockdev-flushbufs
217
218  blockdev-flushbufs device
219
220 This tells the kernel to flush internal buffers associated
221 with C<device>.
222
223 This uses the L<blockdev(8)> command.
224
225 =head2 blockdev-getbsz
226
227  blockdev-getbsz device
228
229 This returns the block size of a device.
230
231 (Note this is different from both I<size in blocks> and
232 I<filesystem block size>).
233
234 This uses the L<blockdev(8)> command.
235
236 =head2 blockdev-getro
237
238  blockdev-getro device
239
240 Returns a boolean indicating if the block device is read-only
241 (true if read-only, false if not).
242
243 This uses the L<blockdev(8)> command.
244
245 =head2 blockdev-getsize64
246
247  blockdev-getsize64 device
248
249 This returns the size of the device in bytes.
250
251 See also C<blockdev-getsz>.
252
253 This uses the L<blockdev(8)> command.
254
255 =head2 blockdev-getss
256
257  blockdev-getss device
258
259 This returns the size of sectors on a block device.
260 Usually 512, but can be larger for modern devices.
261
262 (Note, this is not the size in sectors, use C<blockdev-getsz>
263 for that).
264
265 This uses the L<blockdev(8)> command.
266
267 =head2 blockdev-getsz
268
269  blockdev-getsz device
270
271 This returns the size of the device in units of 512-byte sectors
272 (even if the sectorsize isn't 512 bytes ... weird).
273
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>.
277
278 This uses the L<blockdev(8)> command.
279
280 =head2 blockdev-rereadpt
281
282  blockdev-rereadpt device
283
284 Reread the partition table on C<device>.
285
286 This uses the L<blockdev(8)> command.
287
288 =head2 blockdev-setbsz
289
290  blockdev-setbsz device blocksize
291
292 This sets the block size of a device.
293
294 (Note this is different from both I<size in blocks> and
295 I<filesystem block size>).
296
297 This uses the L<blockdev(8)> command.
298
299 =head2 blockdev-setro
300
301  blockdev-setro device
302
303 Sets the block device named C<device> to read-only.
304
305 This uses the L<blockdev(8)> command.
306
307 =head2 blockdev-setrw
308
309  blockdev-setrw device
310
311 Sets the block device named C<device> to read-write.
312
313 This uses the L<blockdev(8)> command.
314
315 =head2 cat
316
317  cat path
318
319 Return the contents of the file named C<path>.
320
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.
325
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
328 FTP.
329
330 =head2 checksum
331
332  checksum csumtype path
333
334 This call computes the MD5, SHAx or CRC checksum of the
335 file named C<path>.
336
337 The type of checksum to compute is given by the C<csumtype>
338 parameter which must have one of the following values:
339
340 =over 4
341
342 =item C<crc>
343
344 Compute the cyclic redundancy check (CRC) specified by POSIX
345 for the C<cksum> command.
346
347 =item C<md5>
348
349 Compute the MD5 hash (using the C<md5sum> program).
350
351 =item C<sha1>
352
353 Compute the SHA1 hash (using the C<sha1sum> program).
354
355 =item C<sha224>
356
357 Compute the SHA224 hash (using the C<sha224sum> program).
358
359 =item C<sha256>
360
361 Compute the SHA256 hash (using the C<sha256sum> program).
362
363 =item C<sha384>
364
365 Compute the SHA384 hash (using the C<sha384sum> program).
366
367 =item C<sha512>
368
369 Compute the SHA512 hash (using the C<sha512sum> program).
370
371 =back
372
373 The checksum is returned as a printable string.
374
375 =head2 chmod
376
377  chmod mode path
378
379 Change the mode (permissions) of C<path> to C<mode>.  Only
380 numeric modes are supported.
381
382 =head2 chown
383
384  chown owner group path
385
386 Change the file owner to C<owner> and group to C<group>.
387
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).
391
392 =head2 command
393
394  command 'arguments ...'
395
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).
400
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>).
407
408 The return value is anything printed to I<stdout> by
409 the command.
410
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.
414
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
418 first parameter.
419
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
424 locations.
425
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
428 FTP.
429
430 =head2 command-lines
431
432  command-lines 'arguments ...'
433
434 This is the same as C<command>, but splits the
435 result into a list of lines.
436
437 See also: C<sh-lines>
438
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
441 FTP.
442
443 =head2 config
444
445  config qemuparam qemuvalue
446
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.
451
452 The first character of C<param> string must be a C<-> (dash).
453
454 C<value> can be NULL.
455
456 =head2 cp
457
458  cp src dest
459
460 This copies a file from C<src> to C<dest> where C<dest> is
461 either a destination filename or destination directory.
462
463 =head2 cp-a
464
465  cp-a src dest
466
467 This copies a file or directory from C<src> to C<dest>
468 recursively using the C<cp -a> command.
469
470 =head2 debug
471
472  debug subcmd 'extraargs ...'
473
474 The C<debug> command exposes some internals of
475 C<guestfsd> (the guestfs daemon) that runs inside the
476 qemu subprocess.
477
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.
481
482 =head2 df
483
484  df
485
486 This command runs the C<df> command to report disk space used.
487
488 This command is mostly useful for interactive sessions.  It
489 is I<not> intended that you try to parse the output string.
490 Use C<statvfs> from programs.
491
492 =head2 df-h
493
494  df-h
495
496 This command runs the C<df -h> command to report disk space used
497 in human-readable format.
498
499 This command is mostly useful for interactive sessions.  It
500 is I<not> intended that you try to parse the output string.
501 Use C<statvfs> from programs.
502
503 =head2 dmesg
504
505  dmesg
506
507 This returns the kernel messages (C<dmesg> output) from
508 the guest kernel.  This is sometimes useful for extended
509 debugging of problems.
510
511 Another way to get the same information is to enable
512 verbose messages with C<set-verbose> or by setting
513 the environment variable C<LIBGUESTFS_DEBUG=1> before
514 running the program.
515
516 =head2 download
517
518  download remotefilename (filename|-)
519
520 Download file C<remotefilename> and save it as C<filename>
521 on the local machine.
522
523 C<filename> can also be a named pipe.
524
525 See also C<upload>, C<cat>.
526
527 Use C<-> instead of a filename to read/write from stdin/stdout.
528
529 =head2 drop-caches
530
531  drop-caches whattodrop
532
533 This instructs the guest kernel to drop its page cache,
534 and/or dentries and inode caches.  The parameter C<whattodrop>
535 tells the kernel what precisely to drop, see
536 L<http://linux-mm.org/Drop_Caches>
537
538 Setting C<whattodrop> to 3 should drop everything.
539
540 This automatically calls L<sync(2)> before the operation,
541 so that the maximum guest memory is freed.
542
543 =head2 du
544
545  du path
546
547 This command runs the C<du -s> command to estimate file space
548 usage for C<path>.
549
550 C<path> can be a file or a directory.  If C<path> is a directory
551 then the estimate includes the contents of the directory and all
552 subdirectories (recursively).
553
554 The result is the estimated size in I<kilobytes>
555 (ie. units of 1024 bytes).
556
557 =head2 e2fsck-f
558
559  e2fsck-f device
560
561 This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
562 filesystem checker on C<device>, noninteractively (C<-p>),
563 even if the filesystem appears to be clean (C<-f>).
564
565 This command is only needed because of C<resize2fs>
566 (q.v.).  Normally you should use C<fsck>.
567
568 =head2 equal
569
570  equal file1 file2
571
572 This compares the two files C<file1> and C<file2> and returns
573 true if their content is exactly equal, or false otherwise.
574
575 The external L<cmp(1)> program is used for the comparison.
576
577 =head2 exists
578
579  exists path
580
581 This returns C<true> if and only if there is a file, directory
582 (or anything) with the given C<path> name.
583
584 See also C<is-file>, C<is-dir>, C<stat>.
585
586 =head2 file
587
588  file path
589
590 This call uses the standard L<file(1)> command to determine
591 the type or contents of the file.  This also works on devices,
592 for example to find out whether a partition contains a filesystem.
593
594 The exact command which runs is C<file -bsL path>.  Note in
595 particular that the filename is not prepended to the output
596 (the C<-b> option).
597
598 =head2 find
599
600  find directory
601
602 This command lists out all files and directories, recursively,
603 starting at C<directory>.  It is essentially equivalent to
604 running the shell command C<find directory -print> but some
605 post-processing happens on the output, described below.
606
607 This returns a list of strings I<without any prefix>.  Thus
608 if the directory structure was:
609
610  /tmp/a
611  /tmp/b
612  /tmp/c/d
613
614 then the returned list from C<find> C</tmp> would be
615 4 elements:
616
617  a
618  b
619  c
620  c/d
621
622 If C<directory> is not a directory, then this command returns
623 an error.
624
625 The returned list is sorted.
626
627 =head2 fsck
628
629  fsck fstype device
630
631 This runs the filesystem checker (fsck) on C<device> which
632 should have filesystem type C<fstype>.
633
634 The returned integer is the status.  See L<fsck(8)> for the
635 list of status codes from C<fsck>.
636
637 Notes:
638
639 =over 4
640
641 =item *
642
643 Multiple status codes can be summed together.
644
645 =item *
646
647 A non-zero return code can mean "success", for example if
648 errors have been corrected on the filesystem.
649
650 =item *
651
652 Checking or repairing NTFS volumes is not supported
653 (by linux-ntfs).
654
655 =back
656
657 This command is entirely equivalent to running C<fsck -a -t fstype device>.
658
659 =head2 get-append
660
661  get-append
662
663 Return the additional kernel options which are added to the
664 guest kernel command line.
665
666 If C<NULL> then no options are added.
667
668 =head2 get-autosync
669
670  get-autosync
671
672 Get the autosync flag.
673
674 =head2 get-e2label
675
676  get-e2label device
677
678 This returns the ext2/3/4 filesystem label of the filesystem on
679 C<device>.
680
681 =head2 get-e2uuid
682
683  get-e2uuid device
684
685 This returns the ext2/3/4 filesystem UUID of the filesystem on
686 C<device>.
687
688 =head2 get-path
689
690  get-path
691
692 Return the current search path.
693
694 This is always non-NULL.  If it wasn't set already, then this will
695 return the default path.
696
697 =head2 get-qemu
698
699  get-qemu
700
701 Return the current qemu binary.
702
703 This is always non-NULL.  If it wasn't set already, then this will
704 return the default qemu binary name.
705
706 =head2 get-state
707
708  get-state
709
710 This returns the current state as an opaque integer.  This is
711 only useful for printing debug and internal error messages.
712
713 For more information on states, see L<guestfs(3)>.
714
715 =head2 get-verbose
716
717  get-verbose
718
719 This returns the verbose messages flag.
720
721 =head2 glob-expand
722
723  glob-expand pattern
724
725 This command searches for all the pathnames matching
726 C<pattern> according to the wildcard expansion rules
727 used by the shell.
728
729 If no paths match, then this returns an empty list
730 (note: not an error).
731
732 It is just a wrapper around the C L<glob(3)> function
733 with flags C<GLOB_MARK|GLOB_BRACE>.
734 See that manual page for more details.
735
736 =head2 grub-install
737
738  grub-install root device
739
740 This command installs GRUB (the Grand Unified Bootloader) on
741 C<device>, with the root directory being C<root>.
742
743 =head2 head
744
745  head path
746
747 This command returns up to the first 10 lines of a file as
748 a list of strings.
749
750 Because of the message protocol, there is a transfer limit 
751 of somewhere between 2MB and 4MB.  To transfer large files you should use
752 FTP.
753
754 =head2 head-n
755
756  head-n nrlines path
757
758 If the parameter C<nrlines> is a positive number, this returns the first
759 C<nrlines> lines of the file C<path>.
760
761 If the parameter C<nrlines> is a negative number, this returns lines
762 from the file C<path>, excluding the last C<nrlines> lines.
763
764 If the parameter C<nrlines> is zero, this returns an empty list.
765
766 Because of the message protocol, there is a transfer limit 
767 of somewhere between 2MB and 4MB.  To transfer large files you should use
768 FTP.
769
770 =head2 hexdump
771
772  hexdump path
773
774 This runs C<hexdump -C> on the given C<path>.  The result is
775 the human-readable, canonical hex dump of the file.
776
777 Because of the message protocol, there is a transfer limit 
778 of somewhere between 2MB and 4MB.  To transfer large files you should use
779 FTP.
780
781 =head2 initrd-list
782
783  initrd-list path
784
785 This command lists out files contained in an initrd.
786
787 The files are listed without any initial C</> character.  The
788 files are listed in the order they appear (not necessarily
789 alphabetical).  Directory names are listed as separate items.
790
791 Old Linux kernels (2.4 and earlier) used a compressed ext2
792 filesystem as initrd.  We I<only> support the newer initramfs
793 format (compressed cpio files).
794
795 =head2 is-busy
796
797  is-busy
798
799 This returns true iff this handle is busy processing a command
800 (in the C<BUSY> state).
801
802 For more information on states, see L<guestfs(3)>.
803
804 =head2 is-config
805
806  is-config
807
808 This returns true iff this handle is being configured
809 (in the C<CONFIG> state).
810
811 For more information on states, see L<guestfs(3)>.
812
813 =head2 is-dir
814
815  is-dir path
816
817 This returns C<true> if and only if there is a directory
818 with the given C<path> name.  Note that it returns false for
819 other objects like files.
820
821 See also C<stat>.
822
823 =head2 is-file
824
825  is-file path
826
827 This returns C<true> if and only if there is a file
828 with the given C<path> name.  Note that it returns false for
829 other objects like directories.
830
831 See also C<stat>.
832
833 =head2 is-launching
834
835  is-launching
836
837 This returns true iff this handle is launching the subprocess
838 (in the C<LAUNCHING> state).
839
840 For more information on states, see L<guestfs(3)>.
841
842 =head2 is-ready
843
844  is-ready
845
846 This returns true iff this handle is ready to accept commands
847 (in the C<READY> state).
848
849 For more information on states, see L<guestfs(3)>.
850
851 =head2 kill-subprocess
852
853  kill-subprocess
854
855 This kills the qemu subprocess.  You should never need to call this.
856
857 =head2 launch | run
858
859  launch
860
861 Internally libguestfs is implemented by running a virtual machine
862 using L<qemu(1)>.
863
864 You should call this after configuring the handle
865 (eg. adding drives) but before performing any actions.
866
867 =head2 list-devices
868
869  list-devices
870
871 List all the block devices.
872
873 The full block device names are returned, eg. C</dev/sda>
874
875 =head2 list-partitions
876
877  list-partitions
878
879 List all the partitions detected on all block devices.
880
881 The full partition device names are returned, eg. C</dev/sda1>
882
883 This does not return logical volumes.  For that you will need to
884 call C<lvs>.
885
886 =head2 ll
887
888  ll directory
889
890 List the files in C<directory> (relative to the root directory,
891 there is no cwd) in the format of 'ls -la'.
892
893 This command is mostly useful for interactive sessions.  It
894 is I<not> intended that you try to parse the output string.
895
896 =head2 ls
897
898  ls directory
899
900 List the files in C<directory> (relative to the root directory,
901 there is no cwd).  The '.' and '..' entries are not returned, but
902 hidden files are shown.
903
904 This command is mostly useful for interactive sessions.  Programs
905 should probably use C<readdir> instead.
906
907 =head2 lstat
908
909  lstat path
910
911 Returns file information for the given C<path>.
912
913 This is the same as C<stat> except that if C<path>
914 is a symbolic link, then the link is stat-ed, not the file it
915 refers to.
916
917 This is the same as the C<lstat(2)> system call.
918
919 =head2 lvcreate
920
921  lvcreate logvol volgroup mbytes
922
923 This creates an LVM volume group called C<logvol>
924 on the volume group C<volgroup>, with C<size> megabytes.
925
926 =head2 lvm-remove-all
927
928  lvm-remove-all
929
930 This command removes all LVM logical volumes, volume groups
931 and physical volumes.
932
933 B<This command is dangerous.  Without careful use you
934 can easily destroy all your data>.
935
936 =head2 lvremove
937
938  lvremove device
939
940 Remove an LVM logical volume C<device>, where C<device> is
941 the path to the LV, such as C</dev/VG/LV>.
942
943 You can also remove all LVs in a volume group by specifying
944 the VG name, C</dev/VG>.
945
946 =head2 lvresize
947
948  lvresize device mbytes
949
950 This resizes (expands or shrinks) an existing LVM logical
951 volume to C<mbytes>.  When reducing, data in the reduced part
952 is lost.
953
954 =head2 lvs
955
956  lvs
957
958 List all the logical volumes detected.  This is the equivalent
959 of the L<lvs(8)> command.
960
961 This returns a list of the logical volume device names
962 (eg. C</dev/VolGroup00/LogVol00>).
963
964 See also C<lvs-full>.
965
966 =head2 lvs-full
967
968  lvs-full
969
970 List all the logical volumes detected.  This is the equivalent
971 of the L<lvs(8)> command.  The "full" version includes all fields.
972
973 =head2 mkdir
974
975  mkdir path
976
977 Create a directory named C<path>.
978
979 =head2 mkdir-p
980
981  mkdir-p path
982
983 Create a directory named C<path>, creating any parent directories
984 as necessary.  This is like the C<mkdir -p> shell command.
985
986 =head2 mkdtemp
987
988  mkdtemp template
989
990 This command creates a temporary directory.  The
991 C<template> parameter should be a full pathname for the
992 temporary directory name with the final six characters being
993 "XXXXXX".
994
995 For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX",
996 the second one being suitable for Windows filesystems.
997
998 The name of the temporary directory that was created
999 is returned.
1000
1001 The temporary directory is created with mode 0700
1002 and is owned by root.
1003
1004 The caller is responsible for deleting the temporary
1005 directory and its contents after use.
1006
1007 See also: L<mkdtemp(3)>
1008
1009 =head2 mkfs
1010
1011  mkfs fstype device
1012
1013 This creates a filesystem on C<device> (usually a partition
1014 or LVM logical volume).  The filesystem type is C<fstype>, for
1015 example C<ext3>.
1016
1017 =head2 mount
1018
1019  mount device mountpoint
1020
1021 Mount a guest disk at a position in the filesystem.  Block devices
1022 are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
1023 the guest.  If those block devices contain partitions, they will have
1024 the usual names (eg. C</dev/sda1>).  Also LVM C</dev/VG/LV>-style
1025 names can be used.
1026
1027 The rules are the same as for L<mount(2)>:  A filesystem must
1028 first be mounted on C</> before others can be mounted.  Other
1029 filesystems can only be mounted on directories which already
1030 exist.
1031
1032 The mounted filesystem is writable, if we have sufficient permissions
1033 on the underlying device.
1034
1035 The filesystem options C<sync> and C<noatime> are set with this
1036 call, in order to improve reliability.
1037
1038 =head2 mount-options
1039
1040  mount-options options device mountpoint
1041
1042 This is the same as the C<mount> command, but it
1043 allows you to set the mount options as for the
1044 L<mount(8)> I<-o> flag.
1045
1046 =head2 mount-ro
1047
1048  mount-ro device mountpoint
1049
1050 This is the same as the C<mount> command, but it
1051 mounts the filesystem with the read-only (I<-o ro>) flag.
1052
1053 =head2 mount-vfs
1054
1055  mount-vfs options vfstype device mountpoint
1056
1057 This is the same as the C<mount> command, but it
1058 allows you to set both the mount options and the vfstype
1059 as for the L<mount(8)> I<-o> and I<-t> flags.
1060
1061 =head2 mounts
1062
1063  mounts
1064
1065 This returns the list of currently mounted filesystems.  It returns
1066 the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
1067
1068 Some internal mounts are not shown.
1069
1070 =head2 mv
1071
1072  mv src dest
1073
1074 This moves a file from C<src> to C<dest> where C<dest> is
1075 either a destination filename or destination directory.
1076
1077 =head2 ntfs-3g-probe
1078
1079  ntfs-3g-probe true|false device
1080
1081 This command runs the L<ntfs-3g.probe(8)> command which probes
1082 an NTFS C<device> for mountability.  (Not all NTFS volumes can
1083 be mounted read-write, and some cannot be mounted at all).
1084
1085 C<rw> is a boolean flag.  Set it to true if you want to test
1086 if the volume can be mounted read-write.  Set it to false if
1087 you want to test if the volume can be mounted read-only.
1088
1089 The return value is an integer which C<0> if the operation
1090 would succeed, or some non-zero value documented in the
1091 L<ntfs-3g.probe(8)> manual page.
1092
1093 =head2 ping-daemon
1094
1095  ping-daemon
1096
1097 This is a test probe into the guestfs daemon running inside
1098 the qemu subprocess.  Calling this function checks that the
1099 daemon responds to the ping message, without affecting the daemon
1100 or attached block device(s) in any other way.
1101
1102 =head2 pvcreate
1103
1104  pvcreate device
1105
1106 This creates an LVM physical volume on the named C<device>,
1107 where C<device> should usually be a partition name such
1108 as C</dev/sda1>.
1109
1110 =head2 pvremove
1111
1112  pvremove device
1113
1114 This wipes a physical volume C<device> so that LVM will no longer
1115 recognise it.
1116
1117 The implementation uses the C<pvremove> command which refuses to
1118 wipe physical volumes that contain any volume groups, so you have
1119 to remove those first.
1120
1121 =head2 pvresize
1122
1123  pvresize device
1124
1125 This resizes (expands or shrinks) an existing LVM physical
1126 volume to match the new size of the underlying device.
1127
1128 =head2 pvs
1129
1130  pvs
1131
1132 List all the physical volumes detected.  This is the equivalent
1133 of the L<pvs(8)> command.
1134
1135 This returns a list of just the device names that contain
1136 PVs (eg. C</dev/sda2>).
1137
1138 See also C<pvs-full>.
1139
1140 =head2 pvs-full
1141
1142  pvs-full
1143
1144 List all the physical volumes detected.  This is the equivalent
1145 of the L<pvs(8)> command.  The "full" version includes all fields.
1146
1147 =head2 read-lines
1148
1149  read-lines path
1150
1151 Return the contents of the file named C<path>.
1152
1153 The file contents are returned as a list of lines.  Trailing
1154 C<LF> and C<CRLF> character sequences are I<not> returned.
1155
1156 Note that this function cannot correctly handle binary files
1157 (specifically, files containing C<\0> character which is treated
1158 as end of line).  For those you need to use the C<read-file>
1159 function which has a more complex interface.
1160
1161 =head2 resize2fs
1162
1163  resize2fs device
1164
1165 This resizes an ext2 or ext3 filesystem to match the size of
1166 the underlying device.
1167
1168 I<Note:> It is sometimes required that you run C<e2fsck-f>
1169 on the C<device> before calling this command.  For unknown reasons
1170 C<resize2fs> sometimes gives an error about this and sometimes not.
1171 In any case, it is always safe to call C<e2fsck-f> before
1172 calling this function.
1173
1174 =head2 rm
1175
1176  rm path
1177
1178 Remove the single file C<path>.
1179
1180 =head2 rm-rf
1181
1182  rm-rf path
1183
1184 Remove the file or directory C<path>, recursively removing the
1185 contents if its a directory.  This is like the C<rm -rf> shell
1186 command.
1187
1188 =head2 rmdir
1189
1190  rmdir path
1191
1192 Remove the single directory C<path>.
1193
1194 =head2 scrub-device
1195
1196  scrub-device device
1197
1198 This command writes patterns over C<device> to make data retrieval
1199 more difficult.
1200
1201 It is an interface to the L<scrub(1)> program.  See that
1202 manual page for more details.
1203
1204 B<This command is dangerous.  Without careful use you
1205 can easily destroy all your data>.
1206
1207 =head2 scrub-file
1208
1209  scrub-file file
1210
1211 This command writes patterns over a file to make data retrieval
1212 more difficult.
1213
1214 The file is I<removed> after scrubbing.
1215
1216 It is an interface to the L<scrub(1)> program.  See that
1217 manual page for more details.
1218
1219 =head2 scrub-freespace
1220
1221  scrub-freespace dir
1222
1223 This command creates the directory C<dir> and then fills it
1224 with files until the filesystem is full, and scrubs the files
1225 as for C<scrub-file>, and deletes them.
1226 The intention is to scrub any free space on the partition
1227 containing C<dir>.
1228
1229 It is an interface to the L<scrub(1)> program.  See that
1230 manual page for more details.
1231
1232 =head2 set-append | append
1233
1234  set-append append
1235
1236 This function is used to add additional options to the
1237 guest kernel command line.
1238
1239 The default is C<NULL> unless overridden by setting
1240 C<LIBGUESTFS_APPEND> environment variable.
1241
1242 Setting C<append> to C<NULL> means I<no> additional options
1243 are passed (libguestfs always adds a few of its own).
1244
1245 =head2 set-autosync | autosync
1246
1247  set-autosync true|false
1248
1249 If C<autosync> is true, this enables autosync.  Libguestfs will make a
1250 best effort attempt to run C<umount-all> followed by
1251 C<sync> when the handle is closed
1252 (also if the program exits without closing handles).
1253
1254 This is disabled by default (except in guestfish where it is
1255 enabled by default).
1256
1257 =head2 set-e2label
1258
1259  set-e2label device label
1260
1261 This sets the ext2/3/4 filesystem label of the filesystem on
1262 C<device> to C<label>.  Filesystem labels are limited to
1263 16 characters.
1264
1265 You can use either C<tune2fs-l> or C<get-e2label>
1266 to return the existing label on a filesystem.
1267
1268 =head2 set-e2uuid
1269
1270  set-e2uuid device uuid
1271
1272 This sets the ext2/3/4 filesystem UUID of the filesystem on
1273 C<device> to C<uuid>.  The format of the UUID and alternatives
1274 such as C<clear>, C<random> and C<time> are described in the
1275 L<tune2fs(8)> manpage.
1276
1277 You can use either C<tune2fs-l> or C<get-e2uuid>
1278 to return the existing UUID of a filesystem.
1279
1280 =head2 set-path | path
1281
1282  set-path path
1283
1284 Set the path that libguestfs searches for kernel and initrd.img.
1285
1286 The default is C<$libdir/guestfs> unless overridden by setting
1287 C<LIBGUESTFS_PATH> environment variable.
1288
1289 Setting C<path> to C<NULL> restores the default path.
1290
1291 =head2 set-qemu | qemu
1292
1293  set-qemu qemu
1294
1295 Set the qemu binary that we will use.
1296
1297 The default is chosen when the library was compiled by the
1298 configure script.
1299
1300 You can also override this by setting the C<LIBGUESTFS_QEMU>
1301 environment variable.
1302
1303 Setting C<qemu> to C<NULL> restores the default qemu binary.
1304
1305 =head2 set-verbose | verbose
1306
1307  set-verbose true|false
1308
1309 If C<verbose> is true, this turns on verbose messages (to C<stderr>).
1310
1311 Verbose messages are disabled unless the environment variable
1312 C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
1313
1314 =head2 sfdisk
1315
1316  sfdisk device cyls heads sectors 'lines ...'
1317
1318 This is a direct interface to the L<sfdisk(8)> program for creating
1319 partitions on block devices.
1320
1321 C<device> should be a block device, for example C</dev/sda>.
1322
1323 C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
1324 and sectors on the device, which are passed directly to sfdisk as
1325 the I<-C>, I<-H> and I<-S> parameters.  If you pass C<0> for any
1326 of these, then the corresponding parameter is omitted.  Usually for
1327 'large' disks, you can just pass C<0> for these, but for small
1328 (floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
1329 out the right geometry and you will need to tell it.
1330
1331 C<lines> is a list of lines that we feed to C<sfdisk>.  For more
1332 information refer to the L<sfdisk(8)> manpage.
1333
1334 To create a single partition occupying the whole disk, you would
1335 pass C<lines> as a single element list, when the single element being
1336 the string C<,> (comma).
1337
1338 See also: C<sfdisk-l>, C<sfdisk-N>
1339
1340 B<This command is dangerous.  Without careful use you
1341 can easily destroy all your data>.
1342
1343 =head2 sfdisk-N
1344
1345  sfdisk-N device partnum cyls heads sectors line
1346
1347 This runs L<sfdisk(8)> option to modify just the single
1348 partition C<n> (note: C<n> counts from 1).
1349
1350 For other parameters, see C<sfdisk>.  You should usually
1351 pass C<0> for the cyls/heads/sectors parameters.
1352
1353 B<This command is dangerous.  Without careful use you
1354 can easily destroy all your data>.
1355
1356 =head2 sfdisk-disk-geometry
1357
1358  sfdisk-disk-geometry device
1359
1360 This displays the disk geometry of C<device> read from the
1361 partition table.  Especially in the case where the underlying
1362 block device has been resized, this can be different from the
1363 kernel's idea of the geometry (see C<sfdisk-kernel-geometry>).
1364
1365 The result is in human-readable format, and not designed to
1366 be parsed.
1367
1368 =head2 sfdisk-kernel-geometry
1369
1370  sfdisk-kernel-geometry device
1371
1372 This displays the kernel's idea of the geometry of C<device>.
1373
1374 The result is in human-readable format, and not designed to
1375 be parsed.
1376
1377 =head2 sfdisk-l
1378
1379  sfdisk-l device
1380
1381 This displays the partition table on C<device>, in the
1382 human-readable output of the L<sfdisk(8)> command.  It is
1383 not intended to be parsed.
1384
1385 =head2 sh
1386
1387  sh command
1388
1389 This call runs a command from the guest filesystem via the
1390 guest's C</bin/sh>.
1391
1392 This is like C<command>, but passes the command to:
1393
1394  /bin/sh -c "command"
1395
1396 Depending on the guest's shell, this usually results in
1397 wildcards being expanded, shell expressions being interpolated
1398 and so on.
1399
1400 All the provisos about C<command> apply to this call.
1401
1402 =head2 sh-lines
1403
1404  sh-lines command
1405
1406 This is the same as C<sh>, but splits the result
1407 into a list of lines.
1408
1409 See also: C<command-lines>
1410
1411 =head2 sleep
1412
1413  sleep secs
1414
1415 Sleep for C<secs> seconds.
1416
1417 =head2 stat
1418
1419  stat path
1420
1421 Returns file information for the given C<path>.
1422
1423 This is the same as the C<stat(2)> system call.
1424
1425 =head2 statvfs
1426
1427  statvfs path
1428
1429 Returns file system statistics for any mounted file system.
1430 C<path> should be a file or directory in the mounted file system
1431 (typically it is the mount point itself, but it doesn't need to be).
1432
1433 This is the same as the C<statvfs(2)> system call.
1434
1435 =head2 strings
1436
1437  strings path
1438
1439 This runs the L<strings(1)> command on a file and returns
1440 the list of printable strings found.
1441
1442 Because of the message protocol, there is a transfer limit 
1443 of somewhere between 2MB and 4MB.  To transfer large files you should use
1444 FTP.
1445
1446 =head2 strings-e
1447
1448  strings-e encoding path
1449
1450 This is like the C<strings> command, but allows you to
1451 specify the encoding.
1452
1453 See the L<strings(1)> manpage for the full list of encodings.
1454
1455 Commonly useful encodings are C<l> (lower case L) which will
1456 show strings inside Windows/x86 files.
1457
1458 The returned strings are transcoded to UTF-8.
1459
1460 Because of the message protocol, there is a transfer limit 
1461 of somewhere between 2MB and 4MB.  To transfer large files you should use
1462 FTP.
1463
1464 =head2 sync
1465
1466  sync
1467
1468 This syncs the disk, so that any writes are flushed through to the
1469 underlying disk image.
1470
1471 You should always call this if you have modified a disk image, before
1472 closing the handle.
1473
1474 =head2 tail
1475
1476  tail path
1477
1478 This command returns up to the last 10 lines of a file as
1479 a list of strings.
1480
1481 Because of the message protocol, there is a transfer limit 
1482 of somewhere between 2MB and 4MB.  To transfer large files you should use
1483 FTP.
1484
1485 =head2 tail-n
1486
1487  tail-n nrlines path
1488
1489 If the parameter C<nrlines> is a positive number, this returns the last
1490 C<nrlines> lines of the file C<path>.
1491
1492 If the parameter C<nrlines> is a negative number, this returns lines
1493 from the file C<path>, starting with the C<-nrlines>th line.
1494
1495 If the parameter C<nrlines> is zero, this returns an empty list.
1496
1497 Because of the message protocol, there is a transfer limit 
1498 of somewhere between 2MB and 4MB.  To transfer large files you should use
1499 FTP.
1500
1501 =head2 tar-in
1502
1503  tar-in (tarfile|-) directory
1504
1505 This command uploads and unpacks local file C<tarfile> (an
1506 I<uncompressed> tar file) into C<directory>.
1507
1508 To upload a compressed tarball, use C<tgz-in>.
1509
1510 Use C<-> instead of a filename to read/write from stdin/stdout.
1511
1512 =head2 tar-out
1513
1514  tar-out directory (tarfile|-)
1515
1516 This command packs the contents of C<directory> and downloads
1517 it to local file C<tarfile>.
1518
1519 To download a compressed tarball, use C<tgz-out>.
1520
1521 Use C<-> instead of a filename to read/write from stdin/stdout.
1522
1523 =head2 tgz-in
1524
1525  tgz-in (tarball|-) directory
1526
1527 This command uploads and unpacks local file C<tarball> (a
1528 I<gzip compressed> tar file) into C<directory>.
1529
1530 To upload an uncompressed tarball, use C<tar-in>.
1531
1532 Use C<-> instead of a filename to read/write from stdin/stdout.
1533
1534 =head2 tgz-out
1535
1536  tgz-out directory (tarball|-)
1537
1538 This command packs the contents of C<directory> and downloads
1539 it to local file C<tarball>.
1540
1541 To download an uncompressed tarball, use C<tar-out>.
1542
1543 Use C<-> instead of a filename to read/write from stdin/stdout.
1544
1545 =head2 touch
1546
1547  touch path
1548
1549 Touch acts like the L<touch(1)> command.  It can be used to
1550 update the timestamps on a file, or, if the file does not exist,
1551 to create a new zero-length file.
1552
1553 =head2 tune2fs-l
1554
1555  tune2fs-l device
1556
1557 This returns the contents of the ext2, ext3 or ext4 filesystem
1558 superblock on C<device>.
1559
1560 It is the same as running C<tune2fs -l device>.  See L<tune2fs(8)>
1561 manpage for more details.  The list of fields returned isn't
1562 clearly defined, and depends on both the version of C<tune2fs>
1563 that libguestfs was built against, and the filesystem itself.
1564
1565 =head2 umount | unmount
1566
1567  umount pathordevice
1568
1569 This unmounts the given filesystem.  The filesystem may be
1570 specified either by its mountpoint (path) or the device which
1571 contains the filesystem.
1572
1573 =head2 umount-all | unmount-all
1574
1575  umount-all
1576
1577 This unmounts all mounted filesystems.
1578
1579 Some internal mounts are not unmounted by this call.
1580
1581 =head2 upload
1582
1583  upload (filename|-) remotefilename
1584
1585 Upload local file C<filename> to C<remotefilename> on the
1586 filesystem.
1587
1588 C<filename> can also be a named pipe.
1589
1590 See also C<download>.
1591
1592 Use C<-> instead of a filename to read/write from stdin/stdout.
1593
1594 =head2 vg-activate
1595
1596  vg-activate true|false 'volgroups ...'
1597
1598 This command activates or (if C<activate> is false) deactivates
1599 all logical volumes in the listed volume groups C<volgroups>.
1600 If activated, then they are made known to the
1601 kernel, ie. they appear as C</dev/mapper> devices.  If deactivated,
1602 then those devices disappear.
1603
1604 This command is the same as running C<vgchange -a y|n volgroups...>
1605
1606 Note that if C<volgroups> is an empty list then B<all> volume groups
1607 are activated or deactivated.
1608
1609 =head2 vg-activate-all
1610
1611  vg-activate-all true|false
1612
1613 This command activates or (if C<activate> is false) deactivates
1614 all logical volumes in all volume groups.
1615 If activated, then they are made known to the
1616 kernel, ie. they appear as C</dev/mapper> devices.  If deactivated,
1617 then those devices disappear.
1618
1619 This command is the same as running C<vgchange -a y|n>
1620
1621 =head2 vgcreate
1622
1623  vgcreate volgroup 'physvols ...'
1624
1625 This creates an LVM volume group called C<volgroup>
1626 from the non-empty list of physical volumes C<physvols>.
1627
1628 =head2 vgremove
1629
1630  vgremove vgname
1631
1632 Remove an LVM volume group C<vgname>, (for example C<VG>).
1633
1634 This also forcibly removes all logical volumes in the volume
1635 group (if any).
1636
1637 =head2 vgs
1638
1639  vgs
1640
1641 List all the volumes groups detected.  This is the equivalent
1642 of the L<vgs(8)> command.
1643
1644 This returns a list of just the volume group names that were
1645 detected (eg. C<VolGroup00>).
1646
1647 See also C<vgs-full>.
1648
1649 =head2 vgs-full
1650
1651  vgs-full
1652
1653 List all the volumes groups detected.  This is the equivalent
1654 of the L<vgs(8)> command.  The "full" version includes all fields.
1655
1656 =head2 wc-c
1657
1658  wc-c path
1659
1660 This command counts the characters in a file, using the
1661 C<wc -c> external command.
1662
1663 =head2 wc-l
1664
1665  wc-l path
1666
1667 This command counts the lines in a file, using the
1668 C<wc -l> external command.
1669
1670 =head2 wc-w
1671
1672  wc-w path
1673
1674 This command counts the words in a file, using the
1675 C<wc -w> external command.
1676
1677 =head2 write-file
1678
1679  write-file path content size
1680
1681 This call creates a file called C<path>.  The contents of the
1682 file is the string C<content> (which can contain any 8 bit data),
1683 with length C<size>.
1684
1685 As a special case, if C<size> is C<0>
1686 then the length is calculated using C<strlen> (so in this case
1687 the content cannot contain embedded ASCII NULs).
1688
1689 I<NB.> Owing to a bug, writing content containing ASCII NUL
1690 characters does I<not> work, even if the length is specified.
1691 We hope to resolve this bug in a future version.  In the meantime
1692 use C<upload>.
1693
1694 Because of the message protocol, there is a transfer limit 
1695 of somewhere between 2MB and 4MB.  To transfer large files you should use
1696 FTP.
1697
1698 =head2 zero
1699
1700  zero device
1701
1702 This command writes zeroes over the first few blocks of C<device>.
1703
1704 How many blocks are zeroed isn't specified (but it's I<not> enough
1705 to securely wipe the device).  It should be sufficient to remove
1706 any partition tables, filesystem superblocks and so on.
1707
1708 See also: C<scrub-device>.
1709
1710 =head2 zerofree
1711
1712  zerofree device
1713
1714 This runs the I<zerofree> program on C<device>.  This program
1715 claims to zero unused inodes and disk blocks on an ext2/3
1716 filesystem, thus making it possible to compress the filesystem
1717 more effectively.
1718
1719 You should B<not> run this program if the filesystem is
1720 mounted.
1721
1722 It is possible that using this program can damage the filesystem
1723 or data on the filesystem.
1724