1guestfish(1) Virtualization Support guestfish(1)
2
3
4
6 guestfish - the guest filesystem shell
7
9 guestfish [--options] [commands]
10
11 guestfish
12
13 guestfish [--ro|--rw] -a disk.img
14
15 guestfish [--ro|--rw] -a disk.img -m dev[:mountpoint]
16
17 guestfish -d libvirt-domain
18
19 guestfish [--ro|--rw] -a disk.img -i
20
21 guestfish -d libvirt-domain -i
22
24 Using "guestfish" in write mode on live virtual machines, or
25 concurrently with other disk editing tools, can be dangerous,
26 potentially causing disk corruption. The virtual machine must be shut
27 down before you use this command, and disk images must not be edited
28 concurrently.
29
30 Use the --ro (read-only) option to use "guestfish" safely if the disk
31 image or virtual machine might be live. You may see strange or
32 inconsistent results if running concurrently with other changes, but
33 with this option you won't risk disk corruption.
34
36 Guestfish is a shell and command-line tool for examining and modifying
37 virtual machine filesystems. It uses libguestfs and exposes all of the
38 functionality of the guestfs API, see guestfs(3).
39
40 Guestfish gives you structured access to the libguestfs API, from shell
41 scripts or the command line or interactively. If you want to rescue a
42 broken virtual machine image, you should look at the virt-rescue(1)
43 command.
44
46 As an interactive shell
47 $ guestfish
48
49 Welcome to guestfish, the guest filesystem shell for
50 editing virtual machine filesystems.
51
52 Type: 'help' for a list of commands
53 'man' to read the manual
54 'quit' to quit the shell
55
56 ><fs> add-ro disk.img
57 ><fs> run
58 ><fs> list-filesystems
59 /dev/sda1: ext4
60 /dev/vg_guest/lv_root: ext4
61 /dev/vg_guest/lv_swap: swap
62 ><fs> mount /dev/vg_guest/lv_root /
63 ><fs> cat /etc/fstab
64 # /etc/fstab
65 # Created by anaconda
66 [...]
67 ><fs> exit
68
69 From shell scripts
70 Create a new /etc/motd file in a guest or disk image:
71
72 guestfish <<_EOF_
73 add disk.img
74 run
75 mount /dev/vg_guest/lv_root /
76 write /etc/motd "Welcome, new users"
77 _EOF_
78
79 List the LVM logical volumes in a disk image:
80
81 guestfish -a disk.img --ro <<_EOF_
82 run
83 lvs
84 _EOF_
85
86 List all the filesystems in a disk image:
87
88 guestfish -a disk.img --ro <<_EOF_
89 run
90 list-filesystems
91 _EOF_
92
93 On one command line
94 Update /etc/resolv.conf in a guest:
95
96 guestfish \
97 add disk.img : run : mount /dev/vg_guest/lv_root / : \
98 write /etc/resolv.conf "nameserver 1.2.3.4"
99
100 Edit /boot/grub/grub.conf interactively:
101
102 guestfish --rw --add disk.img \
103 --mount /dev/vg_guest/lv_root \
104 --mount /dev/sda1:/boot \
105 edit /boot/grub/grub.conf
106
107 Mount disks automatically
108 Use the -i option to automatically mount the disks from a virtual
109 machine:
110
111 guestfish --ro -a disk.img -i cat /etc/group
112
113 guestfish --ro -d libvirt-domain -i cat /etc/group
114
115 Another way to edit /boot/grub/grub.conf interactively is:
116
117 guestfish --rw -a disk.img -i edit /boot/grub/grub.conf
118
119 As a script interpreter
120 Create a 100MB disk containing an ext2-formatted partition:
121
122 #!/usr/bin/guestfish -f
123 sparse test1.img 100M
124 run
125 part-disk /dev/sda mbr
126 mkfs ext2 /dev/sda1
127
128 Start with a prepared disk
129 Create a 1G disk called test1.img containing a single ext2-formatted
130 partition:
131
132 guestfish -N fs
133
134 To list what is available do:
135
136 guestfish -N help | less
137
138 Remote drives
139 Access a remote disk using ssh:
140
141 guestfish -a ssh://example.com/path/to/disk.img
142
143 Remote control
144 eval "`guestfish --listen`"
145 guestfish --remote add-ro disk.img
146 guestfish --remote run
147 guestfish --remote lvs
148
150 --help
151 Displays general help on options.
152
153 -h
154 --cmd-help
155 Lists all available guestfish commands.
156
157 -h CMD
158 --cmd-help CMD
159 Displays detailed help on a single command "cmd".
160
161 -a IMAGE
162 --add IMAGE
163 Add a block device or virtual machine image to the shell.
164
165 The format of the disk image is auto-detected. To override this
166 and force a particular format use the --format=.. option.
167
168 Using this flag is mostly equivalent to using the "add" command,
169 with "readonly:true" if the --ro flag was given, and with
170 "format:..." if the --format=... flag was given.
171
172 -a URI
173 --add URI
174 Add a remote disk. See "ADDING REMOTE STORAGE".
175
176 --blocksize=512
177 --blocksize=4096
178 --blocksize
179 This parameter sets the sector size of the disk image. It affects
180 all explicitly added subsequent disks after this parameter. Using
181 --blocksize with no argument switches the disk sector size to the
182 default value which is usually 512 bytes. See also
183 "guestfs_add_drive_opts" in guestfs(3).
184
185 -c URI
186 --connect URI
187 When used in conjunction with the -d option, this specifies the
188 libvirt URI to use. The default is to use the default libvirt
189 connection.
190
191 --csh
192 If using the --listen option and a csh-like shell, use this option.
193 See section "REMOTE CONTROL AND CSH" below.
194
195 -d LIBVIRT-DOMAIN
196 --domain LIBVIRT-DOMAIN
197 Add disks from the named libvirt domain. If the --ro option is
198 also used, then any libvirt domain can be used. However in write
199 mode, only libvirt domains which are shut down can be named here.
200
201 Domain UUIDs can be used instead of names.
202
203 Using this flag is mostly equivalent to using the "add-domain"
204 command, with "readonly:true" if the --ro flag was given, and with
205 "format:..." if the --format=... flag was given.
206
207 --echo-keys
208 When prompting for keys and passphrases, guestfish normally turns
209 echoing off so you cannot see what you are typing. If you are not
210 worried about Tempest attacks and there is no one else in the room
211 you can specify this flag to see what you are typing.
212
213 -f FILE
214 --file FILE
215 Read commands from "FILE". To write pure guestfish scripts, use:
216
217 #!/usr/bin/guestfish -f
218
219 --format=raw|qcow2|..
220 --format
221 The default for the -a option is to auto-detect the format of the
222 disk image. Using this forces the disk format for -a options which
223 follow on the command line. Using --format with no argument
224 switches back to auto-detection for subsequent -a options.
225
226 For example:
227
228 guestfish --format=raw -a disk.img
229
230 forces raw format (no auto-detection) for disk.img.
231
232 guestfish --format=raw -a disk.img --format -a another.img
233
234 forces raw format (no auto-detection) for disk.img and reverts to
235 auto-detection for another.img.
236
237 If you have untrusted raw-format guest disk images, you should use
238 this option to specify the disk format. This avoids a possible
239 security problem with malicious guests (CVE-2010-3851). See also
240 "add".
241
242 -i
243 --inspector
244 Using virt-inspector(1) code, inspect the disks looking for an
245 operating system and mount filesystems as they would be mounted on
246 the real virtual machine.
247
248 Typical usage is either:
249
250 guestfish -d myguest -i
251
252 (for an inactive libvirt domain called myguest), or:
253
254 guestfish --ro -d myguest -i
255
256 (for active domains, readonly), or specify the block device
257 directly:
258
259 guestfish --rw -a /dev/Guests/MyGuest -i
260
261 Note that the command line syntax changed slightly over older
262 versions of guestfish. You can still use the old syntax:
263
264 guestfish [--ro] -i disk.img
265
266 guestfish [--ro] -i libvirt-domain
267
268 Using this flag is mostly equivalent to using the "inspect-os"
269 command and then using other commands to mount the filesystems that
270 were found.
271
272 --key SELECTOR
273 Specify a key for LUKS, to automatically open a LUKS device when
274 using the inspection. "ID" can be either the libguestfs device
275 name, or the UUID of the LUKS device.
276
277 --key "ID":key:KEY_STRING
278 Use the specified "KEY_STRING" as passphrase.
279
280 --key "ID":file:FILENAME
281 Read the passphrase from FILENAME.
282
283 --key "ID":clevis
284 Attempt passphrase-less unlocking for "ID" with Clevis, over
285 the network. Please refer to "ENCRYPTED DISKS" in guestfs(3)
286 for more information on network-bound disk encryption (NBDE).
287
288 Note that if any such option is present on the command line,
289 QEMU user networking will be automatically enabled for the
290 libguestfs appliance.
291
292 --keys-from-stdin
293 Read key or passphrase parameters from stdin. The default is to
294 try to read passphrases from the user by opening /dev/tty.
295
296 If there are multiple encrypted devices then you may need to supply
297 multiple keys on stdin, one per line.
298
299 --listen
300 Fork into the background and listen for remote commands. See
301 section "REMOTE CONTROL GUESTFISH OVER A SOCKET" below.
302
303 -m dev[:mountpoint[:options[:fstype]]]
304 --mount dev[:mountpoint[:options[:fstype]]]
305 Mount the named partition or logical volume on the given
306 mountpoint.
307
308 If the mountpoint is omitted, it defaults to /.
309
310 You have to mount something on / before most commands will work.
311
312 If any -m or --mount options are given, the guest is automatically
313 launched.
314
315 If you don’t know what filesystems a disk image contains, you can
316 either run guestfish without this option, then list the partitions,
317 filesystems and LVs available (see "list-partitions", "list-
318 filesystems" and "lvs" commands), or you can use the
319 virt-filesystems(1) program.
320
321 The third (and rarely used) part of the mount parameter is the list
322 of mount options used to mount the underlying filesystem. If this
323 is not given, then the mount options are either the empty string or
324 "ro" (the latter if the --ro flag is used). By specifying the
325 mount options, you override this default choice. Probably the only
326 time you would use this is to enable ACLs and/or extended
327 attributes if the filesystem can support them:
328
329 -m /dev/sda1:/:acl,user_xattr
330
331 Using this flag is equivalent to using the "mount-options" command.
332
333 The fourth part of the parameter is the filesystem driver to use,
334 such as "ext3" or "ntfs". This is rarely needed, but can be useful
335 if multiple drivers are valid for a filesystem (eg: "ext2" and
336 "ext3"), or if libguestfs misidentifies a filesystem.
337
338 --network
339 Enable QEMU user networking in the guest.
340
341 -N [FILENAME=]TYPE
342 --new [FILENAME=]TYPE
343 -N help
344 Prepare a fresh disk image formatted as "TYPE". This is an
345 alternative to the -a option: whereas -a adds an existing disk, -N
346 creates a preformatted disk with a filesystem and adds it. See
347 "PREPARED DISK IMAGES" below.
348
349 -n
350 --no-sync
351 Disable autosync. This is enabled by default. See the discussion
352 of autosync in the guestfs(3) manpage.
353
354 --no-dest-paths
355 Don’t tab-complete paths on the guest filesystem. It is useful to
356 be able to hit the tab key to complete paths on the guest
357 filesystem, but this causes extra "hidden" guestfs calls to be
358 made, so this option is here to allow this feature to be disabled.
359
360 --pipe-error
361 If writes fail to pipe commands (see "PIPES" below), then the
362 command returns an error.
363
364 The default (also for historical reasons) is to ignore such errors
365 so that:
366
367 ><fs> command_with_lots_of_output | head
368
369 doesn't give an error.
370
371 --progress-bars
372 Enable progress bars, even when guestfish is used non-
373 interactively.
374
375 Progress bars are enabled by default when guestfish is used as an
376 interactive shell.
377
378 --no-progress-bars
379 Disable progress bars.
380
381 --remote
382 --remote=PID
383 Send remote commands to $GUESTFISH_PID or "pid". See section
384 "REMOTE CONTROL GUESTFISH OVER A SOCKET" below.
385
386 -r
387 --ro
388 This changes the -a, -d and -m options so that disks are added and
389 mounts are done read-only.
390
391 The option must always be used if the disk image or virtual machine
392 might be running, and is generally recommended in cases where you
393 don't need write access to the disk.
394
395 Note that prepared disk images created with -N are not affected by
396 this option. Also commands like "add" are not affected - you have
397 to specify the "readonly:true" option explicitly if you need it.
398
399 See also "OPENING DISKS FOR READ AND WRITE" below.
400
401 --selinux
402 This option is provided for backwards compatibility and does
403 nothing.
404
405 -v
406 --verbose
407 Enable very verbose messages. This is particularly useful if you
408 find a bug.
409
410 -V
411 --version
412 Display the guestfish / libguestfs version number and exit.
413
414 -w
415 --rw
416 This changes the -a, -d and -m options so that disks are added and
417 mounts are done read-write.
418
419 See "OPENING DISKS FOR READ AND WRITE" below.
420
421 -x Echo each command before executing it.
422
424 Any additional (non-option) arguments are treated as commands to
425 execute.
426
427 Commands to execute should be separated by a colon (":"), where the
428 colon is a separate parameter. Thus:
429
430 guestfish cmd [args...] : cmd [args...] : cmd [args...] ...
431
432 If there are no additional arguments, then we enter a shell, either an
433 interactive shell with a prompt (if the input is a terminal) or a non-
434 interactive shell.
435
436 In either command line mode or non-interactive shell, the first command
437 that gives an error causes the whole shell to exit. In interactive
438 mode (with a prompt) if a command fails, you can continue to enter
439 commands.
440
441 Note that arguments of the commands will be considered as guestfish
442 options if they start with a dash ("-"): you can always separate the
443 guestfish options and the rest of the commands (with their arguments)
444 using a double dash ("--"). For example:
445
446 guestfish -- disk_create overlay.qcow2 qcow2 -1 backingfile:image.img
447
449 As with guestfs(3), you must first configure your guest by adding
450 disks, then launch it, then mount any disks you need, and finally issue
451 actions/commands. So the general order of the day is:
452
453 • add or -a/--add
454
455 • launch (aka run)
456
457 • mount or -m/--mount
458
459 • any other commands
460
461 "run" is a synonym for "launch". You must "launch" (or "run") your
462 guest before mounting or performing any other commands.
463
464 The only exception is that if any of the -i, -m, --mount, -N or --new
465 options were given then "run" is done automatically, simply because
466 guestfish can't perform the action you asked for without doing this.
467
469 The guestfish, guestmount(1) and virt-rescue(1) options --ro and --rw
470 affect whether the other command line options -a, -c, -d, -i and -m
471 open disk images read-only or for writing.
472
473 In libguestfs ≤ 1.10, guestfish, guestmount and virt-rescue defaulted
474 to opening disk images supplied on the command line for write. To open
475 a disk image read-only you have to do -a image --ro.
476
477 This matters: If you accidentally open a live VM disk image writable
478 then you will cause irreversible disk corruption.
479
480 In a future libguestfs we intend to change the default the other way.
481 Disk images will be opened read-only. You will have to either specify
482 guestfish --rw, guestmount --rw, virt-rescue --rw, or change the
483 configuration file in order to get write access for disk images
484 specified by those other command line options.
485
486 This version of guestfish, guestmount and virt-rescue has a --rw option
487 which does nothing (it is already the default). However it is highly
488 recommended that you use this option to indicate that you need write
489 access, and prepare your scripts for the day when this option will be
490 required for write access.
491
492 Note: This does not affect commands like "add" and "mount", or any
493 other libguestfs program apart from guestfish and guestmount.
494
496 You can quote ordinary parameters using either single or double quotes.
497 For example:
498
499 add "file with a space.img"
500
501 rm '/file name'
502
503 rm '/"'
504
505 A few commands require a list of strings to be passed. For these, use
506 a whitespace-separated list, enclosed in quotes. Strings containing
507 whitespace to be passed through must be enclosed in single quotes. A
508 literal single quote must be escaped with a backslash.
509
510 vgcreate VG "/dev/sda1 /dev/sdb1"
511 command "/bin/echo 'foo bar'"
512 command "/bin/echo \'foo\'"
513
514 ESCAPE SEQUENCES IN DOUBLE QUOTED ARGUMENTS
515 In double-quoted arguments (only) use backslash to insert special
516 characters:
517
518 "\a"
519 Alert (bell) character.
520
521 "\b"
522 Backspace character.
523
524 "\f"
525 Form feed character.
526
527 "\n"
528 Newline character.
529
530 "\r"
531 Carriage return character.
532
533 "\t"
534 Horizontal tab character.
535
536 "\v"
537 Vertical tab character.
538
539 "\""
540 A literal double quote character.
541
542 "\ooo"
543 A character with octal value ooo. There must be precisely 3 octal
544 digits (unlike C).
545
546 "\xhh"
547 A character with hex value hh. There must be precisely 2 hex
548 digits.
549
550 In the current implementation "\000" and "\x00" cannot be used in
551 strings.
552
553 "\\"
554 A literal backslash character.
555
557 Some commands take optional arguments. These arguments appear in this
558 documentation as "[argname:..]". You can use them as in these
559 examples:
560
561 add filename
562
563 add filename readonly:true
564
565 add filename format:qcow2 readonly:false
566
567 Each optional argument can appear at most once. All optional arguments
568 must appear after the required ones.
569
571 This section applies to all commands which can take integers as
572 parameters.
573
574 SIZE SUFFIX
575 When the command takes a parameter measured in bytes, you can use one
576 of the following suffixes to specify kilobytes, megabytes and larger
577 sizes:
578
579 k or K or KiB
580 The size in kilobytes (multiplied by 1024).
581
582 KB The size in SI 1000 byte units.
583
584 M or MiB
585 The size in megabytes (multiplied by 1048576).
586
587 MB The size in SI 1000000 byte units.
588
589 G or GiB
590 The size in gigabytes (multiplied by 2**30).
591
592 GB The size in SI 10**9 byte units.
593
594 T or TiB
595 The size in terabytes (multiplied by 2**40).
596
597 TB The size in SI 10**12 byte units.
598
599 P or PiB
600 The size in petabytes (multiplied by 2**50).
601
602 PB The size in SI 10**15 byte units.
603
604 E or EiB
605 The size in exabytes (multiplied by 2**60).
606
607 EB The size in SI 10**18 byte units.
608
609 Z or ZiB
610 The size in zettabytes (multiplied by 2**70).
611
612 ZB The size in SI 10**21 byte units.
613
614 Y or YiB
615 The size in yottabytes (multiplied by 2**80).
616
617 YB The size in SI 10**24 byte units.
618
619 For example:
620
621 truncate-size /file 1G
622
623 would truncate the file to 1 gigabyte.
624
625 Be careful because a few commands take sizes in kilobytes or megabytes
626 (eg. the parameter to "memsize" is specified in megabytes already).
627 Adding a suffix will probably not do what you expect.
628
629 OCTAL AND HEXADECIMAL NUMBERS
630 For specifying the radix (base) use the C convention: 0 to prefix an
631 octal number or "0x" to prefix a hexadecimal number. For example:
632
633 1234 decimal number 1234
634 02322 octal number, equivalent to decimal 1234
635 0x4d2 hexadecimal number, equivalent to decimal 1234
636
637 When using the "chmod" command, you almost always want to specify an
638 octal number for the mode, and you must prefix it with 0 (unlike the
639 Unix chmod(1) program):
640
641 chmod 0777 /public # OK
642 chmod 777 /public # WRONG! This is mode 777 decimal = 01411 octal.
643
644 Commands that return numbers usually print them in decimal, but some
645 commands print numbers in other radices (eg. "umask" prints the mode in
646 octal, preceded by 0).
647
649 Neither guestfish nor the underlying guestfs API performs wildcard
650 expansion (globbing) by default. So for example the following will not
651 do what you expect:
652
653 rm-rf /home/*
654
655 Assuming you don’t have a directory called literally /home/* then the
656 above command will return an error.
657
658 To perform wildcard expansion, use the "glob" command.
659
660 glob rm-rf /home/*
661
662 runs "rm-rf" on each path that matches (ie. potentially running the
663 command many times), equivalent to:
664
665 rm-rf /home/jim
666 rm-rf /home/joe
667 rm-rf /home/mary
668
669 "glob" only works on simple guest paths and not on device names.
670
671 If you have several parameters, each containing a wildcard, then glob
672 will perform a Cartesian product.
673
675 Any line which starts with a # character is treated as a comment and
676 ignored. The # can optionally be preceded by whitespace, but not by a
677 command. For example:
678
679 # this is a comment
680 # this is a comment
681 foo # NOT a comment
682
683 Blank lines are also ignored.
684
686 Any line which starts with a ! character is treated as a command sent
687 to the local shell (/bin/sh or whatever system(3) uses). For example:
688
689 !mkdir local
690 tgz-out /remote local/remote-data.tar.gz
691
692 will create a directory "local" on the host, and then export the
693 contents of /remote on the mounted filesystem to
694 local/remote-data.tar.gz. (See "tgz-out").
695
696 To change the local directory, use the "lcd" command. "!cd" will have
697 no effect, due to the way that subprocesses work in Unix.
698
699 LOCAL COMMANDS WITH INLINE EXECUTION
700 If a line starts with <! then the shell command is executed (as for !),
701 but subsequently any output (stdout) of the shell command is parsed and
702 executed as guestfish commands.
703
704 Thus you can use shell script to construct arbitrary guestfish commands
705 which are then parsed by guestfish.
706
707 For example it is tedious to create a sequence of files (eg. /foo.1
708 through /foo.100) using guestfish commands alone. However this is
709 simple if we use a shell script to create the guestfish commands for
710 us:
711
712 <! for n in `seq 1 100`; do echo write /foo.$n $n; done
713
714 or with names like /foo.001:
715
716 <! for n in `seq 1 100`; do printf "write /foo.%03d %d\n" $n $n; done
717
718 When using guestfish interactively it can be helpful to just run the
719 shell script first (ie. remove the initial "<" character so it is just
720 an ordinary ! local command), see what guestfish commands it would run,
721 and when you are happy with those prepend the "<" character to run the
722 guestfish commands for real.
723
725 Use "command <space> | command" to pipe the output of the first command
726 (a guestfish command) to the second command (any host command). For
727 example:
728
729 cat /etc/passwd | awk -F: '$3 == 0 { print }'
730
731 (where "cat" is the guestfish cat command, but "awk" is the host awk
732 program). The above command would list all accounts in the guest
733 filesystem which have UID 0, ie. root accounts including backdoors.
734 Other examples:
735
736 hexdump /bin/ls | head
737 list-devices | tail -1
738 tgz-out / - | tar ztf -
739
740 The space before the pipe symbol is required, any space after the pipe
741 symbol is optional. Everything after the pipe symbol is just passed
742 straight to the host shell, so it can contain redirections, globs and
743 anything else that makes sense on the host side.
744
745 To use a literal argument which begins with a pipe symbol, you have to
746 quote it, eg:
747
748 echo "|"
749
751 If a parameter starts with the character "~" then the tilde may be
752 expanded as a home directory path (either "~" for the current user's
753 home directory, or "~user" for another user).
754
755 Note that home directory expansion happens for users known on the host,
756 not in the guest filesystem.
757
758 To use a literal argument which begins with a tilde, you have to quote
759 it, eg:
760
761 echo "~"
762
764 Libguestfs has some support for Linux guests encrypted according to the
765 Linux Unified Key Setup (LUKS) standard, which includes nearly all
766 whole disk encryption systems used by modern Linux guests, and Windows
767 BitLocker.
768
769 Identify encrypted block devices and partitions using "vfs-type":
770
771 ><fs> vfs-type /dev/sda2
772 crypto_LUKS
773
774 or:
775
776 ><fs> vfs-type /dev/sda2
777 BitLocker
778
779 Then open those devices using "cryptsetup-open". This creates a
780 device-mapper device called /dev/mapper/name.
781
782 ><fs> cryptsetup-open /dev/sda2 name
783 Enter key or passphrase ("key"): <enter the passphrase>
784
785 For Linux guests you have to tell LVM to scan for volume groups on the
786 newly created mapper device:
787
788 vgscan
789 vg-activate-all true
790
791 The filesystems or logical volumes can now be mounted in the usual way.
792
793 Before closing an encrypted device you must unmount any logical volumes
794 on it and deactivate the volume groups by calling "vg-activate false
795 VG" on each one. Then you can close the mapper device:
796
797 vg-activate false /dev/VG
798 cryptsetup-close /dev/mapper/name
799
801 If a path is prefixed with "win:" then you can use Windows-style drive
802 letters and paths (with some limitations). The following commands are
803 equivalent:
804
805 file /WINDOWS/system32/config/system.LOG
806
807 file win:\windows\system32\config\system.log
808
809 file WIN:C:\Windows\SYSTEM32\CONFIG\SYSTEM.LOG
810
811 The parameter is rewritten "behind the scenes" by looking up the
812 position where the drive is mounted, prepending that to the path,
813 changing all backslash characters to forward slash, then resolving the
814 result using "case-sensitive-path". For example if the E: drive was
815 mounted on /e then the parameter might be rewritten like this:
816
817 win:e:\foo\bar => /e/FOO/bar
818
819 This only works in argument positions that expect a path.
820
822 For commands such as "upload", "download", "tar-in", "tar-out" and
823 others which upload from or download to a local file, you can use the
824 special filename "-" to mean "from stdin" or "to stdout". For example:
825
826 upload - /foo
827
828 reads stdin and creates from that a file /foo in the disk image, and:
829
830 tar-out /etc - | tar tf -
831
832 writes the tarball to stdout and then pipes that into the external
833 "tar" command (see "PIPES").
834
835 When using "-" to read from stdin, the input is read up to the end of
836 stdin. You can also use a special "heredoc"-like syntax to read up to
837 some arbitrary end marker:
838
839 upload -<<END /foo
840 input line 1
841 input line 2
842 input line 3
843 END
844
845 Any string of characters can be used instead of "END". The end marker
846 must appear on a line of its own, without any preceding or following
847 characters (not even spaces).
848
849 Note that the "-<<" syntax only applies to parameters used to upload
850 local files (so-called "FileIn" parameters in the generator).
851
853 By default, guestfish will ignore any errors when in interactive mode
854 (ie. taking commands from a human over a tty), and will exit on the
855 first error in non-interactive mode (scripts, commands given on the
856 command line).
857
858 If you prefix a command with a - character, then that command will not
859 cause guestfish to exit, even if that (one) command returns an error.
860
862 Guestfish can be remote-controlled over a socket. This is useful
863 particularly in shell scripts where you want to make several different
864 changes to a filesystem, but you don't want the overhead of starting up
865 a guestfish process each time.
866
867 Start a guestfish server process using:
868
869 eval "`guestfish --listen`"
870
871 and then send it commands by doing:
872
873 guestfish --remote cmd [...]
874
875 To cause the server to exit, send it the exit command:
876
877 guestfish --remote exit
878
879 Note that the server will normally exit if there is an error in a
880 command. You can change this in the usual way. See section "EXIT ON
881 ERROR BEHAVIOUR".
882
883 CONTROLLING MULTIPLE GUESTFISH PROCESSES
884 The "eval" statement sets the environment variable $GUESTFISH_PID,
885 which is how the --remote option knows where to send the commands. You
886 can have several guestfish listener processes running using:
887
888 eval "`guestfish --listen`"
889 pid1=$GUESTFISH_PID
890 eval "`guestfish --listen`"
891 pid2=$GUESTFISH_PID
892 ...
893 guestfish --remote=$pid1 cmd
894 guestfish --remote=$pid2 cmd
895
896 REMOTE CONTROL AND CSH
897 When using csh-like shells (csh, tcsh etc) you have to add the --csh
898 option:
899
900 eval "`guestfish --listen --csh`"
901
902 REMOTE CONTROL DETAILS
903 Remote control happens over a Unix domain socket called
904 /tmp/.guestfish-$UID/socket-$PID, where $UID is the effective user ID
905 of the process, and $PID is the process ID of the server.
906
907 Guestfish client and server versions must match exactly.
908
909 Older versions of guestfish were vulnerable to CVE-2013-4419 (see
910 "CVE-2013-4419" in guestfs(3)). This is fixed in the current version.
911
912 USING REMOTE CONTROL ROBUSTLY FROM SHELL SCRIPTS
913 From Bash, you can use the following code which creates a guestfish
914 instance, correctly quotes the command line, handles failure to start,
915 and cleans up guestfish when the script exits:
916
917 #!/bin/bash -
918
919 set -e
920
921 guestfish[0]="guestfish"
922 guestfish[1]="--listen"
923 guestfish[2]="--ro"
924 guestfish[3]="-a"
925 guestfish[4]="disk.img"
926
927 GUESTFISH_PID=
928 eval $("${guestfish[@]}")
929 if [ -z "$GUESTFISH_PID" ]; then
930 echo "error: guestfish didn't start up, see error messages above"
931 exit 1
932 fi
933
934 cleanup_guestfish ()
935 {
936 guestfish --remote -- exit >/dev/null 2>&1 ||:
937 }
938 trap cleanup_guestfish EXIT ERR
939
940 guestfish --remote -- run
941
942 # ...
943
944 REMOTE CONTROL DOES NOT WORK WITH -a ETC. OPTIONS
945 Options such as -a, --add, -N, --new etc don’t interact properly with
946 remote support. They are processed locally, and not sent through to
947 the remote guestfish. In particular this won't do what you expect:
948
949 guestfish --remote --add disk.img
950
951 Don’t use these options. Use the equivalent commands instead, eg:
952
953 guestfish --remote add-drive disk.img
954
955 or:
956
957 guestfish --remote
958 ><fs> add disk.img
959
960 REMOTE CONTROL RUN COMMAND HANGING
961 Using the "run" (or "launch") command remotely in a command
962 substitution context hangs, ie. don't do (note the backquotes):
963
964 a=`guestfish --remote run`
965
966 Since the "run" command produces no output on stdout, this is not
967 useful anyway. For further information see
968 https://bugzilla.redhat.com/show_bug.cgi?id=592910.
969
971 Use the -N [filename=]type or --new [filename=]type parameter to select
972 one of a set of preformatted disk images that guestfish can make for
973 you to save typing. This is particularly useful for testing purposes.
974 This option is used instead of the -a option, and like -a can appear
975 multiple times (and can be mixed with -a).
976
977 The new disk is called test1.img for the first -N, test2.img for the
978 second and so on. Existing files in the current directory are
979 overwritten. You can use a different filename by specifying
980 "filename=" before the type (see examples below).
981
982 The type briefly describes how the disk should be sized, partitioned,
983 how filesystem(s) should be created, and how content should be added.
984 Optionally the type can be followed by extra parameters, separated by
985 ":" (colon) characters. For example, -N fs creates a default 1G,
986 sparsely-allocated disk, containing a single partition, with the
987 partition formatted as ext2. -N fs:ext4:2G is the same, but for an
988 ext4 filesystem on a 2GB disk instead.
989
990 Note that the prepared filesystem is not mounted. You would usually
991 have to use the "mount /dev/sda1 /" command or add the -m /dev/sda1
992 option.
993
994 If any -N or --new options are given, the libguestfs appliance is
995 automatically launched.
996
997 EXAMPLES
998 Create a 1G disk with an ext4-formatted partition, called test1.img in
999 the current directory:
1000
1001 guestfish -N fs:ext4
1002
1003 Create a 32MB disk with a VFAT-formatted partition, and mount it:
1004
1005 guestfish -N fs:vfat:32M -m /dev/sda1
1006
1007 Create a blank 200MB disk:
1008
1009 guestfish -N disk:200M
1010
1011 Create a blank 200MB disk called blankdisk.img (instead of test1.img):
1012
1013 guestfish -N blankdisk.img=disk:200M
1014
1015 -N disk - create a blank disk
1016 "guestfish -N [filename=]disk[:size]"
1017
1018 Create a blank disk, size 1G (by default).
1019
1020 The default size can be changed by supplying an optional parameter.
1021
1022 The optional parameters are:
1023
1024 Name Default value
1025 size 1G the size of the disk image
1026
1027 -N part - create a partitioned disk
1028 "guestfish -N [filename=]part[:size[:partition]]"
1029
1030 Create a disk with a single partition. By default the size of the disk
1031 is 1G (the available space in the partition will be a tiny bit smaller)
1032 and the partition table will be MBR (old DOS-style).
1033
1034 These defaults can be changed by supplying optional parameters.
1035
1036 The optional parameters are:
1037
1038 Name Default value
1039 size 1G the size of the disk image
1040 partition mbr partition table type
1041
1042 -N fs - create a filesystem
1043 "guestfish -N [filename=]fs[:filesystem[:size[:partition]]]"
1044
1045 Create a disk with a single partition, with the partition containing an
1046 empty filesystem. This defaults to creating a 1G disk (the available
1047 space in the filesystem will be a tiny bit smaller) with an MBR (old
1048 DOS-style) partition table and an ext2 filesystem.
1049
1050 These defaults can be changed by supplying optional parameters.
1051
1052 The optional parameters are:
1053
1054 Name Default value
1055 filesystem ext2 the type of filesystem to use
1056 size 1G the size of the disk image
1057 partition mbr partition table type
1058
1059 -N lv - create a disk with logical volume
1060 "guestfish -N [filename=]lv[:name[:size[:partition]]]"
1061
1062 Create a disk with a single partition, set up the partition as an LVM2
1063 physical volume, and place a volume group and logical volume on there.
1064 This defaults to creating a 1G disk with the VG and LV called
1065 "/dev/VG/LV". You can change the name of the VG and LV by supplying an
1066 alternate name as the first optional parameter.
1067
1068 Note this does not create a filesystem. Use 'lvfs' to do that.
1069
1070 The optional parameters are:
1071
1072 Name Default value
1073 name /dev/VG/LV the name of the VG and LV to use
1074 size 1G the size of the disk image
1075 partition mbr partition table type
1076
1077 -N lvfs - create a disk with logical volume and filesystem
1078 "guestfish -N [filename=]lvfs[:name[:filesystem[:size[:partition]]]]"
1079
1080 Create a disk with a single partition, set up the partition as an LVM2
1081 physical volume, and place a volume group and logical volume on there.
1082 Then format the LV with a filesystem. This defaults to creating a 1G
1083 disk with the VG and LV called "/dev/VG/LV", with an ext2 filesystem.
1084
1085 The optional parameters are:
1086
1087 Name Default value
1088 name /dev/VG/LV the name of the VG and LV to use
1089 filesystem ext2 the type of filesystem to use
1090 size 1G the size of the disk image
1091 partition mbr partition table type
1092
1093 -N bootroot - create a boot and root filesystem
1094 "guestfish -N
1095 [filename=]bootroot[:bootfs[:rootfs[:size[:bootsize[:partition]]]]]"
1096
1097 Create a disk with two partitions, for boot and root filesystem.
1098 Format the two filesystems independently. There are several optional
1099 parameters which control the exact layout and filesystem types.
1100
1101 The optional parameters are:
1102
1103 Name Default value
1104 bootfs ext2 the type of filesystem to use for boot
1105 rootfs ext2 the type of filesystem to use for root
1106 size 1G the size of the disk image
1107 bootsize 128M the size of the boot filesystem
1108 partition mbr partition table type
1109
1110 -N bootrootlv - create a boot and root filesystem using LVM
1111 "guestfish -N
1112 [filename=]bootrootlv[:name[:bootfs[:rootfs[:size[:bootsize[:partition]]]]]]"
1113
1114 This is the same as "bootroot" but the root filesystem (only) is placed
1115 on a logical volume, named by default "/dev/VG/LV". There are several
1116 optional parameters which control the exact layout.
1117
1118 The optional parameters are:
1119
1120 Name Default value
1121 name /dev/VG/LV the name of the VG and LV for root
1122 bootfs ext2 the type of filesystem to use for boot
1123 rootfs ext2 the type of filesystem to use for root
1124 size 1G the size of the disk image
1125 bootsize 128M the size of the boot filesystem
1126 partition mbr partition table type
1127
1129 For API-level documentation on this topic, see "guestfs_add_drive_opts"
1130 in guestfs(3) and "REMOTE STORAGE" in guestfs(3).
1131
1132 On the command line, you can use the -a option to add network block
1133 devices using a URI-style format, for example:
1134
1135 guestfish -a ssh://root@example.com/disk.img
1136
1137 URIs cannot be used with the "add" command. The equivalent command
1138 using the API directly is:
1139
1140 ><fs> add /disk.img protocol:ssh server:tcp:example.com username:root
1141
1142 The possible -a URI formats are described below.
1143
1144 -a disk.img
1145 -a file:///path/to/disk.img
1146 Add the local disk image (or device) called disk.img.
1147
1148 -a ftp://[user@]example.com[:port]/disk.img
1149 -a ftps://[user@]example.com[:port]/disk.img
1150 -a http://[user@]example.com[:port]/disk.img
1151 -a https://[user@]example.com[:port]/disk.img
1152 -a tftp://[user@]example.com[:port]/disk.img
1153 Add a disk located on a remote FTP, HTTP or TFTP server.
1154
1155 The equivalent API command would be:
1156
1157 ><fs> add /disk.img protocol:(ftp|...) server:tcp:example.com
1158
1159 -a gluster://example.com[:port]/volname/image
1160 Add a disk image located on GlusterFS storage.
1161
1162 The server is the one running "glusterd", and may be "localhost".
1163
1164 The equivalent API command would be:
1165
1166 ><fs> add volname/image protocol:gluster server:tcp:example.com
1167
1168 -a iscsi://example.com[:port]/target-iqn-name[/lun]
1169 Add a disk located on an iSCSI server.
1170
1171 The equivalent API command would be:
1172
1173 ><fs> add target-iqn-name/lun protocol:iscsi server:tcp:example.com
1174
1175 -a nbd://example.com[:port]
1176 -a nbd://example.com[:port]/exportname
1177 -a nbd://?socket=/socket
1178 -a nbd:///exportname?socket=/socket
1179 Add a disk located on Network Block Device (nbd) storage.
1180
1181 The exportname part of the URI specifies an NBD export name, but is
1182 usually left empty.
1183
1184 The optional ?socket parameter can be used to specify a Unix domain
1185 socket that we talk to the NBD server over. Note that you cannot mix
1186 server name (ie. TCP/IP) and socket path.
1187
1188 The equivalent API command would be (no export name):
1189
1190 ><fs> add "" protocol:nbd server:[tcp:example.com|unix:/socket]
1191
1192 -a rbd:///pool/disk
1193 -a rbd://example.com[:port]/pool/disk
1194 Add a disk image located on a Ceph (RBD/librbd) storage volume.
1195
1196 Although libguestfs and Ceph supports multiple servers, only a single
1197 server can be specified when using this URI syntax.
1198
1199 The equivalent API command would be:
1200
1201 ><fs> add pool/disk protocol:rbd server:tcp:example.com:port
1202
1203 -a sheepdog://[example.com[:port]]/volume/image
1204 Add a disk image located on a Sheepdog volume.
1205
1206 The server name is optional. Although libguestfs and Sheepdog supports
1207 multiple servers, only at most one server can be specified when using
1208 this URI syntax.
1209
1210 The equivalent API command would be:
1211
1212 ><fs> add volume protocol:sheepdog [server:tcp:example.com]
1213
1214 -a ssh://[user@]example.com[:port]/disk.img
1215 Add a disk image located on a remote server, accessed using the Secure
1216 Shell (ssh) SFTP protocol. SFTP is supported out of the box by all
1217 major SSH servers.
1218
1219 The equivalent API command would be:
1220
1221 ><fs> add /disk protocol:ssh server:tcp:example.com [username:user]
1222
1223 Note that the URIs follow the syntax of RFC 3986: in particular, there
1224 are restrictions on the allowed characters for the various components
1225 of the URI. Characters such as ":", "@", and "/" must be percent-
1226 encoded:
1227
1228 $ guestfish -a ssh://user:pass%40word@example.com/disk.img
1229
1230 In this case, the password is "pass@word".
1231
1233 Some (not all) long-running commands send progress notification
1234 messages as they are running. Guestfish turns these messages into
1235 progress bars.
1236
1237 When a command that supports progress bars takes longer than two
1238 seconds to run, and if progress bars are enabled, then you will see one
1239 appearing below the command:
1240
1241 ><fs> copy-size /large-file /another-file 2048M
1242 / 10% [#####-----------------------------------------] 00:30
1243
1244 The spinner on the left hand side moves round once for every progress
1245 notification received from the backend. This is a (reasonably) golden
1246 assurance that the command is "doing something" even if the progress
1247 bar is not moving, because the command is able to send the progress
1248 notifications. When the bar reaches 100% and the command finishes, the
1249 spinner disappears.
1250
1251 Progress bars are enabled by default when guestfish is used
1252 interactively. You can enable them even for non-interactive modes
1253 using --progress-bars, and you can disable them completely using
1254 --no-progress-bars.
1255
1257 You can change or add colours to the default prompt ("><fs>") by
1258 setting the "GUESTFISH_PS1" environment variable. A second string
1259 ("GUESTFISH_OUTPUT") is printed after the command has been entered and
1260 before the output, allowing you to control the colour of the output. A
1261 third string ("GUESTFISH_INIT") is printed before the welcome message,
1262 allowing you to control the colour of that message. A fourth string
1263 ("GUESTFISH_RESTORE") is printed before guestfish exits.
1264
1265 A simple prompt can be set by setting "GUESTFISH_PS1" to an alternate
1266 string:
1267
1268 $ GUESTFISH_PS1='(type a command) '
1269 $ export GUESTFISH_PS1
1270 $ guestfish
1271 [...]
1272 (type a command) ▂
1273
1274 You can also use special escape sequences, as described in the table
1275 below:
1276
1277 \\ A literal backslash character.
1278
1279 \[
1280 \] (These should only be used in "GUESTFISH_PS1".)
1281
1282 Place non-printing characters (eg. terminal control codes for
1283 colours) between "\[...\]". What this does it to tell the
1284 readline(3) library that it should treat this subsequence as zero-
1285 width, so that command-line redisplay, editing etc works.
1286
1287 \a A bell character.
1288
1289 \e An ASCII ESC (escape) character.
1290
1291 \n A newline.
1292
1293 \r A carriage return.
1294
1295 \NNN
1296 The ASCII character whose code is the octal value NNN.
1297
1298 \xNN
1299 The ASCII character whose code is the hex value NN.
1300
1301 EXAMPLES OF PROMPTS
1302 Note that these examples require a terminal that supports ANSI escape
1303 codes.
1304
1305 •
1306
1307
1308 GUESTFISH_PS1='\[\e[1;30m\]><fs>\[\e[0;30m\] '
1309
1310 A bold black version of the ordinary prompt.
1311
1312 •
1313
1314
1315 GUESTFISH_PS1='\[\e[1;32m\]><fs>\[\e[0;31m\] '
1316 GUESTFISH_OUTPUT='\e[0m'
1317 GUESTFISH_RESTORE="$GUESTFISH_OUTPUT"
1318 GUESTFISH_INIT='\e[1;34m'
1319
1320 Blue welcome text, green prompt, red commands, black command
1321 output.
1322
1324 Windows 8 "fast startup" can prevent guestfish from mounting NTFS
1325 partitions. See "WINDOWS HIBERNATION AND WINDOWS 8 FAST STARTUP" in
1326 guestfs(3).
1327
1329 The commands in this section are guestfish convenience commands, in
1330 other words, they are not part of the guestfs(3) API.
1331
1332 help
1333 help
1334 help cmd
1335 help -l|--list
1336
1337 Without any parameter, this provides general help.
1338
1339 With a "cmd" parameter, this displays detailed help for that command.
1340
1341 With -l or --list, this list all commands.
1342
1343 exit
1344 quit
1345 This exits guestfish. You can also use "^D" key.
1346
1347 alloc
1348 allocate
1349 alloc filename size
1350
1351 This creates an empty (zeroed) file of the given size, and then adds so
1352 it can be further examined.
1353
1354 For more advanced image creation, see "disk-create".
1355
1356 Size can be specified using standard suffixes, eg. "1M".
1357
1358 To create a sparse file, use "sparse" instead. To create a prepared
1359 disk image, see "PREPARED DISK IMAGES".
1360
1361 copy-in
1362 copy-in local [local ...] /remotedir
1363
1364 "copy-in" copies local files or directories recursively into the disk
1365 image, placing them in the directory called /remotedir (which must
1366 exist). This guestfish meta-command turns into a sequence of "tar-in"
1367 and other commands as necessary.
1368
1369 Multiple local files and directories can be specified, but the last
1370 parameter must always be a remote directory. Wildcards cannot be used.
1371
1372 copy-out
1373 copy-out remote [remote ...] localdir
1374
1375 "copy-out" copies remote files or directories recursively out of the
1376 disk image, placing them on the host disk in a local directory called
1377 "localdir" (which must exist). This guestfish meta-command turns into
1378 a sequence of "download", "tar-out" and other commands as necessary.
1379
1380 Multiple remote files and directories can be specified, but the last
1381 parameter must always be a local directory. To download to the current
1382 directory, use "." as in:
1383
1384 copy-out /home .
1385
1386 Wildcards cannot be used in the ordinary command, but you can use them
1387 with the help of "glob" like this:
1388
1389 glob copy-out /home/* .
1390
1391 delete-event
1392 delete-event name
1393
1394 Delete the event handler which was previously registered as "name". If
1395 multiple event handlers were registered with the same name, they are
1396 all deleted.
1397
1398 See also the guestfish commands "event" and "list-events".
1399
1400 display
1401 display filename
1402
1403 Use "display" (a graphical display program) to display an image file.
1404 It downloads the file, and runs "display" on it.
1405
1406 To use an alternative program, set the "GUESTFISH_DISPLAY_IMAGE"
1407 environment variable. For example to use the GNOME display program:
1408
1409 export GUESTFISH_DISPLAY_IMAGE=eog
1410
1411 See also display(1).
1412
1413 echo
1414 echo [params ...]
1415
1416 This echos the parameters to the terminal.
1417
1418 edit
1419 vi
1420 emacs
1421 edit filename
1422
1423 This is used to edit a file. It downloads the file, edits it locally
1424 using your editor, then uploads the result.
1425
1426 The editor is $EDITOR. However if you use the alternate commands "vi"
1427 or "emacs" you will get those corresponding editors.
1428
1429 event
1430 event name eventset "shell script ..."
1431
1432 Register a shell script fragment which is executed when an event is
1433 raised. See "guestfs_set_event_callback" in guestfs(3) for a
1434 discussion of the event API in libguestfs.
1435
1436 The "name" parameter is a name that you give to this event handler. It
1437 can be any string (even the empty string) and is simply there so you
1438 can delete the handler using the guestfish "delete-event" command.
1439
1440 The "eventset" parameter is a comma-separated list of one or more
1441 events, for example "close" or "close,trace". The special value "*"
1442 means all events.
1443
1444 The third and final parameter is the shell script fragment (or any
1445 external command) that is executed when any of the events in the
1446 eventset occurs. It is executed using "$SHELL -c", or if $SHELL is not
1447 set then /bin/sh -c.
1448
1449 The shell script fragment receives callback parameters as arguments $1,
1450 $2 etc. The actual event that was called is available in the
1451 environment variable $EVENT.
1452
1453 event "" close "echo closed"
1454 event messages appliance,library,trace "echo $@"
1455 event "" progress "echo progress: $3/$4"
1456 event "" * "echo $EVENT $@"
1457
1458 See also the guestfish commands "delete-event" and "list-events".
1459
1460 glob
1461 glob command args...
1462
1463 Expand wildcards in any paths in the args list, and run "command"
1464 repeatedly on each matching path.
1465
1466 See "WILDCARDS AND GLOBBING".
1467
1468 hexedit
1469 hexedit <filename|device>
1470 hexedit <filename|device> <max>
1471 hexedit <filename|device> <start> <max>
1472
1473 Use hexedit (a hex editor) to edit all or part of a binary file or
1474 block device.
1475
1476 This command works by downloading potentially the whole file or device,
1477 editing it locally, then uploading it. If the file or device is large,
1478 you have to specify which part you wish to edit by using "max" and/or
1479 "start" "max" parameters. "start" and "max" are specified in bytes,
1480 with the usual modifiers allowed such as "1M" (1 megabyte).
1481
1482 For example to edit the first few sectors of a disk you might do:
1483
1484 hexedit /dev/sda 1M
1485
1486 which would allow you to edit anywhere within the first megabyte of the
1487 disk.
1488
1489 To edit the superblock of an ext2 filesystem on /dev/sda1, do:
1490
1491 hexedit /dev/sda1 0x400 0x400
1492
1493 (assuming the superblock is in the standard location).
1494
1495 This command requires the external hexedit(1) program. You can specify
1496 another program to use by setting the "HEXEDITOR" environment variable.
1497
1498 See also "hexdump".
1499
1500 lcd
1501 lcd directory
1502
1503 Change the local directory, ie. the current directory of guestfish
1504 itself.
1505
1506 Note that "!cd" won't do what you might expect.
1507
1508 list-events
1509 list-events
1510
1511 List the event handlers registered using the guestfish "event" command.
1512
1513 man
1514 manual
1515 man
1516
1517 Opens the manual page for guestfish.
1518
1519 more
1520 less
1521 more filename
1522
1523 less filename
1524
1525 This is used to view a file.
1526
1527 The default viewer is $PAGER. However if you use the alternate command
1528 "less" you will get the "less" command specifically.
1529
1530 reopen
1531 reopen
1532
1533 Close and reopen the libguestfs handle. It is not necessary to use
1534 this normally, because the handle is closed properly when guestfish
1535 exits. However this is occasionally useful for testing.
1536
1537 setenv
1538 setenv VAR value
1539
1540 Set the environment variable "VAR" to the string "value".
1541
1542 To print the value of an environment variable use a shell command such
1543 as:
1544
1545 !echo $VAR
1546
1547 sparse
1548 sparse filename size
1549
1550 This creates an empty sparse file of the given size, and then adds so
1551 it can be further examined.
1552
1553 In all respects it works the same as the "alloc" command, except that
1554 the image file is allocated sparsely, which means that disk blocks are
1555 not assigned to the file until they are needed. Sparse disk files only
1556 use space when written to, but they are slower and there is a danger
1557 you could run out of real disk space during a write operation.
1558
1559 For more advanced image creation, see "disk-create".
1560
1561 Size can be specified using standard suffixes, eg. "1M".
1562
1563 See also the guestfish "scratch" command.
1564
1565 supported
1566 supported
1567
1568 This command returns a list of the optional groups known to the daemon,
1569 and indicates which ones are supported by this build of the libguestfs
1570 appliance.
1571
1572 See also "AVAILABILITY" in guestfs(3).
1573
1574 time
1575 time command args...
1576
1577 Run the command as usual, but print the elapsed time afterwards. This
1578 can be useful for benchmarking operations.
1579
1580 unsetenv
1581 unsetenv VAR
1582
1583 Remove "VAR" from the environment.
1584
1586 acl-delete-def-file
1587 acl-delete-def-file dir
1588
1589 This function deletes the default POSIX Access Control List (ACL)
1590 attached to directory "dir".
1591
1592 This command depends on the feature "acl". See also "feature-
1593 available".
1594
1595 acl-get-file
1596 acl-get-file path acltype
1597
1598 This function returns the POSIX Access Control List (ACL) attached to
1599 "path". The ACL is returned in "long text form" (see acl(5)).
1600
1601 The "acltype" parameter may be:
1602
1603 "access"
1604 Return the ordinary (access) ACL for any file, directory or other
1605 filesystem object.
1606
1607 "default"
1608 Return the default ACL. Normally this only makes sense if "path"
1609 is a directory.
1610
1611 This command depends on the feature "acl". See also "feature-
1612 available".
1613
1614 acl-set-file
1615 acl-set-file path acltype acl
1616
1617 This function sets the POSIX Access Control List (ACL) attached to
1618 "path".
1619
1620 The "acltype" parameter may be:
1621
1622 "access"
1623 Set the ordinary (access) ACL for any file, directory or other
1624 filesystem object.
1625
1626 "default"
1627 Set the default ACL. Normally this only makes sense if "path" is a
1628 directory.
1629
1630 The "acl" parameter is the new ACL in either "long text form" or "short
1631 text form" (see acl(5)). The new ACL completely replaces any previous
1632 ACL on the file. The ACL must contain the full Unix permissions (eg.
1633 "u::rwx,g::rx,o::rx").
1634
1635 If you are specifying individual users or groups, then the mask field
1636 is also required (eg. "m::rwx"), followed by the "u:ID:..." and/or
1637 "g:ID:..." field(s). A full ACL string might therefore look like this:
1638
1639 u::rwx,g::rwx,o::rwx,m::rwx,u:500:rwx,g:500:rwx
1640 \ Unix permissions / \mask/ \ ACL /
1641
1642 You should use numeric UIDs and GIDs. To map usernames and groupnames
1643 to the correct numeric ID in the context of the guest, use the Augeas
1644 functions (see "aug-init").
1645
1646 This command depends on the feature "acl". See also "feature-
1647 available".
1648
1649 add-cdrom
1650 add-cdrom filename
1651
1652 This function adds a virtual CD-ROM disk image to the guest.
1653
1654 The image is added as read-only drive, so this function is equivalent
1655 of "add-drive-ro".
1656
1657 This function is deprecated. In new code, use the "add-drive-ro" call
1658 instead.
1659
1660 Deprecated functions will not be removed from the API, but the fact
1661 that they are deprecated indicates that there are problems with correct
1662 use of these functions.
1663
1664 add-domain
1665 domain
1666 add-domain dom [libvirturi:..] [readonly:true|false] [iface:..] [live:true|false] [allowuuid:true|false] [readonlydisk:..] [cachemode:..] [discard:..] [copyonread:true|false]
1667
1668 This function adds the disk(s) attached to the named libvirt domain
1669 "dom". It works by connecting to libvirt, requesting the domain and
1670 domain XML from libvirt, parsing it for disks, and calling "add-drive-
1671 opts" on each one.
1672
1673 The number of disks added is returned. This operation is atomic: if an
1674 error is returned, then no disks are added.
1675
1676 This function does some minimal checks to make sure the libvirt domain
1677 is not running (unless "readonly" is true). In a future version we
1678 will try to acquire the libvirt lock on each disk.
1679
1680 Disks must be accessible locally. This often means that adding disks
1681 from a remote libvirt connection (see https://libvirt.org/remote.html)
1682 will fail unless those disks are accessible via the same device path
1683 locally too.
1684
1685 The optional "libvirturi" parameter sets the libvirt URI (see
1686 https://libvirt.org/uri.html). If this is not set then we connect to
1687 the default libvirt URI (or one set through an environment variable,
1688 see the libvirt documentation for full details).
1689
1690 The optional "live" flag is ignored in libguestfs ≥ 1.48.
1691
1692 If the "allowuuid" flag is true (default is false) then a UUID may be
1693 passed instead of the domain name. The "dom" string is treated as a
1694 UUID first and looked up, and if that lookup fails then we treat "dom"
1695 as a name as usual.
1696
1697 The optional "readonlydisk" parameter controls what we do for disks
1698 which are marked <readonly/> in the libvirt XML. Possible values are:
1699
1700 readonlydisk = "error"
1701 If "readonly" is false:
1702
1703 The whole call is aborted with an error if any disk with the
1704 <readonly/> flag is found.
1705
1706 If "readonly" is true:
1707
1708 Disks with the <readonly/> flag are added read-only.
1709
1710 readonlydisk = "read"
1711 If "readonly" is false:
1712
1713 Disks with the <readonly/> flag are added read-only. Other disks
1714 are added read/write.
1715
1716 If "readonly" is true:
1717
1718 Disks with the <readonly/> flag are added read-only.
1719
1720 readonlydisk = "write" (default)
1721 If "readonly" is false:
1722
1723 Disks with the <readonly/> flag are added read/write.
1724
1725 If "readonly" is true:
1726
1727 Disks with the <readonly/> flag are added read-only.
1728
1729 readonlydisk = "ignore"
1730 If "readonly" is true or false:
1731
1732 Disks with the <readonly/> flag are skipped.
1733
1734 If present, the value of "logical_block_size" attribute of <blockio/>
1735 tag in libvirt XML will be passed as "blocksize" parameter to "add-
1736 drive-opts".
1737
1738 The other optional parameters are passed directly through to "add-
1739 drive-opts".
1740
1741 This command has one or more optional arguments. See "OPTIONAL
1742 ARGUMENTS".
1743
1744 add-drive
1745 add
1746 add-drive-opts
1747 add-drive filename [readonly:true|false] [format:..] [iface:..] [name:..] [label:..] [protocol:..] [server:..] [username:..] [secret:..] [cachemode:..] [discard:..] [copyonread:true|false] [blocksize:N]
1748
1749 This function adds a disk image called filename to the handle.
1750 filename may be a regular host file or a host device.
1751
1752 When this function is called before "launch" (the usual case) then the
1753 first time you call this function, the disk appears in the API as
1754 /dev/sda, the second time as /dev/sdb, and so on.
1755
1756 You don't necessarily need to be root when using libguestfs. However
1757 you obviously do need sufficient permissions to access the filename for
1758 whatever operations you want to perform (ie. read access if you just
1759 want to read the image or write access if you want to modify the
1760 image).
1761
1762 This call checks that filename exists.
1763
1764 filename may be the special string "/dev/null". See "NULL DISKS" in
1765 guestfs(3).
1766
1767 The optional arguments are:
1768
1769 "readonly"
1770 If true then the image is treated as read-only. Writes are still
1771 allowed, but they are stored in a temporary snapshot overlay which
1772 is discarded at the end. The disk that you add is not modified.
1773
1774 "format"
1775 This forces the image format. If you omit this (or use "add-drive"
1776 or "add-drive-ro") then the format is automatically detected.
1777 Possible formats include "raw" and "qcow2".
1778
1779 Automatic detection of the format opens you up to a potential
1780 security hole when dealing with untrusted raw-format images. See
1781 CVE-2010-3851 and RHBZ#642934. Specifying the format closes this
1782 security hole.
1783
1784 "iface"
1785 This rarely-used option lets you emulate the behaviour of the
1786 deprecated "add-drive-with-if" call (q.v.)
1787
1788 "name"
1789 This field used to be passed as a hint for guest inspection, but it
1790 is no longer used.
1791
1792 "label"
1793 Give the disk a label. The label should be a unique, short string
1794 using only ASCII characters "[a-zA-Z]". As well as its usual name
1795 in the API (such as /dev/sda), the drive will also be named
1796 /dev/disk/guestfs/label.
1797
1798 See "DISK LABELS" in guestfs(3).
1799
1800 "protocol"
1801 The optional protocol argument can be used to select an alternate
1802 source protocol.
1803
1804 See also: "REMOTE STORAGE" in guestfs(3).
1805
1806 "protocol = "file""
1807 filename is interpreted as a local file or device. This is the
1808 default if the optional protocol parameter is omitted.
1809
1810 "protocol = "ftp"|"ftps"|"http"|"https"|"tftp""
1811 Connect to a remote FTP, HTTP or TFTP server. The "server"
1812 parameter must also be supplied - see below.
1813
1814 See also: "FTP, HTTP AND TFTP" in guestfs(3)
1815
1816 "protocol = "gluster""
1817 Connect to the GlusterFS server. The "server" parameter must
1818 also be supplied - see below.
1819
1820 See also: "GLUSTER" in guestfs(3)
1821
1822 "protocol = "iscsi""
1823 Connect to the iSCSI server. The "server" parameter must also
1824 be supplied - see below. The "username" parameter may be
1825 supplied. See below. The "secret" parameter may be supplied.
1826 See below.
1827
1828 See also: "ISCSI" in guestfs(3).
1829
1830 "protocol = "nbd""
1831 Connect to the Network Block Device server. The "server"
1832 parameter must also be supplied - see below.
1833
1834 See also: "NETWORK BLOCK DEVICE" in guestfs(3).
1835
1836 "protocol = "rbd""
1837 Connect to the Ceph (librbd/RBD) server. The "server"
1838 parameter must also be supplied - see below. The "username"
1839 parameter may be supplied. See below. The "secret" parameter
1840 may be supplied. See below.
1841
1842 See also: "CEPH" in guestfs(3).
1843
1844 "protocol = "sheepdog""
1845 Connect to the Sheepdog server. The "server" parameter may
1846 also be supplied - see below.
1847
1848 See also: "SHEEPDOG" in guestfs(3).
1849
1850 "protocol = "ssh""
1851 Connect to the Secure Shell (ssh) server.
1852
1853 The "server" parameter must be supplied. The "username"
1854 parameter may be supplied. See below.
1855
1856 See also: "SSH" in guestfs(3).
1857
1858 "server"
1859 For protocols which require access to a remote server, this is a
1860 list of server(s).
1861
1862 Protocol Number of servers required
1863 -------- --------------------------
1864 file List must be empty or param not used at all
1865 ftp|ftps|http|https|tftp Exactly one
1866 gluster Exactly one
1867 iscsi Exactly one
1868 nbd Exactly one
1869 rbd Zero or more
1870 sheepdog Zero or more
1871 ssh Exactly one
1872
1873 Each list element is a string specifying a server. The string must
1874 be in one of the following formats:
1875
1876 hostname
1877 hostname:port
1878 tcp:hostname
1879 tcp:hostname:port
1880 unix:/path/to/socket
1881
1882 If the port number is omitted, then the standard port number for
1883 the protocol is used (see /etc/services).
1884
1885 "username"
1886 For the "ftp", "ftps", "http", "https", "iscsi", "rbd", "ssh" and
1887 "tftp" protocols, this specifies the remote username.
1888
1889 If not given, then the local username is used for "ssh", and no
1890 authentication is attempted for ceph. But note this sometimes may
1891 give unexpected results, for example if using the libvirt backend
1892 and if the libvirt backend is configured to start the qemu
1893 appliance as a special user such as "qemu.qemu". If in doubt,
1894 specify the remote username you want.
1895
1896 "secret"
1897 For the "rbd" protocol only, this specifies the ‘secret’ to use
1898 when connecting to the remote device. It must be base64 encoded.
1899
1900 If not given, then a secret matching the given username will be
1901 looked up in the default keychain locations, or if no username is
1902 given, then no authentication will be used.
1903
1904 "cachemode"
1905 Choose whether or not libguestfs will obey sync operations (safe
1906 but slow) or not (unsafe but fast). The possible values for this
1907 string are:
1908
1909 "cachemode = "writeback""
1910 This is the default.
1911
1912 Write operations in the API do not return until a write(2) call
1913 has completed in the host [but note this does not imply that
1914 anything gets written to disk].
1915
1916 Sync operations in the API, including implicit syncs caused by
1917 filesystem journalling, will not return until an fdatasync(2)
1918 call has completed in the host, indicating that data has been
1919 committed to disk.
1920
1921 "cachemode = "unsafe""
1922 In this mode, there are no guarantees. Libguestfs may cache
1923 anything and ignore sync requests. This is suitable only for
1924 scratch or temporary disks.
1925
1926 "discard"
1927 Enable or disable discard (a.k.a. trim or unmap) support on this
1928 drive. If enabled, operations such as "fstrim" will be able to
1929 discard / make thin / punch holes in the underlying host file or
1930 device.
1931
1932 Possible discard settings are:
1933
1934 "discard = "disable""
1935 Disable discard support. This is the default.
1936
1937 "discard = "enable""
1938 Enable discard support. Fail if discard is not possible.
1939
1940 "discard = "besteffort""
1941 Enable discard support if possible, but don't fail if it is not
1942 supported.
1943
1944 Since not all backends and not all underlying systems support
1945 discard, this is a good choice if you want to use discard if
1946 possible, but don't mind if it doesn't work.
1947
1948 "copyonread"
1949 The boolean parameter "copyonread" enables copy-on-read support.
1950 This only affects disk formats which have backing files, and causes
1951 reads to be stored in the overlay layer, speeding up multiple reads
1952 of the same area of disk.
1953
1954 The default is false.
1955
1956 "blocksize"
1957 This parameter sets the sector size of the disk. Possible values
1958 are 512 (the default if the parameter is omitted) or 4096. Use
1959 4096 when handling an "Advanced Format" disk that uses 4K sector
1960 size (https://en.wikipedia.org/wiki/Advanced_Format).
1961
1962 Only a subset of the backends support this parameter (currently
1963 only the libvirt and direct backends do).
1964
1965 This command has one or more optional arguments. See "OPTIONAL
1966 ARGUMENTS".
1967
1968 add-drive-ro
1969 add-ro
1970 add-drive-ro filename
1971
1972 This function is the equivalent of calling "add-drive-opts" with the
1973 optional parameter "GUESTFS_ADD_DRIVE_OPTS_READONLY" set to 1, so the
1974 disk is added read-only, with the format being detected automatically.
1975
1976 add-drive-ro-with-if
1977 add-drive-ro-with-if filename iface
1978
1979 This is the same as "add-drive-ro" but it allows you to specify the
1980 QEMU interface emulation to use at run time. Both the direct and the
1981 libvirt backends ignore "iface".
1982
1983 This function is deprecated. In new code, use the "add-drive" call
1984 instead.
1985
1986 Deprecated functions will not be removed from the API, but the fact
1987 that they are deprecated indicates that there are problems with correct
1988 use of these functions.
1989
1990 add-drive-scratch
1991 scratch
1992 add-drive-scratch size [name:..] [label:..] [blocksize:N]
1993
1994 This command adds a temporary scratch drive to the handle. The "size"
1995 parameter is the virtual size (in bytes). The scratch drive is blank
1996 initially (all reads return zeroes until you start writing to it). The
1997 drive is deleted when the handle is closed.
1998
1999 The optional arguments "name", "label" and "blocksize" are passed
2000 through to "add-drive-opts".
2001
2002 This command has one or more optional arguments. See "OPTIONAL
2003 ARGUMENTS".
2004
2005 add-drive-with-if
2006 add-drive-with-if filename iface
2007
2008 This is the same as "add-drive" but it allows you to specify the QEMU
2009 interface emulation to use at run time. Both the direct and the
2010 libvirt backends ignore "iface".
2011
2012 This function is deprecated. In new code, use the "add-drive" call
2013 instead.
2014
2015 Deprecated functions will not be removed from the API, but the fact
2016 that they are deprecated indicates that there are problems with correct
2017 use of these functions.
2018
2019 aug-clear
2020 aug-clear augpath
2021
2022 Set the value associated with "path" to "NULL". This is the same as
2023 the augtool(1) "clear" command.
2024
2025 aug-close
2026 aug-close
2027
2028 Close the current Augeas handle and free up any resources used by it.
2029 After calling this, you have to call "aug-init" again before you can
2030 use any other Augeas functions.
2031
2032 aug-defnode
2033 aug-defnode name expr val
2034
2035 Defines a variable "name" whose value is the result of evaluating
2036 "expr".
2037
2038 If "expr" evaluates to an empty nodeset, a node is created, equivalent
2039 to calling "aug-set" "expr", "val". "name" will be the nodeset
2040 containing that single node.
2041
2042 On success this returns a pair containing the number of nodes in the
2043 nodeset, and a boolean flag if a node was created.
2044
2045 aug-defvar
2046 aug-defvar name expr
2047
2048 Defines an Augeas variable "name" whose value is the result of
2049 evaluating "expr". If "expr" is NULL, then "name" is undefined.
2050
2051 On success this returns the number of nodes in "expr", or 0 if "expr"
2052 evaluates to something which is not a nodeset.
2053
2054 aug-get
2055 aug-get augpath
2056
2057 Look up the value associated with "path". If "path" matches exactly
2058 one node, the "value" is returned.
2059
2060 aug-init
2061 aug-init root flags
2062
2063 Create a new Augeas handle for editing configuration files. If there
2064 was any previous Augeas handle associated with this guestfs session,
2065 then it is closed.
2066
2067 You must call this before using any other "aug-*" commands.
2068
2069 "root" is the filesystem root. "root" must not be NULL, use / instead.
2070
2071 The flags are the same as the flags defined in <augeas.h>, the logical
2072 or of the following integers:
2073
2074 "AUG_SAVE_BACKUP" = 1
2075 Keep the original file with a ".augsave" extension.
2076
2077 "AUG_SAVE_NEWFILE" = 2
2078 Save changes into a file with extension ".augnew", and do not
2079 overwrite original. Overrides "AUG_SAVE_BACKUP".
2080
2081 "AUG_TYPE_CHECK" = 4
2082 Typecheck lenses.
2083
2084 This option is only useful when debugging Augeas lenses. Use of
2085 this option may require additional memory for the libguestfs
2086 appliance. You may need to set the "LIBGUESTFS_MEMSIZE"
2087 environment variable or call "set-memsize".
2088
2089 "AUG_NO_STDINC" = 8
2090 Do not use standard load path for modules.
2091
2092 "AUG_SAVE_NOOP" = 16
2093 Make save a no-op, just record what would have been changed.
2094
2095 "AUG_NO_LOAD" = 32
2096 Do not load the tree in "aug-init".
2097
2098 To close the handle, you can call "aug-close".
2099
2100 To find out more about Augeas, see http://augeas.net/.
2101
2102 aug-insert
2103 aug-insert augpath label true|false
2104
2105 Create a new sibling "label" for "path", inserting it into the tree
2106 before or after "path" (depending on the boolean flag "before").
2107
2108 "path" must match exactly one existing node in the tree, and "label"
2109 must be a label, ie. not contain /, "*" or end with a bracketed index
2110 "[N]".
2111
2112 aug-label
2113 aug-label augpath
2114
2115 The label (name of the last element) of the Augeas path expression
2116 "augpath" is returned. "augpath" must match exactly one node, else
2117 this function returns an error.
2118
2119 aug-load
2120 aug-load
2121
2122 Load files into the tree.
2123
2124 See "aug_load" in the Augeas documentation for the full gory details.
2125
2126 aug-ls
2127 aug-ls augpath
2128
2129 This is just a shortcut for listing "aug-match" "path/*" and sorting
2130 the resulting nodes into alphabetical order.
2131
2132 aug-match
2133 aug-match augpath
2134
2135 Returns a list of paths which match the path expression "path". The
2136 returned paths are sufficiently qualified so that they match exactly
2137 one node in the current tree.
2138
2139 aug-mv
2140 aug-mv src dest
2141
2142 Move the node "src" to "dest". "src" must match exactly one node.
2143 "dest" is overwritten if it exists.
2144
2145 aug-rm
2146 aug-rm augpath
2147
2148 Remove "path" and all of its children.
2149
2150 On success this returns the number of entries which were removed.
2151
2152 aug-save
2153 aug-save
2154
2155 This writes all pending changes to disk.
2156
2157 The flags which were passed to "aug-init" affect exactly how files are
2158 saved.
2159
2160 aug-set
2161 aug-set augpath val
2162
2163 Set the value associated with "augpath" to "val".
2164
2165 In the Augeas API, it is possible to clear a node by setting the value
2166 to NULL. Due to an oversight in the libguestfs API you cannot do that
2167 with this call. Instead you must use the "aug-clear" call.
2168
2169 aug-setm
2170 aug-setm base sub val
2171
2172 Change multiple Augeas nodes in a single operation. "base" is an
2173 expression matching multiple nodes. "sub" is a path expression
2174 relative to "base". All nodes matching "base" are found, and then for
2175 each node, "sub" is changed to "val". "sub" may also be "NULL" in
2176 which case the "base" nodes are modified.
2177
2178 This returns the number of nodes modified.
2179
2180 aug-transform
2181 aug-transform lens file [remove:true|false]
2182
2183 Add an Augeas transformation for the specified "lens" so it can handle
2184 "file".
2185
2186 If "remove" is true ("false" by default), then the transformation is
2187 removed.
2188
2189 This command has one or more optional arguments. See "OPTIONAL
2190 ARGUMENTS".
2191
2192 available
2193 available 'groups ...'
2194
2195 This command is used to check the availability of some groups of
2196 functionality in the appliance, which not all builds of the libguestfs
2197 appliance will be able to provide.
2198
2199 The libguestfs groups, and the functions that those groups correspond
2200 to, are listed in "AVAILABILITY" in guestfs(3). You can also fetch
2201 this list at runtime by calling "available-all-groups".
2202
2203 The argument "groups" is a list of group names, eg: "["inotify",
2204 "augeas"]" would check for the availability of the Linux inotify
2205 functions and Augeas (configuration file editing) functions.
2206
2207 The command returns no error if all requested groups are available.
2208
2209 It fails with an error if one or more of the requested groups is
2210 unavailable in the appliance.
2211
2212 If an unknown group name is included in the list of groups then an
2213 error is always returned.
2214
2215 Notes:
2216
2217 • "feature-available" is the same as this call, but with a slightly
2218 simpler to use API: that call returns a boolean true/false instead
2219 of throwing an error.
2220
2221 • You must call "launch" before calling this function.
2222
2223 The reason is because we don't know what groups are supported by
2224 the appliance/daemon until it is running and can be queried.
2225
2226 • If a group of functions is available, this does not necessarily
2227 mean that they will work. You still have to check for errors when
2228 calling individual API functions even if they are available.
2229
2230 • It is usually the job of distro packagers to build complete
2231 functionality into the libguestfs appliance. Upstream libguestfs,
2232 if built from source with all requirements satisfied, will support
2233 everything.
2234
2235 • This call was added in version 1.0.80. In previous versions of
2236 libguestfs all you could do would be to speculatively execute a
2237 command to find out if the daemon implemented it. See also
2238 "version".
2239
2240 See also "filesystem-available".
2241
2242 available-all-groups
2243 available-all-groups
2244
2245 This command returns a list of all optional groups that this daemon
2246 knows about. Note this returns both supported and unsupported groups.
2247 To find out which ones the daemon can actually support you have to call
2248 "available" / "feature-available" on each member of the returned list.
2249
2250 See also "available", "feature-available" and "AVAILABILITY" in
2251 guestfs(3).
2252
2253 base64-in
2254 base64-in (base64file|-) filename
2255
2256 This command uploads base64-encoded data from "base64file" to filename.
2257
2258 Use "-" instead of a filename to read/write from stdin/stdout.
2259
2260 base64-out
2261 base64-out filename (base64file|-)
2262
2263 This command downloads the contents of filename, writing it out to
2264 local file "base64file" encoded as base64.
2265
2266 Use "-" instead of a filename to read/write from stdin/stdout.
2267
2268 blkdiscard
2269 blkdiscard device
2270
2271 This discards all blocks on the block device "device", giving the free
2272 space back to the host.
2273
2274 This operation requires support in libguestfs, the host filesystem,
2275 qemu and the host kernel. If this support isn't present it may give an
2276 error or even appear to run but do nothing. You must also set the
2277 "discard" attribute on the underlying drive (see "add-drive-opts").
2278
2279 This command depends on the feature "blkdiscard". See also "feature-
2280 available".
2281
2282 blkdiscardzeroes
2283 blkdiscardzeroes device
2284
2285 This call returns true if blocks on "device" that have been discarded
2286 by a call to "blkdiscard" are returned as blocks of zero bytes when
2287 read the next time.
2288
2289 If it returns false, then it may be that discarded blocks are read as
2290 stale or random data.
2291
2292 This command depends on the feature "blkdiscardzeroes". See also
2293 "feature-available".
2294
2295 blkid
2296 blkid device
2297
2298 This command returns block device attributes for "device". The
2299 following fields are usually present in the returned hash. Other fields
2300 may also be present.
2301
2302 "UUID"
2303 The uuid of this device.
2304
2305 "LABEL"
2306 The label of this device.
2307
2308 "VERSION"
2309 The version of blkid command.
2310
2311 "TYPE"
2312 The filesystem type or RAID of this device.
2313
2314 "USAGE"
2315 The usage of this device, for example "filesystem" or "raid".
2316
2317 blockdev-flushbufs
2318 blockdev-flushbufs device
2319
2320 This tells the kernel to flush internal buffers associated with
2321 "device".
2322
2323 This uses the blockdev(8) command.
2324
2325 blockdev-getbsz
2326 blockdev-getbsz device
2327
2328 This returns the block size of a device.
2329
2330 Note: this is different from both size in blocks and filesystem block
2331 size. Also this setting is not really used by anything. You should
2332 probably not use it for anything. Filesystems have their own idea
2333 about what block size to choose.
2334
2335 This uses the blockdev(8) command.
2336
2337 blockdev-getro
2338 blockdev-getro device
2339
2340 Returns a boolean indicating if the block device is read-only (true if
2341 read-only, false if not).
2342
2343 This uses the blockdev(8) command.
2344
2345 blockdev-getsize64
2346 blockdev-getsize64 device
2347
2348 This returns the size of the device in bytes.
2349
2350 See also "blockdev-getsz".
2351
2352 This uses the blockdev(8) command.
2353
2354 blockdev-getss
2355 blockdev-getss device
2356
2357 This returns the size of sectors on a block device. Usually 512, but
2358 can be larger for modern devices.
2359
2360 (Note, this is not the size in sectors, use "blockdev-getsz" for that).
2361
2362 This uses the blockdev(8) command.
2363
2364 blockdev-getsz
2365 blockdev-getsz device
2366
2367 This returns the size of the device in units of 512-byte sectors (even
2368 if the sectorsize isn't 512 bytes ... weird).
2369
2370 See also "blockdev-getss" for the real sector size of the device, and
2371 "blockdev-getsize64" for the more useful size in bytes.
2372
2373 This uses the blockdev(8) command.
2374
2375 blockdev-rereadpt
2376 blockdev-rereadpt device
2377
2378 Reread the partition table on "device".
2379
2380 This uses the blockdev(8) command.
2381
2382 blockdev-setbsz
2383 blockdev-setbsz device blocksize
2384
2385 This call does nothing and has never done anything because of a bug in
2386 blockdev. Do not use it.
2387
2388 If you need to set the filesystem block size, use the "blocksize"
2389 option of "mkfs".
2390
2391 This function is deprecated. There is no replacement. Consult the API
2392 documentation in guestfs(3) for further information.
2393
2394 Deprecated functions will not be removed from the API, but the fact
2395 that they are deprecated indicates that there are problems with correct
2396 use of these functions.
2397
2398 blockdev-setra
2399 blockdev-setra device sectors
2400
2401 Set readahead (in 512-byte sectors) for the device.
2402
2403 This uses the blockdev(8) command.
2404
2405 blockdev-setro
2406 blockdev-setro device
2407
2408 Sets the block device named "device" to read-only.
2409
2410 This uses the blockdev(8) command.
2411
2412 blockdev-setrw
2413 blockdev-setrw device
2414
2415 Sets the block device named "device" to read-write.
2416
2417 This uses the blockdev(8) command.
2418
2419 btrfs-balance-cancel
2420 btrfs-balance-cancel path
2421
2422 Cancel a running balance on a btrfs filesystem.
2423
2424 This command depends on the feature "btrfs". See also "feature-
2425 available".
2426
2427 btrfs-balance-pause
2428 btrfs-balance-pause path
2429
2430 Pause a running balance on a btrfs filesystem.
2431
2432 This command depends on the feature "btrfs". See also "feature-
2433 available".
2434
2435 btrfs-balance-resume
2436 btrfs-balance-resume path
2437
2438 Resume a paused balance on a btrfs filesystem.
2439
2440 This command depends on the feature "btrfs". See also "feature-
2441 available".
2442
2443 btrfs-balance-status
2444 btrfs-balance-status path
2445
2446 Show the status of a running or paused balance on a btrfs filesystem.
2447
2448 This command depends on the feature "btrfs". See also "feature-
2449 available".
2450
2451 btrfs-device-add
2452 btrfs-device-add 'devices ...' fs
2453
2454 Add the list of device(s) in "devices" to the btrfs filesystem mounted
2455 at "fs". If "devices" is an empty list, this does nothing.
2456
2457 This command depends on the feature "btrfs". See also "feature-
2458 available".
2459
2460 btrfs-device-delete
2461 btrfs-device-delete 'devices ...' fs
2462
2463 Remove the "devices" from the btrfs filesystem mounted at "fs". If
2464 "devices" is an empty list, this does nothing.
2465
2466 This command depends on the feature "btrfs". See also "feature-
2467 available".
2468
2469 btrfs-filesystem-balance
2470 btrfs-balance
2471 btrfs-filesystem-balance fs
2472
2473 Balance the chunks in the btrfs filesystem mounted at "fs" across the
2474 underlying devices.
2475
2476 This command depends on the feature "btrfs". See also "feature-
2477 available".
2478
2479 btrfs-filesystem-defragment
2480 btrfs-filesystem-defragment path [flush:true|false] [compress:..]
2481
2482 Defragment a file or directory on a btrfs filesystem. compress is one
2483 of zlib or lzo.
2484
2485 This command has one or more optional arguments. See "OPTIONAL
2486 ARGUMENTS".
2487
2488 This command depends on the feature "btrfs". See also "feature-
2489 available".
2490
2491 btrfs-filesystem-resize
2492 btrfs-filesystem-resize mountpoint [size:N]
2493
2494 This command resizes a btrfs filesystem.
2495
2496 Note that unlike other resize calls, the filesystem has to be mounted
2497 and the parameter is the mountpoint not the device (this is a
2498 requirement of btrfs itself).
2499
2500 The optional parameters are:
2501
2502 "size"
2503 The new size (in bytes) of the filesystem. If omitted, the
2504 filesystem is resized to the maximum size.
2505
2506 See also btrfs(8).
2507
2508 This command has one or more optional arguments. See "OPTIONAL
2509 ARGUMENTS".
2510
2511 This command depends on the feature "btrfs". See also "feature-
2512 available".
2513
2514 btrfs-filesystem-show
2515 btrfs-filesystem-show device
2516
2517 Show all the devices where the filesystems in "device" is spanned over.
2518
2519 If not all the devices for the filesystems are present, then this
2520 function fails and the "errno" is set to "ENODEV".
2521
2522 This command depends on the feature "btrfs". See also "feature-
2523 available".
2524
2525 btrfs-filesystem-sync
2526 btrfs-filesystem-sync fs
2527
2528 Force sync on the btrfs filesystem mounted at "fs".
2529
2530 This command depends on the feature "btrfs". See also "feature-
2531 available".
2532
2533 btrfs-fsck
2534 btrfs-fsck device [superblock:N] [repair:true|false]
2535
2536 Used to check a btrfs filesystem, "device" is the device file where the
2537 filesystem is stored.
2538
2539 This command has one or more optional arguments. See "OPTIONAL
2540 ARGUMENTS".
2541
2542 This command depends on the feature "btrfs". See also "feature-
2543 available".
2544
2545 btrfs-image
2546 btrfs-image 'source ...' image [compresslevel:N]
2547
2548 This is used to create an image of a btrfs filesystem. All data will
2549 be zeroed, but metadata and the like is preserved.
2550
2551 This command has one or more optional arguments. See "OPTIONAL
2552 ARGUMENTS".
2553
2554 This command depends on the feature "btrfs". See also "feature-
2555 available".
2556
2557 btrfs-qgroup-assign
2558 btrfs-qgroup-assign src dst path
2559
2560 Add qgroup "src" to parent qgroup "dst". This command can group several
2561 qgroups into a parent qgroup to share common limit.
2562
2563 This command depends on the feature "btrfs". See also "feature-
2564 available".
2565
2566 btrfs-qgroup-create
2567 btrfs-qgroup-create qgroupid subvolume
2568
2569 Create a quota group (qgroup) for subvolume at "subvolume".
2570
2571 This command depends on the feature "btrfs". See also "feature-
2572 available".
2573
2574 btrfs-qgroup-destroy
2575 btrfs-qgroup-destroy qgroupid subvolume
2576
2577 Destroy a quota group.
2578
2579 This command depends on the feature "btrfs". See also "feature-
2580 available".
2581
2582 btrfs-qgroup-limit
2583 btrfs-qgroup-limit subvolume size
2584
2585 Limit the size of the subvolume with path "subvolume".
2586
2587 This command depends on the feature "btrfs". See also "feature-
2588 available".
2589
2590 btrfs-qgroup-remove
2591 btrfs-qgroup-remove src dst path
2592
2593 Remove qgroup "src" from the parent qgroup "dst".
2594
2595 This command depends on the feature "btrfs". See also "feature-
2596 available".
2597
2598 btrfs-qgroup-show
2599 btrfs-qgroup-show path
2600
2601 Show all subvolume quota groups in a btrfs filesystem, including their
2602 usages.
2603
2604 This command depends on the feature "btrfs". See also "feature-
2605 available".
2606
2607 btrfs-quota-enable
2608 btrfs-quota-enable fs true|false
2609
2610 Enable or disable subvolume quota support for filesystem which contains
2611 "path".
2612
2613 This command depends on the feature "btrfs". See also "feature-
2614 available".
2615
2616 btrfs-quota-rescan
2617 btrfs-quota-rescan fs
2618
2619 Trash all qgroup numbers and scan the metadata again with the current
2620 config.
2621
2622 This command depends on the feature "btrfs". See also "feature-
2623 available".
2624
2625 btrfs-replace
2626 btrfs-replace srcdev targetdev mntpoint
2627
2628 Replace device of a btrfs filesystem. On a live filesystem, duplicate
2629 the data to the target device which is currently stored on the source
2630 device. After completion of the operation, the source device is wiped
2631 out and removed from the filesystem.
2632
2633 The "targetdev" needs to be same size or larger than the "srcdev".
2634 Devices which are currently mounted are never allowed to be used as the
2635 "targetdev".
2636
2637 This command depends on the feature "btrfs". See also "feature-
2638 available".
2639
2640 btrfs-rescue-chunk-recover
2641 btrfs-rescue-chunk-recover device
2642
2643 Recover the chunk tree of btrfs filesystem by scanning the devices one
2644 by one.
2645
2646 This command depends on the feature "btrfs". See also "feature-
2647 available".
2648
2649 btrfs-rescue-super-recover
2650 btrfs-rescue-super-recover device
2651
2652 Recover bad superblocks from good copies.
2653
2654 This command depends on the feature "btrfs". See also "feature-
2655 available".
2656
2657 btrfs-scrub-cancel
2658 btrfs-scrub-cancel path
2659
2660 Cancel a running scrub on a btrfs filesystem.
2661
2662 This command depends on the feature "btrfs". See also "feature-
2663 available".
2664
2665 btrfs-scrub-resume
2666 btrfs-scrub-resume path
2667
2668 Resume a previously canceled or interrupted scrub on a btrfs
2669 filesystem.
2670
2671 This command depends on the feature "btrfs". See also "feature-
2672 available".
2673
2674 btrfs-scrub-start
2675 btrfs-scrub-start path
2676
2677 Reads all the data and metadata on the filesystem, and uses checksums
2678 and the duplicate copies from RAID storage to identify and repair any
2679 corrupt data.
2680
2681 This command depends on the feature "btrfs". See also "feature-
2682 available".
2683
2684 btrfs-scrub-status
2685 btrfs-scrub-status path
2686
2687 Show status of running or finished scrub on a btrfs filesystem.
2688
2689 This command depends on the feature "btrfs". See also "feature-
2690 available".
2691
2692 btrfs-set-seeding
2693 btrfs-set-seeding device true|false
2694
2695 Enable or disable the seeding feature of a device that contains a btrfs
2696 filesystem.
2697
2698 This command depends on the feature "btrfs". See also "feature-
2699 available".
2700
2701 btrfs-subvolume-create
2702 btrfs-subvolume-create-opts
2703 btrfs-subvolume-create dest [qgroupid:..]
2704
2705 Create a btrfs subvolume. The "dest" argument is the destination
2706 directory and the name of the subvolume, in the form
2707 /path/to/dest/name. The optional parameter "qgroupid" represents the
2708 qgroup which the newly created subvolume will be added to.
2709
2710 This command has one or more optional arguments. See "OPTIONAL
2711 ARGUMENTS".
2712
2713 This command depends on the feature "btrfs". See also "feature-
2714 available".
2715
2716 btrfs-subvolume-delete
2717 btrfs-subvolume-delete subvolume
2718
2719 Delete the named btrfs subvolume or snapshot.
2720
2721 This command depends on the feature "btrfs". See also "feature-
2722 available".
2723
2724 btrfs-subvolume-get-default
2725 btrfs-subvolume-get-default fs
2726
2727 Get the default subvolume or snapshot of a filesystem mounted at
2728 "mountpoint".
2729
2730 This command depends on the feature "btrfs". See also "feature-
2731 available".
2732
2733 btrfs-subvolume-list
2734 btrfs-subvolume-list fs
2735
2736 List the btrfs snapshots and subvolumes of the btrfs filesystem which
2737 is mounted at "fs".
2738
2739 This command depends on the feature "btrfs". See also "feature-
2740 available".
2741
2742 btrfs-subvolume-set-default
2743 btrfs-subvolume-set-default id fs
2744
2745 Set the subvolume of the btrfs filesystem "fs" which will be mounted by
2746 default. See "btrfs-subvolume-list" to get a list of subvolumes.
2747
2748 This command depends on the feature "btrfs". See also "feature-
2749 available".
2750
2751 btrfs-subvolume-show
2752 btrfs-subvolume-show subvolume
2753
2754 Return detailed information of the subvolume.
2755
2756 This command depends on the feature "btrfs". See also "feature-
2757 available".
2758
2759 btrfs-subvolume-snapshot
2760 btrfs-subvolume-snapshot-opts
2761 btrfs-subvolume-snapshot source dest [ro:true|false] [qgroupid:..]
2762
2763 Create a snapshot of the btrfs subvolume "source". The "dest" argument
2764 is the destination directory and the name of the snapshot, in the form
2765 /path/to/dest/name. By default the newly created snapshot is writable,
2766 if the value of optional parameter "ro" is true, then a readonly
2767 snapshot is created. The optional parameter "qgroupid" represents the
2768 qgroup which the newly created snapshot will be added to.
2769
2770 This command has one or more optional arguments. See "OPTIONAL
2771 ARGUMENTS".
2772
2773 This command depends on the feature "btrfs". See also "feature-
2774 available".
2775
2776 btrfstune-enable-extended-inode-refs
2777 btrfstune-enable-extended-inode-refs device
2778
2779 This will Enable extended inode refs.
2780
2781 This command depends on the feature "btrfs". See also "feature-
2782 available".
2783
2784 btrfstune-enable-skinny-metadata-extent-refs
2785 btrfstune-enable-skinny-metadata-extent-refs device
2786
2787 This enable skinny metadata extent refs.
2788
2789 This command depends on the feature "btrfs". See also "feature-
2790 available".
2791
2792 btrfstune-seeding
2793 btrfstune-seeding device true|false
2794
2795 Enable seeding of a btrfs device, this will force a fs readonly so that
2796 you can use it to build other filesystems.
2797
2798 This command depends on the feature "btrfs". See also "feature-
2799 available".
2800
2801 c-pointer
2802 c-pointer
2803
2804 In non-C language bindings, this allows you to retrieve the underlying
2805 C pointer to the handle (ie. "h *"). The purpose of this is to allow
2806 other libraries to interwork with libguestfs.
2807
2808 canonical-device-name
2809 canonical-device-name device
2810
2811 This utility function is useful when displaying device names to the
2812 user. It takes a number of irregular device names and returns them in
2813 a consistent format:
2814
2815 /dev/hdX
2816 /dev/vdX
2817 These are returned as /dev/sdX. Note this works for device names
2818 and partition names. This is approximately the reverse of the
2819 algorithm described in "BLOCK DEVICE NAMING" in guestfs(3).
2820
2821 /dev/mapper/VG-LV
2822 /dev/dm-N
2823 Converted to /dev/VG/LV form using "lvm-canonical-lv-name".
2824
2825 Other strings are returned unmodified.
2826
2827 cap-get-file
2828 cap-get-file path
2829
2830 This function returns the Linux capabilities attached to "path". The
2831 capabilities set is returned in text form (see cap_to_text(3)).
2832
2833 If no capabilities are attached to a file, an empty string is returned.
2834
2835 This command depends on the feature "linuxcaps". See also "feature-
2836 available".
2837
2838 cap-set-file
2839 cap-set-file path cap
2840
2841 This function sets the Linux capabilities attached to "path". The
2842 capabilities set "cap" should be passed in text form (see
2843 cap_from_text(3)).
2844
2845 This command depends on the feature "linuxcaps". See also "feature-
2846 available".
2847
2848 case-sensitive-path
2849 case-sensitive-path path
2850
2851 This can be used to resolve case insensitive paths on a filesystem
2852 which is case sensitive. The use case is to resolve paths which you
2853 have read from Windows configuration files or the Windows Registry, to
2854 the true path.
2855
2856 The command handles a peculiarity of the Linux ntfs-3g filesystem
2857 driver (and probably others), which is that although the underlying
2858 filesystem is case-insensitive, the driver exports the filesystem to
2859 Linux as case-sensitive.
2860
2861 One consequence of this is that special directories such as C:\windows
2862 may appear as /WINDOWS or /windows (or other things) depending on the
2863 precise details of how they were created. In Windows itself this would
2864 not be a problem.
2865
2866 Bug or feature? You decide:
2867 https://www.tuxera.com/community/ntfs-3g-faq/#posixfilenames1
2868
2869 "case-sensitive-path" attempts to resolve the true case of each element
2870 in the path. It will return a resolved path if either the full path or
2871 its parent directory exists. If the parent directory exists but the
2872 full path does not, the case of the parent directory will be correctly
2873 resolved, and the remainder appended unmodified. For example, if the
2874 file "/Windows/System32/netkvm.sys" exists:
2875
2876 "case-sensitive-path" ("/windows/system32/netkvm.sys")
2877 "Windows/System32/netkvm.sys"
2878
2879 "case-sensitive-path" ("/windows/system32/NoSuchFile")
2880 "Windows/System32/NoSuchFile"
2881
2882 "case-sensitive-path" ("/windows/system33/netkvm.sys")
2883 ERROR
2884
2885 Note: Because of the above behaviour, "case-sensitive-path" cannot be
2886 used to check for the existence of a file.
2887
2888 Note: This function does not handle drive names, backslashes etc.
2889
2890 See also "realpath".
2891
2892 cat
2893 cat path
2894
2895 Return the contents of the file named "path".
2896
2897 Because, in C, this function returns a "char *", there is no way to
2898 differentiate between a "\0" character in a file and end of string. To
2899 handle binary files, use the "read-file" or "download" functions.
2900
2901 checksum
2902 checksum csumtype path
2903
2904 This call computes the MD5, SHAx or CRC checksum of the file named
2905 "path".
2906
2907 The type of checksum to compute is given by the "csumtype" parameter
2908 which must have one of the following values:
2909
2910 "crc"
2911 Compute the cyclic redundancy check (CRC) specified by POSIX for
2912 the "cksum" command.
2913
2914 "md5"
2915 Compute the MD5 hash (using the md5sum(1) program).
2916
2917 "sha1"
2918 Compute the SHA1 hash (using the sha1sum(1) program).
2919
2920 "sha224"
2921 Compute the SHA224 hash (using the sha224sum(1) program).
2922
2923 "sha256"
2924 Compute the SHA256 hash (using the sha256sum(1) program).
2925
2926 "sha384"
2927 Compute the SHA384 hash (using the sha384sum(1) program).
2928
2929 "sha512"
2930 Compute the SHA512 hash (using the sha512sum(1) program).
2931
2932 The checksum is returned as a printable string.
2933
2934 To get the checksum for a device, use "checksum-device".
2935
2936 To get the checksums for many files, use "checksums-out".
2937
2938 checksum-device
2939 checksum-device csumtype device
2940
2941 This call computes the MD5, SHAx or CRC checksum of the contents of the
2942 device named "device". For the types of checksums supported see the
2943 "checksum" command.
2944
2945 checksums-out
2946 checksums-out csumtype directory (sumsfile|-)
2947
2948 This command computes the checksums of all regular files in directory
2949 and then emits a list of those checksums to the local output file
2950 "sumsfile".
2951
2952 This can be used for verifying the integrity of a virtual machine.
2953 However to be properly secure you should pay attention to the output of
2954 the checksum command (it uses the ones from GNU coreutils). In
2955 particular when the filename is not printable, coreutils uses a special
2956 backslash syntax. For more information, see the GNU coreutils info
2957 file.
2958
2959 Use "-" instead of a filename to read/write from stdin/stdout.
2960
2961 chmod
2962 chmod mode path
2963
2964 Change the mode (permissions) of "path" to "mode". Only numeric modes
2965 are supported.
2966
2967 Note: When using this command from guestfish, "mode" by default would
2968 be decimal, unless you prefix it with 0 to get octal, ie. use 0700 not
2969 700.
2970
2971 The mode actually set is affected by the umask.
2972
2973 chown
2974 chown owner group path
2975
2976 Change the file owner to "owner" and group to "group".
2977
2978 Only numeric uid and gid are supported. If you want to use names, you
2979 will need to locate and parse the password file yourself (Augeas
2980 support makes this relatively easy).
2981
2982 clear-backend-setting
2983 clear-backend-setting name
2984
2985 If there is a backend setting string matching "name" or beginning with
2986 "name=", then that string is removed from the backend settings.
2987
2988 This call returns the number of strings which were removed (which may
2989 be 0, 1 or greater than 1).
2990
2991 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
2992
2993 clevis-luks-unlock
2994 clevis-luks-unlock device mapname
2995
2996 This command opens a block device that has been encrypted according to
2997 the Linux Unified Key Setup (LUKS) standard, using network-bound disk
2998 encryption (NBDE).
2999
3000 "device" is the encrypted block device.
3001
3002 The appliance will connect to the Tang servers noted in the tree of
3003 Clevis pins that is bound to a keyslot of the LUKS header. The Clevis
3004 pin tree may comprise "sss" (redudancy) pins as internal nodes
3005 (optionally), and "tang" pins as leaves. "tpm2" pins are not
3006 supported. The appliance unlocks the encrypted block device by
3007 combining responses from the Tang servers with metadata from the LUKS
3008 header; there is no "key" parameter.
3009
3010 This command will fail if networking has not been enabled for the
3011 appliance. Refer to "set-network".
3012
3013 The command creates a new block device called /dev/mapper/mapname.
3014 Reads and writes to this block device are decrypted from and encrypted
3015 to the underlying "device" respectively. Close the decrypted block
3016 device with "cryptsetup-close".
3017
3018 "mapname" cannot be "control" because that name is reserved by device-
3019 mapper.
3020
3021 If this block device contains LVM volume groups, then calling "lvm-
3022 scan" with the "activate" parameter "true" will make them visible.
3023
3024 Use "list-dm-devices" to list all device mapper devices.
3025
3026 This command depends on the feature "clevisluks". See also "feature-
3027 available".
3028
3029 command
3030 command 'arguments ...'
3031
3032 This call runs a command from the guest filesystem. The filesystem
3033 must be mounted, and must contain a compatible operating system (ie.
3034 something Linux, with the same or compatible processor architecture).
3035
3036 The single parameter is an argv-style list of arguments. The first
3037 element is the name of the program to run. Subsequent elements are
3038 parameters. The list must be non-empty (ie. must contain a program
3039 name). Note that the command runs directly, and is not invoked via the
3040 shell (see "sh").
3041
3042 The return value is anything printed to stdout by the command.
3043
3044 If the command returns a non-zero exit status, then this function
3045 returns an error message. The error message string is the content of
3046 stderr from the command.
3047
3048 The $PATH environment variable will contain at least /usr/bin and /bin.
3049 If you require a program from another location, you should provide the
3050 full path in the first parameter.
3051
3052 Shared libraries and data files required by the program must be
3053 available on filesystems which are mounted in the correct places. It
3054 is the caller’s responsibility to ensure all filesystems that are
3055 needed are mounted at the right locations.
3056
3057 Because of the message protocol, there is a transfer limit of somewhere
3058 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3059
3060 command-lines
3061 command-lines 'arguments ...'
3062
3063 This is the same as "command", but splits the result into a list of
3064 lines.
3065
3066 See also: "sh-lines"
3067
3068 Because of the message protocol, there is a transfer limit of somewhere
3069 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3070
3071 compress-device-out
3072 compress-device-out ctype device (zdevice|-) [level:N]
3073
3074 This command compresses "device" and writes it out to the local file
3075 "zdevice".
3076
3077 The "ctype" and optional "level" parameters have the same meaning as in
3078 "compress-out".
3079
3080 Use "-" instead of a filename to read/write from stdin/stdout.
3081
3082 This command has one or more optional arguments. See "OPTIONAL
3083 ARGUMENTS".
3084
3085 compress-out
3086 compress-out ctype file (zfile|-) [level:N]
3087
3088 This command compresses file and writes it out to the local file zfile.
3089
3090 The compression program used is controlled by the "ctype" parameter.
3091 Currently this includes: "compress", "gzip", "bzip2", "xz" or "lzop".
3092 Some compression types may not be supported by particular builds of
3093 libguestfs, in which case you will get an error containing the
3094 substring "not supported".
3095
3096 The optional "level" parameter controls compression level. The meaning
3097 and default for this parameter depends on the compression program being
3098 used.
3099
3100 Use "-" instead of a filename to read/write from stdin/stdout.
3101
3102 This command has one or more optional arguments. See "OPTIONAL
3103 ARGUMENTS".
3104
3105 config
3106 config hvparam hvvalue
3107
3108 This can be used to add arbitrary hypervisor parameters of the form
3109 -param value. Actually it’s not quite arbitrary - we prevent you from
3110 setting some parameters which would interfere with parameters that we
3111 use.
3112
3113 The first character of "hvparam" string must be a "-" (dash).
3114
3115 "hvvalue" can be NULL.
3116
3117 copy-attributes
3118 copy-attributes src dest [all:true|false] [mode:true|false] [xattributes:true|false] [ownership:true|false]
3119
3120 Copy the attributes of a path (which can be a file or a directory) to
3121 another path.
3122
3123 By default no attribute is copied, so make sure to specify any (or
3124 "all" to copy everything).
3125
3126 The optional arguments specify which attributes can be copied:
3127
3128 "mode"
3129 Copy part of the file mode from "source" to "destination". Only the
3130 UNIX permissions and the sticky/setuid/setgid bits can be copied.
3131
3132 "xattributes"
3133 Copy the Linux extended attributes (xattrs) from "source" to
3134 "destination". This flag does nothing if the linuxxattrs feature
3135 is not available (see "feature-available").
3136
3137 "ownership"
3138 Copy the owner uid and the group gid of "source" to "destination".
3139
3140 "all"
3141 Copy all the attributes from "source" to "destination". Enabling it
3142 enables all the other flags, if they are not specified already.
3143
3144 This command has one or more optional arguments. See "OPTIONAL
3145 ARGUMENTS".
3146
3147 copy-device-to-device
3148 copy-device-to-device src dest [srcoffset:N] [destoffset:N] [size:N] [sparse:true|false] [append:true|false]
3149
3150 The four calls "copy-device-to-device", "copy-device-to-file", "copy-
3151 file-to-device", and "copy-file-to-file" let you copy from a source
3152 (device|file) to a destination (device|file).
3153
3154 Partial copies can be made since you can specify optionally the source
3155 offset, destination offset and size to copy. These values are all
3156 specified in bytes. If not given, the offsets both default to zero,
3157 and the size defaults to copying as much as possible until we hit the
3158 end of the source.
3159
3160 The source and destination may be the same object. However overlapping
3161 regions may not be copied correctly.
3162
3163 If the destination is a file, it is created if required. If the
3164 destination file is not large enough, it is extended.
3165
3166 If the destination is a file and the "append" flag is not set, then the
3167 destination file is truncated. If the "append" flag is set, then the
3168 copy appends to the destination file. The "append" flag currently
3169 cannot be set for devices.
3170
3171 If the "sparse" flag is true then the call avoids writing blocks that
3172 contain only zeroes, which can help in some situations where the
3173 backing disk is thin-provisioned. Note that unless the target is
3174 already zeroed, using this option will result in incorrect copying.
3175
3176 This command has one or more optional arguments. See "OPTIONAL
3177 ARGUMENTS".
3178
3179 copy-device-to-file
3180 copy-device-to-file src dest [srcoffset:N] [destoffset:N] [size:N] [sparse:true|false] [append:true|false]
3181
3182 See "copy-device-to-device" for a general overview of this call.
3183
3184 This command has one or more optional arguments. See "OPTIONAL
3185 ARGUMENTS".
3186
3187 copy-file-to-device
3188 copy-file-to-device src dest [srcoffset:N] [destoffset:N] [size:N] [sparse:true|false] [append:true|false]
3189
3190 See "copy-device-to-device" for a general overview of this call.
3191
3192 This command has one or more optional arguments. See "OPTIONAL
3193 ARGUMENTS".
3194
3195 copy-file-to-file
3196 copy-file-to-file src dest [srcoffset:N] [destoffset:N] [size:N] [sparse:true|false] [append:true|false]
3197
3198 See "copy-device-to-device" for a general overview of this call.
3199
3200 This is not the function you want for copying files. This is for
3201 copying blocks within existing files. See "cp", "cp-a" and "mv" for
3202 general file copying and moving functions.
3203
3204 This command has one or more optional arguments. See "OPTIONAL
3205 ARGUMENTS".
3206
3207 copy-size
3208 copy-size src dest size
3209
3210 This command copies exactly "size" bytes from one source device or file
3211 "src" to another destination device or file "dest".
3212
3213 Note this will fail if the source is too short or if the destination is
3214 not large enough.
3215
3216 This function is deprecated. In new code, use the "copy-device-to-
3217 device" call instead.
3218
3219 Deprecated functions will not be removed from the API, but the fact
3220 that they are deprecated indicates that there are problems with correct
3221 use of these functions.
3222
3223 cp
3224 cp src dest
3225
3226 This copies a file from "src" to "dest" where "dest" is either a
3227 destination filename or destination directory.
3228
3229 cp-a
3230 cp-a src dest
3231
3232 This copies a file or directory from "src" to "dest" recursively using
3233 the "cp -a" command.
3234
3235 cp-r
3236 cp-r src dest
3237
3238 This copies a file or directory from "src" to "dest" recursively using
3239 the "cp -rP" command.
3240
3241 Most users should use "cp-a" instead. This command is useful when you
3242 don't want to preserve permissions, because the target filesystem does
3243 not support it (primarily when writing to DOS FAT filesystems).
3244
3245 cpio-out
3246 cpio-out directory (cpiofile|-) [format:..]
3247
3248 This command packs the contents of directory and downloads it to local
3249 file "cpiofile".
3250
3251 The optional "format" parameter can be used to select the format. Only
3252 the following formats are currently permitted:
3253
3254 "newc"
3255 New (SVR4) portable format. This format happens to be compatible
3256 with the cpio-like format used by the Linux kernel for initramfs.
3257
3258 This is the default format.
3259
3260 "crc"
3261 New (SVR4) portable format with a checksum.
3262
3263 Use "-" instead of a filename to read/write from stdin/stdout.
3264
3265 This command has one or more optional arguments. See "OPTIONAL
3266 ARGUMENTS".
3267
3268 cryptsetup-close
3269 cryptsetup-close device
3270
3271 This closes an encrypted device that was created earlier by
3272 "cryptsetup-open". The "device" parameter must be the name of the
3273 mapping device (ie. /dev/mapper/mapname) and not the name of the
3274 underlying block device.
3275
3276 This command depends on the feature "luks". See also "feature-
3277 available".
3278
3279 cryptsetup-open
3280 cryptsetup-open device mapname [readonly:true|false] [crypttype:..]
3281
3282 This command opens a block device which has been encrypted according to
3283 the Linux Unified Key Setup (LUKS) standard, Windows BitLocker, or some
3284 other types.
3285
3286 "device" is the encrypted block device or partition.
3287
3288 The caller must supply one of the keys associated with the encrypted
3289 block device, in the "key" parameter.
3290
3291 This creates a new block device called /dev/mapper/mapname. Reads and
3292 writes to this block device are decrypted from and encrypted to the
3293 underlying "device" respectively.
3294
3295 "mapname" cannot be "control" because that name is reserved by device-
3296 mapper.
3297
3298 If the optional "crypttype" parameter is not present then libguestfs
3299 tries to guess the correct type (for example LUKS or BitLocker).
3300 However you can override this by specifying one of the following types:
3301
3302 "luks"
3303 A Linux LUKS device.
3304
3305 "bitlk"
3306 A Windows BitLocker device.
3307
3308 The optional "readonly" flag, if set to true, creates a read-only
3309 mapping.
3310
3311 If this block device contains LVM volume groups, then calling "lvm-
3312 scan" with the "activate" parameter "true" will make them visible.
3313
3314 Use "list-dm-devices" to list all device mapper devices.
3315
3316 This command has one or more key or passphrase parameters. Guestfish
3317 will prompt for these separately.
3318
3319 This command has one or more optional arguments. See "OPTIONAL
3320 ARGUMENTS".
3321
3322 This command depends on the feature "luks". See also "feature-
3323 available".
3324
3325 dd
3326 dd src dest
3327
3328 This command copies from one source device or file "src" to another
3329 destination device or file "dest". Normally you would use this to copy
3330 to or from a device or partition, for example to duplicate a
3331 filesystem.
3332
3333 If the destination is a device, it must be as large or larger than the
3334 source file or device, otherwise the copy will fail. This command
3335 cannot do partial copies (see "copy-device-to-device").
3336
3337 This function is deprecated. In new code, use the "copy-device-to-
3338 device" call instead.
3339
3340 Deprecated functions will not be removed from the API, but the fact
3341 that they are deprecated indicates that there are problems with correct
3342 use of these functions.
3343
3344 device-index
3345 device-index device
3346
3347 This function takes a device name (eg. "/dev/sdb") and returns the
3348 index of the device in the list of devices.
3349
3350 Index numbers start from 0. The named device must exist, for example
3351 as a string returned from "list-devices".
3352
3353 See also "list-devices", "part-to-dev", "device-name".
3354
3355 device-name
3356 device-name index
3357
3358 This function takes a device index and returns the device name. For
3359 example index 0 will return the string "/dev/sda".
3360
3361 The drive index must have been added to the handle.
3362
3363 See also "list-devices", "part-to-dev", "device-index".
3364
3365 df
3366 df
3367
3368 This command runs the df(1) command to report disk space used.
3369
3370 This command is mostly useful for interactive sessions. It is not
3371 intended that you try to parse the output string. Use "statvfs" from
3372 programs.
3373
3374 df-h
3375 df-h
3376
3377 This command runs the "df -h" command to report disk space used in
3378 human-readable format.
3379
3380 This command is mostly useful for interactive sessions. It is not
3381 intended that you try to parse the output string. Use "statvfs" from
3382 programs.
3383
3384 disk-create
3385 disk-create filename format size [backingfile:..] [backingformat:..] [preallocation:..] [compat:..] [clustersize:N]
3386
3387 Create a blank disk image called filename (a host file) with format
3388 "format" (usually "raw" or "qcow2"). The size is "size" bytes.
3389
3390 If used with the optional "backingfile" parameter, then a snapshot is
3391 created on top of the backing file. In this case, "size" must be
3392 passed as "-1". The size of the snapshot is the same as the size of
3393 the backing file, which is discovered automatically. You are
3394 encouraged to also pass "backingformat" to describe the format of
3395 "backingfile".
3396
3397 If filename refers to a block device, then the device is formatted.
3398 The "size" is ignored since block devices have an intrinsic size.
3399
3400 The other optional parameters are:
3401
3402 "preallocation"
3403 If format is "raw", then this can be either "off" (or "sparse") or
3404 "full" to create a sparse or fully allocated file respectively.
3405 The default is "off".
3406
3407 If format is "qcow2", then this can be "off" (or "sparse"),
3408 "metadata" or "full". Preallocating metadata can be faster when
3409 doing lots of writes, but uses more space. The default is "off".
3410
3411 "compat"
3412 "qcow2" only: Pass the string 1.1 to use the advanced qcow2 format
3413 supported by qemu ≥ 1.1.
3414
3415 "clustersize"
3416 "qcow2" only: Change the qcow2 cluster size. The default is 65536
3417 (bytes) and this setting may be any power of two between 512 and
3418 2097152.
3419
3420 Note that this call does not add the new disk to the handle. You may
3421 need to call "add-drive-opts" separately.
3422
3423 This command has one or more optional arguments. See "OPTIONAL
3424 ARGUMENTS".
3425
3426 disk-format
3427 disk-format filename
3428
3429 Detect and return the format of the disk image called filename.
3430 filename can also be a host device, etc. If the format of the image
3431 could not be detected, then "unknown" is returned.
3432
3433 Note that detecting the disk format can be insecure under some
3434 circumstances. See "CVE-2010-3851" in guestfs(3).
3435
3436 See also: "DISK IMAGE FORMATS" in guestfs(3)
3437
3438 disk-has-backing-file
3439 disk-has-backing-file filename
3440
3441 Detect and return whether the disk image filename has a backing file.
3442
3443 Note that detecting disk features can be insecure under some
3444 circumstances. See "CVE-2010-3851" in guestfs(3).
3445
3446 disk-virtual-size
3447 disk-virtual-size filename
3448
3449 Detect and return the virtual size in bytes of the disk image called
3450 filename.
3451
3452 Note that detecting disk features can be insecure under some
3453 circumstances. See "CVE-2010-3851" in guestfs(3).
3454
3455 dmesg
3456 dmesg
3457
3458 This returns the kernel messages (dmesg(1) output) from the guest
3459 kernel. This is sometimes useful for extended debugging of problems.
3460
3461 Another way to get the same information is to enable verbose messages
3462 with "set-verbose" or by setting the environment variable
3463 "LIBGUESTFS_DEBUG=1" before running the program.
3464
3465 download
3466 download remotefilename (filename|-)
3467
3468 Download file remotefilename and save it as filename on the local
3469 machine.
3470
3471 filename can also be a named pipe.
3472
3473 See also "upload", "cat".
3474
3475 Use "-" instead of a filename to read/write from stdin/stdout.
3476
3477 download-blocks
3478 download-blocks device start stop (filename|-) [unallocated:true|false]
3479
3480 Download the data units from start address to stop from the disk
3481 partition (eg. /dev/sda1) and save them as filename on the local
3482 machine.
3483
3484 The use of this API on sparse disk image formats such as QCOW, may
3485 result in large zero-filled files downloaded on the host.
3486
3487 The size of a data unit varies across filesystem implementations. On
3488 NTFS filesystems data units are referred as clusters while on ExtX ones
3489 they are referred as fragments.
3490
3491 If the optional "unallocated" flag is true (default is false), only the
3492 unallocated blocks will be extracted. This is useful to detect hidden
3493 data or to retrieve deleted files which data units have not been
3494 overwritten yet.
3495
3496 Use "-" instead of a filename to read/write from stdin/stdout.
3497
3498 This command has one or more optional arguments. See "OPTIONAL
3499 ARGUMENTS".
3500
3501 This command depends on the feature "sleuthkit". See also "feature-
3502 available".
3503
3504 download-inode
3505 download-inode device inode (filename|-)
3506
3507 Download a file given its inode from the disk partition (eg. /dev/sda1)
3508 and save it as filename on the local machine.
3509
3510 It is not required to mount the disk to run this command.
3511
3512 The command is capable of downloading deleted or inaccessible files.
3513
3514 Use "-" instead of a filename to read/write from stdin/stdout.
3515
3516 This command depends on the feature "sleuthkit". See also "feature-
3517 available".
3518
3519 download-offset
3520 download-offset remotefilename (filename|-) offset size
3521
3522 Download file remotefilename and save it as filename on the local
3523 machine.
3524
3525 remotefilename is read for "size" bytes starting at "offset" (this
3526 region must be within the file or device).
3527
3528 Note that there is no limit on the amount of data that can be
3529 downloaded with this call, unlike with "pread", and this call always
3530 reads the full amount unless an error occurs.
3531
3532 See also "download", "pread".
3533
3534 Use "-" instead of a filename to read/write from stdin/stdout.
3535
3536 drop-caches
3537 drop-caches whattodrop
3538
3539 This instructs the guest kernel to drop its page cache, and/or dentries
3540 and inode caches. The parameter "whattodrop" tells the kernel what
3541 precisely to drop, see https://linux-mm.org/Drop_Caches
3542
3543 Setting "whattodrop" to 3 should drop everything.
3544
3545 This automatically calls sync(2) before the operation, so that the
3546 maximum guest memory is freed.
3547
3548 du
3549 du path
3550
3551 This command runs the "du -s" command to estimate file space usage for
3552 "path".
3553
3554 "path" can be a file or a directory. If "path" is a directory then the
3555 estimate includes the contents of the directory and all subdirectories
3556 (recursively).
3557
3558 The result is the estimated size in kilobytes (ie. units of 1024
3559 bytes).
3560
3561 e2fsck
3562 e2fsck device [correct:true|false] [forceall:true|false]
3563
3564 This runs the ext2/ext3 filesystem checker on "device". It can take
3565 the following optional arguments:
3566
3567 "correct"
3568 Automatically repair the file system. This option will cause e2fsck
3569 to automatically fix any filesystem problems that can be safely
3570 fixed without human intervention.
3571
3572 This option may not be specified at the same time as the "forceall"
3573 option.
3574
3575 "forceall"
3576 Assume an answer of ‘yes’ to all questions; allows e2fsck to be
3577 used non-interactively.
3578
3579 This option may not be specified at the same time as the "correct"
3580 option.
3581
3582 This command has one or more optional arguments. See "OPTIONAL
3583 ARGUMENTS".
3584
3585 e2fsck-f
3586 e2fsck-f device
3587
3588 This runs "e2fsck -p -f device", ie. runs the ext2/ext3 filesystem
3589 checker on "device", noninteractively (-p), even if the filesystem
3590 appears to be clean (-f).
3591
3592 This function is deprecated. In new code, use the "e2fsck" call
3593 instead.
3594
3595 Deprecated functions will not be removed from the API, but the fact
3596 that they are deprecated indicates that there are problems with correct
3597 use of these functions.
3598
3599 echo-daemon
3600 echo-daemon 'words ...'
3601
3602 This command concatenates the list of "words" passed with single spaces
3603 between them and returns the resulting string.
3604
3605 You can use this command to test the connection through to the daemon.
3606
3607 See also "ping-daemon".
3608
3609 egrep
3610 egrep regex path
3611
3612 This calls the external egrep(1) program and returns the matching
3613 lines.
3614
3615 Because of the message protocol, there is a transfer limit of somewhere
3616 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3617
3618 This function is deprecated. In new code, use the "grep" call instead.
3619
3620 Deprecated functions will not be removed from the API, but the fact
3621 that they are deprecated indicates that there are problems with correct
3622 use of these functions.
3623
3624 egrepi
3625 egrepi regex path
3626
3627 This calls the external "egrep -i" program and returns the matching
3628 lines.
3629
3630 Because of the message protocol, there is a transfer limit of somewhere
3631 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3632
3633 This function is deprecated. In new code, use the "grep" call instead.
3634
3635 Deprecated functions will not be removed from the API, but the fact
3636 that they are deprecated indicates that there are problems with correct
3637 use of these functions.
3638
3639 equal
3640 equal file1 file2
3641
3642 This compares the two files file1 and file2 and returns true if their
3643 content is exactly equal, or false otherwise.
3644
3645 The external cmp(1) program is used for the comparison.
3646
3647 exists
3648 exists path
3649
3650 This returns "true" if and only if there is a file, directory (or
3651 anything) with the given "path" name.
3652
3653 See also "is-file", "is-dir", "stat".
3654
3655 extlinux
3656 extlinux directory
3657
3658 Install the SYSLINUX bootloader on the device mounted at directory.
3659 Unlike "syslinux" which requires a FAT filesystem, this can be used on
3660 an ext2/3/4 or btrfs filesystem.
3661
3662 The directory parameter can be either a mountpoint, or a directory
3663 within the mountpoint.
3664
3665 You also have to mark the partition as "active" ("part-set-bootable")
3666 and a Master Boot Record must be installed (eg. using "pwrite-device")
3667 on the first sector of the whole disk. The SYSLINUX package comes with
3668 some suitable Master Boot Records. See the extlinux(1) man page for
3669 further information.
3670
3671 Additional configuration can be supplied to SYSLINUX by placing a file
3672 called extlinux.conf on the filesystem under directory. For further
3673 information about the contents of this file, see extlinux(1).
3674
3675 See also "syslinux".
3676
3677 This command depends on the feature "extlinux". See also "feature-
3678 available".
3679
3680 f2fs-expand
3681 f2fs-expand device
3682
3683 This expands a f2fs filesystem to match the size of the underlying
3684 device.
3685
3686 This command depends on the feature "f2fs". See also "feature-
3687 available".
3688
3689 fallocate
3690 fallocate path len
3691
3692 This command preallocates a file (containing zero bytes) named "path"
3693 of size "len" bytes. If the file exists already, it is overwritten.
3694
3695 Do not confuse this with the guestfish-specific "alloc" command which
3696 allocates a file in the host and attaches it as a device.
3697
3698 This function is deprecated. In new code, use the "fallocate64" call
3699 instead.
3700
3701 Deprecated functions will not be removed from the API, but the fact
3702 that they are deprecated indicates that there are problems with correct
3703 use of these functions.
3704
3705 fallocate64
3706 fallocate64 path len
3707
3708 This command preallocates a file (containing zero bytes) named "path"
3709 of size "len" bytes. If the file exists already, it is overwritten.
3710
3711 Note that this call allocates disk blocks for the file. To create a
3712 sparse file use "truncate-size" instead.
3713
3714 The deprecated call "fallocate" does the same, but owing to an
3715 oversight it only allowed 30 bit lengths to be specified, effectively
3716 limiting the maximum size of files created through that call to 1GB.
3717
3718 Do not confuse this with the guestfish-specific "alloc" and "sparse"
3719 commands which create a file in the host and attach it as a device.
3720
3721 feature-available
3722 feature-available 'groups ...'
3723
3724 This is the same as "available", but unlike that call it returns a
3725 simple true/false boolean result, instead of throwing an exception if a
3726 feature is not found. For other documentation see "available".
3727
3728 fgrep
3729 fgrep pattern path
3730
3731 This calls the external fgrep(1) program and returns the matching
3732 lines.
3733
3734 Because of the message protocol, there is a transfer limit of somewhere
3735 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3736
3737 This function is deprecated. In new code, use the "grep" call instead.
3738
3739 Deprecated functions will not be removed from the API, but the fact
3740 that they are deprecated indicates that there are problems with correct
3741 use of these functions.
3742
3743 fgrepi
3744 fgrepi pattern path
3745
3746 This calls the external "fgrep -i" program and returns the matching
3747 lines.
3748
3749 Because of the message protocol, there is a transfer limit of somewhere
3750 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3751
3752 This function is deprecated. In new code, use the "grep" call instead.
3753
3754 Deprecated functions will not be removed from the API, but the fact
3755 that they are deprecated indicates that there are problems with correct
3756 use of these functions.
3757
3758 file
3759 file path
3760
3761 This call uses the standard file(1) command to determine the type or
3762 contents of the file.
3763
3764 This call will also transparently look inside various types of
3765 compressed file.
3766
3767 The filename is not prepended to the output (like the file command -b
3768 option).
3769
3770 The output depends on the output of the underlying file(1) command and
3771 it can change in future in ways beyond our control. In other words,
3772 the output is not guaranteed by the ABI.
3773
3774 See also: file(1), "vfs-type", "lstat", "is-file", "is-blockdev" (etc),
3775 "is-zero".
3776
3777 file-architecture
3778 file-architecture filename
3779
3780 This detects the architecture of the binary filename, and returns it if
3781 known.
3782
3783 Currently defined architectures are:
3784
3785 "aarch64"
3786 64 bit ARM.
3787
3788 "arm"
3789 32 bit ARM.
3790
3791 "i386"
3792 This string is returned for all 32 bit i386, i486, i586, i686
3793 binaries irrespective of the precise processor requirements of the
3794 binary.
3795
3796 "ia64"
3797 Intel Itanium.
3798
3799 "ppc"
3800 32 bit Power PC.
3801
3802 "ppc64"
3803 64 bit Power PC (big endian).
3804
3805 "ppc64le"
3806 64 bit Power PC (little endian).
3807
3808 "riscv32"
3809 "riscv64"
3810 "riscv128"
3811 RISC-V 32-, 64- or 128-bit variants.
3812
3813 "s390"
3814 31 bit IBM S/390.
3815
3816 "s390x"
3817 64 bit IBM S/390.
3818
3819 "sparc"
3820 32 bit SPARC.
3821
3822 "sparc64"
3823 64 bit SPARC V9 and above.
3824
3825 "x86_64"
3826 64 bit x86-64.
3827
3828 Libguestfs may return other architecture strings in future.
3829
3830 The function works on at least the following types of files:
3831
3832 • many types of Un*x and Linux binary
3833
3834 • many types of Un*x and Linux shared library
3835
3836 • Windows Win32 and Win64 binaries
3837
3838 • Windows Win32 and Win64 DLLs
3839
3840 Win32 binaries and DLLs return "i386".
3841
3842 Win64 binaries and DLLs return "x86_64".
3843
3844 • Linux kernel modules
3845
3846 • Linux new-style initrd images
3847
3848 • some non-x86 Linux vmlinuz kernels
3849
3850 What it can't do currently:
3851
3852 • static libraries (libfoo.a)
3853
3854 • Linux old-style initrd as compressed ext2 filesystem (RHEL 3)
3855
3856 • x86 Linux vmlinuz kernels
3857
3858 x86 vmlinuz images (bzImage format) consist of a mix of 16-, 32-
3859 and compressed code, and are horribly hard to unpack. If you want
3860 to find the architecture of a kernel, use the architecture of the
3861 associated initrd or kernel module(s) instead.
3862
3863 filesize
3864 filesize file
3865
3866 This command returns the size of file in bytes.
3867
3868 To get other stats about a file, use "stat", "lstat", "is-dir", "is-
3869 file" etc. To get the size of block devices, use "blockdev-getsize64".
3870
3871 filesystem-available
3872 filesystem-available filesystem
3873
3874 Check whether libguestfs supports the named filesystem. The argument
3875 "filesystem" is a filesystem name, such as "ext3".
3876
3877 You must call "launch" before using this command.
3878
3879 This is mainly useful as a negative test. If this returns true, it
3880 doesn't mean that a particular filesystem can be created or mounted,
3881 since filesystems can fail for other reasons such as it being a later
3882 version of the filesystem, or having incompatible features, or lacking
3883 the right mkfs.<fs> tool.
3884
3885 See also "available", "feature-available", "AVAILABILITY" in
3886 guestfs(3).
3887
3888 filesystem-walk
3889 filesystem-walk device
3890
3891 Walk through the internal structures of a disk partition (eg.
3892 /dev/sda1) in order to return a list of all the files and directories
3893 stored within.
3894
3895 It is not necessary to mount the disk partition to run this command.
3896
3897 All entries in the filesystem are returned. This function can list
3898 deleted or unaccessible files. The entries are not sorted.
3899
3900 The "tsk_dirent" structure contains the following fields.
3901
3902 "tsk_inode"
3903 Filesystem reference number of the node. It might be 0 if the node
3904 has been deleted.
3905
3906 "tsk_type"
3907 Basic file type information. See below for a detailed list of
3908 values.
3909
3910 "tsk_size"
3911 File size in bytes. It might be "-1" if the node has been deleted.
3912
3913 "tsk_name"
3914 The file path relative to its directory.
3915
3916 "tsk_flags"
3917 Bitfield containing extra information regarding the entry. It
3918 contains the logical OR of the following values:
3919
3920 0x0001
3921 If set to 1, the file is allocated and visible within the
3922 filesystem. Otherwise, the file has been deleted. Under
3923 certain circumstances, the function "download_inode" can be
3924 used to recover deleted files.
3925
3926 0x0002
3927 Filesystem such as NTFS and Ext2 or greater, separate the file
3928 name from the metadata structure. The bit is set to 1 when the
3929 file name is in an unallocated state and the metadata structure
3930 is in an allocated one. This generally implies the metadata
3931 has been reallocated to a new file. Therefore, information
3932 such as file type, file size, timestamps, number of links and
3933 symlink target might not correspond with the ones of the
3934 original deleted entry.
3935
3936 0x0004
3937 The bit is set to 1 when the file is compressed using
3938 filesystem native compression support (NTFS). The API is not
3939 able to detect application level compression.
3940
3941 "tsk_atime_sec"
3942 "tsk_atime_nsec"
3943 "tsk_mtime_sec"
3944 "tsk_mtime_nsec"
3945 "tsk_ctime_sec"
3946 "tsk_ctime_nsec"
3947 "tsk_crtime_sec"
3948 "tsk_crtime_nsec"
3949 Respectively, access, modification, last status change and creation
3950 time in Unix format in seconds and nanoseconds.
3951
3952 "tsk_nlink"
3953 Number of file names pointing to this entry.
3954
3955 "tsk_link"
3956 If the entry is a symbolic link, this field will contain the path
3957 to the target file.
3958
3959 The "tsk_type" field will contain one of the following characters:
3960
3961 'b' Block special
3962
3963 'c' Char special
3964
3965 'd' Directory
3966
3967 'f' FIFO (named pipe)
3968
3969 'l' Symbolic link
3970
3971 'r' Regular file
3972
3973 's' Socket
3974
3975 'h' Shadow inode (Solaris)
3976
3977 'w' Whiteout inode (BSD)
3978
3979 'u' Unknown file type
3980
3981 This command depends on the feature "libtsk". See also "feature-
3982 available".
3983
3984 fill
3985 fill c len path
3986
3987 This command creates a new file called "path". The initial content of
3988 the file is "len" octets of "c", where "c" must be a number in the
3989 range "[0..255]".
3990
3991 To fill a file with zero bytes (sparsely), it is much more efficient to
3992 use "truncate-size". To create a file with a pattern of repeating
3993 bytes use "fill-pattern".
3994
3995 fill-dir
3996 fill-dir dir nr
3997
3998 This function, useful for testing filesystems, creates "nr" empty files
3999 in the directory "dir" with names 00000000 through "nr-1" (ie. each
4000 file name is 8 digits long padded with zeroes).
4001
4002 fill-pattern
4003 fill-pattern pattern len path
4004
4005 This function is like "fill" except that it creates a new file of
4006 length "len" containing the repeating pattern of bytes in "pattern".
4007 The pattern is truncated if necessary to ensure the length of the file
4008 is exactly "len" bytes.
4009
4010 find
4011 find directory
4012
4013 This command lists out all files and directories, recursively, starting
4014 at directory. It is essentially equivalent to running the shell
4015 command "find directory -print" but some post-processing happens on the
4016 output, described below.
4017
4018 This returns a list of strings without any prefix. Thus if the
4019 directory structure was:
4020
4021 /tmp/a
4022 /tmp/b
4023 /tmp/c/d
4024
4025 then the returned list from "find" /tmp would be 4 elements:
4026
4027 a
4028 b
4029 c
4030 c/d
4031
4032 If directory is not a directory, then this command returns an error.
4033
4034 The returned list is sorted.
4035
4036 find0
4037 find0 directory (files|-)
4038
4039 This command lists out all files and directories, recursively, starting
4040 at directory, placing the resulting list in the external file called
4041 files.
4042
4043 This command works the same way as "find" with the following
4044 exceptions:
4045
4046 • The resulting list is written to an external file.
4047
4048 • Items (filenames) in the result are separated by "\0" characters.
4049 See find(1) option -print0.
4050
4051 • The result list is not sorted.
4052
4053 Use "-" instead of a filename to read/write from stdin/stdout.
4054
4055 find-inode
4056 find-inode device inode
4057
4058 Searches all the entries associated with the given inode.
4059
4060 For each entry, a "tsk_dirent" structure is returned. See
4061 "filesystem_walk" for more information about "tsk_dirent" structures.
4062
4063 This command depends on the feature "libtsk". See also "feature-
4064 available".
4065
4066 findfs-label
4067 findfs-label label
4068
4069 This command searches the filesystems and returns the one which has the
4070 given label. An error is returned if no such filesystem can be found.
4071
4072 To find the label of a filesystem, use "vfs-label".
4073
4074 findfs-uuid
4075 findfs-uuid uuid
4076
4077 This command searches the filesystems and returns the one which has the
4078 given UUID. An error is returned if no such filesystem can be found.
4079
4080 To find the UUID of a filesystem, use "vfs-uuid".
4081
4082 fsck
4083 fsck fstype device
4084
4085 This runs the filesystem checker (fsck) on "device" which should have
4086 filesystem type "fstype".
4087
4088 The returned integer is the status. See fsck(8) for the list of status
4089 codes from "fsck".
4090
4091 Notes:
4092
4093 • Multiple status codes can be summed together.
4094
4095 • A non-zero return code can mean "success", for example if errors
4096 have been corrected on the filesystem.
4097
4098 • Checking or repairing NTFS volumes is not supported (by linux-
4099 ntfs).
4100
4101 This command is entirely equivalent to running "fsck -a -t fstype
4102 device".
4103
4104 fstrim
4105 fstrim mountpoint [offset:N] [length:N] [minimumfreeextent:N]
4106
4107 Trim the free space in the filesystem mounted on "mountpoint". The
4108 filesystem must be mounted read-write.
4109
4110 The filesystem contents are not affected, but any free space in the
4111 filesystem is "trimmed", that is, given back to the host device, thus
4112 making disk images more sparse, allowing unused space in qcow2 files to
4113 be reused, etc.
4114
4115 This operation requires support in libguestfs, the mounted filesystem,
4116 the host filesystem, qemu and the host kernel. If this support isn't
4117 present it may give an error or even appear to run but do nothing.
4118
4119 In the case where the kernel vfs driver does not support trimming, this
4120 call will fail with errno set to "ENOTSUP". Currently this happens
4121 when trying to trim FAT filesystems.
4122
4123 See also "zero-free-space". That is a slightly different operation
4124 that turns free space in the filesystem into zeroes. It is valid to
4125 call "fstrim" either instead of, or after calling "zero-free-space".
4126
4127 This command has one or more optional arguments. See "OPTIONAL
4128 ARGUMENTS".
4129
4130 This command depends on the feature "fstrim". See also "feature-
4131 available".
4132
4133 get-append
4134 get-append
4135
4136 Return the additional kernel options which are added to the libguestfs
4137 appliance kernel command line.
4138
4139 If "NULL" then no options are added.
4140
4141 get-attach-method
4142 get-attach-method
4143
4144 Return the current backend.
4145
4146 See "set-backend" and "BACKEND" in guestfs(3).
4147
4148 This function is deprecated. In new code, use the "get-backend" call
4149 instead.
4150
4151 Deprecated functions will not be removed from the API, but the fact
4152 that they are deprecated indicates that there are problems with correct
4153 use of these functions.
4154
4155 get-autosync
4156 get-autosync
4157
4158 Get the autosync flag.
4159
4160 get-backend
4161 get-backend
4162
4163 Return the current backend.
4164
4165 This handle property was previously called the "attach method".
4166
4167 See "set-backend" and "BACKEND" in guestfs(3).
4168
4169 get-backend-setting
4170 get-backend-setting name
4171
4172 Find a backend setting string which is either "name" or begins with
4173 "name=". If "name", this returns the string "1". If "name=", this
4174 returns the part after the equals sign (which may be an empty string).
4175
4176 If no such setting is found, this function throws an error. The errno
4177 (see "last-errno") will be "ESRCH" in this case.
4178
4179 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
4180
4181 get-backend-settings
4182 get-backend-settings
4183
4184 Return the current backend settings.
4185
4186 This call returns all backend settings strings. If you want to find a
4187 single backend setting, see "get-backend-setting".
4188
4189 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
4190
4191 get-cachedir
4192 get-cachedir
4193
4194 Get the directory used by the handle to store the appliance cache.
4195
4196 get-direct
4197 get-direct
4198
4199 Return the direct appliance mode flag.
4200
4201 This function is deprecated. In new code, use the "internal-get-
4202 console-socket" call instead.
4203
4204 Deprecated functions will not be removed from the API, but the fact
4205 that they are deprecated indicates that there are problems with correct
4206 use of these functions.
4207
4208 get-e2attrs
4209 get-e2attrs file
4210
4211 This returns the file attributes associated with file.
4212
4213 The attributes are a set of bits associated with each inode which
4214 affect the behaviour of the file. The attributes are returned as a
4215 string of letters (described below). The string may be empty,
4216 indicating that no file attributes are set for this file.
4217
4218 These attributes are only present when the file is located on an
4219 ext2/3/4 filesystem. Using this call on other filesystem types will
4220 result in an error.
4221
4222 The characters (file attributes) in the returned string are currently:
4223
4224 'A' When the file is accessed, its atime is not modified.
4225
4226 'a' The file is append-only.
4227
4228 'c' The file is compressed on-disk.
4229
4230 'D' (Directories only.) Changes to this directory are written
4231 synchronously to disk.
4232
4233 'd' The file is not a candidate for backup (see dump(8)).
4234
4235 'E' The file has compression errors.
4236
4237 'e' The file is using extents.
4238
4239 'h' The file is storing its blocks in units of the filesystem blocksize
4240 instead of sectors.
4241
4242 'I' (Directories only.) The directory is using hashed trees.
4243
4244 'i' The file is immutable. It cannot be modified, deleted or renamed.
4245 No link can be created to this file.
4246
4247 'j' The file is data-journaled.
4248
4249 's' When the file is deleted, all its blocks will be zeroed.
4250
4251 'S' Changes to this file are written synchronously to disk.
4252
4253 'T' (Directories only.) This is a hint to the block allocator that
4254 subdirectories contained in this directory should be spread across
4255 blocks. If not present, the block allocator will try to group
4256 subdirectories together.
4257
4258 't' For a file, this disables tail-merging. (Not used by upstream
4259 implementations of ext2.)
4260
4261 'u' When the file is deleted, its blocks will be saved, allowing the
4262 file to be undeleted.
4263
4264 'X' The raw contents of the compressed file may be accessed.
4265
4266 'Z' The compressed file is dirty.
4267
4268 More file attributes may be added to this list later. Not all file
4269 attributes may be set for all kinds of files. For detailed
4270 information, consult the chattr(1) man page.
4271
4272 See also "set-e2attrs".
4273
4274 Don't confuse these attributes with extended attributes (see
4275 "getxattr").
4276
4277 get-e2generation
4278 get-e2generation file
4279
4280 This returns the ext2 file generation of a file. The generation (which
4281 used to be called the "version") is a number associated with an inode.
4282 This is most commonly used by NFS servers.
4283
4284 The generation is only present when the file is located on an ext2/3/4
4285 filesystem. Using this call on other filesystem types will result in
4286 an error.
4287
4288 See "set-e2generation".
4289
4290 get-e2label
4291 get-e2label device
4292
4293 This returns the ext2/3/4 filesystem label of the filesystem on
4294 "device".
4295
4296 This function is deprecated. In new code, use the "vfs-label" call
4297 instead.
4298
4299 Deprecated functions will not be removed from the API, but the fact
4300 that they are deprecated indicates that there are problems with correct
4301 use of these functions.
4302
4303 get-e2uuid
4304 get-e2uuid device
4305
4306 This returns the ext2/3/4 filesystem UUID of the filesystem on
4307 "device".
4308
4309 This function is deprecated. In new code, use the "vfs-uuid" call
4310 instead.
4311
4312 Deprecated functions will not be removed from the API, but the fact
4313 that they are deprecated indicates that there are problems with correct
4314 use of these functions.
4315
4316 get-hv
4317 get-hv
4318
4319 Return the current hypervisor binary.
4320
4321 This is always non-NULL. If it wasn't set already, then this will
4322 return the default qemu binary name.
4323
4324 get-identifier
4325 get-identifier
4326
4327 Get the handle identifier. See "set-identifier".
4328
4329 get-libvirt-requested-credential-challenge
4330 get-libvirt-requested-credential-challenge index
4331
4332 Get the challenge (provided by libvirt) for the "index"'th requested
4333 credential. If libvirt did not provide a challenge, this returns the
4334 empty string "".
4335
4336 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
4337 example code.
4338
4339 get-libvirt-requested-credential-defresult
4340 get-libvirt-requested-credential-defresult index
4341
4342 Get the default result (provided by libvirt) for the "index"'th
4343 requested credential. If libvirt did not provide a default result,
4344 this returns the empty string "".
4345
4346 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
4347 example code.
4348
4349 get-libvirt-requested-credential-prompt
4350 get-libvirt-requested-credential-prompt index
4351
4352 Get the prompt (provided by libvirt) for the "index"'th requested
4353 credential. If libvirt did not provide a prompt, this returns the
4354 empty string "".
4355
4356 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
4357 example code.
4358
4359 get-libvirt-requested-credentials
4360 get-libvirt-requested-credentials
4361
4362 This should only be called during the event callback for events of type
4363 "GUESTFS_EVENT_LIBVIRT_AUTH".
4364
4365 Return the list of credentials requested by libvirt. Possible values
4366 are a subset of the strings provided when you called "set-libvirt-
4367 supported-credentials".
4368
4369 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
4370 example code.
4371
4372 get-memsize
4373 get-memsize
4374
4375 This gets the memory size in megabytes allocated to the hypervisor.
4376
4377 If "set-memsize" was not called on this handle, and if
4378 "LIBGUESTFS_MEMSIZE" was not set, then this returns the compiled-in
4379 default value for memsize.
4380
4381 For more information on the architecture of libguestfs, see guestfs(3).
4382
4383 get-network
4384 get-network
4385
4386 This returns the enable network flag.
4387
4388 get-path
4389 get-path
4390
4391 Return the current search path.
4392
4393 This is always non-NULL. If it wasn't set already, then this will
4394 return the default path.
4395
4396 get-pgroup
4397 get-pgroup
4398
4399 This returns the process group flag.
4400
4401 get-pid
4402 pid
4403 get-pid
4404
4405 Return the process ID of the hypervisor. If there is no hypervisor
4406 running, then this will return an error.
4407
4408 This is an internal call used for debugging and testing.
4409
4410 get-program
4411 get-program
4412
4413 Get the program name. See "set-program".
4414
4415 get-qemu
4416 get-qemu
4417
4418 Return the current hypervisor binary (usually qemu).
4419
4420 This is always non-NULL. If it wasn't set already, then this will
4421 return the default qemu binary name.
4422
4423 This function is deprecated. In new code, use the "get-hv" call
4424 instead.
4425
4426 Deprecated functions will not be removed from the API, but the fact
4427 that they are deprecated indicates that there are problems with correct
4428 use of these functions.
4429
4430 get-recovery-proc
4431 get-recovery-proc
4432
4433 Return the recovery process enabled flag.
4434
4435 get-selinux
4436 get-selinux
4437
4438 This returns the current setting of the selinux flag which is passed to
4439 the appliance at boot time. See "set-selinux".
4440
4441 For more information on the architecture of libguestfs, see guestfs(3).
4442
4443 This function is deprecated. In new code, use the "selinux-relabel"
4444 call instead.
4445
4446 Deprecated functions will not be removed from the API, but the fact
4447 that they are deprecated indicates that there are problems with correct
4448 use of these functions.
4449
4450 get-smp
4451 get-smp
4452
4453 This returns the number of virtual CPUs assigned to the appliance.
4454
4455 get-sockdir
4456 get-sockdir
4457
4458 Get the directory used by the handle to store temporary socket files.
4459
4460 This is different from "get-tmpdir", as we need shorter paths for
4461 sockets (due to the limited buffers of filenames for UNIX sockets), and
4462 "get-tmpdir" may be too long for them.
4463
4464 The environment variable "XDG_RUNTIME_DIR" controls the default value:
4465 If "XDG_RUNTIME_DIR" is set, then that is the default. Else /tmp is
4466 the default.
4467
4468 get-tmpdir
4469 get-tmpdir
4470
4471 Get the directory used by the handle to store temporary files.
4472
4473 get-trace
4474 get-trace
4475
4476 Return the command trace flag.
4477
4478 get-umask
4479 get-umask
4480
4481 Return the current umask. By default the umask is 022 unless it has
4482 been set by calling "umask".
4483
4484 get-verbose
4485 get-verbose
4486
4487 This returns the verbose messages flag.
4488
4489 getcon
4490 getcon
4491
4492 This gets the SELinux security context of the daemon.
4493
4494 See the documentation about SELINUX in guestfs(3), and "setcon"
4495
4496 This function is deprecated. In new code, use the "selinux-relabel"
4497 call instead.
4498
4499 Deprecated functions will not be removed from the API, but the fact
4500 that they are deprecated indicates that there are problems with correct
4501 use of these functions.
4502
4503 This command depends on the feature "selinux". See also "feature-
4504 available".
4505
4506 getxattr
4507 getxattr path name
4508
4509 Get a single extended attribute from file "path" named "name". This
4510 call follows symlinks. If you want to lookup an extended attribute for
4511 the symlink itself, use "lgetxattr".
4512
4513 Normally it is better to get all extended attributes from a file in one
4514 go by calling "getxattrs". However some Linux filesystem
4515 implementations are buggy and do not provide a way to list out
4516 attributes. For these filesystems (notably ntfs-3g) you have to know
4517 the names of the extended attributes you want in advance and call this
4518 function.
4519
4520 Extended attribute values are blobs of binary data. If there is no
4521 extended attribute named "name", this returns an error.
4522
4523 See also: "getxattrs", "lgetxattr", attr(5).
4524
4525 This command depends on the feature "linuxxattrs". See also "feature-
4526 available".
4527
4528 getxattrs
4529 getxattrs path
4530
4531 This call lists the extended attributes of the file or directory
4532 "path".
4533
4534 At the system call level, this is a combination of the listxattr(2) and
4535 getxattr(2) calls.
4536
4537 See also: "lgetxattrs", attr(5).
4538
4539 This command depends on the feature "linuxxattrs". See also "feature-
4540 available".
4541
4542 glob-expand
4543 glob-expand-opts
4544 glob-expand pattern [directoryslash:true|false]
4545
4546 This command searches for all the pathnames matching "pattern"
4547 according to the wildcard expansion rules used by the shell.
4548
4549 If no paths match, then this returns an empty list (note: not an
4550 error).
4551
4552 It is just a wrapper around the C glob(3) function with flags
4553 "GLOB_MARK|GLOB_BRACE". See that manual page for more details.
4554
4555 "directoryslash" controls whether use the "GLOB_MARK" flag for glob(3),
4556 and it defaults to true. It can be explicitly set as off to return no
4557 trailing slashes in filenames of directories.
4558
4559 Notice that there is no equivalent command for expanding a device name
4560 (eg. /dev/sd*). Use "list-devices", "list-partitions" etc functions
4561 instead.
4562
4563 This command has one or more optional arguments. See "OPTIONAL
4564 ARGUMENTS".
4565
4566 grep
4567 grep-opts
4568 grep regex path [extended:true|false] [fixed:true|false] [insensitive:true|false] [compressed:true|false]
4569
4570 This calls the external grep(1) program and returns the matching lines.
4571
4572 The optional flags are:
4573
4574 "extended"
4575 Use extended regular expressions. This is the same as using the -E
4576 flag.
4577
4578 "fixed"
4579 Match fixed (don't use regular expressions). This is the same as
4580 using the -F flag.
4581
4582 "insensitive"
4583 Match case-insensitive. This is the same as using the -i flag.
4584
4585 "compressed"
4586 Use zgrep(1) instead of grep(1). This allows the input to be
4587 compress- or gzip-compressed.
4588
4589 This command has one or more optional arguments. See "OPTIONAL
4590 ARGUMENTS".
4591
4592 Because of the message protocol, there is a transfer limit of somewhere
4593 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4594
4595 grepi
4596 grepi regex path
4597
4598 This calls the external "grep -i" program and returns the matching
4599 lines.
4600
4601 Because of the message protocol, there is a transfer limit of somewhere
4602 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4603
4604 This function is deprecated. In new code, use the "grep" call instead.
4605
4606 Deprecated functions will not be removed from the API, but the fact
4607 that they are deprecated indicates that there are problems with correct
4608 use of these functions.
4609
4610 grub-install
4611 grub-install root device
4612
4613 This command installs GRUB 1 (the Grand Unified Bootloader) on
4614 "device", with the root directory being "root".
4615
4616 Notes:
4617
4618 • There is currently no way in the API to install grub2, which is
4619 used by most modern Linux guests. It is possible to run the grub2
4620 command from the guest, although see the caveats in "RUNNING
4621 COMMANDS" in guestfs(3).
4622
4623 • This uses grub-install(8) from the host. Unfortunately grub is not
4624 always compatible with itself, so this only works in rather narrow
4625 circumstances. Careful testing with each guest version is
4626 advisable.
4627
4628 • If grub-install reports the error "No suitable drive was found in
4629 the generated device map." it may be that you need to create a
4630 /boot/grub/device.map file first that contains the mapping between
4631 grub device names and Linux device names. It is usually sufficient
4632 to create a file containing:
4633
4634 (hd0) /dev/vda
4635
4636 replacing /dev/vda with the name of the installation device.
4637
4638 This command depends on the feature "grub". See also "feature-
4639 available".
4640
4641 head
4642 head path
4643
4644 This command returns up to the first 10 lines of a file as a list of
4645 strings.
4646
4647 Because of the message protocol, there is a transfer limit of somewhere
4648 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4649
4650 head-n
4651 head-n nrlines path
4652
4653 If the parameter "nrlines" is a positive number, this returns the first
4654 "nrlines" lines of the file "path".
4655
4656 If the parameter "nrlines" is a negative number, this returns lines
4657 from the file "path", excluding the last "nrlines" lines.
4658
4659 If the parameter "nrlines" is zero, this returns an empty list.
4660
4661 Because of the message protocol, there is a transfer limit of somewhere
4662 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4663
4664 hexdump
4665 hexdump path
4666
4667 This runs "hexdump -C" on the given "path". The result is the human-
4668 readable, canonical hex dump of the file.
4669
4670 Because of the message protocol, there is a transfer limit of somewhere
4671 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4672
4673 hivex-close
4674 hivex-close
4675
4676 Close the current hivex handle.
4677
4678 This is a wrapper around the hivex(3) call of the same name.
4679
4680 This command depends on the feature "hivex". See also "feature-
4681 available".
4682
4683 hivex-commit
4684 hivex-commit filename
4685
4686 Commit (write) changes to the hive.
4687
4688 If the optional filename parameter is null, then the changes are
4689 written back to the same hive that was opened. If this is not null
4690 then they are written to the alternate filename given and the original
4691 hive is left untouched.
4692
4693 This is a wrapper around the hivex(3) call of the same name.
4694
4695 This command depends on the feature "hivex". See also "feature-
4696 available".
4697
4698 hivex-node-add-child
4699 hivex-node-add-child parent name
4700
4701 Add a child node to "parent" named "name".
4702
4703 This is a wrapper around the hivex(3) call of the same name.
4704
4705 This command depends on the feature "hivex". See also "feature-
4706 available".
4707
4708 hivex-node-children
4709 hivex-node-children nodeh
4710
4711 Return the list of nodes which are subkeys of "nodeh".
4712
4713 This is a wrapper around the hivex(3) call of the same name.
4714
4715 This command depends on the feature "hivex". See also "feature-
4716 available".
4717
4718 hivex-node-delete-child
4719 hivex-node-delete-child nodeh
4720
4721 Delete "nodeh", recursively if necessary.
4722
4723 This is a wrapper around the hivex(3) call of the same name.
4724
4725 This command depends on the feature "hivex". See also "feature-
4726 available".
4727
4728 hivex-node-get-child
4729 hivex-node-get-child nodeh name
4730
4731 Return the child of "nodeh" with the name "name", if it exists. This
4732 can return 0 meaning the name was not found.
4733
4734 This is a wrapper around the hivex(3) call of the same name.
4735
4736 This command depends on the feature "hivex". See also "feature-
4737 available".
4738
4739 hivex-node-get-value
4740 hivex-node-get-value nodeh key
4741
4742 Return the value attached to "nodeh" which has the name "key", if it
4743 exists. This can return 0 meaning the key was not found.
4744
4745 This is a wrapper around the hivex(3) call of the same name.
4746
4747 This command depends on the feature "hivex". See also "feature-
4748 available".
4749
4750 hivex-node-name
4751 hivex-node-name nodeh
4752
4753 Return the name of "nodeh".
4754
4755 This is a wrapper around the hivex(3) call of the same name.
4756
4757 This command depends on the feature "hivex". See also "feature-
4758 available".
4759
4760 hivex-node-parent
4761 hivex-node-parent nodeh
4762
4763 Return the parent node of "nodeh".
4764
4765 This is a wrapper around the hivex(3) call of the same name.
4766
4767 This command depends on the feature "hivex". See also "feature-
4768 available".
4769
4770 hivex-node-set-value
4771 hivex-node-set-value nodeh key t val
4772
4773 Set or replace a single value under the node "nodeh". The "key" is the
4774 name, "t" is the type, and "val" is the data.
4775
4776 This is a wrapper around the hivex(3) call of the same name.
4777
4778 This command depends on the feature "hivex". See also "feature-
4779 available".
4780
4781 hivex-node-values
4782 hivex-node-values nodeh
4783
4784 Return the array of (key, datatype, data) tuples attached to "nodeh".
4785
4786 This is a wrapper around the hivex(3) call of the same name.
4787
4788 This command depends on the feature "hivex". See also "feature-
4789 available".
4790
4791 hivex-open
4792 hivex-open filename [verbose:true|false] [debug:true|false] [write:true|false] [unsafe:true|false]
4793
4794 Open the Windows Registry hive file named filename. If there was any
4795 previous hivex handle associated with this guestfs session, then it is
4796 closed.
4797
4798 This is a wrapper around the hivex(3) call of the same name.
4799
4800 This command has one or more optional arguments. See "OPTIONAL
4801 ARGUMENTS".
4802
4803 This command depends on the feature "hivex". See also "feature-
4804 available".
4805
4806 hivex-root
4807 hivex-root
4808
4809 Return the root node of the hive.
4810
4811 This is a wrapper around the hivex(3) call of the same name.
4812
4813 This command depends on the feature "hivex". See also "feature-
4814 available".
4815
4816 hivex-value-key
4817 hivex-value-key valueh
4818
4819 Return the key (name) field of a (key, datatype, data) tuple.
4820
4821 This is a wrapper around the hivex(3) call of the same name.
4822
4823 This command depends on the feature "hivex". See also "feature-
4824 available".
4825
4826 hivex-value-string
4827 hivex-value-string valueh
4828
4829 This calls "hivex-value-value" (which returns the data field from a
4830 hivex value tuple). It then assumes that the field is a UTF-16LE
4831 string and converts the result to UTF-8 (or if this is not possible, it
4832 returns an error).
4833
4834 This is useful for reading strings out of the Windows registry.
4835 However it is not foolproof because the registry is not strongly-typed
4836 and fields can contain arbitrary or unexpected data.
4837
4838 This command depends on the feature "hivex". See also "feature-
4839 available".
4840
4841 hivex-value-type
4842 hivex-value-type valueh
4843
4844 Return the data type field from a (key, datatype, data) tuple.
4845
4846 This is a wrapper around the hivex(3) call of the same name.
4847
4848 This command depends on the feature "hivex". See also "feature-
4849 available".
4850
4851 hivex-value-utf8
4852 hivex-value-utf8 valueh
4853
4854 This calls "hivex-value-value" (which returns the data field from a
4855 hivex value tuple). It then assumes that the field is a UTF-16LE
4856 string and converts the result to UTF-8 (or if this is not possible, it
4857 returns an error).
4858
4859 This is useful for reading strings out of the Windows registry.
4860 However it is not foolproof because the registry is not strongly-typed
4861 and fields can contain arbitrary or unexpected data.
4862
4863 This function is deprecated. In new code, use the "hivex-value-string"
4864 call instead.
4865
4866 Deprecated functions will not be removed from the API, but the fact
4867 that they are deprecated indicates that there are problems with correct
4868 use of these functions.
4869
4870 This command depends on the feature "hivex". See also "feature-
4871 available".
4872
4873 hivex-value-value
4874 hivex-value-value valueh
4875
4876 Return the data field of a (key, datatype, data) tuple.
4877
4878 This is a wrapper around the hivex(3) call of the same name.
4879
4880 See also: "hivex-value-utf8".
4881
4882 This command depends on the feature "hivex". See also "feature-
4883 available".
4884
4885 initrd-cat
4886 initrd-cat initrdpath filename
4887
4888 This command unpacks the file filename from the initrd file called
4889 initrdpath. The filename must be given without the initial /
4890 character.
4891
4892 For example, in guestfish you could use the following command to
4893 examine the boot script (usually called /init) contained in a Linux
4894 initrd or initramfs image:
4895
4896 initrd-cat /boot/initrd-<version>.img init
4897
4898 See also "initrd-list".
4899
4900 Because of the message protocol, there is a transfer limit of somewhere
4901 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4902
4903 initrd-list
4904 initrd-list path
4905
4906 This command lists out files contained in an initrd.
4907
4908 The files are listed without any initial / character. The files are
4909 listed in the order they appear (not necessarily alphabetical).
4910 Directory names are listed as separate items.
4911
4912 Old Linux kernels (2.4 and earlier) used a compressed ext2 filesystem
4913 as initrd. We only support the newer initramfs format (compressed cpio
4914 files).
4915
4916 inotify-add-watch
4917 inotify-add-watch path mask
4918
4919 Watch "path" for the events listed in "mask".
4920
4921 Note that if "path" is a directory then events within that directory
4922 are watched, but this does not happen recursively (in subdirectories).
4923
4924 Note for non-C or non-Linux callers: the inotify events are defined by
4925 the Linux kernel ABI and are listed in /usr/include/sys/inotify.h.
4926
4927 This command depends on the feature "inotify". See also "feature-
4928 available".
4929
4930 inotify-close
4931 inotify-close
4932
4933 This closes the inotify handle which was previously opened by
4934 inotify_init. It removes all watches, throws away any pending events,
4935 and deallocates all resources.
4936
4937 This command depends on the feature "inotify". See also "feature-
4938 available".
4939
4940 inotify-files
4941 inotify-files
4942
4943 This function is a helpful wrapper around "inotify-read" which just
4944 returns a list of pathnames of objects that were touched. The returned
4945 pathnames are sorted and deduplicated.
4946
4947 This command depends on the feature "inotify". See also "feature-
4948 available".
4949
4950 inotify-init
4951 inotify-init maxevents
4952
4953 This command creates a new inotify handle. The inotify subsystem can
4954 be used to notify events which happen to objects in the guest
4955 filesystem.
4956
4957 "maxevents" is the maximum number of events which will be queued up
4958 between calls to "inotify-read" or "inotify-files". If this is passed
4959 as 0, then the kernel (or previously set) default is used. For Linux
4960 2.6.29 the default was 16384 events. Beyond this limit, the kernel
4961 throws away events, but records the fact that it threw them away by
4962 setting a flag "IN_Q_OVERFLOW" in the returned structure list (see
4963 "inotify-read").
4964
4965 Before any events are generated, you have to add some watches to the
4966 internal watch list. See: "inotify-add-watch" and "inotify-rm-watch".
4967
4968 Queued up events should be read periodically by calling "inotify-read"
4969 (or "inotify-files" which is just a helpful wrapper around "inotify-
4970 read"). If you don't read the events out often enough then you risk
4971 the internal queue overflowing.
4972
4973 The handle should be closed after use by calling "inotify-close". This
4974 also removes any watches automatically.
4975
4976 See also inotify(7) for an overview of the inotify interface as exposed
4977 by the Linux kernel, which is roughly what we expose via libguestfs.
4978 Note that there is one global inotify handle per libguestfs instance.
4979
4980 This command depends on the feature "inotify". See also "feature-
4981 available".
4982
4983 inotify-read
4984 inotify-read
4985
4986 Return the complete queue of events that have happened since the
4987 previous read call.
4988
4989 If no events have happened, this returns an empty list.
4990
4991 Note: In order to make sure that all events have been read, you must
4992 call this function repeatedly until it returns an empty list. The
4993 reason is that the call will read events up to the maximum appliance-
4994 to-host message size and leave remaining events in the queue.
4995
4996 This command depends on the feature "inotify". See also "feature-
4997 available".
4998
4999 inotify-rm-watch
5000 inotify-rm-watch wd
5001
5002 Remove a previously defined inotify watch. See "inotify-add-watch".
5003
5004 This command depends on the feature "inotify". See also "feature-
5005 available".
5006
5007 inspect-get-arch
5008 inspect-get-arch root
5009
5010 This returns the architecture of the inspected operating system. The
5011 possible return values are listed under "file-architecture".
5012
5013 If the architecture could not be determined, then the string "unknown"
5014 is returned.
5015
5016 Please read "INSPECTION" in guestfs(3) for more details.
5017
5018 inspect-get-build-id
5019 inspect-get-build-id root
5020
5021 This returns the build ID of the system, or the string "unknown" if the
5022 system does not have a build ID.
5023
5024 For Windows, this gets the build number. Although it is returned as a
5025 string, it is (so far) always a number. See
5026 https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions for
5027 some possible values.
5028
5029 For Linux, this returns the "BUILD_ID" string from /etc/os-release,
5030 although this is not often used.
5031
5032 Please read "INSPECTION" in guestfs(3) for more details.
5033
5034 inspect-get-distro
5035 inspect-get-distro root
5036
5037 This returns the distro (distribution) of the inspected operating
5038 system.
5039
5040 Currently defined distros are:
5041
5042 "alpinelinux"
5043 Alpine Linux.
5044
5045 "altlinux"
5046 ALT Linux.
5047
5048 "archlinux"
5049 Arch Linux.
5050
5051 "buildroot"
5052 Buildroot-derived distro, but not one we specifically recognize.
5053
5054 "centos"
5055 CentOS.
5056
5057 "cirros"
5058 Cirros.
5059
5060 "coreos"
5061 CoreOS.
5062
5063 "debian"
5064 Debian.
5065
5066 "fedora"
5067 Fedora.
5068
5069 "freebsd"
5070 FreeBSD.
5071
5072 "freedos"
5073 FreeDOS.
5074
5075 "frugalware"
5076 Frugalware.
5077
5078 "gentoo"
5079 Gentoo.
5080
5081 "kalilinux"
5082 Kali Linux.
5083
5084 "kylin"
5085 Kylin.
5086
5087 "linuxmint"
5088 Linux Mint.
5089
5090 "mageia"
5091 Mageia.
5092
5093 "mandriva"
5094 Mandriva.
5095
5096 "meego"
5097 MeeGo.
5098
5099 "msdos"
5100 Microsoft DOS.
5101
5102 "neokylin"
5103 NeoKylin.
5104
5105 "netbsd"
5106 NetBSD.
5107
5108 "openbsd"
5109 OpenBSD.
5110
5111 "openmandriva"
5112 OpenMandriva Lx.
5113
5114 "opensuse"
5115 OpenSUSE.
5116
5117 "oraclelinux"
5118 Oracle Linux.
5119
5120 "pardus"
5121 Pardus.
5122
5123 "pldlinux"
5124 PLD Linux.
5125
5126 "redhat-based"
5127 Some Red Hat-derived distro.
5128
5129 "rhel"
5130 Red Hat Enterprise Linux.
5131
5132 "rocky"
5133 Rocky Linux.
5134
5135 "scientificlinux"
5136 Scientific Linux.
5137
5138 "slackware"
5139 Slackware.
5140
5141 "sles"
5142 SuSE Linux Enterprise Server or Desktop.
5143
5144 "suse-based"
5145 Some openSuSE-derived distro.
5146
5147 "ttylinux"
5148 ttylinux.
5149
5150 "ubuntu"
5151 Ubuntu.
5152
5153 "unknown"
5154 The distro could not be determined.
5155
5156 "voidlinux"
5157 Void Linux.
5158
5159 "windows"
5160 Windows does not have distributions. This string is returned if
5161 the OS type is Windows.
5162
5163 Future versions of libguestfs may return other strings here. The
5164 caller should be prepared to handle any string.
5165
5166 Please read "INSPECTION" in guestfs(3) for more details.
5167
5168 inspect-get-drive-mappings
5169 inspect-get-drive-mappings root
5170
5171 This call is useful for Windows which uses a primitive system of
5172 assigning drive letters (like C:\) to partitions. This inspection API
5173 examines the Windows Registry to find out how disks/partitions are
5174 mapped to drive letters, and returns a hash table as in the example
5175 below:
5176
5177 C => /dev/vda2
5178 E => /dev/vdb1
5179 F => /dev/vdc1
5180
5181 Note that keys are drive letters. For Windows, the key is case
5182 insensitive and just contains the drive letter, without the customary
5183 colon separator character.
5184
5185 In future we may support other operating systems that also used drive
5186 letters, but the keys for those might not be case insensitive and might
5187 be longer than 1 character. For example in OS-9, hard drives were
5188 named "h0", "h1" etc.
5189
5190 For Windows guests, currently only hard drive mappings are returned.
5191 Removable disks (eg. DVD-ROMs) are ignored.
5192
5193 For guests that do not use drive mappings, or if the drive mappings
5194 could not be determined, this returns an empty hash table.
5195
5196 Please read "INSPECTION" in guestfs(3) for more details. See also
5197 "inspect-get-mountpoints", "inspect-get-filesystems".
5198
5199 inspect-get-filesystems
5200 inspect-get-filesystems root
5201
5202 This returns a list of all the filesystems that we think are associated
5203 with this operating system. This includes the root filesystem, other
5204 ordinary filesystems, and non-mounted devices like swap partitions.
5205
5206 In the case of a multi-boot virtual machine, it is possible for a
5207 filesystem to be shared between operating systems.
5208
5209 Please read "INSPECTION" in guestfs(3) for more details. See also
5210 "inspect-get-mountpoints".
5211
5212 inspect-get-format
5213 inspect-get-format root
5214
5215 Before libguestfs 1.38, there was some unreliable support for detecting
5216 installer CDs. This API would return:
5217
5218 "installed"
5219 This is an installed operating system.
5220
5221 "installer"
5222 The disk image being inspected is not an installed operating
5223 system, but a bootable install disk, live CD, or similar.
5224
5225 "unknown"
5226 The format of this disk image is not known.
5227
5228 In libguestfs ≥ 1.38, this only returns "installed". Use libosinfo
5229 directly to detect installer CDs.
5230
5231 Please read "INSPECTION" in guestfs(3) for more details.
5232
5233 This function is deprecated. There is no replacement. Consult the API
5234 documentation in guestfs(3) for further information.
5235
5236 Deprecated functions will not be removed from the API, but the fact
5237 that they are deprecated indicates that there are problems with correct
5238 use of these functions.
5239
5240 inspect-get-hostname
5241 inspect-get-hostname root
5242
5243 This function returns the hostname of the operating system as found by
5244 inspection of the guest’s configuration files.
5245
5246 If the hostname could not be determined, then the string "unknown" is
5247 returned.
5248
5249 Please read "INSPECTION" in guestfs(3) for more details.
5250
5251 inspect-get-icon
5252 inspect-get-icon root [favicon:true|false] [highquality:true|false]
5253
5254 This function returns an icon corresponding to the inspected operating
5255 system. The icon is returned as a buffer containing a PNG image (re-
5256 encoded to PNG if necessary).
5257
5258 If it was not possible to get an icon this function returns a zero-
5259 length (non-NULL) buffer. Callers must check for this case.
5260
5261 Libguestfs will start by looking for a file called /etc/favicon.png or
5262 C:\etc\favicon.png and if it has the correct format, the contents of
5263 this file will be returned. You can disable favicons by passing the
5264 optional "favicon" boolean as false (default is true).
5265
5266 If finding the favicon fails, then we look in other places in the guest
5267 for a suitable icon.
5268
5269 If the optional "highquality" boolean is true then only high quality
5270 icons are returned, which means only icons of high resolution with an
5271 alpha channel. The default (false) is to return any icon we can, even
5272 if it is of substandard quality.
5273
5274 Notes:
5275
5276 • Unlike most other inspection API calls, the guest’s disks must be
5277 mounted up before you call this, since it needs to read information
5278 from the guest filesystem during the call.
5279
5280 • Security: The icon data comes from the untrusted guest, and should
5281 be treated with caution. PNG files have been known to contain
5282 exploits. Ensure that libpng (or other relevant libraries) are
5283 fully up to date before trying to process or display the icon.
5284
5285 • The PNG image returned can be any size. It might not be square.
5286 Libguestfs tries to return the largest, highest quality icon
5287 available. The application must scale the icon to the required
5288 size.
5289
5290 • Extracting icons from Windows guests requires the external
5291 wrestool(1) program from the "icoutils" package, and several
5292 programs (bmptopnm(1), pnmtopng(1), pamcut(1)) from the "netpbm"
5293 package. These must be installed separately.
5294
5295 • Operating system icons are usually trademarks. Seek legal advice
5296 before using trademarks in applications.
5297
5298 This command has one or more optional arguments. See "OPTIONAL
5299 ARGUMENTS".
5300
5301 inspect-get-major-version
5302 inspect-get-major-version root
5303
5304 This returns the major version number of the inspected operating
5305 system.
5306
5307 Windows uses a consistent versioning scheme which is not reflected in
5308 the popular public names used by the operating system. Notably the
5309 operating system known as "Windows 7" is really version 6.1 (ie. major
5310 = 6, minor = 1). You can find out the real versions corresponding to
5311 releases of Windows by consulting Wikipedia or MSDN.
5312
5313 If the version could not be determined, then 0 is returned.
5314
5315 Please read "INSPECTION" in guestfs(3) for more details.
5316
5317 inspect-get-minor-version
5318 inspect-get-minor-version root
5319
5320 This returns the minor version number of the inspected operating
5321 system.
5322
5323 If the version could not be determined, then 0 is returned.
5324
5325 Please read "INSPECTION" in guestfs(3) for more details. See also
5326 "inspect-get-major-version".
5327
5328 inspect-get-mountpoints
5329 inspect-get-mountpoints root
5330
5331 This returns a hash of where we think the filesystems associated with
5332 this operating system should be mounted. Callers should note that this
5333 is at best an educated guess made by reading configuration files such
5334 as /etc/fstab. In particular note that this may return filesystems
5335 which are non-existent or not mountable and callers should be prepared
5336 to handle or ignore failures if they try to mount them.
5337
5338 Each element in the returned hashtable has a key which is the path of
5339 the mountpoint (eg. /boot) and a value which is the filesystem that
5340 would be mounted there (eg. /dev/sda1).
5341
5342 Non-mounted devices such as swap devices are not returned in this list.
5343
5344 For operating systems like Windows which still use drive letters, this
5345 call will only return an entry for the first drive "mounted on" /. For
5346 information about the mapping of drive letters to partitions, see
5347 "inspect-get-drive-mappings".
5348
5349 Please read "INSPECTION" in guestfs(3) for more details. See also
5350 "inspect-get-filesystems".
5351
5352 inspect-get-osinfo
5353 inspect-get-osinfo root
5354
5355 This function returns a possible short ID for libosinfo corresponding
5356 to the guest.
5357
5358 Note: The returned ID is only a guess by libguestfs, and nothing
5359 ensures that it actually exists in osinfo-db.
5360
5361 If no ID could not be determined, then the string "unknown" is
5362 returned.
5363
5364 inspect-get-package-format
5365 inspect-get-package-format root
5366
5367 This function and "inspect-get-package-management" return the package
5368 format and package management tool used by the inspected operating
5369 system. For example for Fedora these functions would return "rpm"
5370 (package format), and "yum" or "dnf" (package management).
5371
5372 This returns the string "unknown" if we could not determine the package
5373 format or if the operating system does not have a real packaging system
5374 (eg. Windows).
5375
5376 Possible strings include: "rpm", "deb", "ebuild", "pisi", "pacman",
5377 "pkgsrc", "apk", "xbps". Future versions of libguestfs may return
5378 other strings.
5379
5380 Please read "INSPECTION" in guestfs(3) for more details.
5381
5382 inspect-get-package-management
5383 inspect-get-package-management root
5384
5385 "inspect-get-package-format" and this function return the package
5386 format and package management tool used by the inspected operating
5387 system. For example for Fedora these functions would return "rpm"
5388 (package format), and "yum" or "dnf" (package management).
5389
5390 This returns the string "unknown" if we could not determine the package
5391 management tool or if the operating system does not have a real
5392 packaging system (eg. Windows).
5393
5394 Possible strings include: "yum", "dnf", "up2date", "apt" (for all
5395 Debian derivatives), "portage", "pisi", "pacman", "urpmi", "zypper",
5396 "apk", "xbps". Future versions of libguestfs may return other strings.
5397
5398 Please read "INSPECTION" in guestfs(3) for more details.
5399
5400 inspect-get-product-name
5401 inspect-get-product-name root
5402
5403 This returns the product name of the inspected operating system. The
5404 product name is generally some freeform string which can be displayed
5405 to the user, but should not be parsed by programs.
5406
5407 If the product name could not be determined, then the string "unknown"
5408 is returned.
5409
5410 Please read "INSPECTION" in guestfs(3) for more details.
5411
5412 inspect-get-product-variant
5413 inspect-get-product-variant root
5414
5415 This returns the product variant of the inspected operating system.
5416
5417 For Windows guests, this returns the contents of the Registry key
5418 "HKLM\Software\Microsoft\Windows NT\CurrentVersion" "InstallationType"
5419 which is usually a string such as "Client" or "Server" (other values
5420 are possible). This can be used to distinguish consumer and enterprise
5421 versions of Windows that have the same version number (for example,
5422 Windows 7 and Windows 2008 Server are both version 6.1, but the former
5423 is "Client" and the latter is "Server").
5424
5425 For enterprise Linux guests, in future we intend this to return the
5426 product variant such as "Desktop", "Server" and so on. But this is not
5427 implemented at present.
5428
5429 If the product variant could not be determined, then the string
5430 "unknown" is returned.
5431
5432 Please read "INSPECTION" in guestfs(3) for more details. See also
5433 "inspect-get-product-name", "inspect-get-major-version".
5434
5435 inspect-get-roots
5436 inspect-get-roots
5437
5438 This function is a convenient way to get the list of root devices, as
5439 returned from a previous call to "inspect-os", but without redoing the
5440 whole inspection process.
5441
5442 This returns an empty list if either no root devices were found or the
5443 caller has not called "inspect-os".
5444
5445 Please read "INSPECTION" in guestfs(3) for more details.
5446
5447 inspect-get-type
5448 inspect-get-type root
5449
5450 This returns the type of the inspected operating system. Currently
5451 defined types are:
5452
5453 "linux"
5454 Any Linux-based operating system.
5455
5456 "windows"
5457 Any Microsoft Windows operating system.
5458
5459 "freebsd"
5460 FreeBSD.
5461
5462 "netbsd"
5463 NetBSD.
5464
5465 "openbsd"
5466 OpenBSD.
5467
5468 "hurd"
5469 GNU/Hurd.
5470
5471 "dos"
5472 MS-DOS, FreeDOS and others.
5473
5474 "minix"
5475 MINIX.
5476
5477 "unknown"
5478 The operating system type could not be determined.
5479
5480 Future versions of libguestfs may return other strings here. The
5481 caller should be prepared to handle any string.
5482
5483 Please read "INSPECTION" in guestfs(3) for more details.
5484
5485 inspect-get-windows-current-control-set
5486 inspect-get-windows-current-control-set root
5487
5488 This returns the Windows CurrentControlSet of the inspected guest. The
5489 CurrentControlSet is a registry key name such as "ControlSet001".
5490
5491 This call assumes that the guest is Windows and that the Registry could
5492 be examined by inspection. If this is not the case then an error is
5493 returned.
5494
5495 Please read "INSPECTION" in guestfs(3) for more details.
5496
5497 inspect-get-windows-software-hive
5498 inspect-get-windows-software-hive root
5499
5500 This returns the path to the hive (binary Windows Registry file)
5501 corresponding to HKLM\SOFTWARE.
5502
5503 This call assumes that the guest is Windows and that the guest has a
5504 software hive file with the right name. If this is not the case then
5505 an error is returned. This call does not check that the hive is a
5506 valid Windows Registry hive.
5507
5508 You can use "hivex-open" to read or write to the hive.
5509
5510 Please read "INSPECTION" in guestfs(3) for more details.
5511
5512 inspect-get-windows-system-hive
5513 inspect-get-windows-system-hive root
5514
5515 This returns the path to the hive (binary Windows Registry file)
5516 corresponding to HKLM\SYSTEM.
5517
5518 This call assumes that the guest is Windows and that the guest has a
5519 system hive file with the right name. If this is not the case then an
5520 error is returned. This call does not check that the hive is a valid
5521 Windows Registry hive.
5522
5523 You can use "hivex-open" to read or write to the hive.
5524
5525 Please read "INSPECTION" in guestfs(3) for more details.
5526
5527 inspect-get-windows-systemroot
5528 inspect-get-windows-systemroot root
5529
5530 This returns the Windows systemroot of the inspected guest. The
5531 systemroot is a directory path such as /WINDOWS.
5532
5533 This call assumes that the guest is Windows and that the systemroot
5534 could be determined by inspection. If this is not the case then an
5535 error is returned.
5536
5537 Please read "INSPECTION" in guestfs(3) for more details.
5538
5539 inspect-is-live
5540 inspect-is-live root
5541
5542 This is deprecated and always returns "false".
5543
5544 Please read "INSPECTION" in guestfs(3) for more details.
5545
5546 This function is deprecated. There is no replacement. Consult the API
5547 documentation in guestfs(3) for further information.
5548
5549 Deprecated functions will not be removed from the API, but the fact
5550 that they are deprecated indicates that there are problems with correct
5551 use of these functions.
5552
5553 inspect-is-multipart
5554 inspect-is-multipart root
5555
5556 This is deprecated and always returns "false".
5557
5558 Please read "INSPECTION" in guestfs(3) for more details.
5559
5560 This function is deprecated. There is no replacement. Consult the API
5561 documentation in guestfs(3) for further information.
5562
5563 Deprecated functions will not be removed from the API, but the fact
5564 that they are deprecated indicates that there are problems with correct
5565 use of these functions.
5566
5567 inspect-is-netinst
5568 inspect-is-netinst root
5569
5570 This is deprecated and always returns "false".
5571
5572 Please read "INSPECTION" in guestfs(3) for more details.
5573
5574 This function is deprecated. There is no replacement. Consult the API
5575 documentation in guestfs(3) for further information.
5576
5577 Deprecated functions will not be removed from the API, but the fact
5578 that they are deprecated indicates that there are problems with correct
5579 use of these functions.
5580
5581 inspect-list-applications
5582 inspect-list-applications root
5583
5584 Return the list of applications installed in the operating system.
5585
5586 Note: This call works differently from other parts of the inspection
5587 API. You have to call "inspect-os", then "inspect-get-mountpoints",
5588 then mount up the disks, before calling this. Listing applications is
5589 a significantly more difficult operation which requires access to the
5590 full filesystem. Also note that unlike the other "inspect-get-*" calls
5591 which are just returning data cached in the libguestfs handle, this
5592 call actually reads parts of the mounted filesystems during the call.
5593
5594 This returns an empty list if the inspection code was not able to
5595 determine the list of applications.
5596
5597 The application structure contains the following fields:
5598
5599 "app_name"
5600 The name of the application. For Linux guests, this is the package
5601 name.
5602
5603 "app_display_name"
5604 The display name of the application, sometimes localized to the
5605 install language of the guest operating system.
5606
5607 If unavailable this is returned as an empty string "". Callers
5608 needing to display something can use "app_name" instead.
5609
5610 "app_epoch"
5611 For package managers which use epochs, this contains the epoch of
5612 the package (an integer). If unavailable, this is returned as 0.
5613
5614 "app_version"
5615 The version string of the application or package. If unavailable
5616 this is returned as an empty string "".
5617
5618 "app_release"
5619 The release string of the application or package, for package
5620 managers that use this. If unavailable this is returned as an
5621 empty string "".
5622
5623 "app_install_path"
5624 The installation path of the application (on operating systems such
5625 as Windows which use installation paths). This path is in the
5626 format used by the guest operating system, it is not a libguestfs
5627 path.
5628
5629 If unavailable this is returned as an empty string "".
5630
5631 "app_trans_path"
5632 The install path translated into a libguestfs path. If unavailable
5633 this is returned as an empty string "".
5634
5635 "app_publisher"
5636 The name of the publisher of the application, for package managers
5637 that use this. If unavailable this is returned as an empty string
5638 "".
5639
5640 "app_url"
5641 The URL (eg. upstream URL) of the application. If unavailable this
5642 is returned as an empty string "".
5643
5644 "app_source_package"
5645 For packaging systems which support this, the name of the source
5646 package. If unavailable this is returned as an empty string "".
5647
5648 "app_summary"
5649 A short (usually one line) description of the application or
5650 package. If unavailable this is returned as an empty string "".
5651
5652 "app_description"
5653 A longer description of the application or package. If unavailable
5654 this is returned as an empty string "".
5655
5656 Please read "INSPECTION" in guestfs(3) for more details.
5657
5658 This function is deprecated. In new code, use the
5659 "inspect-list-applications2" call instead.
5660
5661 Deprecated functions will not be removed from the API, but the fact
5662 that they are deprecated indicates that there are problems with correct
5663 use of these functions.
5664
5665 inspect-list-applications2
5666 inspect-list-applications2 root
5667
5668 Return the list of applications installed in the operating system.
5669
5670 Note: This call works differently from other parts of the inspection
5671 API. You have to call "inspect-os", then "inspect-get-mountpoints",
5672 then mount up the disks, before calling this. Listing applications is
5673 a significantly more difficult operation which requires access to the
5674 full filesystem. Also note that unlike the other "inspect-get-*" calls
5675 which are just returning data cached in the libguestfs handle, this
5676 call actually reads parts of the mounted filesystems during the call.
5677
5678 This returns an empty list if the inspection code was not able to
5679 determine the list of applications.
5680
5681 The application structure contains the following fields:
5682
5683 "app2_name"
5684 The name of the application. For Linux guests, this is the package
5685 name.
5686
5687 "app2_display_name"
5688 The display name of the application, sometimes localized to the
5689 install language of the guest operating system.
5690
5691 If unavailable this is returned as an empty string "". Callers
5692 needing to display something can use "app2_name" instead.
5693
5694 "app2_epoch"
5695 For package managers which use epochs, this contains the epoch of
5696 the package (an integer). If unavailable, this is returned as 0.
5697
5698 "app2_version"
5699 The version string of the application or package. If unavailable
5700 this is returned as an empty string "".
5701
5702 "app2_release"
5703 The release string of the application or package, for package
5704 managers that use this. If unavailable this is returned as an
5705 empty string "".
5706
5707 "app2_arch"
5708 The architecture string of the application or package, for package
5709 managers that use this. If unavailable this is returned as an
5710 empty string "".
5711
5712 "app2_install_path"
5713 The installation path of the application (on operating systems such
5714 as Windows which use installation paths). This path is in the
5715 format used by the guest operating system, it is not a libguestfs
5716 path.
5717
5718 If unavailable this is returned as an empty string "".
5719
5720 "app2_trans_path"
5721 The install path translated into a libguestfs path. If unavailable
5722 this is returned as an empty string "".
5723
5724 "app2_publisher"
5725 The name of the publisher of the application, for package managers
5726 that use this. If unavailable this is returned as an empty string
5727 "".
5728
5729 "app2_url"
5730 The URL (eg. upstream URL) of the application. If unavailable this
5731 is returned as an empty string "".
5732
5733 "app2_source_package"
5734 For packaging systems which support this, the name of the source
5735 package. If unavailable this is returned as an empty string "".
5736
5737 "app2_summary"
5738 A short (usually one line) description of the application or
5739 package. If unavailable this is returned as an empty string "".
5740
5741 "app2_description"
5742 A longer description of the application or package. If unavailable
5743 this is returned as an empty string "".
5744
5745 Please read "INSPECTION" in guestfs(3) for more details.
5746
5747 inspect-os
5748 inspect-os
5749
5750 This function uses other libguestfs functions and certain heuristics to
5751 inspect the disk(s) (usually disks belonging to a virtual machine),
5752 looking for operating systems.
5753
5754 The list returned is empty if no operating systems were found.
5755
5756 If one operating system was found, then this returns a list with a
5757 single element, which is the name of the root filesystem of this
5758 operating system. It is also possible for this function to return a
5759 list containing more than one element, indicating a dual-boot or multi-
5760 boot virtual machine, with each element being the root filesystem of
5761 one of the operating systems.
5762
5763 You can pass the root string(s) returned to other "inspect-get-*"
5764 functions in order to query further information about each operating
5765 system, such as the name and version.
5766
5767 This function uses other libguestfs features such as "mount-ro" and
5768 "umount-all" in order to mount and unmount filesystems and look at the
5769 contents. This should be called with no disks currently mounted. The
5770 function may also use Augeas, so any existing Augeas handle will be
5771 closed.
5772
5773 This function cannot decrypt encrypted disks. The caller must do that
5774 first (supplying the necessary keys) if the disk is encrypted.
5775
5776 Please read "INSPECTION" in guestfs(3) for more details.
5777
5778 See also "list-filesystems".
5779
5780 is-blockdev
5781 is-blockdev-opts
5782 is-blockdev path [followsymlinks:true|false]
5783
5784 This returns "true" if and only if there is a block device with the
5785 given "path" name.
5786
5787 If the optional flag "followsymlinks" is true, then a symlink (or chain
5788 of symlinks) that ends with a block device also causes the function to
5789 return true.
5790
5791 This call only looks at files within the guest filesystem. Libguestfs
5792 partitions and block devices (eg. /dev/sda) cannot be used as the
5793 "path" parameter of this call.
5794
5795 See also "stat".
5796
5797 This command has one or more optional arguments. See "OPTIONAL
5798 ARGUMENTS".
5799
5800 is-chardev
5801 is-chardev-opts
5802 is-chardev path [followsymlinks:true|false]
5803
5804 This returns "true" if and only if there is a character device with the
5805 given "path" name.
5806
5807 If the optional flag "followsymlinks" is true, then a symlink (or chain
5808 of symlinks) that ends with a chardev also causes the function to
5809 return true.
5810
5811 See also "stat".
5812
5813 This command has one or more optional arguments. See "OPTIONAL
5814 ARGUMENTS".
5815
5816 is-config
5817 is-config
5818
5819 This returns true iff this handle is being configured (in the "CONFIG"
5820 state).
5821
5822 For more information on states, see guestfs(3).
5823
5824 is-dir
5825 is-dir-opts
5826 is-dir path [followsymlinks:true|false]
5827
5828 This returns "true" if and only if there is a directory with the given
5829 "path" name. Note that it returns false for other objects like files.
5830
5831 If the optional flag "followsymlinks" is true, then a symlink (or chain
5832 of symlinks) that ends with a directory also causes the function to
5833 return true.
5834
5835 See also "stat".
5836
5837 This command has one or more optional arguments. See "OPTIONAL
5838 ARGUMENTS".
5839
5840 is-fifo
5841 is-fifo-opts
5842 is-fifo path [followsymlinks:true|false]
5843
5844 This returns "true" if and only if there is a FIFO (named pipe) with
5845 the given "path" name.
5846
5847 If the optional flag "followsymlinks" is true, then a symlink (or chain
5848 of symlinks) that ends with a FIFO also causes the function to return
5849 true.
5850
5851 See also "stat".
5852
5853 This command has one or more optional arguments. See "OPTIONAL
5854 ARGUMENTS".
5855
5856 is-file
5857 is-file-opts
5858 is-file path [followsymlinks:true|false]
5859
5860 This returns "true" if and only if there is a regular file with the
5861 given "path" name. Note that it returns false for other objects like
5862 directories.
5863
5864 If the optional flag "followsymlinks" is true, then a symlink (or chain
5865 of symlinks) that ends with a file also causes the function to return
5866 true.
5867
5868 See also "stat".
5869
5870 This command has one or more optional arguments. See "OPTIONAL
5871 ARGUMENTS".
5872
5873 is-lv
5874 is-lv mountable
5875
5876 This command tests whether "mountable" is a logical volume, and returns
5877 true iff this is the case.
5878
5879 is-socket
5880 is-socket-opts
5881 is-socket path [followsymlinks:true|false]
5882
5883 This returns "true" if and only if there is a Unix domain socket with
5884 the given "path" name.
5885
5886 If the optional flag "followsymlinks" is true, then a symlink (or chain
5887 of symlinks) that ends with a socket also causes the function to return
5888 true.
5889
5890 See also "stat".
5891
5892 This command has one or more optional arguments. See "OPTIONAL
5893 ARGUMENTS".
5894
5895 is-symlink
5896 is-symlink path
5897
5898 This returns "true" if and only if there is a symbolic link with the
5899 given "path" name.
5900
5901 See also "stat".
5902
5903 is-whole-device
5904 is-whole-device device
5905
5906 This returns "true" if and only if "device" refers to a whole block
5907 device. That is, not a partition or a logical device.
5908
5909 is-zero
5910 is-zero path
5911
5912 This returns true iff the file exists and the file is empty or it
5913 contains all zero bytes.
5914
5915 is-zero-device
5916 is-zero-device device
5917
5918 This returns true iff the device exists and contains all zero bytes.
5919
5920 Note that for large devices this can take a long time to run.
5921
5922 isoinfo
5923 isoinfo isofile
5924
5925 This is the same as "isoinfo-device" except that it works for an ISO
5926 file located inside some other mounted filesystem. Note that in the
5927 common case where you have added an ISO file as a libguestfs device,
5928 you would not call this. Instead you would call "isoinfo-device".
5929
5930 isoinfo-device
5931 isoinfo-device device
5932
5933 "device" is an ISO device. This returns a struct of information read
5934 from the primary volume descriptor (the ISO equivalent of the
5935 superblock) of the device.
5936
5937 Usually it is more efficient to use the isoinfo(1) command with the -d
5938 option on the host to analyze ISO files, instead of going through
5939 libguestfs.
5940
5941 For information on the primary volume descriptor fields, see
5942 https://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor
5943
5944 journal-close
5945 journal-close
5946
5947 Close the journal handle.
5948
5949 This command depends on the feature "journal". See also "feature-
5950 available".
5951
5952 journal-get
5953 journal-get
5954
5955 Read the current journal entry. This returns all the fields in the
5956 journal as a set of "(attrname, attrval)" pairs. The "attrname" is the
5957 field name (a string).
5958
5959 The "attrval" is the field value (a binary blob, often but not always a
5960 string). Please note that "attrval" is a byte array, not a
5961 \0-terminated C string.
5962
5963 The length of data may be truncated to the data threshold (see:
5964 "journal-set-data-threshold", "journal-get-data-threshold").
5965
5966 If you set the data threshold to unlimited (0) then this call can read
5967 a journal entry of any size, ie. it is not limited by the libguestfs
5968 protocol.
5969
5970 This command depends on the feature "journal". See also "feature-
5971 available".
5972
5973 journal-get-data-threshold
5974 journal-get-data-threshold
5975
5976 Get the current data threshold for reading journal entries. This is a
5977 hint to the journal that it may truncate data fields to this size when
5978 reading them (note also that it may not truncate them). If this
5979 returns 0, then the threshold is unlimited.
5980
5981 See also "journal-set-data-threshold".
5982
5983 This command depends on the feature "journal". See also "feature-
5984 available".
5985
5986 journal-get-realtime-usec
5987 journal-get-realtime-usec
5988
5989 Get the realtime (wallclock) timestamp of the current journal entry.
5990
5991 This command depends on the feature "journal". See also "feature-
5992 available".
5993
5994 journal-next
5995 journal-next
5996
5997 Move to the next journal entry. You have to call this at least once
5998 after opening the handle before you are able to read data.
5999
6000 The returned boolean tells you if there are any more journal records to
6001 read. "true" means you can read the next record (eg. using "journal-
6002 get"), and "false" means you have reached the end of the journal.
6003
6004 This command depends on the feature "journal". See also "feature-
6005 available".
6006
6007 journal-open
6008 journal-open directory
6009
6010 Open the systemd journal located in directory. Any previously opened
6011 journal handle is closed.
6012
6013 The contents of the journal can be read using "journal-next" and
6014 "journal-get".
6015
6016 After you have finished using the journal, you should close the handle
6017 by calling "journal-close".
6018
6019 This command depends on the feature "journal". See also "feature-
6020 available".
6021
6022 journal-set-data-threshold
6023 journal-set-data-threshold threshold
6024
6025 Set the data threshold for reading journal entries. This is a hint to
6026 the journal that it may truncate data fields to this size when reading
6027 them (note also that it may not truncate them). If you set this to 0,
6028 then the threshold is unlimited.
6029
6030 See also "journal-get-data-threshold".
6031
6032 This command depends on the feature "journal". See also "feature-
6033 available".
6034
6035 journal-skip
6036 journal-skip skip
6037
6038 Skip forwards ("skip ≥ 0") or backwards ("skip < 0") in the journal.
6039
6040 The number of entries actually skipped is returned (note "rskip ≥ 0").
6041 If this is not the same as the absolute value of the skip parameter
6042 ("|skip|") you passed in then it means you have reached the end or the
6043 start of the journal.
6044
6045 This command depends on the feature "journal". See also "feature-
6046 available".
6047
6048 kill-subprocess
6049 kill-subprocess
6050
6051 This kills the hypervisor.
6052
6053 Do not call this. See: "shutdown" instead.
6054
6055 This function is deprecated. In new code, use the "shutdown" call
6056 instead.
6057
6058 Deprecated functions will not be removed from the API, but the fact
6059 that they are deprecated indicates that there are problems with correct
6060 use of these functions.
6061
6062 launch
6063 run
6064 launch
6065
6066 You should call this after configuring the handle (eg. adding drives)
6067 but before performing any actions.
6068
6069 Do not call "launch" twice on the same handle. Although it will not
6070 give an error (for historical reasons), the precise behaviour when you
6071 do this is not well defined. Handles are very cheap to create, so
6072 create a new one for each launch.
6073
6074 lchown
6075 lchown owner group path
6076
6077 Change the file owner to "owner" and group to "group". This is like
6078 "chown" but if "path" is a symlink then the link itself is changed, not
6079 the target.
6080
6081 Only numeric uid and gid are supported. If you want to use names, you
6082 will need to locate and parse the password file yourself (Augeas
6083 support makes this relatively easy).
6084
6085 ldmtool-create-all
6086 ldmtool-create-all
6087
6088 This function scans all block devices looking for Windows dynamic disk
6089 volumes and partitions, and creates devices for any that were found.
6090
6091 Call "list-ldm-volumes" and "list-ldm-partitions" to return all
6092 devices.
6093
6094 Note that you don't normally need to call this explicitly, since it is
6095 done automatically at "launch" time.
6096
6097 This command depends on the feature "ldm". See also "feature-
6098 available".
6099
6100 ldmtool-diskgroup-disks
6101 ldmtool-diskgroup-disks diskgroup
6102
6103 Return the disks in a Windows dynamic disk group. The "diskgroup"
6104 parameter should be the GUID of a disk group, one element from the list
6105 returned by "ldmtool-scan".
6106
6107 This command depends on the feature "ldm". See also "feature-
6108 available".
6109
6110 ldmtool-diskgroup-name
6111 ldmtool-diskgroup-name diskgroup
6112
6113 Return the name of a Windows dynamic disk group. The "diskgroup"
6114 parameter should be the GUID of a disk group, one element from the list
6115 returned by "ldmtool-scan".
6116
6117 This command depends on the feature "ldm". See also "feature-
6118 available".
6119
6120 ldmtool-diskgroup-volumes
6121 ldmtool-diskgroup-volumes diskgroup
6122
6123 Return the volumes in a Windows dynamic disk group. The "diskgroup"
6124 parameter should be the GUID of a disk group, one element from the list
6125 returned by "ldmtool-scan".
6126
6127 This command depends on the feature "ldm". See also "feature-
6128 available".
6129
6130 ldmtool-remove-all
6131 ldmtool-remove-all
6132
6133 This is essentially the opposite of "ldmtool-create-all". It removes
6134 the device mapper mappings for all Windows dynamic disk volumes
6135
6136 This command depends on the feature "ldm". See also "feature-
6137 available".
6138
6139 ldmtool-scan
6140 ldmtool-scan
6141
6142 This function scans for Windows dynamic disks. It returns a list of
6143 identifiers (GUIDs) for all disk groups that were found. These
6144 identifiers can be passed to other "ldmtool-*" functions.
6145
6146 This function scans all block devices. To scan a subset of block
6147 devices, call "ldmtool-scan-devices" instead.
6148
6149 This command depends on the feature "ldm". See also "feature-
6150 available".
6151
6152 ldmtool-scan-devices
6153 ldmtool-scan-devices 'devices ...'
6154
6155 This function scans for Windows dynamic disks. It returns a list of
6156 identifiers (GUIDs) for all disk groups that were found. These
6157 identifiers can be passed to other "ldmtool-*" functions.
6158
6159 The parameter "devices" is a list of block devices which are scanned.
6160 If this list is empty, all block devices are scanned.
6161
6162 This command depends on the feature "ldm". See also "feature-
6163 available".
6164
6165 ldmtool-volume-hint
6166 ldmtool-volume-hint diskgroup volume
6167
6168 Return the hint field of the volume named "volume" in the disk group
6169 with GUID "diskgroup". This may not be defined, in which case the
6170 empty string is returned. The hint field is often, though not always,
6171 the name of a Windows drive, eg. "E:".
6172
6173 This command depends on the feature "ldm". See also "feature-
6174 available".
6175
6176 ldmtool-volume-partitions
6177 ldmtool-volume-partitions diskgroup volume
6178
6179 Return the list of partitions in the volume named "volume" in the disk
6180 group with GUID "diskgroup".
6181
6182 This command depends on the feature "ldm". See also "feature-
6183 available".
6184
6185 ldmtool-volume-type
6186 ldmtool-volume-type diskgroup volume
6187
6188 Return the type of the volume named "volume" in the disk group with
6189 GUID "diskgroup".
6190
6191 Possible volume types that can be returned here include: "simple",
6192 "spanned", "striped", "mirrored", "raid5". Other types may also be
6193 returned.
6194
6195 This command depends on the feature "ldm". See also "feature-
6196 available".
6197
6198 lgetxattr
6199 lgetxattr path name
6200
6201 Get a single extended attribute from file "path" named "name". If
6202 "path" is a symlink, then this call returns an extended attribute from
6203 the symlink.
6204
6205 Normally it is better to get all extended attributes from a file in one
6206 go by calling "getxattrs". However some Linux filesystem
6207 implementations are buggy and do not provide a way to list out
6208 attributes. For these filesystems (notably ntfs-3g) you have to know
6209 the names of the extended attributes you want in advance and call this
6210 function.
6211
6212 Extended attribute values are blobs of binary data. If there is no
6213 extended attribute named "name", this returns an error.
6214
6215 See also: "lgetxattrs", "getxattr", attr(5).
6216
6217 This command depends on the feature "linuxxattrs". See also "feature-
6218 available".
6219
6220 lgetxattrs
6221 lgetxattrs path
6222
6223 This is the same as "getxattrs", but if "path" is a symbolic link, then
6224 it returns the extended attributes of the link itself.
6225
6226 This command depends on the feature "linuxxattrs". See also "feature-
6227 available".
6228
6229 list-9p
6230 list-9p
6231
6232 This call does nothing and returns an error.
6233
6234 This function is deprecated. There is no replacement. Consult the API
6235 documentation in guestfs(3) for further information.
6236
6237 Deprecated functions will not be removed from the API, but the fact
6238 that they are deprecated indicates that there are problems with correct
6239 use of these functions.
6240
6241 list-devices
6242 list-devices
6243
6244 List all the block devices.
6245
6246 The full block device names are returned, eg. /dev/sda.
6247
6248 See also "list-filesystems".
6249
6250 list-disk-labels
6251 list-disk-labels
6252
6253 If you add drives using the optional "label" parameter of "add-drive-
6254 opts", you can use this call to map between disk labels, and raw block
6255 device and partition names (like /dev/sda and /dev/sda1).
6256
6257 This returns a hashtable, where keys are the disk labels (without the
6258 /dev/disk/guestfs prefix), and the values are the full raw block device
6259 and partition names (eg. /dev/sda and /dev/sda1).
6260
6261 list-dm-devices
6262 list-dm-devices
6263
6264 List all device mapper devices.
6265
6266 The returned list contains /dev/mapper/* devices, eg. ones created by a
6267 previous call to "luks-open".
6268
6269 Device mapper devices which correspond to logical volumes are not
6270 returned in this list. Call "lvs" if you want to list logical volumes.
6271
6272 list-filesystems
6273 list-filesystems
6274
6275 This inspection command looks for filesystems on partitions, block
6276 devices and logical volumes, returning a list of "mountables"
6277 containing filesystems and their type.
6278
6279 The return value is a hash, where the keys are the devices containing
6280 filesystems, and the values are the filesystem types. For example:
6281
6282 "/dev/sda1" => "ntfs"
6283 "/dev/sda2" => "ext2"
6284 "/dev/vg_guest/lv_root" => "ext4"
6285 "/dev/vg_guest/lv_swap" => "swap"
6286
6287 The key is not necessarily a block device. It may also be an opaque
6288 ‘mountable’ string which can be passed to "mount".
6289
6290 The value can have the special value "unknown", meaning the content of
6291 the device is undetermined or empty. "swap" means a Linux swap
6292 partition.
6293
6294 In libguestfs ≤ 1.36 this command ran other libguestfs commands, which
6295 might have included "mount" and "umount", and therefore you had to use
6296 this soon after launch and only when nothing else was mounted. This
6297 restriction is removed in libguestfs ≥ 1.38.
6298
6299 Not all of the filesystems returned will be mountable. In particular,
6300 swap partitions are returned in the list. Also this command does not
6301 check that each filesystem found is valid and mountable, and some
6302 filesystems might be mountable but require special options.
6303 Filesystems may not all belong to a single logical operating system
6304 (use "inspect-os" to look for OSes).
6305
6306 list-ldm-partitions
6307 list-ldm-partitions
6308
6309 This function returns all Windows dynamic disk partitions that were
6310 found at launch time. It returns a list of device names.
6311
6312 This command depends on the feature "ldm". See also "feature-
6313 available".
6314
6315 list-ldm-volumes
6316 list-ldm-volumes
6317
6318 This function returns all Windows dynamic disk volumes that were found
6319 at launch time. It returns a list of device names.
6320
6321 This command depends on the feature "ldm". See also "feature-
6322 available".
6323
6324 list-md-devices
6325 list-md-devices
6326
6327 List all Linux md devices.
6328
6329 list-partitions
6330 list-partitions
6331
6332 List all the partitions detected on all block devices.
6333
6334 The full partition device names are returned, eg. /dev/sda1
6335
6336 This does not return logical volumes. For that you will need to call
6337 "lvs".
6338
6339 See also "list-filesystems".
6340
6341 ll
6342 ll directory
6343
6344 List the files in directory (relative to the root directory, there is
6345 no cwd) in the format of "ls -la".
6346
6347 This command is mostly useful for interactive sessions. It is not
6348 intended that you try to parse the output string.
6349
6350 llz
6351 llz directory
6352
6353 List the files in directory in the format of "ls -laZ".
6354
6355 This command is mostly useful for interactive sessions. It is not
6356 intended that you try to parse the output string.
6357
6358 This function is deprecated. In new code, use the "lgetxattrs" call
6359 instead.
6360
6361 Deprecated functions will not be removed from the API, but the fact
6362 that they are deprecated indicates that there are problems with correct
6363 use of these functions.
6364
6365 ln
6366 ln target linkname
6367
6368 This command creates a hard link.
6369
6370 ln-f
6371 ln-f target linkname
6372
6373 This command creates a hard link, removing the link "linkname" if it
6374 exists already.
6375
6376 ln-s
6377 ln-s target linkname
6378
6379 This command creates a symbolic link using the "ln -s" command.
6380
6381 ln-sf
6382 ln-sf target linkname
6383
6384 This command creates a symbolic link using the "ln -sf" command, The -f
6385 option removes the link ("linkname") if it exists already.
6386
6387 lremovexattr
6388 lremovexattr xattr path
6389
6390 This is the same as "removexattr", but if "path" is a symbolic link,
6391 then it removes an extended attribute of the link itself.
6392
6393 This command depends on the feature "linuxxattrs". See also "feature-
6394 available".
6395
6396 ls
6397 ls directory
6398
6399 List the files in directory (relative to the root directory, there is
6400 no cwd). The "." and ".." entries are not returned, but hidden files
6401 are shown.
6402
6403 ls0
6404 ls0 dir (filenames|-)
6405
6406 This specialized command is used to get a listing of the filenames in
6407 the directory "dir". The list of filenames is written to the local
6408 file filenames (on the host).
6409
6410 In the output file, the filenames are separated by "\0" characters.
6411
6412 "." and ".." are not returned. The filenames are not sorted.
6413
6414 Use "-" instead of a filename to read/write from stdin/stdout.
6415
6416 lsetxattr
6417 lsetxattr xattr val vallen path
6418
6419 This is the same as "setxattr", but if "path" is a symbolic link, then
6420 it sets an extended attribute of the link itself.
6421
6422 This command depends on the feature "linuxxattrs". See also "feature-
6423 available".
6424
6425 lstat
6426 lstat path
6427
6428 Returns file information for the given "path".
6429
6430 This is the same as "stat" except that if "path" is a symbolic link,
6431 then the link is stat-ed, not the file it refers to.
6432
6433 This is the same as the lstat(2) system call.
6434
6435 This function is deprecated. In new code, use the "lstatns" call
6436 instead.
6437
6438 Deprecated functions will not be removed from the API, but the fact
6439 that they are deprecated indicates that there are problems with correct
6440 use of these functions.
6441
6442 lstatlist
6443 lstatlist path 'names ...'
6444
6445 This call allows you to perform the "lstat" operation on multiple
6446 files, where all files are in the directory "path". "names" is the
6447 list of files from this directory.
6448
6449 On return you get a list of stat structs, with a one-to-one
6450 correspondence to the "names" list. If any name did not exist or could
6451 not be lstat'd, then the "st_ino" field of that structure is set to
6452 "-1".
6453
6454 This call is intended for programs that want to efficiently list a
6455 directory contents without making many round-trips. See also
6456 "lxattrlist" for a similarly efficient call for getting extended
6457 attributes.
6458
6459 This function is deprecated. In new code, use the "lstatnslist" call
6460 instead.
6461
6462 Deprecated functions will not be removed from the API, but the fact
6463 that they are deprecated indicates that there are problems with correct
6464 use of these functions.
6465
6466 lstatns
6467 lstatns path
6468
6469 Returns file information for the given "path".
6470
6471 This is the same as "statns" except that if "path" is a symbolic link,
6472 then the link is stat-ed, not the file it refers to.
6473
6474 This is the same as the lstat(2) system call.
6475
6476 lstatnslist
6477 lstatnslist path 'names ...'
6478
6479 This call allows you to perform the "lstatns" operation on multiple
6480 files, where all files are in the directory "path". "names" is the
6481 list of files from this directory.
6482
6483 On return you get a list of stat structs, with a one-to-one
6484 correspondence to the "names" list. If any name did not exist or could
6485 not be lstat'd, then the "st_ino" field of that structure is set to
6486 "-1".
6487
6488 This call is intended for programs that want to efficiently list a
6489 directory contents without making many round-trips. See also
6490 "lxattrlist" for a similarly efficient call for getting extended
6491 attributes.
6492
6493 luks-add-key
6494 luks-add-key device keyslot
6495
6496 This command adds a new key on LUKS device "device". "key" is any
6497 existing key, and is used to access the device. "newkey" is the new
6498 key to add. "keyslot" is the key slot that will be replaced.
6499
6500 Note that if "keyslot" already contains a key, then this command will
6501 fail. You have to use "luks-kill-slot" first to remove that key.
6502
6503 This command has one or more key or passphrase parameters. Guestfish
6504 will prompt for these separately.
6505
6506 This command depends on the feature "luks". See also "feature-
6507 available".
6508
6509 luks-close
6510 luks-close device
6511
6512 This closes a LUKS device that was created earlier by "luks-open" or
6513 "luks-open-ro". The "device" parameter must be the name of the LUKS
6514 mapping device (ie. /dev/mapper/mapname) and not the name of the
6515 underlying block device.
6516
6517 This function is deprecated. In new code, use the "cryptsetup-close"
6518 call instead.
6519
6520 Deprecated functions will not be removed from the API, but the fact
6521 that they are deprecated indicates that there are problems with correct
6522 use of these functions.
6523
6524 This command depends on the feature "luks". See also "feature-
6525 available".
6526
6527 luks-format
6528 luks-format device keyslot
6529
6530 This command erases existing data on "device" and formats the device as
6531 a LUKS encrypted device. "key" is the initial key, which is added to
6532 key slot "keyslot". (LUKS supports 8 key slots, numbered 0-7).
6533
6534 This command has one or more key or passphrase parameters. Guestfish
6535 will prompt for these separately.
6536
6537 This command depends on the feature "luks". See also "feature-
6538 available".
6539
6540 luks-format-cipher
6541 luks-format-cipher device keyslot cipher
6542
6543 This command is the same as "luks-format" but it also allows you to set
6544 the "cipher" used.
6545
6546 This command has one or more key or passphrase parameters. Guestfish
6547 will prompt for these separately.
6548
6549 This command depends on the feature "luks". See also "feature-
6550 available".
6551
6552 luks-kill-slot
6553 luks-kill-slot device keyslot
6554
6555 This command deletes the key in key slot "keyslot" from the encrypted
6556 LUKS device "device". "key" must be one of the other keys.
6557
6558 This command has one or more key or passphrase parameters. Guestfish
6559 will prompt for these separately.
6560
6561 This command depends on the feature "luks". See also "feature-
6562 available".
6563
6564 luks-open
6565 luks-open device mapname
6566
6567 This command opens a block device which has been encrypted according to
6568 the Linux Unified Key Setup (LUKS) standard.
6569
6570 "device" is the encrypted block device or partition.
6571
6572 The caller must supply one of the keys associated with the LUKS block
6573 device, in the "key" parameter.
6574
6575 This creates a new block device called /dev/mapper/mapname. Reads and
6576 writes to this block device are decrypted from and encrypted to the
6577 underlying "device" respectively.
6578
6579 If this block device contains LVM volume groups, then calling "lvm-
6580 scan" with the "activate" parameter "true" will make them visible.
6581
6582 Use "list-dm-devices" to list all device mapper devices.
6583
6584 This command has one or more key or passphrase parameters. Guestfish
6585 will prompt for these separately.
6586
6587 This function is deprecated. In new code, use the "cryptsetup-open"
6588 call instead.
6589
6590 Deprecated functions will not be removed from the API, but the fact
6591 that they are deprecated indicates that there are problems with correct
6592 use of these functions.
6593
6594 This command depends on the feature "luks". See also "feature-
6595 available".
6596
6597 luks-open-ro
6598 luks-open-ro device mapname
6599
6600 This is the same as "luks-open" except that a read-only mapping is
6601 created.
6602
6603 This command has one or more key or passphrase parameters. Guestfish
6604 will prompt for these separately.
6605
6606 This function is deprecated. In new code, use the "cryptsetup-open"
6607 call instead.
6608
6609 Deprecated functions will not be removed from the API, but the fact
6610 that they are deprecated indicates that there are problems with correct
6611 use of these functions.
6612
6613 This command depends on the feature "luks". See also "feature-
6614 available".
6615
6616 luks-uuid
6617 luks-uuid device
6618
6619 This returns the UUID of the LUKS device "device".
6620
6621 This command depends on the feature "luks". See also "feature-
6622 available".
6623
6624 lvcreate
6625 lvcreate logvol volgroup mbytes
6626
6627 This creates an LVM logical volume called "logvol" on the volume group
6628 "volgroup", with "size" megabytes.
6629
6630 This command depends on the feature "lvm2". See also "feature-
6631 available".
6632
6633 lvcreate-free
6634 lvcreate-free logvol volgroup percent
6635
6636 Create an LVM logical volume called /dev/volgroup/logvol, using
6637 approximately "percent" % of the free space remaining in the volume
6638 group. Most usefully, when "percent" is 100 this will create the
6639 largest possible LV.
6640
6641 This command depends on the feature "lvm2". See also "feature-
6642 available".
6643
6644 lvm-canonical-lv-name
6645 lvm-canonical-lv-name lvname
6646
6647 This converts alternative naming schemes for LVs that you might find to
6648 the canonical name. For example, /dev/mapper/VG-LV is converted to
6649 /dev/VG/LV.
6650
6651 This command returns an error if the "lvname" parameter does not refer
6652 to a logical volume. In this case errno will be set to "EINVAL".
6653
6654 See also "is-lv", "canonical-device-name".
6655
6656 lvm-clear-filter
6657 lvm-clear-filter
6658
6659 This undoes the effect of "lvm-set-filter". LVM will be able to see
6660 every block device.
6661
6662 This command also clears the LVM cache and performs a volume group
6663 scan.
6664
6665 lvm-remove-all
6666 lvm-remove-all
6667
6668 This command removes all LVM logical volumes, volume groups and
6669 physical volumes.
6670
6671 This command depends on the feature "lvm2". See also "feature-
6672 available".
6673
6674 lvm-scan
6675 lvm-scan true|false
6676
6677 This scans all block devices and rebuilds the list of LVM physical
6678 volumes, volume groups and logical volumes.
6679
6680 If the "activate" parameter is "true" then newly found volume groups
6681 and logical volumes are activated, meaning the LV /dev/VG/LV devices
6682 become visible.
6683
6684 When a libguestfs handle is launched it scans for existing devices, so
6685 you do not normally need to use this API. However it is useful when
6686 you have added a new device or deleted an existing device (such as when
6687 the "luks-open" API is used).
6688
6689 lvm-set-filter
6690 lvm-set-filter 'devices ...'
6691
6692 This sets the LVM device filter so that LVM will only be able to "see"
6693 the block devices in the list "devices", and will ignore all other
6694 attached block devices.
6695
6696 Where disk image(s) contain duplicate PVs or VGs, this command is
6697 useful to get LVM to ignore the duplicates, otherwise LVM can get
6698 confused. Note also there are two types of duplication possible:
6699 either cloned PVs/VGs which have identical UUIDs; or VGs that are not
6700 cloned but just happen to have the same name. In normal operation you
6701 cannot create this situation, but you can do it outside LVM, eg. by
6702 cloning disk images or by bit twiddling inside the LVM metadata.
6703
6704 This command also clears the LVM cache and performs a volume group
6705 scan.
6706
6707 You can filter whole block devices or individual partitions.
6708
6709 You cannot use this if any VG is currently in use (eg. contains a
6710 mounted filesystem), even if you are not filtering out that VG.
6711
6712 This command depends on the feature "lvm2". See also "feature-
6713 available".
6714
6715 lvremove
6716 lvremove device
6717
6718 Remove an LVM logical volume "device", where "device" is the path to
6719 the LV, such as /dev/VG/LV.
6720
6721 You can also remove all LVs in a volume group by specifying the VG
6722 name, /dev/VG.
6723
6724 This command depends on the feature "lvm2". See also "feature-
6725 available".
6726
6727 lvrename
6728 lvrename logvol newlogvol
6729
6730 Rename a logical volume "logvol" with the new name "newlogvol".
6731
6732 lvresize
6733 lvresize device mbytes
6734
6735 This resizes (expands or shrinks) an existing LVM logical volume to
6736 "mbytes". When reducing, data in the reduced part is lost.
6737
6738 This command depends on the feature "lvm2". See also "feature-
6739 available".
6740
6741 lvresize-free
6742 lvresize-free lv percent
6743
6744 This expands an existing logical volume "lv" so that it fills "pc" % of
6745 the remaining free space in the volume group. Commonly you would call
6746 this with pc = 100 which expands the logical volume as much as
6747 possible, using all remaining free space in the volume group.
6748
6749 This command depends on the feature "lvm2". See also "feature-
6750 available".
6751
6752 lvs
6753 lvs
6754
6755 List all the logical volumes detected. This is the equivalent of the
6756 lvs(8) command.
6757
6758 This returns a list of the logical volume device names (eg.
6759 /dev/VolGroup00/LogVol00).
6760
6761 See also "lvs-full", "list-filesystems".
6762
6763 This command depends on the feature "lvm2". See also "feature-
6764 available".
6765
6766 lvs-full
6767 lvs-full
6768
6769 List all the logical volumes detected. This is the equivalent of the
6770 lvs(8) command. The "full" version includes all fields.
6771
6772 This command depends on the feature "lvm2". See also "feature-
6773 available".
6774
6775 lvuuid
6776 lvuuid device
6777
6778 This command returns the UUID of the LVM LV "device".
6779
6780 lxattrlist
6781 lxattrlist path 'names ...'
6782
6783 This call allows you to get the extended attributes of multiple files,
6784 where all files are in the directory "path". "names" is the list of
6785 files from this directory.
6786
6787 On return you get a flat list of xattr structs which must be
6788 interpreted sequentially. The first xattr struct always has a zero-
6789 length "attrname". "attrval" in this struct is zero-length to indicate
6790 there was an error doing "lgetxattr" for this file, or is a C string
6791 which is a decimal number (the number of following attributes for this
6792 file, which could be "0"). Then after the first xattr struct are the
6793 zero or more attributes for the first named file. This repeats for the
6794 second and subsequent files.
6795
6796 This call is intended for programs that want to efficiently list a
6797 directory contents without making many round-trips. See also
6798 "lstatlist" for a similarly efficient call for getting standard stats.
6799
6800 This command depends on the feature "linuxxattrs". See also "feature-
6801 available".
6802
6803 max-disks
6804 max-disks
6805
6806 Return the maximum number of disks that may be added to a handle (eg.
6807 by "add-drive-opts" and similar calls).
6808
6809 This function was added in libguestfs 1.19.7. In previous versions of
6810 libguestfs the limit was 25.
6811
6812 See "MAXIMUM NUMBER OF DISKS" in guestfs(3) for additional information
6813 on this topic.
6814
6815 md-create
6816 md-create name 'devices ...' [missingbitmap:N] [nrdevices:N] [spare:N] [chunk:N] [level:..]
6817
6818 Create a Linux md (RAID) device named "name" on the devices in the list
6819 "devices".
6820
6821 The optional parameters are:
6822
6823 "missingbitmap"
6824 A bitmap of missing devices. If a bit is set it means that a
6825 missing device is added to the array. The least significant bit
6826 corresponds to the first device in the array.
6827
6828 As examples:
6829
6830 If "devices = ["/dev/sda"]" and "missingbitmap = 0x1" then the
6831 resulting array would be "[<missing>, "/dev/sda"]".
6832
6833 If "devices = ["/dev/sda"]" and "missingbitmap = 0x2" then the
6834 resulting array would be "["/dev/sda", <missing>]".
6835
6836 This defaults to 0 (no missing devices).
6837
6838 The length of "devices" + the number of bits set in "missingbitmap"
6839 must equal "nrdevices" + "spare".
6840
6841 "nrdevices"
6842 The number of active RAID devices.
6843
6844 If not set, this defaults to the length of "devices" plus the
6845 number of bits set in "missingbitmap".
6846
6847 "spare"
6848 The number of spare devices.
6849
6850 If not set, this defaults to 0.
6851
6852 "chunk"
6853 The chunk size in bytes.
6854
6855 The "chunk" parameter does not make sense, and should not be
6856 specified, when "level" is "raid1" (which is the default; see
6857 below).
6858
6859 "level"
6860 The RAID level, which can be one of: "linear", "raid0", 0,
6861 "stripe", "raid1", 1, "mirror", "raid4", 4, "raid5", 5, "raid6", 6,
6862 "raid10", 10. Some of these are synonymous, and more levels may be
6863 added in future.
6864
6865 If not set, this defaults to "raid1".
6866
6867 This command has one or more optional arguments. See "OPTIONAL
6868 ARGUMENTS".
6869
6870 This command depends on the feature "mdadm". See also "feature-
6871 available".
6872
6873 md-detail
6874 md-detail md
6875
6876 This command exposes the output of "mdadm -DY <md>". The following
6877 fields are usually present in the returned hash. Other fields may also
6878 be present.
6879
6880 "level"
6881 The raid level of the MD device.
6882
6883 "devices"
6884 The number of underlying devices in the MD device.
6885
6886 "metadata"
6887 The metadata version used.
6888
6889 "uuid"
6890 The UUID of the MD device.
6891
6892 "name"
6893 The name of the MD device.
6894
6895 This command depends on the feature "mdadm". See also "feature-
6896 available".
6897
6898 md-stat
6899 md-stat md
6900
6901 This call returns a list of the underlying devices which make up the
6902 single software RAID array device "md".
6903
6904 To get a list of software RAID devices, call "list-md-devices".
6905
6906 Each structure returned corresponds to one device along with additional
6907 status information:
6908
6909 "mdstat_device"
6910 The name of the underlying device.
6911
6912 "mdstat_index"
6913 The index of this device within the array.
6914
6915 "mdstat_flags"
6916 Flags associated with this device. This is a string containing (in
6917 no specific order) zero or more of the following flags:
6918
6919 "W" write-mostly
6920
6921 "F" device is faulty
6922
6923 "S" device is a RAID spare
6924
6925 "R" replacement
6926
6927 This command depends on the feature "mdadm". See also "feature-
6928 available".
6929
6930 md-stop
6931 md-stop md
6932
6933 This command deactivates the MD array named "md". The device is
6934 stopped, but it is not destroyed or zeroed.
6935
6936 This command depends on the feature "mdadm". See also "feature-
6937 available".
6938
6939 mkdir
6940 mkdir path
6941
6942 Create a directory named "path".
6943
6944 mkdir-mode
6945 mkdir-mode path mode
6946
6947 This command creates a directory, setting the initial permissions of
6948 the directory to "mode".
6949
6950 For common Linux filesystems, the actual mode which is set will be
6951 "mode & ~umask & 01777". Non-native-Linux filesystems may interpret
6952 the mode in other ways.
6953
6954 See also "mkdir", "umask"
6955
6956 mkdir-p
6957 mkdir-p path
6958
6959 Create a directory named "path", creating any parent directories as
6960 necessary. This is like the "mkdir -p" shell command.
6961
6962 mkdtemp
6963 mkdtemp tmpl
6964
6965 This command creates a temporary directory. The "tmpl" parameter
6966 should be a full pathname for the temporary directory name with the
6967 final six characters being "XXXXXX".
6968
6969 For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX", the second
6970 one being suitable for Windows filesystems.
6971
6972 The name of the temporary directory that was created is returned.
6973
6974 The temporary directory is created with mode 0700 and is owned by root.
6975
6976 The caller is responsible for deleting the temporary directory and its
6977 contents after use.
6978
6979 See also: mkdtemp(3)
6980
6981 mke2fs
6982 mke2fs device [blockscount:N] [blocksize:N] [fragsize:N] [blockspergroup:N] [numberofgroups:N] [bytesperinode:N] [inodesize:N] [journalsize:N] [numberofinodes:N] [stridesize:N] [stripewidth:N] [maxonlineresize:N] [reservedblockspercentage:N] [mmpupdateinterval:N] [journaldevice:..] [label:..] [lastmounteddir:..] [creatoros:..] [fstype:..] [usagetype:..] [uuid:..] [forcecreate:true|false] [writesbandgrouponly:true|false] [lazyitableinit:true|false] [lazyjournalinit:true|false] [testfs:true|false] [discard:true|false] [quotatype:true|false] [extent:true|false] [filetype:true|false] [flexbg:true|false] [hasjournal:true|false] [journaldev:true|false] [largefile:true|false] [quota:true|false] [resizeinode:true|false] [sparsesuper:true|false] [uninitbg:true|false]
6983
6984 "mke2fs" is used to create an ext2, ext3, or ext4 filesystem on
6985 "device".
6986
6987 The optional "blockscount" is the size of the filesystem in blocks. If
6988 omitted it defaults to the size of "device". Note if the filesystem is
6989 too small to contain a journal, "mke2fs" will silently create an ext2
6990 filesystem instead.
6991
6992 This command has one or more optional arguments. See "OPTIONAL
6993 ARGUMENTS".
6994
6995 mke2fs-J
6996 mke2fs-J fstype blocksize device journal
6997
6998 This creates an ext2/3/4 filesystem on "device" with an external
6999 journal on "journal". It is equivalent to the command:
7000
7001 mke2fs -t fstype -b blocksize -J device=<journal> <device>
7002
7003 See also "mke2journal".
7004
7005 This function is deprecated. In new code, use the "mke2fs" call
7006 instead.
7007
7008 Deprecated functions will not be removed from the API, but the fact
7009 that they are deprecated indicates that there are problems with correct
7010 use of these functions.
7011
7012 mke2fs-JL
7013 mke2fs-JL fstype blocksize device label
7014
7015 This creates an ext2/3/4 filesystem on "device" with an external
7016 journal on the journal labeled "label".
7017
7018 See also "mke2journal-L".
7019
7020 This function is deprecated. In new code, use the "mke2fs" call
7021 instead.
7022
7023 Deprecated functions will not be removed from the API, but the fact
7024 that they are deprecated indicates that there are problems with correct
7025 use of these functions.
7026
7027 mke2fs-JU
7028 mke2fs-JU fstype blocksize device uuid
7029
7030 This creates an ext2/3/4 filesystem on "device" with an external
7031 journal on the journal with UUID "uuid".
7032
7033 See also "mke2journal-U".
7034
7035 This function is deprecated. In new code, use the "mke2fs" call
7036 instead.
7037
7038 Deprecated functions will not be removed from the API, but the fact
7039 that they are deprecated indicates that there are problems with correct
7040 use of these functions.
7041
7042 This command depends on the feature "linuxfsuuid". See also "feature-
7043 available".
7044
7045 mke2journal
7046 mke2journal blocksize device
7047
7048 This creates an ext2 external journal on "device". It is equivalent to
7049 the command:
7050
7051 mke2fs -O journal_dev -b blocksize device
7052
7053 This function is deprecated. In new code, use the "mke2fs" call
7054 instead.
7055
7056 Deprecated functions will not be removed from the API, but the fact
7057 that they are deprecated indicates that there are problems with correct
7058 use of these functions.
7059
7060 mke2journal-L
7061 mke2journal-L blocksize label device
7062
7063 This creates an ext2 external journal on "device" with label "label".
7064
7065 This function is deprecated. In new code, use the "mke2fs" call
7066 instead.
7067
7068 Deprecated functions will not be removed from the API, but the fact
7069 that they are deprecated indicates that there are problems with correct
7070 use of these functions.
7071
7072 mke2journal-U
7073 mke2journal-U blocksize uuid device
7074
7075 This creates an ext2 external journal on "device" with UUID "uuid".
7076
7077 This function is deprecated. In new code, use the "mke2fs" call
7078 instead.
7079
7080 Deprecated functions will not be removed from the API, but the fact
7081 that they are deprecated indicates that there are problems with correct
7082 use of these functions.
7083
7084 This command depends on the feature "linuxfsuuid". See also "feature-
7085 available".
7086
7087 mkfifo
7088 mkfifo mode path
7089
7090 This call creates a FIFO (named pipe) called "path" with mode "mode".
7091 It is just a convenient wrapper around "mknod".
7092
7093 Unlike with "mknod", "mode" must contain only permissions bits.
7094
7095 The mode actually set is affected by the umask.
7096
7097 This command depends on the feature "mknod". See also "feature-
7098 available".
7099
7100 mkfs
7101 mkfs-opts
7102 mkfs fstype device [blocksize:N] [features:..] [inode:N] [sectorsize:N] [label:..]
7103
7104 This function creates a filesystem on "device". The filesystem type is
7105 "fstype", for example "ext3".
7106
7107 The optional arguments are:
7108
7109 "blocksize"
7110 The filesystem block size. Supported block sizes depend on the
7111 filesystem type, but typically they are 1024, 2048 or 4096 for
7112 Linux ext2/3 filesystems.
7113
7114 For VFAT and NTFS the "blocksize" parameter is treated as the
7115 requested cluster size.
7116
7117 For UFS block sizes, please see mkfs.ufs(8).
7118
7119 "features"
7120 This passes the -O parameter to the external mkfs program.
7121
7122 For certain filesystem types, this allows extra filesystem features
7123 to be selected. See mke2fs(8) and mkfs.ufs(8) for more details.
7124
7125 You cannot use this optional parameter with the "gfs" or "gfs2"
7126 filesystem type.
7127
7128 "inode"
7129 This passes the -I parameter to the external mke2fs(8) program
7130 which sets the inode size (only for ext2/3/4 filesystems at
7131 present).
7132
7133 "sectorsize"
7134 This passes the -S parameter to external mkfs.ufs(8) program, which
7135 sets sector size for ufs filesystem.
7136
7137 This command has one or more optional arguments. See "OPTIONAL
7138 ARGUMENTS".
7139
7140 mkfs-b
7141 mkfs-b fstype blocksize device
7142
7143 This call is similar to "mkfs", but it allows you to control the block
7144 size of the resulting filesystem. Supported block sizes depend on the
7145 filesystem type, but typically they are 1024, 2048 or 4096 only.
7146
7147 For VFAT and NTFS the "blocksize" parameter is treated as the requested
7148 cluster size.
7149
7150 This function is deprecated. In new code, use the "mkfs" call instead.
7151
7152 Deprecated functions will not be removed from the API, but the fact
7153 that they are deprecated indicates that there are problems with correct
7154 use of these functions.
7155
7156 mkfs-btrfs
7157 mkfs-btrfs 'devices ...' [allocstart:N] [bytecount:N] [datatype:..] [leafsize:N] [label:..] [metadata:..] [nodesize:N] [sectorsize:N]
7158
7159 Create a btrfs filesystem, allowing all configurables to be set. For
7160 more information on the optional arguments, see mkfs.btrfs(8).
7161
7162 Since btrfs filesystems can span multiple devices, this takes a non-
7163 empty list of devices.
7164
7165 To create general filesystems, use "mkfs".
7166
7167 This command has one or more optional arguments. See "OPTIONAL
7168 ARGUMENTS".
7169
7170 This command depends on the feature "btrfs". See also "feature-
7171 available".
7172
7173 mklost-and-found
7174 mklost-and-found mountpoint
7175
7176 Make the "lost+found" directory, normally in the root directory of an
7177 ext2/3/4 filesystem. "mountpoint" is the directory under which we try
7178 to create the "lost+found" directory.
7179
7180 mkmountpoint
7181 mkmountpoint exemptpath
7182
7183 "mkmountpoint" and "rmmountpoint" are specialized calls that can be
7184 used to create extra mountpoints before mounting the first filesystem.
7185
7186 These calls are only necessary in some very limited circumstances,
7187 mainly the case where you want to mount a mix of unrelated and/or read-
7188 only filesystems together.
7189
7190 For example, live CDs often contain a "Russian doll" nest of
7191 filesystems, an ISO outer layer, with a squashfs image inside, with an
7192 ext2/3 image inside that. You can unpack this as follows in guestfish:
7193
7194 add-ro Fedora-11-i686-Live.iso
7195 run
7196 mkmountpoint /cd
7197 mkmountpoint /sqsh
7198 mkmountpoint /ext3fs
7199 mount /dev/sda /cd
7200 mount-loop /cd/LiveOS/squashfs.img /sqsh
7201 mount-loop /sqsh/LiveOS/ext3fs.img /ext3fs
7202
7203 The inner filesystem is now unpacked under the /ext3fs mountpoint.
7204
7205 "mkmountpoint" is not compatible with "umount-all". You may get
7206 unexpected errors if you try to mix these calls. It is safest to
7207 manually unmount filesystems and remove mountpoints after use.
7208
7209 "umount-all" unmounts filesystems by sorting the paths longest first,
7210 so for this to work for manual mountpoints, you must ensure that the
7211 innermost mountpoints have the longest pathnames, as in the example
7212 code above.
7213
7214 For more details see https://bugzilla.redhat.com/show_bug.cgi?id=599503
7215
7216 Autosync [see "set-autosync", this is set by default on handles] can
7217 cause "umount-all" to be called when the handle is closed which can
7218 also trigger these issues.
7219
7220 mknod
7221 mknod mode devmajor devminor path
7222
7223 This call creates block or character special devices, or named pipes
7224 (FIFOs).
7225
7226 The "mode" parameter should be the mode, using the standard constants.
7227 "devmajor" and "devminor" are the device major and minor numbers, only
7228 used when creating block and character special devices.
7229
7230 Note that, just like mknod(2), the mode must be bitwise OR'd with
7231 S_IFBLK, S_IFCHR, S_IFIFO or S_IFSOCK (otherwise this call just creates
7232 a regular file). These constants are available in the standard Linux
7233 header files, or you can use "mknod-b", "mknod-c" or "mkfifo" which are
7234 wrappers around this command which bitwise OR in the appropriate
7235 constant for you.
7236
7237 The mode actually set is affected by the umask.
7238
7239 This command depends on the feature "mknod". See also "feature-
7240 available".
7241
7242 mknod-b
7243 mknod-b mode devmajor devminor path
7244
7245 This call creates a block device node called "path" with mode "mode"
7246 and device major/minor "devmajor" and "devminor". It is just a
7247 convenient wrapper around "mknod".
7248
7249 Unlike with "mknod", "mode" must contain only permissions bits.
7250
7251 The mode actually set is affected by the umask.
7252
7253 This command depends on the feature "mknod". See also "feature-
7254 available".
7255
7256 mknod-c
7257 mknod-c mode devmajor devminor path
7258
7259 This call creates a char device node called "path" with mode "mode" and
7260 device major/minor "devmajor" and "devminor". It is just a convenient
7261 wrapper around "mknod".
7262
7263 Unlike with "mknod", "mode" must contain only permissions bits.
7264
7265 The mode actually set is affected by the umask.
7266
7267 This command depends on the feature "mknod". See also "feature-
7268 available".
7269
7270 mksquashfs
7271 mksquashfs path (filename|-) [compress:..] [excludes:..]
7272
7273 Create a squashfs filesystem for the specified "path".
7274
7275 The optional "compress" flag controls compression. If not given, then
7276 the output compressed using "gzip". Otherwise one of the following
7277 strings may be given to select the compression type of the squashfs:
7278 "gzip", "lzma", "lzo", "lz4", "xz".
7279
7280 The other optional arguments are:
7281
7282 "excludes"
7283 A list of wildcards. Files are excluded if they match any of the
7284 wildcards.
7285
7286 Please note that this API may fail when used to compress directories
7287 with large files, such as the resulting squashfs will be over 3GB big.
7288
7289 Use "-" instead of a filename to read/write from stdin/stdout.
7290
7291 This command has one or more optional arguments. See "OPTIONAL
7292 ARGUMENTS".
7293
7294 This command depends on the feature "squashfs". See also "feature-
7295 available".
7296
7297 mkswap
7298 mkswap-opts
7299 mkswap device [label:..] [uuid:..]
7300
7301 Create a Linux swap partition on "device".
7302
7303 The option arguments "label" and "uuid" allow you to set the label
7304 and/or UUID of the new swap partition.
7305
7306 This command has one or more optional arguments. See "OPTIONAL
7307 ARGUMENTS".
7308
7309 mkswap-L
7310 mkswap-L label device
7311
7312 Create a swap partition on "device" with label "label".
7313
7314 Note that you cannot attach a swap label to a block device (eg.
7315 /dev/sda), just to a partition. This appears to be a limitation of the
7316 kernel or swap tools.
7317
7318 This function is deprecated. In new code, use the "mkswap" call
7319 instead.
7320
7321 Deprecated functions will not be removed from the API, but the fact
7322 that they are deprecated indicates that there are problems with correct
7323 use of these functions.
7324
7325 mkswap-U
7326 mkswap-U uuid device
7327
7328 Create a swap partition on "device" with UUID "uuid".
7329
7330 This function is deprecated. In new code, use the "mkswap" call
7331 instead.
7332
7333 Deprecated functions will not be removed from the API, but the fact
7334 that they are deprecated indicates that there are problems with correct
7335 use of these functions.
7336
7337 This command depends on the feature "linuxfsuuid". See also "feature-
7338 available".
7339
7340 mkswap-file
7341 mkswap-file path
7342
7343 Create a swap file.
7344
7345 This command just writes a swap file signature to an existing file. To
7346 create the file itself, use something like "fallocate".
7347
7348 mktemp
7349 mktemp tmpl [suffix:..]
7350
7351 This command creates a temporary file. The "tmpl" parameter should be
7352 a full pathname for the temporary directory name with the final six
7353 characters being "XXXXXX".
7354
7355 For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX", the second
7356 one being suitable for Windows filesystems.
7357
7358 The name of the temporary file that was created is returned.
7359
7360 The temporary file is created with mode 0600 and is owned by root.
7361
7362 The caller is responsible for deleting the temporary file after use.
7363
7364 If the optional "suffix" parameter is given, then the suffix (eg.
7365 ".txt") is appended to the temporary name.
7366
7367 See also: "mkdtemp".
7368
7369 This command has one or more optional arguments. See "OPTIONAL
7370 ARGUMENTS".
7371
7372 modprobe
7373 modprobe modulename
7374
7375 This loads a kernel module in the appliance.
7376
7377 This command depends on the feature "linuxmodules". See also
7378 "feature-available".
7379
7380 mount
7381 mount mountable mountpoint
7382
7383 Mount a guest disk at a position in the filesystem. Block devices are
7384 named /dev/sda, /dev/sdb and so on, as they were added to the guest.
7385 If those block devices contain partitions, they will have the usual
7386 names (eg. /dev/sda1). Also LVM /dev/VG/LV-style names can be used, or
7387 ‘mountable’ strings returned by "list-filesystems" or "inspect-get-
7388 mountpoints".
7389
7390 The rules are the same as for mount(2): A filesystem must first be
7391 mounted on / before others can be mounted. Other filesystems can only
7392 be mounted on directories which already exist.
7393
7394 The mounted filesystem is writable, if we have sufficient permissions
7395 on the underlying device.
7396
7397 Before libguestfs 1.13.16, this call implicitly added the options
7398 "sync" and "noatime". The "sync" option greatly slowed writes and
7399 caused many problems for users. If your program might need to work
7400 with older versions of libguestfs, use "mount-options" instead (using
7401 an empty string for the first parameter if you don't want any options).
7402
7403 mount-9p
7404 mount-9p mounttag mountpoint [options:..]
7405
7406 This call does nothing and returns an error.
7407
7408 This command has one or more optional arguments. See "OPTIONAL
7409 ARGUMENTS".
7410
7411 This function is deprecated. There is no replacement. Consult the API
7412 documentation in guestfs(3) for further information.
7413
7414 Deprecated functions will not be removed from the API, but the fact
7415 that they are deprecated indicates that there are problems with correct
7416 use of these functions.
7417
7418 mount-local
7419 mount-local localmountpoint [readonly:true|false] [options:..] [cachetimeout:N] [debugcalls:true|false]
7420
7421 This call exports the libguestfs-accessible filesystem to a local
7422 mountpoint (directory) called "localmountpoint". Ordinary reads and
7423 writes to files and directories under "localmountpoint" are redirected
7424 through libguestfs.
7425
7426 If the optional "readonly" flag is set to true, then writes to the
7427 filesystem return error "EROFS".
7428
7429 "options" is a comma-separated list of mount options. See
7430 guestmount(1) for some useful options.
7431
7432 "cachetimeout" sets the timeout (in seconds) for cached directory
7433 entries. The default is 60 seconds. See guestmount(1) for further
7434 information.
7435
7436 If "debugcalls" is set to true, then additional debugging information
7437 is generated for every FUSE call.
7438
7439 When "mount-local" returns, the filesystem is ready, but is not
7440 processing requests (access to it will block). You have to call
7441 "mount-local-run" to run the main loop.
7442
7443 See "MOUNT LOCAL" in guestfs(3) for full documentation.
7444
7445 This command has one or more optional arguments. See "OPTIONAL
7446 ARGUMENTS".
7447
7448 mount-local-run
7449 mount-local-run
7450
7451 Run the main loop which translates kernel calls to libguestfs calls.
7452
7453 This should only be called after "mount-local" returns successfully.
7454 The call will not return until the filesystem is unmounted.
7455
7456 Note you must not make concurrent libguestfs calls on the same handle
7457 from another thread.
7458
7459 You may call this from a different thread than the one which called
7460 "mount-local", subject to the usual rules for threads and libguestfs
7461 (see "MULTIPLE HANDLES AND MULTIPLE THREADS" in guestfs(3)).
7462
7463 See "MOUNT LOCAL" in guestfs(3) for full documentation.
7464
7465 mount-loop
7466 mount-loop file mountpoint
7467
7468 This command lets you mount file (a filesystem image in a file) on a
7469 mount point. It is entirely equivalent to the command "mount -o loop
7470 file mountpoint".
7471
7472 mount-options
7473 mount-options options mountable mountpoint
7474
7475 This is the same as the "mount" command, but it allows you to set the
7476 mount options as for the mount(8) -o flag.
7477
7478 If the "options" parameter is an empty string, then no options are
7479 passed (all options default to whatever the filesystem uses).
7480
7481 mount-ro
7482 mount-ro mountable mountpoint
7483
7484 This is the same as the "mount" command, but it mounts the filesystem
7485 with the read-only (-o ro) flag.
7486
7487 mount-vfs
7488 mount-vfs options vfstype mountable mountpoint
7489
7490 This is the same as the "mount" command, but it allows you to set both
7491 the mount options and the vfstype as for the mount(8) -o and -t flags.
7492
7493 mountable-device
7494 mountable-device mountable
7495
7496 Returns the device name of a mountable. In quite a lot of cases, the
7497 mountable is the device name.
7498
7499 However this doesn't apply for btrfs subvolumes, where the mountable is
7500 a combination of both the device name and the subvolume path (see also
7501 "mountable-subvolume" to extract the subvolume path of the mountable if
7502 any).
7503
7504 mountable-subvolume
7505 mountable-subvolume mountable
7506
7507 Returns the subvolume path of a mountable. Btrfs subvolumes mountables
7508 are a combination of both the device name and the subvolume path (see
7509 also "mountable-device" to extract the device of the mountable).
7510
7511 If the mountable does not represent a btrfs subvolume, then this
7512 function fails and the "errno" is set to "EINVAL".
7513
7514 mountpoints
7515 mountpoints
7516
7517 This call is similar to "mounts". That call returns a list of devices.
7518 This one returns a hash table (map) of device name to directory where
7519 the device is mounted.
7520
7521 mounts
7522 mounts
7523
7524 This returns the list of currently mounted filesystems. It returns the
7525 list of devices (eg. /dev/sda1, /dev/VG/LV).
7526
7527 Some internal mounts are not shown.
7528
7529 See also: "mountpoints"
7530
7531 mv
7532 mv src dest
7533
7534 This moves a file from "src" to "dest" where "dest" is either a
7535 destination filename or destination directory.
7536
7537 See also: "rename".
7538
7539 nr-devices
7540 nr-devices
7541
7542 This returns the number of whole block devices that were added. This
7543 is the same as the number of devices that would be returned if you
7544 called "list-devices".
7545
7546 To find out the maximum number of devices that could be added, call
7547 "max-disks".
7548
7549 ntfs-3g-probe
7550 ntfs-3g-probe true|false device
7551
7552 This command runs the ntfs-3g.probe(8) command which probes an NTFS
7553 "device" for mountability. (Not all NTFS volumes can be mounted read-
7554 write, and some cannot be mounted at all).
7555
7556 "rw" is a boolean flag. Set it to true if you want to test if the
7557 volume can be mounted read-write. Set it to false if you want to test
7558 if the volume can be mounted read-only.
7559
7560 The return value is an integer which 0 if the operation would succeed,
7561 or some non-zero value documented in the ntfs-3g.probe(8) manual page.
7562
7563 This command depends on the feature "ntfs3g". See also "feature-
7564 available".
7565
7566 ntfscat-i
7567 ntfscat-i device inode (filename|-)
7568
7569 Download a file given its inode from a NTFS filesystem and save it as
7570 filename on the local machine.
7571
7572 This allows to download some otherwise inaccessible files such as the
7573 ones within the $Extend folder.
7574
7575 The filesystem from which to extract the file must be unmounted,
7576 otherwise the call will fail.
7577
7578 Use "-" instead of a filename to read/write from stdin/stdout.
7579
7580 ntfsclone-in
7581 ntfsclone-in (backupfile|-) device
7582
7583 Restore the "backupfile" (from a previous call to "ntfsclone-out") to
7584 "device", overwriting any existing contents of this device.
7585
7586 Use "-" instead of a filename to read/write from stdin/stdout.
7587
7588 This command depends on the feature "ntfs3g". See also "feature-
7589 available".
7590
7591 ntfsclone-out
7592 ntfsclone-out device (backupfile|-) [metadataonly:true|false] [rescue:true|false] [ignorefscheck:true|false] [preservetimestamps:true|false] [force:true|false]
7593
7594 Stream the NTFS filesystem "device" to the local file "backupfile".
7595 The format used for the backup file is a special format used by the
7596 ntfsclone(8) tool.
7597
7598 If the optional "metadataonly" flag is true, then only the metadata is
7599 saved, losing all the user data (this is useful for diagnosing some
7600 filesystem problems).
7601
7602 The optional "rescue", "ignorefscheck", "preservetimestamps" and
7603 "force" flags have precise meanings detailed in the ntfsclone(8) man
7604 page.
7605
7606 Use "ntfsclone-in" to restore the file back to a libguestfs device.
7607
7608 Use "-" instead of a filename to read/write from stdin/stdout.
7609
7610 This command has one or more optional arguments. See "OPTIONAL
7611 ARGUMENTS".
7612
7613 This command depends on the feature "ntfs3g". See also "feature-
7614 available".
7615
7616 ntfsfix
7617 ntfsfix device [clearbadsectors:true|false]
7618
7619 This command repairs some fundamental NTFS inconsistencies, resets the
7620 NTFS journal file, and schedules an NTFS consistency check for the
7621 first boot into Windows.
7622
7623 This is not an equivalent of Windows "chkdsk". It does not scan the
7624 filesystem for inconsistencies.
7625
7626 The optional "clearbadsectors" flag clears the list of bad sectors.
7627 This is useful after cloning a disk with bad sectors to a new disk.
7628
7629 This command has one or more optional arguments. See "OPTIONAL
7630 ARGUMENTS".
7631
7632 This command depends on the feature "ntfs3g". See also "feature-
7633 available".
7634
7635 ntfsresize
7636 ntfsresize-opts
7637 ntfsresize device [size:N] [force:true|false]
7638
7639 This command resizes an NTFS filesystem, expanding or shrinking it to
7640 the size of the underlying device.
7641
7642 The optional parameters are:
7643
7644 "size"
7645 The new size (in bytes) of the filesystem. If omitted, the
7646 filesystem is resized to fit the container (eg. partition).
7647
7648 "force"
7649 If this option is true, then force the resize of the filesystem
7650 even if the filesystem is marked as requiring a consistency check.
7651
7652 After the resize operation, the filesystem is always marked as
7653 requiring a consistency check (for safety). You have to boot into
7654 Windows to perform this check and clear this condition. If you
7655 don't set the "force" option then it is not possible to call
7656 "ntfsresize" multiple times on a single filesystem without booting
7657 into Windows between each resize.
7658
7659 See also ntfsresize(8).
7660
7661 This command has one or more optional arguments. See "OPTIONAL
7662 ARGUMENTS".
7663
7664 This command depends on the feature "ntfsprogs". See also "feature-
7665 available".
7666
7667 ntfsresize-size
7668 ntfsresize-size device size
7669
7670 This command is the same as "ntfsresize" except that it allows you to
7671 specify the new size (in bytes) explicitly.
7672
7673 This function is deprecated. In new code, use the "ntfsresize" call
7674 instead.
7675
7676 Deprecated functions will not be removed from the API, but the fact
7677 that they are deprecated indicates that there are problems with correct
7678 use of these functions.
7679
7680 This command depends on the feature "ntfsprogs". See also "feature-
7681 available".
7682
7683 parse-environment
7684 parse-environment
7685
7686 Parse the program’s environment and set flags in the handle
7687 accordingly. For example if "LIBGUESTFS_DEBUG=1" then the ‘verbose’
7688 flag is set in the handle.
7689
7690 Most programs do not need to call this. It is done implicitly when you
7691 call "create".
7692
7693 See "ENVIRONMENT VARIABLES" in guestfs(3) for a list of environment
7694 variables that can affect libguestfs handles. See also
7695 "guestfs_create_flags" in guestfs(3), and "parse-environment-list".
7696
7697 parse-environment-list
7698 parse-environment-list 'environment ...'
7699
7700 Parse the list of strings in the argument "environment" and set flags
7701 in the handle accordingly. For example if "LIBGUESTFS_DEBUG=1" is a
7702 string in the list, then the ‘verbose’ flag is set in the handle.
7703
7704 This is the same as "parse-environment" except that it parses an
7705 explicit list of strings instead of the program's environment.
7706
7707 part-add
7708 part-add device prlogex startsect endsect
7709
7710 This command adds a partition to "device". If there is no partition
7711 table on the device, call "part-init" first.
7712
7713 The "prlogex" parameter is the type of partition. Normally you should
7714 pass "p" or "primary" here, but MBR partition tables also support "l"
7715 (or "logical") and "e" (or "extended") partition types.
7716
7717 "startsect" and "endsect" are the start and end of the partition in
7718 sectors. "endsect" may be negative, which means it counts backwards
7719 from the end of the disk ("-1" is the last sector).
7720
7721 Creating a partition which covers the whole disk is not so easy. Use
7722 "part-disk" to do that.
7723
7724 part-del
7725 part-del device partnum
7726
7727 This command deletes the partition numbered "partnum" on "device".
7728
7729 Note that in the case of MBR partitioning, deleting an extended
7730 partition also deletes any logical partitions it contains.
7731
7732 part-disk
7733 part-disk device parttype
7734
7735 This command is simply a combination of "part-init" followed by "part-
7736 add" to create a single primary partition covering the whole disk.
7737
7738 "parttype" is the partition table type, usually "mbr" or "gpt", but
7739 other possible values are described in "part-init".
7740
7741 part-expand-gpt
7742 part-expand-gpt device
7743
7744 Move backup GPT data structures to the end of the disk. This is useful
7745 in case of in-place image expand since disk space after backup GPT
7746 header is not usable. This is equivalent to "sgdisk -e".
7747
7748 See also sgdisk(8).
7749
7750 This command depends on the feature "gdisk". See also "feature-
7751 available".
7752
7753 part-get-bootable
7754 part-get-bootable device partnum
7755
7756 This command returns true if the partition "partnum" on "device" has
7757 the bootable flag set.
7758
7759 See also "part-set-bootable".
7760
7761 part-get-disk-guid
7762 part-get-disk-guid device
7763
7764 Return the disk identifier (GUID) of a GPT-partitioned "device".
7765 Behaviour is undefined for other partition types.
7766
7767 This command depends on the feature "gdisk". See also "feature-
7768 available".
7769
7770 part-get-gpt-attributes
7771 part-get-gpt-attributes device partnum
7772
7773 Return the attribute flags of numbered GPT partition "partnum". An
7774 error is returned for MBR partitions.
7775
7776 This command depends on the feature "gdisk". See also "feature-
7777 available".
7778
7779 part-get-gpt-guid
7780 part-get-gpt-guid device partnum
7781
7782 Return the GUID of numbered GPT partition "partnum".
7783
7784 This command depends on the feature "gdisk". See also "feature-
7785 available".
7786
7787 part-get-gpt-type
7788 part-get-gpt-type device partnum
7789
7790 Return the type GUID of numbered GPT partition "partnum". For MBR
7791 partitions, return an appropriate GUID corresponding to the MBR type.
7792 Behaviour is undefined for other partition types.
7793
7794 This command depends on the feature "gdisk". See also "feature-
7795 available".
7796
7797 part-get-mbr-id
7798 part-get-mbr-id device partnum
7799
7800 Returns the MBR type byte (also known as the ID byte) from the numbered
7801 partition "partnum".
7802
7803 Note that only MBR (old DOS-style) partitions have type bytes. You
7804 will get undefined results for other partition table types (see "part-
7805 get-parttype").
7806
7807 part-get-mbr-part-type
7808 part-get-mbr-part-type device partnum
7809
7810 This returns the partition type of an MBR partition numbered "partnum"
7811 on device "device".
7812
7813 It returns "primary", "logical", or "extended".
7814
7815 part-get-name
7816 part-get-name device partnum
7817
7818 This gets the partition name on partition numbered "partnum" on device
7819 "device". Note that partitions are numbered from 1.
7820
7821 The partition name can only be read on certain types of partition
7822 table. This works on "gpt" but not on "mbr" partitions.
7823
7824 part-get-parttype
7825 part-get-parttype device
7826
7827 This command examines the partition table on "device" and returns the
7828 partition table type (format) being used.
7829
7830 Common return values include: "msdos" (a DOS/Windows style MBR
7831 partition table), "gpt" (a GPT/EFI-style partition table). Other
7832 values are possible, although unusual. See "part-init" for a full
7833 list.
7834
7835 part-init
7836 part-init device parttype
7837
7838 This creates an empty partition table on "device" of one of the
7839 partition types listed below. Usually "parttype" should be either
7840 "msdos" or "gpt" (for large disks).
7841
7842 Initially there are no partitions. Following this, you should call
7843 "part-add" for each partition required.
7844
7845 Possible values for "parttype" are:
7846
7847 "efi"
7848 "gpt"
7849 Intel EFI / GPT partition table.
7850
7851 This is recommended for >= 2 TB partitions that will be accessed
7852 from Linux and Intel-based Mac OS X. It also has limited backwards
7853 compatibility with the "mbr" format.
7854
7855 "mbr"
7856 "msdos"
7857 The standard PC "Master Boot Record" (MBR) format used by MS-DOS
7858 and Windows. This partition type will only work for device sizes
7859 up to 2 TB. For large disks we recommend using "gpt".
7860
7861 Other partition table types that may work but are not supported
7862 include:
7863
7864 "aix"
7865 AIX disk labels.
7866
7867 "amiga"
7868 "rdb"
7869 Amiga "Rigid Disk Block" format.
7870
7871 "bsd"
7872 BSD disk labels.
7873
7874 "dasd"
7875 DASD, used on IBM mainframes.
7876
7877 "dvh"
7878 MIPS/SGI volumes.
7879
7880 "mac"
7881 Old Mac partition format. Modern Macs use "gpt".
7882
7883 "pc98"
7884 NEC PC-98 format, common in Japan apparently.
7885
7886 "sun"
7887 Sun disk labels.
7888
7889 part-list
7890 part-list device
7891
7892 This command parses the partition table on "device" and returns the
7893 list of partitions found.
7894
7895 The fields in the returned structure are:
7896
7897 "part_num"
7898 Partition number, counting from 1.
7899
7900 "part_start"
7901 Start of the partition in bytes. To get sectors you have to divide
7902 by the device’s sector size, see "blockdev-getss".
7903
7904 "part_end"
7905 End of the partition in bytes.
7906
7907 "part_size"
7908 Size of the partition in bytes.
7909
7910 part-resize
7911 part-resize device partnum endsect
7912
7913 This command resizes the partition numbered "partnum" on "device" by
7914 moving the end position.
7915
7916 Note that this does not modify any filesystem present in the partition.
7917 If you wish to do this, you will need to use filesystem resizing
7918 commands like "resize2fs".
7919
7920 When growing a partition you will want to grow the filesystem
7921 afterwards, but when shrinking, you need to shrink the filesystem
7922 before the partition.
7923
7924 part-set-bootable
7925 part-set-bootable device partnum true|false
7926
7927 This sets the bootable flag on partition numbered "partnum" on device
7928 "device". Note that partitions are numbered from 1.
7929
7930 The bootable flag is used by some operating systems (notably Windows)
7931 to determine which partition to boot from. It is by no means
7932 universally recognized.
7933
7934 part-set-disk-guid
7935 part-set-disk-guid device guid
7936
7937 Set the disk identifier (GUID) of a GPT-partitioned "device" to "guid".
7938 Return an error if the partition table of "device" isn't GPT, or if
7939 "guid" is not a valid GUID.
7940
7941 This command depends on the feature "gdisk". See also "feature-
7942 available".
7943
7944 part-set-disk-guid-random
7945 part-set-disk-guid-random device
7946
7947 Set the disk identifier (GUID) of a GPT-partitioned "device" to a
7948 randomly generated value. Return an error if the partition table of
7949 "device" isn't GPT.
7950
7951 This command depends on the feature "gdisk". See also "feature-
7952 available".
7953
7954 part-set-gpt-attributes
7955 part-set-gpt-attributes device partnum attributes
7956
7957 Set the attribute flags of numbered GPT partition "partnum" to
7958 "attributes". Return an error if the partition table of "device" isn't
7959 GPT.
7960
7961 See
7962 https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries
7963 for a useful list of partition attributes.
7964
7965 This command depends on the feature "gdisk". See also "feature-
7966 available".
7967
7968 part-set-gpt-guid
7969 part-set-gpt-guid device partnum guid
7970
7971 Set the GUID of numbered GPT partition "partnum" to "guid". Return an
7972 error if the partition table of "device" isn't GPT, or if "guid" is not
7973 a valid GUID.
7974
7975 This command depends on the feature "gdisk". See also "feature-
7976 available".
7977
7978 part-set-gpt-type
7979 part-set-gpt-type device partnum guid
7980
7981 Set the type GUID of numbered GPT partition "partnum" to "guid". Return
7982 an error if the partition table of "device" isn't GPT, or if "guid" is
7983 not a valid GUID.
7984
7985 See
7986 https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
7987 for a useful list of type GUIDs.
7988
7989 This command depends on the feature "gdisk". See also "feature-
7990 available".
7991
7992 part-set-mbr-id
7993 part-set-mbr-id device partnum idbyte
7994
7995 Sets the MBR type byte (also known as the ID byte) of the numbered
7996 partition "partnum" to "idbyte". Note that the type bytes quoted in
7997 most documentation are in fact hexadecimal numbers, but usually
7998 documented without any leading "0x" which might be confusing.
7999
8000 Note that only MBR (old DOS-style) partitions have type bytes. You
8001 will get undefined results for other partition table types (see "part-
8002 get-parttype").
8003
8004 part-set-name
8005 part-set-name device partnum name
8006
8007 This sets the partition name on partition numbered "partnum" on device
8008 "device". Note that partitions are numbered from 1.
8009
8010 The partition name can only be set on certain types of partition table.
8011 This works on "gpt" but not on "mbr" partitions.
8012
8013 part-to-dev
8014 part-to-dev partition
8015
8016 This function takes a partition name (eg. "/dev/sdb1") and removes the
8017 partition number, returning the device name (eg. "/dev/sdb").
8018
8019 The named partition must exist, for example as a string returned from
8020 "list-partitions".
8021
8022 See also "part-to-partnum", "device-index".
8023
8024 part-to-partnum
8025 part-to-partnum partition
8026
8027 This function takes a partition name (eg. "/dev/sdb1") and returns the
8028 partition number (eg. 1).
8029
8030 The named partition must exist, for example as a string returned from
8031 "list-partitions".
8032
8033 See also "part-to-dev".
8034
8035 ping-daemon
8036 ping-daemon
8037
8038 This is a test probe into the guestfs daemon running inside the
8039 libguestfs appliance. Calling this function checks that the daemon
8040 responds to the ping message, without affecting the daemon or attached
8041 block device(s) in any other way.
8042
8043 pread
8044 pread path count offset
8045
8046 This command lets you read part of a file. It reads "count" bytes of
8047 the file, starting at "offset", from file "path".
8048
8049 This may read fewer bytes than requested. For further details see the
8050 pread(2) system call.
8051
8052 See also "pwrite", "pread-device".
8053
8054 Because of the message protocol, there is a transfer limit of somewhere
8055 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
8056
8057 pread-device
8058 pread-device device count offset
8059
8060 This command lets you read part of a block device. It reads "count"
8061 bytes of "device", starting at "offset".
8062
8063 This may read fewer bytes than requested. For further details see the
8064 pread(2) system call.
8065
8066 See also "pread".
8067
8068 Because of the message protocol, there is a transfer limit of somewhere
8069 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
8070
8071 pvchange-uuid
8072 pvchange-uuid device
8073
8074 Generate a new random UUID for the physical volume "device".
8075
8076 This command depends on the feature "lvm2". See also "feature-
8077 available".
8078
8079 pvchange-uuid-all
8080 pvchange-uuid-all
8081
8082 Generate new random UUIDs for all physical volumes.
8083
8084 This command depends on the feature "lvm2". See also "feature-
8085 available".
8086
8087 pvcreate
8088 pvcreate device
8089
8090 This creates an LVM physical volume on the named "device", where
8091 "device" should usually be a partition name such as /dev/sda1.
8092
8093 This command depends on the feature "lvm2". See also "feature-
8094 available".
8095
8096 pvremove
8097 pvremove device
8098
8099 This wipes a physical volume "device" so that LVM will no longer
8100 recognise it.
8101
8102 The implementation uses the pvremove(8) command which refuses to wipe
8103 physical volumes that contain any volume groups, so you have to remove
8104 those first.
8105
8106 This command depends on the feature "lvm2". See also "feature-
8107 available".
8108
8109 pvresize
8110 pvresize device
8111
8112 This resizes (expands or shrinks) an existing LVM physical volume to
8113 match the new size of the underlying device.
8114
8115 This command depends on the feature "lvm2". See also "feature-
8116 available".
8117
8118 pvresize-size
8119 pvresize-size device size
8120
8121 This command is the same as "pvresize" except that it allows you to
8122 specify the new size (in bytes) explicitly.
8123
8124 This command depends on the feature "lvm2". See also "feature-
8125 available".
8126
8127 pvs
8128 pvs
8129
8130 List all the physical volumes detected. This is the equivalent of the
8131 pvs(8) command.
8132
8133 This returns a list of just the device names that contain PVs (eg.
8134 /dev/sda2).
8135
8136 See also "pvs-full".
8137
8138 This command depends on the feature "lvm2". See also "feature-
8139 available".
8140
8141 pvs-full
8142 pvs-full
8143
8144 List all the physical volumes detected. This is the equivalent of the
8145 pvs(8) command. The "full" version includes all fields.
8146
8147 This command depends on the feature "lvm2". See also "feature-
8148 available".
8149
8150 pvuuid
8151 pvuuid device
8152
8153 This command returns the UUID of the LVM PV "device".
8154
8155 pwrite
8156 pwrite path content offset
8157
8158 This command writes to part of a file. It writes the data buffer
8159 "content" to the file "path" starting at offset "offset".
8160
8161 This command implements the pwrite(2) system call, and like that system
8162 call it may not write the full data requested. The return value is the
8163 number of bytes that were actually written to the file. This could
8164 even be 0, although short writes are unlikely for regular files in
8165 ordinary circumstances.
8166
8167 See also "pread", "pwrite-device".
8168
8169 Because of the message protocol, there is a transfer limit of somewhere
8170 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
8171
8172 pwrite-device
8173 pwrite-device device content offset
8174
8175 This command writes to part of a device. It writes the data buffer
8176 "content" to "device" starting at offset "offset".
8177
8178 This command implements the pwrite(2) system call, and like that system
8179 call it may not write the full data requested (although short writes to
8180 disk devices and partitions are probably impossible with standard Linux
8181 kernels).
8182
8183 See also "pwrite".
8184
8185 Because of the message protocol, there is a transfer limit of somewhere
8186 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
8187
8188 read-file
8189 read-file path
8190
8191 This calls returns the contents of the file "path" as a buffer.
8192
8193 Unlike "cat", this function can correctly handle files that contain
8194 embedded ASCII NUL characters.
8195
8196 read-lines
8197 read-lines path
8198
8199 Return the contents of the file named "path".
8200
8201 The file contents are returned as a list of lines. Trailing "LF" and
8202 "CRLF" character sequences are not returned.
8203
8204 Note that this function cannot correctly handle binary files
8205 (specifically, files containing "\0" character which is treated as end
8206 of string). For those you need to use the "read-file" function and
8207 split the buffer into lines yourself.
8208
8209 readdir
8210 readdir dir
8211
8212 This returns the list of directory entries in directory "dir".
8213
8214 All entries in the directory are returned, including "." and "..". The
8215 entries are not sorted, but returned in the same order as the
8216 underlying filesystem.
8217
8218 Also this call returns basic file type information about each file.
8219 The "ftyp" field will contain one of the following characters:
8220
8221 'b' Block special
8222
8223 'c' Char special
8224
8225 'd' Directory
8226
8227 'f' FIFO (named pipe)
8228
8229 'l' Symbolic link
8230
8231 'r' Regular file
8232
8233 's' Socket
8234
8235 'u' Unknown file type
8236
8237 '?' The readdir(3) call returned a "d_type" field with an unexpected
8238 value
8239
8240 This function is primarily intended for use by programs. To get a
8241 simple list of names, use "ls". To get a printable directory for human
8242 consumption, use "ll".
8243
8244 readlink
8245 readlink path
8246
8247 This command reads the target of a symbolic link.
8248
8249 readlinklist
8250 readlinklist path 'names ...'
8251
8252 This call allows you to do a "readlink" operation on multiple files,
8253 where all files are in the directory "path". "names" is the list of
8254 files from this directory.
8255
8256 On return you get a list of strings, with a one-to-one correspondence
8257 to the "names" list. Each string is the value of the symbolic link.
8258
8259 If the readlink(2) operation fails on any name, then the corresponding
8260 result string is the empty string "". However the whole operation is
8261 completed even if there were readlink(2) errors, and so you can call
8262 this function with names where you don't know if they are symbolic
8263 links already (albeit slightly less efficient).
8264
8265 This call is intended for programs that want to efficiently list a
8266 directory contents without making many round-trips.
8267
8268 realpath
8269 realpath path
8270
8271 Return the canonicalized absolute pathname of "path". The returned
8272 path has no ".", ".." or symbolic link path elements.
8273
8274 remount
8275 remount mountpoint [rw:true|false]
8276
8277 This call allows you to change the "rw" (readonly/read-write) flag on
8278 an already mounted filesystem at "mountpoint", converting a readonly
8279 filesystem to be read-write, or vice-versa.
8280
8281 Note that at the moment you must supply the "optional" "rw" parameter.
8282 In future we may allow other flags to be adjusted.
8283
8284 This command has one or more optional arguments. See "OPTIONAL
8285 ARGUMENTS".
8286
8287 remove-drive
8288 remove-drive label
8289
8290 This call does nothing and returns an error.
8291
8292 This function is deprecated. There is no replacement. Consult the API
8293 documentation in guestfs(3) for further information.
8294
8295 Deprecated functions will not be removed from the API, but the fact
8296 that they are deprecated indicates that there are problems with correct
8297 use of these functions.
8298
8299 removexattr
8300 removexattr xattr path
8301
8302 This call removes the extended attribute named "xattr" of the file
8303 "path".
8304
8305 See also: "lremovexattr", attr(5).
8306
8307 This command depends on the feature "linuxxattrs". See also "feature-
8308 available".
8309
8310 rename
8311 rename oldpath newpath
8312
8313 Rename a file to a new place on the same filesystem. This is the same
8314 as the Linux rename(2) system call. In most cases you are better to
8315 use "mv" instead.
8316
8317 resize2fs
8318 resize2fs device
8319
8320 This resizes an ext2, ext3 or ext4 filesystem to match the size of the
8321 underlying device.
8322
8323 See also "RESIZE2FS ERRORS" in guestfs(3).
8324
8325 resize2fs-M
8326 resize2fs-M device
8327
8328 This command is the same as "resize2fs", but the filesystem is resized
8329 to its minimum size. This works like the -M option to the resize2fs(8)
8330 command.
8331
8332 To get the resulting size of the filesystem you should call "tune2fs-l"
8333 and read the "Block size" and "Block count" values. These two numbers,
8334 multiplied together, give the resulting size of the minimal filesystem
8335 in bytes.
8336
8337 See also "RESIZE2FS ERRORS" in guestfs(3).
8338
8339 resize2fs-size
8340 resize2fs-size device size
8341
8342 This command is the same as "resize2fs" except that it allows you to
8343 specify the new size (in bytes) explicitly.
8344
8345 See also "RESIZE2FS ERRORS" in guestfs(3).
8346
8347 rm
8348 rm path
8349
8350 Remove the single file "path".
8351
8352 rm-f
8353 rm-f path
8354
8355 Remove the file "path".
8356
8357 If the file doesn't exist, that error is ignored. (Other errors, eg.
8358 I/O errors or bad paths, are not ignored)
8359
8360 This call cannot remove directories. Use "rmdir" to remove an empty
8361 directory, or "rm-rf" to remove directories recursively.
8362
8363 rm-rf
8364 rm-rf path
8365
8366 Remove the file or directory "path", recursively removing the contents
8367 if its a directory. This is like the "rm -rf" shell command.
8368
8369 rmdir
8370 rmdir path
8371
8372 Remove the single directory "path".
8373
8374 rmmountpoint
8375 rmmountpoint exemptpath
8376
8377 This call removes a mountpoint that was previously created with
8378 "mkmountpoint". See "mkmountpoint" for full details.
8379
8380 rsync
8381 rsync src dest [archive:true|false] [deletedest:true|false]
8382
8383 This call may be used to copy or synchronize two directories under the
8384 same libguestfs handle. This uses the rsync(1) program which uses a
8385 fast algorithm that avoids copying files unnecessarily.
8386
8387 "src" and "dest" are the source and destination directories. Files are
8388 copied from "src" to "dest".
8389
8390 The optional arguments are:
8391
8392 "archive"
8393 Turns on archive mode. This is the same as passing the --archive
8394 flag to "rsync".
8395
8396 "deletedest"
8397 Delete files at the destination that do not exist at the source.
8398
8399 This command has one or more optional arguments. See "OPTIONAL
8400 ARGUMENTS".
8401
8402 This command depends on the feature "rsync". See also "feature-
8403 available".
8404
8405 rsync-in
8406 rsync-in remote dest [archive:true|false] [deletedest:true|false]
8407
8408 This call may be used to copy or synchronize the filesystem on the host
8409 or on a remote computer with the filesystem within libguestfs. This
8410 uses the rsync(1) program which uses a fast algorithm that avoids
8411 copying files unnecessarily.
8412
8413 This call only works if the network is enabled. See "set-network" or
8414 the --network option to various tools like guestfish(1).
8415
8416 Files are copied from the remote server and directory specified by
8417 "remote" to the destination directory "dest".
8418
8419 The format of the remote server string is defined by rsync(1). Note
8420 that there is no way to supply a password or passphrase so the target
8421 must be set up not to require one.
8422
8423 The optional arguments are the same as those of "rsync".
8424
8425 This command has one or more optional arguments. See "OPTIONAL
8426 ARGUMENTS".
8427
8428 This command depends on the feature "rsync". See also "feature-
8429 available".
8430
8431 rsync-out
8432 rsync-out src remote [archive:true|false] [deletedest:true|false]
8433
8434 This call may be used to copy or synchronize the filesystem within
8435 libguestfs with a filesystem on the host or on a remote computer. This
8436 uses the rsync(1) program which uses a fast algorithm that avoids
8437 copying files unnecessarily.
8438
8439 This call only works if the network is enabled. See "set-network" or
8440 the --network option to various tools like guestfish(1).
8441
8442 Files are copied from the source directory "src" to the remote server
8443 and directory specified by "remote".
8444
8445 The format of the remote server string is defined by rsync(1). Note
8446 that there is no way to supply a password or passphrase so the target
8447 must be set up not to require one.
8448
8449 The optional arguments are the same as those of "rsync".
8450
8451 Globbing does not happen on the "src" parameter. In programs which use
8452 the API directly you have to expand wildcards yourself (see "glob-
8453 expand"). In guestfish you can use the "glob" command (see "glob"),
8454 for example:
8455
8456 ><fs> glob rsync-out /* rsync://remote/
8457
8458 This command has one or more optional arguments. See "OPTIONAL
8459 ARGUMENTS".
8460
8461 This command depends on the feature "rsync". See also "feature-
8462 available".
8463
8464 scrub-device
8465 scrub-device device
8466
8467 This command writes patterns over "device" to make data retrieval more
8468 difficult.
8469
8470 It is an interface to the scrub(1) program. See that manual page for
8471 more details.
8472
8473 This command depends on the feature "scrub". See also "feature-
8474 available".
8475
8476 scrub-file
8477 scrub-file file
8478
8479 This command writes patterns over a file to make data retrieval more
8480 difficult.
8481
8482 The file is removed after scrubbing.
8483
8484 It is an interface to the scrub(1) program. See that manual page for
8485 more details.
8486
8487 This command depends on the feature "scrub". See also "feature-
8488 available".
8489
8490 scrub-freespace
8491 scrub-freespace dir
8492
8493 This command creates the directory "dir" and then fills it with files
8494 until the filesystem is full, and scrubs the files as for "scrub-file",
8495 and deletes them. The intention is to scrub any free space on the
8496 partition containing "dir".
8497
8498 It is an interface to the scrub(1) program. See that manual page for
8499 more details.
8500
8501 This command depends on the feature "scrub". See also "feature-
8502 available".
8503
8504 selinux-relabel
8505 selinux-relabel specfile path [force:true|false]
8506
8507 SELinux relabel parts of the filesystem.
8508
8509 The "specfile" parameter controls the policy spec file used. You have
8510 to parse "/etc/selinux/config" to find the correct SELinux policy and
8511 then pass the spec file, usually: "/etc/selinux/" + selinuxtype +
8512 "/contexts/files/file_contexts".
8513
8514 The required "path" parameter is the top level directory where
8515 relabelling starts. Normally you should pass "path" as "/" to relabel
8516 the whole guest filesystem.
8517
8518 The optional "force" boolean controls whether the context is reset for
8519 customizable files, and also whether the user, role and range parts of
8520 the file context is changed.
8521
8522 This command has one or more optional arguments. See "OPTIONAL
8523 ARGUMENTS".
8524
8525 This command depends on the feature "selinuxrelabel". See also
8526 "feature-available".
8527
8528 set-append
8529 append
8530 set-append append
8531
8532 This function is used to add additional options to the libguestfs
8533 appliance kernel command line.
8534
8535 The default is "NULL" unless overridden by setting "LIBGUESTFS_APPEND"
8536 environment variable.
8537
8538 Setting "append" to "NULL" means no additional options are passed
8539 (libguestfs always adds a few of its own).
8540
8541 set-attach-method
8542 attach-method
8543 set-attach-method backend
8544
8545 Set the method that libguestfs uses to connect to the backend guestfsd
8546 daemon.
8547
8548 See "BACKEND" in guestfs(3).
8549
8550 This function is deprecated. In new code, use the "set-backend" call
8551 instead.
8552
8553 Deprecated functions will not be removed from the API, but the fact
8554 that they are deprecated indicates that there are problems with correct
8555 use of these functions.
8556
8557 set-autosync
8558 autosync
8559 set-autosync true|false
8560
8561 If "autosync" is true, this enables autosync. Libguestfs will make a
8562 best effort attempt to make filesystems consistent and synchronized
8563 when the handle is closed (also if the program exits without closing
8564 handles).
8565
8566 This is enabled by default (since libguestfs 1.5.24, previously it was
8567 disabled by default).
8568
8569 set-backend
8570 backend
8571 set-backend backend
8572
8573 Set the method that libguestfs uses to connect to the backend guestfsd
8574 daemon.
8575
8576 This handle property was previously called the "attach method".
8577
8578 See "BACKEND" in guestfs(3).
8579
8580 set-backend-setting
8581 set-backend-setting name val
8582
8583 Append "name=value" to the backend settings string list. However if a
8584 string already exists matching "name" or beginning with "name=", then
8585 that setting is replaced.
8586
8587 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
8588
8589 set-backend-settings
8590 set-backend-settings 'settings ...'
8591
8592 Set a list of zero or more settings which are passed through to the
8593 current backend. Each setting is a string which is interpreted in a
8594 backend-specific way, or ignored if not understood by the backend.
8595
8596 The default value is an empty list, unless the environment variable
8597 "LIBGUESTFS_BACKEND_SETTINGS" was set when the handle was created.
8598 This environment variable contains a colon-separated list of settings.
8599
8600 This call replaces all backend settings. If you want to replace a
8601 single backend setting, see "set-backend-setting". If you want to
8602 clear a single backend setting, see "clear-backend-setting".
8603
8604 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
8605
8606 set-cachedir
8607 cachedir
8608 set-cachedir cachedir
8609
8610 Set the directory used by the handle to store the appliance cache, when
8611 using a supermin appliance. The appliance is cached and shared between
8612 all handles which have the same effective user ID.
8613
8614 The environment variables "LIBGUESTFS_CACHEDIR" and "TMPDIR" control
8615 the default value: If "LIBGUESTFS_CACHEDIR" is set, then that is the
8616 default. Else if "TMPDIR" is set, then that is the default. Else
8617 /var/tmp is the default.
8618
8619 set-direct
8620 direct
8621 set-direct true|false
8622
8623 If the direct appliance mode flag is enabled, then stdin and stdout are
8624 passed directly through to the appliance once it is launched.
8625
8626 One consequence of this is that log messages aren't caught by the
8627 library and handled by "set-log-message-callback", but go straight to
8628 stdout.
8629
8630 You probably don't want to use this unless you know what you are doing.
8631
8632 The default is disabled.
8633
8634 This function is deprecated. In new code, use the "internal-get-
8635 console-socket" call instead.
8636
8637 Deprecated functions will not be removed from the API, but the fact
8638 that they are deprecated indicates that there are problems with correct
8639 use of these functions.
8640
8641 set-e2attrs
8642 set-e2attrs file attrs [clear:true|false]
8643
8644 This sets or clears the file attributes "attrs" associated with the
8645 inode file.
8646
8647 "attrs" is a string of characters representing file attributes. See
8648 "get-e2attrs" for a list of possible attributes. Not all attributes
8649 can be changed.
8650
8651 If optional boolean "clear" is not present or false, then the "attrs"
8652 listed are set in the inode.
8653
8654 If "clear" is true, then the "attrs" listed are cleared in the inode.
8655
8656 In both cases, other attributes not present in the "attrs" string are
8657 left unchanged.
8658
8659 These attributes are only present when the file is located on an
8660 ext2/3/4 filesystem. Using this call on other filesystem types will
8661 result in an error.
8662
8663 This command has one or more optional arguments. See "OPTIONAL
8664 ARGUMENTS".
8665
8666 set-e2generation
8667 set-e2generation file generation
8668
8669 This sets the ext2 file generation of a file.
8670
8671 See "get-e2generation".
8672
8673 set-e2label
8674 set-e2label device label
8675
8676 This sets the ext2/3/4 filesystem label of the filesystem on "device"
8677 to "label". Filesystem labels are limited to 16 characters.
8678
8679 You can use either "tune2fs-l" or "get-e2label" to return the existing
8680 label on a filesystem.
8681
8682 This function is deprecated. In new code, use the "set-label" call
8683 instead.
8684
8685 Deprecated functions will not be removed from the API, but the fact
8686 that they are deprecated indicates that there are problems with correct
8687 use of these functions.
8688
8689 set-e2uuid
8690 set-e2uuid device uuid
8691
8692 This sets the ext2/3/4 filesystem UUID of the filesystem on "device" to
8693 "uuid". The format of the UUID and alternatives such as "clear",
8694 "random" and "time" are described in the tune2fs(8) manpage.
8695
8696 You can use "vfs-uuid" to return the existing UUID of a filesystem.
8697
8698 This function is deprecated. In new code, use the "set-uuid" call
8699 instead.
8700
8701 Deprecated functions will not be removed from the API, but the fact
8702 that they are deprecated indicates that there are problems with correct
8703 use of these functions.
8704
8705 set-hv
8706 hv
8707 set-hv hv
8708
8709 Set the hypervisor binary that we will use. The hypervisor depends on
8710 the backend, but is usually the location of the qemu/KVM hypervisor.
8711
8712 The default is chosen when the library was compiled by the configure
8713 script.
8714
8715 You can also override this by setting the "LIBGUESTFS_HV" environment
8716 variable.
8717
8718 Note that you should call this function as early as possible after
8719 creating the handle. This is because some pre-launch operations depend
8720 on testing qemu features (by running "qemu -help"). If the qemu binary
8721 changes, we don't retest features, and so you might see inconsistent
8722 results. Using the environment variable "LIBGUESTFS_HV" is safest of
8723 all since that picks the qemu binary at the same time as the handle is
8724 created.
8725
8726 set-identifier
8727 identifier
8728 set-identifier identifier
8729
8730 This is an informative string which the caller may optionally set in
8731 the handle. It is printed in various places, allowing the current
8732 handle to be identified in debugging output.
8733
8734 One important place is when tracing is enabled. If the identifier
8735 string is not an empty string, then trace messages change from this:
8736
8737 libguestfs: trace: get_tmpdir
8738 libguestfs: trace: get_tmpdir = "/tmp"
8739
8740 to this:
8741
8742 libguestfs: trace: ID: get_tmpdir
8743 libguestfs: trace: ID: get_tmpdir = "/tmp"
8744
8745 where "ID" is the identifier string set by this call.
8746
8747 The identifier must only contain alphanumeric ASCII characters,
8748 underscore and minus sign. The default is the empty string.
8749
8750 See also "set-program", "set-trace", "get-identifier".
8751
8752 set-label
8753 set-label mountable label
8754
8755 Set the filesystem label on "mountable" to "label".
8756
8757 Only some filesystem types support labels, and libguestfs supports
8758 setting labels on only a subset of these.
8759
8760 ext2, ext3, ext4
8761 Labels are limited to 16 bytes.
8762
8763 NTFS
8764 Labels are limited to 128 unicode characters.
8765
8766 XFS The label is limited to 12 bytes. The filesystem must not be
8767 mounted when trying to set the label.
8768
8769 btrfs
8770 The label is limited to 255 bytes and some characters are not
8771 allowed. Setting the label on a btrfs subvolume will set the label
8772 on its parent filesystem. The filesystem must not be mounted when
8773 trying to set the label.
8774
8775 fat The label is limited to 11 bytes.
8776
8777 swap
8778 The label is limited to 16 bytes.
8779
8780 If there is no support for changing the label for the type of the
8781 specified filesystem, set_label will fail and set errno as ENOTSUP.
8782
8783 To read the label on a filesystem, call "vfs-label".
8784
8785 set-libvirt-requested-credential
8786 set-libvirt-requested-credential index cred
8787
8788 After requesting the "index"'th credential from the user, call this
8789 function to pass the answer back to libvirt.
8790
8791 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
8792 example code.
8793
8794 set-libvirt-supported-credentials
8795 set-libvirt-supported-credentials 'creds ...'
8796
8797 Call this function before setting an event handler for
8798 "GUESTFS_EVENT_LIBVIRT_AUTH", to supply the list of credential types
8799 that the program knows how to process.
8800
8801 The "creds" list must be a non-empty list of strings. Possible strings
8802 are:
8803
8804 "username"
8805 "authname"
8806 "language"
8807 "cnonce"
8808 "passphrase"
8809 "echoprompt"
8810 "noechoprompt"
8811 "realm"
8812 "external"
8813
8814 See libvirt documentation for the meaning of these credential types.
8815
8816 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
8817 example code.
8818
8819 set-memsize
8820 memsize
8821 set-memsize memsize
8822
8823 This sets the memory size in megabytes allocated to the hypervisor.
8824 This only has any effect if called before "launch".
8825
8826 You can also change this by setting the environment variable
8827 "LIBGUESTFS_MEMSIZE" before the handle is created.
8828
8829 For more information on the architecture of libguestfs, see guestfs(3).
8830
8831 set-network
8832 network
8833 set-network true|false
8834
8835 If "network" is true, then the network is enabled in the libguestfs
8836 appliance. The default is false.
8837
8838 This affects whether commands are able to access the network (see
8839 "RUNNING COMMANDS" in guestfs(3)).
8840
8841 You must call this before calling "launch", otherwise it has no effect.
8842
8843 set-path
8844 path
8845 set-path searchpath
8846
8847 Set the path that libguestfs searches for kernel and initrd.img.
8848
8849 The default is "$libdir/guestfs" unless overridden by setting
8850 "LIBGUESTFS_PATH" environment variable.
8851
8852 Setting "path" to "NULL" restores the default path.
8853
8854 set-pgroup
8855 pgroup
8856 set-pgroup true|false
8857
8858 If "pgroup" is true, child processes are placed into their own process
8859 group.
8860
8861 The practical upshot of this is that signals like "SIGINT" (from users
8862 pressing "^C") won't be received by the child process.
8863
8864 The default for this flag is false, because usually you want "^C" to
8865 kill the subprocess. Guestfish sets this flag to true when used
8866 interactively, so that "^C" can cancel long-running commands gracefully
8867 (see "user-cancel").
8868
8869 set-program
8870 program
8871 set-program program
8872
8873 Set the program name. This is an informative string which the main
8874 program may optionally set in the handle.
8875
8876 When the handle is created, the program name in the handle is set to
8877 the basename from "argv[0]". The program name can never be "NULL".
8878
8879 set-qemu
8880 qemu
8881 set-qemu hv
8882
8883 Set the hypervisor binary (usually qemu) that we will use.
8884
8885 The default is chosen when the library was compiled by the configure
8886 script.
8887
8888 You can also override this by setting the "LIBGUESTFS_HV" environment
8889 variable.
8890
8891 Setting "hv" to "NULL" restores the default qemu binary.
8892
8893 Note that you should call this function as early as possible after
8894 creating the handle. This is because some pre-launch operations depend
8895 on testing qemu features (by running "qemu -help"). If the qemu binary
8896 changes, we don't retest features, and so you might see inconsistent
8897 results. Using the environment variable "LIBGUESTFS_HV" is safest of
8898 all since that picks the qemu binary at the same time as the handle is
8899 created.
8900
8901 This function is deprecated. In new code, use the "set-hv" call
8902 instead.
8903
8904 Deprecated functions will not be removed from the API, but the fact
8905 that they are deprecated indicates that there are problems with correct
8906 use of these functions.
8907
8908 set-recovery-proc
8909 recovery-proc
8910 set-recovery-proc true|false
8911
8912 If this is called with the parameter "false" then "launch" does not
8913 create a recovery process. The purpose of the recovery process is to
8914 stop runaway hypervisor processes in the case where the main program
8915 aborts abruptly.
8916
8917 This only has any effect if called before "launch", and the default is
8918 true.
8919
8920 About the only time when you would want to disable this is if the main
8921 process will fork itself into the background ("daemonize" itself). In
8922 this case the recovery process thinks that the main program has
8923 disappeared and so kills the hypervisor, which is not very helpful.
8924
8925 set-selinux
8926 selinux
8927 set-selinux true|false
8928
8929 This sets the selinux flag that is passed to the appliance at boot
8930 time. The default is "selinux=0" (disabled).
8931
8932 Note that if SELinux is enabled, it is always in Permissive mode
8933 ("enforcing=0").
8934
8935 For more information on the architecture of libguestfs, see guestfs(3).
8936
8937 This function is deprecated. In new code, use the "selinux-relabel"
8938 call instead.
8939
8940 Deprecated functions will not be removed from the API, but the fact
8941 that they are deprecated indicates that there are problems with correct
8942 use of these functions.
8943
8944 set-smp
8945 smp
8946 set-smp smp
8947
8948 Change the number of virtual CPUs assigned to the appliance. The
8949 default is 1. Increasing this may improve performance, though often it
8950 has no effect.
8951
8952 This function must be called before "launch".
8953
8954 set-tmpdir
8955 tmpdir
8956 set-tmpdir tmpdir
8957
8958 Set the directory used by the handle to store temporary files.
8959
8960 The environment variables "LIBGUESTFS_TMPDIR" and "TMPDIR" control the
8961 default value: If "LIBGUESTFS_TMPDIR" is set, then that is the default.
8962 Else if "TMPDIR" is set, then that is the default. Else /tmp is the
8963 default.
8964
8965 set-trace
8966 trace
8967 set-trace true|false
8968
8969 If the command trace flag is set to 1, then libguestfs calls,
8970 parameters and return values are traced.
8971
8972 If you want to trace C API calls into libguestfs (and other libraries)
8973 then possibly a better way is to use the external ltrace(1) command.
8974
8975 Command traces are disabled unless the environment variable
8976 "LIBGUESTFS_TRACE" is defined and set to 1.
8977
8978 Trace messages are normally sent to "stderr", unless you register a
8979 callback to send them somewhere else (see "set-event-callback").
8980
8981 set-uuid
8982 set-uuid device uuid
8983
8984 Set the filesystem UUID on "device" to "uuid". If this fails and the
8985 errno is ENOTSUP, means that there is no support for changing the UUID
8986 for the type of the specified filesystem.
8987
8988 Only some filesystem types support setting UUIDs.
8989
8990 To read the UUID on a filesystem, call "vfs-uuid".
8991
8992 set-uuid-random
8993 set-uuid-random device
8994
8995 Set the filesystem UUID on "device" to a random UUID. If this fails
8996 and the errno is ENOTSUP, means that there is no support for changing
8997 the UUID for the type of the specified filesystem.
8998
8999 Only some filesystem types support setting UUIDs.
9000
9001 To read the UUID on a filesystem, call "vfs-uuid".
9002
9003 set-verbose
9004 verbose
9005 set-verbose true|false
9006
9007 If "verbose" is true, this turns on verbose messages.
9008
9009 Verbose messages are disabled unless the environment variable
9010 "LIBGUESTFS_DEBUG" is defined and set to 1.
9011
9012 Verbose messages are normally sent to "stderr", unless you register a
9013 callback to send them somewhere else (see "set-event-callback").
9014
9015 setcon
9016 setcon context
9017
9018 This sets the SELinux security context of the daemon to the string
9019 "context".
9020
9021 See the documentation about SELINUX in guestfs(3).
9022
9023 This function is deprecated. In new code, use the "selinux-relabel"
9024 call instead.
9025
9026 Deprecated functions will not be removed from the API, but the fact
9027 that they are deprecated indicates that there are problems with correct
9028 use of these functions.
9029
9030 This command depends on the feature "selinux". See also "feature-
9031 available".
9032
9033 setxattr
9034 setxattr xattr val vallen path
9035
9036 This call sets the extended attribute named "xattr" of the file "path"
9037 to the value "val" (of length "vallen"). The value is arbitrary 8 bit
9038 data.
9039
9040 See also: "lsetxattr", attr(5).
9041
9042 This command depends on the feature "linuxxattrs". See also "feature-
9043 available".
9044
9045 sfdisk
9046 sfdisk device cyls heads sectors 'lines ...'
9047
9048 This is a direct interface to the sfdisk(8) program for creating
9049 partitions on block devices.
9050
9051 "device" should be a block device, for example /dev/sda.
9052
9053 "cyls", "heads" and "sectors" are the number of cylinders, heads and
9054 sectors on the device, which are passed directly to sfdisk(8) as the
9055 -C, -H and -S parameters. If you pass 0 for any of these, then the
9056 corresponding parameter is omitted. Usually for ‘large’ disks, you can
9057 just pass 0 for these, but for small (floppy-sized) disks, sfdisk(8)
9058 (or rather, the kernel) cannot work out the right geometry and you will
9059 need to tell it.
9060
9061 "lines" is a list of lines that we feed to sfdisk(8). For more
9062 information refer to the sfdisk(8) manpage.
9063
9064 To create a single partition occupying the whole disk, you would pass
9065 "lines" as a single element list, when the single element being the
9066 string "," (comma).
9067
9068 See also: "sfdisk-l", "sfdisk-N", "part-init"
9069
9070 This function is deprecated. In new code, use the "part-add" call
9071 instead.
9072
9073 Deprecated functions will not be removed from the API, but the fact
9074 that they are deprecated indicates that there are problems with correct
9075 use of these functions.
9076
9077 sfdiskM
9078 sfdiskM device 'lines ...'
9079
9080 This is a simplified interface to the "sfdisk" command, where partition
9081 sizes are specified in megabytes only (rounded to the nearest cylinder)
9082 and you don't need to specify the cyls, heads and sectors parameters
9083 which were rarely if ever used anyway.
9084
9085 See also: "sfdisk", the sfdisk(8) manpage and "part-disk"
9086
9087 This function is deprecated. In new code, use the "part-add" call
9088 instead.
9089
9090 Deprecated functions will not be removed from the API, but the fact
9091 that they are deprecated indicates that there are problems with correct
9092 use of these functions.
9093
9094 sfdisk-N
9095 sfdisk-N device partnum cyls heads sectors line
9096
9097 This runs sfdisk(8) option to modify just the single partition "n"
9098 (note: "n" counts from 1).
9099
9100 For other parameters, see "sfdisk". You should usually pass 0 for the
9101 cyls/heads/sectors parameters.
9102
9103 See also: "part-add"
9104
9105 This function is deprecated. In new code, use the "part-add" call
9106 instead.
9107
9108 Deprecated functions will not be removed from the API, but the fact
9109 that they are deprecated indicates that there are problems with correct
9110 use of these functions.
9111
9112 sfdisk-disk-geometry
9113 sfdisk-disk-geometry device
9114
9115 This displays the disk geometry of "device" read from the partition
9116 table. Especially in the case where the underlying block device has
9117 been resized, this can be different from the kernel’s idea of the
9118 geometry (see "sfdisk-kernel-geometry").
9119
9120 The result is in human-readable format, and not designed to be parsed.
9121
9122 sfdisk-kernel-geometry
9123 sfdisk-kernel-geometry device
9124
9125 This displays the kernel’s idea of the geometry of "device".
9126
9127 The result is in human-readable format, and not designed to be parsed.
9128
9129 sfdisk-l
9130 sfdisk-l device
9131
9132 This displays the partition table on "device", in the human-readable
9133 output of the sfdisk(8) command. It is not intended to be parsed.
9134
9135 See also: "part-list"
9136
9137 This function is deprecated. In new code, use the "part-list" call
9138 instead.
9139
9140 Deprecated functions will not be removed from the API, but the fact
9141 that they are deprecated indicates that there are problems with correct
9142 use of these functions.
9143
9144 sh
9145 sh command
9146
9147 This call runs a command from the guest filesystem via the guest’s
9148 /bin/sh.
9149
9150 This is like "command", but passes the command to:
9151
9152 /bin/sh -c "command"
9153
9154 Depending on the guest’s shell, this usually results in wildcards being
9155 expanded, shell expressions being interpolated and so on.
9156
9157 All the provisos about "command" apply to this call.
9158
9159 sh-lines
9160 sh-lines command
9161
9162 This is the same as "sh", but splits the result into a list of lines.
9163
9164 See also: "command-lines"
9165
9166 shutdown
9167 shutdown
9168
9169 This is the opposite of "launch". It performs an orderly shutdown of
9170 the backend process(es). If the autosync flag is set (which is the
9171 default) then the disk image is synchronized.
9172
9173 If the subprocess exits with an error then this function will return an
9174 error, which should not be ignored (it may indicate that the disk image
9175 could not be written out properly).
9176
9177 It is safe to call this multiple times. Extra calls are ignored.
9178
9179 This call does not close or free up the handle. You still need to call
9180 "close" afterwards.
9181
9182 "close" will call this if you don't do it explicitly, but note that any
9183 errors are ignored in that case.
9184
9185 sleep
9186 sleep secs
9187
9188 Sleep for "secs" seconds.
9189
9190 stat
9191 stat path
9192
9193 Returns file information for the given "path".
9194
9195 This is the same as the stat(2) system call.
9196
9197 This function is deprecated. In new code, use the "statns" call
9198 instead.
9199
9200 Deprecated functions will not be removed from the API, but the fact
9201 that they are deprecated indicates that there are problems with correct
9202 use of these functions.
9203
9204 statns
9205 statns path
9206
9207 Returns file information for the given "path".
9208
9209 This is the same as the stat(2) system call.
9210
9211 statvfs
9212 statvfs path
9213
9214 Returns file system statistics for any mounted file system. "path"
9215 should be a file or directory in the mounted file system (typically it
9216 is the mount point itself, but it doesn't need to be).
9217
9218 This is the same as the statvfs(2) system call.
9219
9220 strings
9221 strings path
9222
9223 This runs the strings(1) command on a file and returns the list of
9224 printable strings found.
9225
9226 The "strings" command has, in the past, had problems with parsing
9227 untrusted files. These are mitigated in the current version of
9228 libguestfs, but see "CVE-2014-8484" in guestfs(3).
9229
9230 Because of the message protocol, there is a transfer limit of somewhere
9231 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
9232
9233 strings-e
9234 strings-e encoding path
9235
9236 This is like the "strings" command, but allows you to specify the
9237 encoding of strings that are looked for in the source file "path".
9238
9239 Allowed encodings are:
9240
9241 s Single 7-bit-byte characters like ASCII and the ASCII-compatible
9242 parts of ISO-8859-X (this is what "strings" uses).
9243
9244 S Single 8-bit-byte characters.
9245
9246 b 16-bit big endian strings such as those encoded in UTF-16BE or
9247 UCS-2BE.
9248
9249 l (lower case letter L)
9250 16-bit little endian such as UTF-16LE and UCS-2LE. This is useful
9251 for examining binaries in Windows guests.
9252
9253 B 32-bit big endian such as UCS-4BE.
9254
9255 L 32-bit little endian such as UCS-4LE.
9256
9257 The returned strings are transcoded to UTF-8.
9258
9259 The "strings" command has, in the past, had problems with parsing
9260 untrusted files. These are mitigated in the current version of
9261 libguestfs, but see "CVE-2014-8484" in guestfs(3).
9262
9263 Because of the message protocol, there is a transfer limit of somewhere
9264 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
9265
9266 swapoff-device
9267 swapoff-device device
9268
9269 This command disables the libguestfs appliance swap device or partition
9270 named "device". See "swapon-device".
9271
9272 swapoff-file
9273 swapoff-file file
9274
9275 This command disables the libguestfs appliance swap on file.
9276
9277 swapoff-label
9278 swapoff-label label
9279
9280 This command disables the libguestfs appliance swap on labeled swap
9281 partition.
9282
9283 swapoff-uuid
9284 swapoff-uuid uuid
9285
9286 This command disables the libguestfs appliance swap partition with the
9287 given UUID.
9288
9289 This command depends on the feature "linuxfsuuid". See also "feature-
9290 available".
9291
9292 swapon-device
9293 swapon-device device
9294
9295 This command enables the libguestfs appliance to use the swap device or
9296 partition named "device". The increased memory is made available for
9297 all commands, for example those run using "command" or "sh".
9298
9299 Note that you should not swap to existing guest swap partitions unless
9300 you know what you are doing. They may contain hibernation information,
9301 or other information that the guest doesn't want you to trash. You
9302 also risk leaking information about the host to the guest this way.
9303 Instead, attach a new host device to the guest and swap on that.
9304
9305 swapon-file
9306 swapon-file file
9307
9308 This command enables swap to a file. See "swapon-device" for other
9309 notes.
9310
9311 swapon-label
9312 swapon-label label
9313
9314 This command enables swap to a labeled swap partition. See "swapon-
9315 device" for other notes.
9316
9317 swapon-uuid
9318 swapon-uuid uuid
9319
9320 This command enables swap to a swap partition with the given UUID. See
9321 "swapon-device" for other notes.
9322
9323 This command depends on the feature "linuxfsuuid". See also "feature-
9324 available".
9325
9326 sync
9327 sync
9328
9329 This syncs the disk, so that any writes are flushed through to the
9330 underlying disk image.
9331
9332 You should always call this if you have modified a disk image, before
9333 closing the handle.
9334
9335 syslinux
9336 syslinux device [directory:..]
9337
9338 Install the SYSLINUX bootloader on "device".
9339
9340 The device parameter must be either a whole disk formatted as a FAT
9341 filesystem, or a partition formatted as a FAT filesystem. In the
9342 latter case, the partition should be marked as "active" ("part-set-
9343 bootable") and a Master Boot Record must be installed (eg. using
9344 "pwrite-device") on the first sector of the whole disk. The SYSLINUX
9345 package comes with some suitable Master Boot Records. See the
9346 syslinux(1) man page for further information.
9347
9348 The optional arguments are:
9349
9350 directory
9351 Install SYSLINUX in the named subdirectory, instead of in the root
9352 directory of the FAT filesystem.
9353
9354 Additional configuration can be supplied to SYSLINUX by placing a file
9355 called syslinux.cfg on the FAT filesystem, either in the root
9356 directory, or under directory if that optional argument is being used.
9357 For further information about the contents of this file, see
9358 syslinux(1).
9359
9360 See also "extlinux".
9361
9362 This command has one or more optional arguments. See "OPTIONAL
9363 ARGUMENTS".
9364
9365 This command depends on the feature "syslinux". See also "feature-
9366 available".
9367
9368 tail
9369 tail path
9370
9371 This command returns up to the last 10 lines of a file as a list of
9372 strings.
9373
9374 Because of the message protocol, there is a transfer limit of somewhere
9375 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
9376
9377 tail-n
9378 tail-n nrlines path
9379
9380 If the parameter "nrlines" is a positive number, this returns the last
9381 "nrlines" lines of the file "path".
9382
9383 If the parameter "nrlines" is a negative number, this returns lines
9384 from the file "path", starting with the "-nrlines"'th line.
9385
9386 If the parameter "nrlines" is zero, this returns an empty list.
9387
9388 Because of the message protocol, there is a transfer limit of somewhere
9389 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
9390
9391 tar-in
9392 tar-in-opts
9393 tar-in (tarfile|-) directory [compress:..] [xattrs:true|false] [selinux:true|false] [acls:true|false]
9394
9395 This command uploads and unpacks local file "tarfile" into directory.
9396
9397 The optional "compress" flag controls compression. If not given, then
9398 the input should be an uncompressed tar file. Otherwise one of the
9399 following strings may be given to select the compression type of the
9400 input file: "compress", "gzip", "bzip2", "xz", "lzop". (Note that not
9401 all builds of libguestfs will support all of these compression types).
9402
9403 The other optional arguments are:
9404
9405 "xattrs"
9406 If set to true, extended attributes are restored from the tar file.
9407
9408 "selinux"
9409 If set to true, SELinux contexts are restored from the tar file.
9410
9411 "acls"
9412 If set to true, POSIX ACLs are restored from the tar file.
9413
9414 Use "-" instead of a filename to read/write from stdin/stdout.
9415
9416 This command has one or more optional arguments. See "OPTIONAL
9417 ARGUMENTS".
9418
9419 tar-out
9420 tar-out-opts
9421 tar-out directory (tarfile|-) [compress:..] [numericowner:true|false] [excludes:..] [xattrs:true|false] [selinux:true|false] [acls:true|false]
9422
9423 This command packs the contents of directory and downloads it to local
9424 file "tarfile".
9425
9426 The optional "compress" flag controls compression. If not given, then
9427 the output will be an uncompressed tar file. Otherwise one of the
9428 following strings may be given to select the compression type of the
9429 output file: "compress", "gzip", "bzip2", "xz", "lzop". (Note that not
9430 all builds of libguestfs will support all of these compression types).
9431
9432 The other optional arguments are:
9433
9434 "excludes"
9435 A list of wildcards. Files are excluded if they match any of the
9436 wildcards.
9437
9438 "numericowner"
9439 If set to true, the output tar file will contain UID/GID numbers
9440 instead of user/group names.
9441
9442 "xattrs"
9443 If set to true, extended attributes are saved in the output tar.
9444
9445 "selinux"
9446 If set to true, SELinux contexts are saved in the output tar.
9447
9448 "acls"
9449 If set to true, POSIX ACLs are saved in the output tar.
9450
9451 Use "-" instead of a filename to read/write from stdin/stdout.
9452
9453 This command has one or more optional arguments. See "OPTIONAL
9454 ARGUMENTS".
9455
9456 tgz-in
9457 tgz-in (tarball|-) directory
9458
9459 This command uploads and unpacks local file "tarball" (a gzip
9460 compressed tar file) into directory.
9461
9462 Use "-" instead of a filename to read/write from stdin/stdout.
9463
9464 This function is deprecated. In new code, use the "tar-in" call
9465 instead.
9466
9467 Deprecated functions will not be removed from the API, but the fact
9468 that they are deprecated indicates that there are problems with correct
9469 use of these functions.
9470
9471 tgz-out
9472 tgz-out directory (tarball|-)
9473
9474 This command packs the contents of directory and downloads it to local
9475 file "tarball".
9476
9477 Use "-" instead of a filename to read/write from stdin/stdout.
9478
9479 This function is deprecated. In new code, use the "tar-out" call
9480 instead.
9481
9482 Deprecated functions will not be removed from the API, but the fact
9483 that they are deprecated indicates that there are problems with correct
9484 use of these functions.
9485
9486 touch
9487 touch path
9488
9489 Touch acts like the touch(1) command. It can be used to update the
9490 timestamps on a file, or, if the file does not exist, to create a new
9491 zero-length file.
9492
9493 This command only works on regular files, and will fail on other file
9494 types such as directories, symbolic links, block special etc.
9495
9496 truncate
9497 truncate path
9498
9499 This command truncates "path" to a zero-length file. The file must
9500 exist already.
9501
9502 truncate-size
9503 truncate-size path size
9504
9505 This command truncates "path" to size "size" bytes. The file must
9506 exist already.
9507
9508 If the current file size is less than "size" then the file is extended
9509 to the required size with zero bytes. This creates a sparse file (ie.
9510 disk blocks are not allocated for the file until you write to it). To
9511 create a non-sparse file of zeroes, use "fallocate64" instead.
9512
9513 tune2fs
9514 tune2fs device [force:true|false] [maxmountcount:N] [mountcount:N] [errorbehavior:..] [group:N] [intervalbetweenchecks:N] [reservedblockspercentage:N] [lastmounteddirectory:..] [reservedblockscount:N] [user:N]
9515
9516 This call allows you to adjust various filesystem parameters of an
9517 ext2/ext3/ext4 filesystem called "device".
9518
9519 The optional parameters are:
9520
9521 "force"
9522 Force tune2fs to complete the operation even in the face of errors.
9523 This is the same as the tune2fs(8) "-f" option.
9524
9525 "maxmountcount"
9526 Set the number of mounts after which the filesystem is checked by
9527 e2fsck(8). If this is 0 then the number of mounts is disregarded.
9528 This is the same as the tune2fs(8) "-c" option.
9529
9530 "mountcount"
9531 Set the number of times the filesystem has been mounted. This is
9532 the same as the tune2fs(8) "-C" option.
9533
9534 "errorbehavior"
9535 Change the behavior of the kernel code when errors are detected.
9536 Possible values currently are: "continue", "remount-ro", "panic".
9537 In practice these options don't really make any difference,
9538 particularly for write errors.
9539
9540 This is the same as the tune2fs(8) "-e" option.
9541
9542 "group"
9543 Set the group which can use reserved filesystem blocks. This is
9544 the same as the tune2fs(8) "-g" option except that it can only be
9545 specified as a number.
9546
9547 "intervalbetweenchecks"
9548 Adjust the maximal time between two filesystem checks (in seconds).
9549 If the option is passed as 0 then time-dependent checking is
9550 disabled.
9551
9552 This is the same as the tune2fs(8) "-i" option.
9553
9554 "reservedblockspercentage"
9555 Set the percentage of the filesystem which may only be allocated by
9556 privileged processes. This is the same as the tune2fs(8) "-m"
9557 option.
9558
9559 "lastmounteddirectory"
9560 Set the last mounted directory. This is the same as the tune2fs(8)
9561 "-M" option.
9562
9563 "reservedblockscount" Set the number of reserved filesystem blocks.
9564 This is the same as the tune2fs(8) "-r" option.
9565 "user"
9566 Set the user who can use the reserved filesystem blocks. This is
9567 the same as the tune2fs(8) "-u" option except that it can only be
9568 specified as a number.
9569
9570 To get the current values of filesystem parameters, see "tune2fs-l".
9571 For precise details of how tune2fs works, see the tune2fs(8) man page.
9572
9573 This command has one or more optional arguments. See "OPTIONAL
9574 ARGUMENTS".
9575
9576 tune2fs-l
9577 tune2fs-l device
9578
9579 This returns the contents of the ext2, ext3 or ext4 filesystem
9580 superblock on "device".
9581
9582 It is the same as running "tune2fs -l device". See tune2fs(8) manpage
9583 for more details. The list of fields returned isn't clearly defined,
9584 and depends on both the version of "tune2fs" that libguestfs was built
9585 against, and the filesystem itself.
9586
9587 txz-in
9588 txz-in (tarball|-) directory
9589
9590 This command uploads and unpacks local file "tarball" (an xz compressed
9591 tar file) into directory.
9592
9593 Use "-" instead of a filename to read/write from stdin/stdout.
9594
9595 This function is deprecated. In new code, use the "tar-in" call
9596 instead.
9597
9598 Deprecated functions will not be removed from the API, but the fact
9599 that they are deprecated indicates that there are problems with correct
9600 use of these functions.
9601
9602 This command depends on the feature "xz". See also "feature-
9603 available".
9604
9605 txz-out
9606 txz-out directory (tarball|-)
9607
9608 This command packs the contents of directory and downloads it to local
9609 file "tarball" (as an xz compressed tar archive).
9610
9611 Use "-" instead of a filename to read/write from stdin/stdout.
9612
9613 This function is deprecated. In new code, use the "tar-out" call
9614 instead.
9615
9616 Deprecated functions will not be removed from the API, but the fact
9617 that they are deprecated indicates that there are problems with correct
9618 use of these functions.
9619
9620 This command depends on the feature "xz". See also "feature-
9621 available".
9622
9623 umask
9624 umask mask
9625
9626 This function sets the mask used for creating new files and device
9627 nodes to "mask & 0777".
9628
9629 Typical umask values would be 022 which creates new files with
9630 permissions like "-rw-r--r--" or "-rwxr-xr-x", and 002 which creates
9631 new files with permissions like "-rw-rw-r--" or "-rwxrwxr-x".
9632
9633 The default umask is 022. This is important because it means that
9634 directories and device nodes will be created with 0644 or 0755 mode
9635 even if you specify 0777.
9636
9637 See also "get-umask", umask(2), "mknod", "mkdir".
9638
9639 This call returns the previous umask.
9640
9641 umount
9642 unmount
9643 umount-opts
9644 umount pathordevice [force:true|false] [lazyunmount:true|false]
9645
9646 This unmounts the given filesystem. The filesystem may be specified
9647 either by its mountpoint (path) or the device which contains the
9648 filesystem.
9649
9650 This command has one or more optional arguments. See "OPTIONAL
9651 ARGUMENTS".
9652
9653 umount-all
9654 unmount-all
9655 umount-all
9656
9657 This unmounts all mounted filesystems.
9658
9659 Some internal mounts are not unmounted by this call.
9660
9661 umount-local
9662 umount-local [retry:true|false]
9663
9664 If libguestfs is exporting the filesystem on a local mountpoint, then
9665 this unmounts it.
9666
9667 See "MOUNT LOCAL" in guestfs(3) for full documentation.
9668
9669 This command has one or more optional arguments. See "OPTIONAL
9670 ARGUMENTS".
9671
9672 upload
9673 upload (filename|-) remotefilename
9674
9675 Upload local file filename to remotefilename on the filesystem.
9676
9677 filename can also be a named pipe.
9678
9679 See also "download".
9680
9681 Use "-" instead of a filename to read/write from stdin/stdout.
9682
9683 upload-offset
9684 upload-offset (filename|-) remotefilename offset
9685
9686 Upload local file filename to remotefilename on the filesystem.
9687
9688 remotefilename is overwritten starting at the byte "offset" specified.
9689 The intention is to overwrite parts of existing files or devices,
9690 although if a non-existent file is specified then it is created with a
9691 "hole" before "offset". The size of the data written is implicit in
9692 the size of the source filename.
9693
9694 Note that there is no limit on the amount of data that can be uploaded
9695 with this call, unlike with "pwrite", and this call always writes the
9696 full amount unless an error occurs.
9697
9698 See also "upload", "pwrite".
9699
9700 Use "-" instead of a filename to read/write from stdin/stdout.
9701
9702 user-cancel
9703 user-cancel
9704
9705 This function cancels the current upload or download operation.
9706
9707 Unlike most other libguestfs calls, this function is signal safe and
9708 thread safe. You can call it from a signal handler or from another
9709 thread, without needing to do any locking.
9710
9711 The transfer that was in progress (if there is one) will stop shortly
9712 afterwards, and will return an error. The errno (see
9713 "guestfs_last_errno") is set to "EINTR", so you can test for this to
9714 find out if the operation was cancelled or failed because of another
9715 error.
9716
9717 No cleanup is performed: for example, if a file was being uploaded then
9718 after cancellation there may be a partially uploaded file. It is the
9719 caller’s responsibility to clean up if necessary.
9720
9721 There are two common places that you might call "user-cancel":
9722
9723 In an interactive text-based program, you might call it from a "SIGINT"
9724 signal handler so that pressing "^C" cancels the current operation.
9725 (You also need to call "set-pgroup" so that child processes don't
9726 receive the "^C" signal).
9727
9728 In a graphical program, when the main thread is displaying a progress
9729 bar with a cancel button, wire up the cancel button to call this
9730 function.
9731
9732 utimens
9733 utimens path atsecs atnsecs mtsecs mtnsecs
9734
9735 This command sets the timestamps of a file with nanosecond precision.
9736
9737 "atsecs", "atnsecs" are the last access time (atime) in secs and
9738 nanoseconds from the epoch.
9739
9740 "mtsecs", "mtnsecs" are the last modification time (mtime) in secs and
9741 nanoseconds from the epoch.
9742
9743 If the *nsecs field contains the special value "-1" then the
9744 corresponding timestamp is set to the current time. (The *secs field
9745 is ignored in this case).
9746
9747 If the *nsecs field contains the special value "-2" then the
9748 corresponding timestamp is left unchanged. (The *secs field is ignored
9749 in this case).
9750
9751 utsname
9752 utsname
9753
9754 This returns the kernel version of the appliance, where this is
9755 available. This information is only useful for debugging. Nothing in
9756 the returned structure is defined by the API.
9757
9758 version
9759 version
9760
9761 Return the libguestfs version number that the program is linked
9762 against.
9763
9764 Note that because of dynamic linking this is not necessarily the
9765 version of libguestfs that you compiled against. You can compile the
9766 program, and then at runtime dynamically link against a completely
9767 different libguestfs.so library.
9768
9769 This call was added in version 1.0.58. In previous versions of
9770 libguestfs there was no way to get the version number. From C code you
9771 can use dynamic linker functions to find out if this symbol exists (if
9772 it doesn't, then it’s an earlier version).
9773
9774 The call returns a structure with four elements. The first three
9775 ("major", "minor" and "release") are numbers and correspond to the
9776 usual version triplet. The fourth element ("extra") is a string and is
9777 normally empty, but may be used for distro-specific information.
9778
9779 To construct the original version string:
9780 "$major.$minor.$release$extra"
9781
9782 See also: "LIBGUESTFS VERSION NUMBERS" in guestfs(3).
9783
9784 Note: Don't use this call to test for availability of features. In
9785 enterprise distributions we backport features from later versions into
9786 earlier versions, making this an unreliable way to test for features.
9787 Use "available" or "feature-available" instead.
9788
9789 vfs-label
9790 vfs-label mountable
9791
9792 This returns the label of the filesystem on "mountable".
9793
9794 If the filesystem is unlabeled, this returns the empty string.
9795
9796 To find a filesystem from the label, use "findfs-label".
9797
9798 vfs-minimum-size
9799 vfs-minimum-size mountable
9800
9801 Get the minimum size of filesystem in bytes. This is the minimum
9802 possible size for filesystem shrinking.
9803
9804 If getting minimum size of specified filesystem is not supported, this
9805 will fail and set errno as ENOTSUP.
9806
9807 See also ntfsresize(8), resize2fs(8), btrfs(8), xfs_info(8).
9808
9809 vfs-type
9810 vfs-type mountable
9811
9812 This command gets the filesystem type corresponding to the filesystem
9813 on "mountable".
9814
9815 For most filesystems, the result is the name of the Linux VFS module
9816 which would be used to mount this filesystem if you mounted it without
9817 specifying the filesystem type. For example a string such as "ext3" or
9818 "ntfs".
9819
9820 vfs-uuid
9821 get-uuid
9822 vfs-uuid mountable
9823
9824 This returns the filesystem UUID of the filesystem on "mountable".
9825
9826 If the filesystem does not have a UUID, this returns the empty string.
9827
9828 To find a filesystem from the UUID, use "findfs-uuid".
9829
9830 vg-activate
9831 vg-activate true|false 'volgroups ...'
9832
9833 This command activates or (if "activate" is false) deactivates all
9834 logical volumes in the listed volume groups "volgroups".
9835
9836 This command is the same as running "vgchange -a y|n volgroups..."
9837
9838 Note that if "volgroups" is an empty list then all volume groups are
9839 activated or deactivated.
9840
9841 This command depends on the feature "lvm2". See also "feature-
9842 available".
9843
9844 vg-activate-all
9845 vg-activate-all true|false
9846
9847 This command activates or (if "activate" is false) deactivates all
9848 logical volumes in all volume groups.
9849
9850 This command is the same as running "vgchange -a y|n"
9851
9852 This command depends on the feature "lvm2". See also "feature-
9853 available".
9854
9855 vgchange-uuid
9856 vgchange-uuid vg
9857
9858 Generate a new random UUID for the volume group "vg".
9859
9860 This command depends on the feature "lvm2". See also "feature-
9861 available".
9862
9863 vgchange-uuid-all
9864 vgchange-uuid-all
9865
9866 Generate new random UUIDs for all volume groups.
9867
9868 This command depends on the feature "lvm2". See also "feature-
9869 available".
9870
9871 vgcreate
9872 vgcreate volgroup 'physvols ...'
9873
9874 This creates an LVM volume group called "volgroup" from the non-empty
9875 list of physical volumes "physvols".
9876
9877 This command depends on the feature "lvm2". See also "feature-
9878 available".
9879
9880 vglvuuids
9881 vglvuuids vgname
9882
9883 Given a VG called "vgname", this returns the UUIDs of all the logical
9884 volumes created in this volume group.
9885
9886 You can use this along with "lvs" and "lvuuid" calls to associate
9887 logical volumes and volume groups.
9888
9889 See also "vgpvuuids".
9890
9891 vgmeta
9892 vgmeta vgname
9893
9894 "vgname" is an LVM volume group. This command examines the volume
9895 group and returns its metadata.
9896
9897 Note that the metadata is an internal structure used by LVM, subject to
9898 change at any time, and is provided for information only.
9899
9900 This command depends on the feature "lvm2". See also "feature-
9901 available".
9902
9903 vgpvuuids
9904 vgpvuuids vgname
9905
9906 Given a VG called "vgname", this returns the UUIDs of all the physical
9907 volumes that this volume group resides on.
9908
9909 You can use this along with "pvs" and "pvuuid" calls to associate
9910 physical volumes and volume groups.
9911
9912 See also "vglvuuids".
9913
9914 vgremove
9915 vgremove vgname
9916
9917 Remove an LVM volume group "vgname", (for example "VG").
9918
9919 This also forcibly removes all logical volumes in the volume group (if
9920 any).
9921
9922 This command depends on the feature "lvm2". See also "feature-
9923 available".
9924
9925 vgrename
9926 vgrename volgroup newvolgroup
9927
9928 Rename a volume group "volgroup" with the new name "newvolgroup".
9929
9930 vgs
9931 vgs
9932
9933 List all the volumes groups detected. This is the equivalent of the
9934 vgs(8) command.
9935
9936 This returns a list of just the volume group names that were detected
9937 (eg. "VolGroup00").
9938
9939 See also "vgs-full".
9940
9941 This command depends on the feature "lvm2". See also "feature-
9942 available".
9943
9944 vgs-full
9945 vgs-full
9946
9947 List all the volumes groups detected. This is the equivalent of the
9948 vgs(8) command. The "full" version includes all fields.
9949
9950 This command depends on the feature "lvm2". See also "feature-
9951 available".
9952
9953 vgscan
9954 vgscan
9955
9956 This rescans all block devices and rebuilds the list of LVM physical
9957 volumes, volume groups and logical volumes.
9958
9959 This function is deprecated. In new code, use the "lvm-scan" call
9960 instead.
9961
9962 Deprecated functions will not be removed from the API, but the fact
9963 that they are deprecated indicates that there are problems with correct
9964 use of these functions.
9965
9966 vguuid
9967 vguuid vgname
9968
9969 This command returns the UUID of the LVM VG named "vgname".
9970
9971 wc-c
9972 wc-c path
9973
9974 This command counts the characters in a file, using the "wc -c"
9975 external command.
9976
9977 wc-l
9978 wc-l path
9979
9980 This command counts the lines in a file, using the "wc -l" external
9981 command.
9982
9983 wc-w
9984 wc-w path
9985
9986 This command counts the words in a file, using the "wc -w" external
9987 command.
9988
9989 wipefs
9990 wipefs device
9991
9992 This command erases filesystem or RAID signatures from the specified
9993 "device" to make the filesystem invisible to libblkid.
9994
9995 This does not erase the filesystem itself nor any other data from the
9996 "device".
9997
9998 Compare with "zero" which zeroes the first few blocks of a device.
9999
10000 This command depends on the feature "wipefs". See also "feature-
10001 available".
10002
10003 write
10004 write path content
10005
10006 This call creates a file called "path". The content of the file is the
10007 string "content" (which can contain any 8 bit data).
10008
10009 See also "write-append".
10010
10011 write-append
10012 write-append path content
10013
10014 This call appends "content" to the end of file "path". If "path" does
10015 not exist, then a new file is created.
10016
10017 See also "write".
10018
10019 write-file
10020 write-file path content size
10021
10022 This call creates a file called "path". The contents of the file is
10023 the string "content" (which can contain any 8 bit data), with length
10024 "size".
10025
10026 As a special case, if "size" is 0 then the length is calculated using
10027 "strlen" (so in this case the content cannot contain embedded ASCII
10028 NULs).
10029
10030 NB. Owing to a bug, writing content containing ASCII NUL characters
10031 does not work, even if the length is specified.
10032
10033 Because of the message protocol, there is a transfer limit of somewhere
10034 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10035
10036 This function is deprecated. In new code, use the "write" call
10037 instead.
10038
10039 Deprecated functions will not be removed from the API, but the fact
10040 that they are deprecated indicates that there are problems with correct
10041 use of these functions.
10042
10043 xfs-admin
10044 xfs-admin device [extunwritten:true|false] [imgfile:true|false] [v2log:true|false] [projid32bit:true|false] [lazycounter:true|false] [label:..] [uuid:..]
10045
10046 Change the parameters of the XFS filesystem on "device".
10047
10048 Devices that are mounted cannot be modified. Administrators must
10049 unmount filesystems before this call can modify parameters.
10050
10051 Some of the parameters of a mounted filesystem can be examined and
10052 modified using the "xfs-info" and "xfs-growfs" calls.
10053
10054 Beginning with XFS version 5, it is no longer possible to modify the
10055 lazy-counters setting (ie. "lazycounter" parameter has no effect).
10056
10057 This command has one or more optional arguments. See "OPTIONAL
10058 ARGUMENTS".
10059
10060 This command depends on the feature "xfs". See also "feature-
10061 available".
10062
10063 xfs-growfs
10064 xfs-growfs path [datasec:true|false] [logsec:true|false] [rtsec:true|false] [datasize:N] [logsize:N] [rtsize:N] [rtextsize:N] [maxpct:N]
10065
10066 Grow the XFS filesystem mounted at "path".
10067
10068 The returned struct contains geometry information. Missing fields are
10069 returned as "-1" (for numeric fields) or empty string.
10070
10071 This command has one or more optional arguments. See "OPTIONAL
10072 ARGUMENTS".
10073
10074 This command depends on the feature "xfs". See also "feature-
10075 available".
10076
10077 xfs-info
10078 xfs-info pathordevice
10079
10080 "pathordevice" is a mounted XFS filesystem or a device containing an
10081 XFS filesystem. This command returns the geometry of the filesystem.
10082
10083 The returned struct contains geometry information. Missing fields are
10084 returned as "-1" (for numeric fields) or empty string.
10085
10086 This command depends on the feature "xfs". See also "feature-
10087 available".
10088
10089 xfs-repair
10090 xfs-repair device [forcelogzero:true|false] [nomodify:true|false] [noprefetch:true|false] [forcegeometry:true|false] [maxmem:N] [ihashsize:N] [bhashsize:N] [agstride:N] [logdev:..] [rtdev:..]
10091
10092 Repair corrupt or damaged XFS filesystem on "device".
10093
10094 The filesystem is specified using the "device" argument which should be
10095 the device name of the disk partition or volume containing the
10096 filesystem. If given the name of a block device, "xfs_repair" will
10097 attempt to find the raw device associated with the specified block
10098 device and will use the raw device instead.
10099
10100 Regardless, the filesystem to be repaired must be unmounted, otherwise,
10101 the resulting filesystem may be inconsistent or corrupt.
10102
10103 The returned status indicates whether filesystem corruption was
10104 detected (returns 1) or was not detected (returns 0).
10105
10106 This command has one or more optional arguments. See "OPTIONAL
10107 ARGUMENTS".
10108
10109 This command depends on the feature "xfs". See also "feature-
10110 available".
10111
10112 yara-destroy
10113 yara-destroy
10114
10115 Destroy previously loaded Yara rules in order to free libguestfs
10116 resources.
10117
10118 This command depends on the feature "libyara". See also "feature-
10119 available".
10120
10121 yara-load
10122 yara-load (filename|-)
10123
10124 Upload a set of Yara rules from local file filename.
10125
10126 Yara rules allow to categorize files based on textual or binary
10127 patterns within their content. See "yara-scan" to see how to scan
10128 files with the loaded rules.
10129
10130 Rules can be in binary format, as when compiled with yarac command, or
10131 in source code format. In the latter case, the rules will be first
10132 compiled and then loaded.
10133
10134 Rules in source code format cannot include external files. In such
10135 cases, it is recommended to compile them first.
10136
10137 Previously loaded rules will be destroyed.
10138
10139 Use "-" instead of a filename to read/write from stdin/stdout.
10140
10141 This command depends on the feature "libyara". See also "feature-
10142 available".
10143
10144 yara-scan
10145 yara-scan path
10146
10147 Scan a file with the previously loaded Yara rules.
10148
10149 For each matching rule, a "yara_detection" structure is returned.
10150
10151 The "yara_detection" structure contains the following fields.
10152
10153 "yara_name"
10154 Path of the file matching a Yara rule.
10155
10156 "yara_rule"
10157 Identifier of the Yara rule which matched against the given file.
10158
10159 This command depends on the feature "libyara". See also "feature-
10160 available".
10161
10162 zegrep
10163 zegrep regex path
10164
10165 This calls the external "zegrep" program and returns the matching
10166 lines.
10167
10168 Because of the message protocol, there is a transfer limit of somewhere
10169 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10170
10171 This function is deprecated. In new code, use the "grep" call instead.
10172
10173 Deprecated functions will not be removed from the API, but the fact
10174 that they are deprecated indicates that there are problems with correct
10175 use of these functions.
10176
10177 zegrepi
10178 zegrepi regex path
10179
10180 This calls the external "zegrep -i" program and returns the matching
10181 lines.
10182
10183 Because of the message protocol, there is a transfer limit of somewhere
10184 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10185
10186 This function is deprecated. In new code, use the "grep" call instead.
10187
10188 Deprecated functions will not be removed from the API, but the fact
10189 that they are deprecated indicates that there are problems with correct
10190 use of these functions.
10191
10192 zero
10193 zero device
10194
10195 This command writes zeroes over the first few blocks of "device".
10196
10197 How many blocks are zeroed isn't specified (but it’s not enough to
10198 securely wipe the device). It should be sufficient to remove any
10199 partition tables, filesystem superblocks and so on.
10200
10201 If blocks are already zero, then this command avoids writing zeroes.
10202 This prevents the underlying device from becoming non-sparse or growing
10203 unnecessarily.
10204
10205 See also: "zero-device", "scrub-device", "is-zero-device"
10206
10207 zero-device
10208 zero-device device
10209
10210 This command writes zeroes over the entire "device". Compare with
10211 "zero" which just zeroes the first few blocks of a device.
10212
10213 If blocks are already zero, then this command avoids writing zeroes.
10214 This prevents the underlying device from becoming non-sparse or growing
10215 unnecessarily.
10216
10217 zero-free-space
10218 zero-free-space directory
10219
10220 Zero the free space in the filesystem mounted on directory. The
10221 filesystem must be mounted read-write.
10222
10223 The filesystem contents are not affected, but any free space in the
10224 filesystem is freed.
10225
10226 Free space is not "trimmed". You may want to call "fstrim" either as
10227 an alternative to this, or after calling this, depending on your
10228 requirements.
10229
10230 zerofree
10231 zerofree device
10232
10233 This runs the zerofree program on "device". This program claims to
10234 zero unused inodes and disk blocks on an ext2/3 filesystem, thus making
10235 it possible to compress the filesystem more effectively.
10236
10237 You should not run this program if the filesystem is mounted.
10238
10239 It is possible that using this program can damage the filesystem or
10240 data on the filesystem.
10241
10242 This command depends on the feature "zerofree". See also "feature-
10243 available".
10244
10245 zfgrep
10246 zfgrep pattern path
10247
10248 This calls the external "zfgrep" program and returns the matching
10249 lines.
10250
10251 Because of the message protocol, there is a transfer limit of somewhere
10252 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10253
10254 This function is deprecated. In new code, use the "grep" call instead.
10255
10256 Deprecated functions will not be removed from the API, but the fact
10257 that they are deprecated indicates that there are problems with correct
10258 use of these functions.
10259
10260 zfgrepi
10261 zfgrepi pattern path
10262
10263 This calls the external "zfgrep -i" program and returns the matching
10264 lines.
10265
10266 Because of the message protocol, there is a transfer limit of somewhere
10267 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10268
10269 This function is deprecated. In new code, use the "grep" call instead.
10270
10271 Deprecated functions will not be removed from the API, but the fact
10272 that they are deprecated indicates that there are problems with correct
10273 use of these functions.
10274
10275 zfile
10276 zfile meth path
10277
10278 This command runs file(1) after first decompressing "path" using
10279 "meth".
10280
10281 "meth" must be one of "gzip", "compress" or "bzip2".
10282
10283 Since 1.0.63, use "file" instead which can now process compressed
10284 files.
10285
10286 This function is deprecated. In new code, use the "file" call instead.
10287
10288 Deprecated functions will not be removed from the API, but the fact
10289 that they are deprecated indicates that there are problems with correct
10290 use of these functions.
10291
10292 zgrep
10293 zgrep regex path
10294
10295 This calls the external zgrep(1) program and returns the matching
10296 lines.
10297
10298 Because of the message protocol, there is a transfer limit of somewhere
10299 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10300
10301 This function is deprecated. In new code, use the "grep" call instead.
10302
10303 Deprecated functions will not be removed from the API, but the fact
10304 that they are deprecated indicates that there are problems with correct
10305 use of these functions.
10306
10307 zgrepi
10308 zgrepi regex path
10309
10310 This calls the external "zgrep -i" program and returns the matching
10311 lines.
10312
10313 Because of the message protocol, there is a transfer limit of somewhere
10314 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10315
10316 This function is deprecated. In new code, use the "grep" call instead.
10317
10318 Deprecated functions will not be removed from the API, but the fact
10319 that they are deprecated indicates that there are problems with correct
10320 use of these functions.
10321
10323 guestfish returns 0 if the commands completed without error, or 1 if
10324 there was an error.
10325
10327 EDITOR
10328 The "edit" command uses $EDITOR as the editor. If not set, it uses
10329 "vi".
10330
10331 GUESTFISH_DISPLAY_IMAGE
10332 The "display" command uses $GUESTFISH_DISPLAY_IMAGE to display
10333 images. If not set, it uses display(1).
10334
10335 GUESTFISH_INIT
10336 Printed when guestfish starts. See "PROMPT".
10337
10338 GUESTFISH_OUTPUT
10339 Printed before guestfish output. See "PROMPT".
10340
10341 GUESTFISH_PID
10342 Used with the --remote option to specify the remote guestfish
10343 process to control. See section "REMOTE CONTROL GUESTFISH OVER A
10344 SOCKET".
10345
10346 GUESTFISH_PS1
10347 Set the command prompt. See "PROMPT".
10348
10349 GUESTFISH_RESTORE
10350 Printed before guestfish exits. See "PROMPT".
10351
10352 HEXEDITOR
10353 The "hexedit" command uses $HEXEDITOR as the external hex editor.
10354 If not specified, the external hexedit(1) program is used.
10355
10356 HOME
10357 If compiled with GNU readline support, various files in the home
10358 directory can be used. See "FILES".
10359
10360 LIBGUESTFS_APPEND
10361 Pass additional options to the guest kernel.
10362
10363 LIBGUESTFS_ATTACH_METHOD
10364 This is the old way to set "LIBGUESTFS_BACKEND".
10365
10366 LIBGUESTFS_BACKEND
10367 Choose the default way to create the appliance. See
10368 "guestfs_set_backend" in guestfs(3).
10369
10370 LIBGUESTFS_BACKEND_SETTINGS
10371 A colon-separated list of backend-specific settings. See "BACKEND"
10372 in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
10373
10374 LIBGUESTFS_CACHEDIR
10375 The location where libguestfs will cache its appliance, when using
10376 a supermin appliance. The appliance is cached and shared between
10377 all handles which have the same effective user ID.
10378
10379 If "LIBGUESTFS_CACHEDIR" is not set, then "TMPDIR" is used. If
10380 "TMPDIR" is not set, then /var/tmp is used.
10381
10382 See also "LIBGUESTFS_TMPDIR", "set-cachedir".
10383
10384 LIBGUESTFS_DEBUG
10385 Set "LIBGUESTFS_DEBUG=1" to enable verbose messages. This has the
10386 same effect as using the -v option.
10387
10388 LIBGUESTFS_HV
10389 Set the default hypervisor (usually qemu) binary that libguestfs
10390 uses. If not set, then the qemu which was found at compile time by
10391 the configure script is used.
10392
10393 LIBGUESTFS_MEMSIZE
10394 Set the memory allocated to the qemu process, in megabytes. For
10395 example:
10396
10397 LIBGUESTFS_MEMSIZE=700
10398
10399 LIBGUESTFS_PATH
10400 Set the path that guestfish uses to search for kernel and
10401 initrd.img. See the discussion of paths in guestfs(3).
10402
10403 LIBGUESTFS_QEMU
10404 This is the old way to set "LIBGUESTFS_HV".
10405
10406 LIBGUESTFS_TMPDIR
10407 The location where libguestfs will store temporary files used by
10408 each handle.
10409
10410 If "LIBGUESTFS_TMPDIR" is not set, then "TMPDIR" is used. If
10411 "TMPDIR" is not set, then /tmp is used.
10412
10413 See also "LIBGUESTFS_CACHEDIR", "set-tmpdir".
10414
10415 LIBGUESTFS_TRACE
10416 Set "LIBGUESTFS_TRACE=1" to enable command traces.
10417
10418 PAGER
10419 The "more" command uses $PAGER as the pager. If not set, it uses
10420 "more".
10421
10422 PATH
10423 Libguestfs and guestfish may run some external programs, and rely
10424 on $PATH being set to a reasonable value. If using the libvirt
10425 backend, libvirt will not work at all unless $PATH contains the
10426 path of qemu/KVM.
10427
10428 SUPERMIN_KERNEL
10429 SUPERMIN_KERNEL_VERSION
10430 SUPERMIN_MODULES
10431 These three environment variables allow the kernel that libguestfs
10432 uses in the appliance to be selected. If $SUPERMIN_KERNEL is not
10433 set, then the most recent host kernel is chosen. For more
10434 information about kernel selection, see supermin(1).
10435
10436 TMPDIR
10437 See "LIBGUESTFS_CACHEDIR", "LIBGUESTFS_TMPDIR".
10438
10439 XDG_RUNTIME_DIR
10440 This directory represents a user-specific directory for storing
10441 non-essential runtime files.
10442
10443 If it is set, then is used to store temporary sockets. Otherwise,
10444 /tmp is used.
10445
10446 See also "get-sockdir",
10447 http://www.freedesktop.org/wiki/Specifications/basedir-spec/.
10448
10450 $XDG_CONFIG_HOME/libguestfs/libguestfs-tools.conf
10451 $HOME/.libguestfs-tools.rc
10452 $XDG_CONFIG_DIRS/libguestfs/libguestfs-tools.conf
10453 /etc/libguestfs-tools.conf
10454 This configuration file controls the default read-only or read-
10455 write mode (--ro or --rw).
10456
10457 See libguestfs-tools.conf(5).
10458
10459 $HOME/.guestfish
10460 If compiled with GNU readline support, then the command history is
10461 saved in this file.
10462
10463 $HOME/.inputrc
10464 /etc/inputrc
10465 If compiled with GNU readline support, then these files can be used
10466 to configure readline. For further information, please see
10467 "INITIALIZATION FILE" in readline(3).
10468
10469 To write rules which only apply to guestfish, use:
10470
10471 $if guestfish
10472 ...
10473 $endif
10474
10475 Variables that you can set in inputrc that change the behaviour of
10476 guestfish in useful ways include:
10477
10478 completion-ignore-case (default: on)
10479 By default, guestfish will ignore case when tab-completing
10480 paths on the disk. Use:
10481
10482 set completion-ignore-case off
10483
10484 to make guestfish case sensitive.
10485
10486 test1.img
10487 test2.img (etc)
10488 When using the -N or --new option, the prepared disk or filesystem
10489 will be created in the file test1.img in the current directory.
10490 The second use of -N will use test2.img and so on. Any existing
10491 file with the same name will be overwritten. You can use a
10492 different filename by using the "filename=" prefix.
10493
10495 guestfs(3), http://libguestfs.org/, virt-alignment-scan(1),
10496 virt-builder(1), virt-builder-repository(1), virt-cat(1),
10497 virt-copy-in(1), virt-copy-out(1), virt-customize(1), virt-df(1),
10498 virt-diff(1), virt-edit(1), virt-filesystems(1), virt-inspector(1),
10499 virt-list-filesystems(1), virt-list-partitions(1), virt-log(1),
10500 virt-ls(1), virt-make-fs(1), virt-p2v(1), virt-rescue(1),
10501 virt-resize(1), virt-sparsify(1), virt-sysprep(1), virt-tail(1),
10502 virt-tar(1), virt-tar-in(1), virt-tar-out(1), virt-v2v(1),
10503 virt-win-reg(1), libguestfs-tools.conf(5), display(1), hexedit(1),
10504 supermin(1).
10505
10507 Richard W.M. Jones ("rjones at redhat dot com")
10508
10510 Copyright (C) 2009-2020 Red Hat Inc.
10511
10513 This program is free software; you can redistribute it and/or modify it
10514 under the terms of the GNU General Public License as published by the
10515 Free Software Foundation; either version 2 of the License, or (at your
10516 option) any later version.
10517
10518 This program is distributed in the hope that it will be useful, but
10519 WITHOUT ANY WARRANTY; without even the implied warranty of
10520 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10521 General Public License for more details.
10522
10523 You should have received a copy of the GNU General Public License along
10524 with this program; if not, write to the Free Software Foundation, Inc.,
10525 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
10526
10528 To get a list of bugs against libguestfs, use this link:
10529 https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
10530
10531 To report a new bug against libguestfs, use this link:
10532 https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
10533
10534 When reporting a bug, please supply:
10535
10536 • The version of libguestfs.
10537
10538 • Where you got libguestfs (eg. which Linux distro, compiled from
10539 source, etc)
10540
10541 • Describe the bug accurately and give a way to reproduce it.
10542
10543 • Run libguestfs-test-tool(1) and paste the complete, unedited output
10544 into the bug report.
10545
10546
10547
10548libguestfs-1.49.9 2023-01-19 guestfish(1)