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 the
3393 backing file, which is discovered automatically. You are encouraged to
3394 also pass "backingformat" to describe the format of "backingfile".
3395
3396 If filename refers to a block device, then the device is formatted.
3397 The "size" is ignored since block devices have an intrinsic size.
3398
3399 The other optional parameters are:
3400
3401 "preallocation"
3402 If format is "raw", then this can be either "off" (or "sparse") or
3403 "full" to create a sparse or fully allocated file respectively.
3404 The default is "off".
3405
3406 If format is "qcow2", then this can be "off" (or "sparse"),
3407 "metadata" or "full". Preallocating metadata can be faster when
3408 doing lots of writes, but uses more space. The default is "off".
3409
3410 "compat"
3411 "qcow2" only: Pass the string 1.1 to use the advanced qcow2 format
3412 supported by qemu ≥ 1.1.
3413
3414 "clustersize"
3415 "qcow2" only: Change the qcow2 cluster size. The default is 65536
3416 (bytes) and this setting may be any power of two between 512 and
3417 2097152.
3418
3419 Note that this call does not add the new disk to the handle. You may
3420 need to call "add-drive-opts" separately.
3421
3422 This command has one or more optional arguments. See "OPTIONAL
3423 ARGUMENTS".
3424
3425 disk-format
3426 disk-format filename
3427
3428 Detect and return the format of the disk image called filename.
3429 filename can also be a host device, etc. If the format of the image
3430 could not be detected, then "unknown" is returned.
3431
3432 Note that detecting the disk format can be insecure under some
3433 circumstances. See "CVE-2010-3851" in guestfs(3).
3434
3435 See also: "DISK IMAGE FORMATS" in guestfs(3)
3436
3437 disk-has-backing-file
3438 disk-has-backing-file filename
3439
3440 Detect and return whether the disk image filename has a backing file.
3441
3442 Note that detecting disk features can be insecure under some
3443 circumstances. See "CVE-2010-3851" in guestfs(3).
3444
3445 disk-virtual-size
3446 disk-virtual-size filename
3447
3448 Detect and return the virtual size in bytes of the disk image called
3449 filename.
3450
3451 Note that detecting disk features can be insecure under some
3452 circumstances. See "CVE-2010-3851" in guestfs(3).
3453
3454 dmesg
3455 dmesg
3456
3457 This returns the kernel messages (dmesg(1) output) from the guest
3458 kernel. This is sometimes useful for extended debugging of problems.
3459
3460 Another way to get the same information is to enable verbose messages
3461 with "set-verbose" or by setting the environment variable
3462 "LIBGUESTFS_DEBUG=1" before running the program.
3463
3464 download
3465 download remotefilename (filename|-)
3466
3467 Download file remotefilename and save it as filename on the local
3468 machine.
3469
3470 filename can also be a named pipe.
3471
3472 See also "upload", "cat".
3473
3474 Use "-" instead of a filename to read/write from stdin/stdout.
3475
3476 download-blocks
3477 download-blocks device start stop (filename|-) [unallocated:true|false]
3478
3479 Download the data units from start address to stop from the disk
3480 partition (eg. /dev/sda1) and save them as filename on the local
3481 machine.
3482
3483 The use of this API on sparse disk image formats such as QCOW, may
3484 result in large zero-filled files downloaded on the host.
3485
3486 The size of a data unit varies across filesystem implementations. On
3487 NTFS filesystems data units are referred as clusters while on ExtX ones
3488 they are referred as fragments.
3489
3490 If the optional "unallocated" flag is true (default is false), only the
3491 unallocated blocks will be extracted. This is useful to detect hidden
3492 data or to retrieve deleted files which data units have not been
3493 overwritten yet.
3494
3495 Use "-" instead of a filename to read/write from stdin/stdout.
3496
3497 This command has one or more optional arguments. See "OPTIONAL
3498 ARGUMENTS".
3499
3500 This command depends on the feature "sleuthkit". See also "feature-
3501 available".
3502
3503 download-inode
3504 download-inode device inode (filename|-)
3505
3506 Download a file given its inode from the disk partition (eg. /dev/sda1)
3507 and save it as filename on the local machine.
3508
3509 It is not required to mount the disk to run this command.
3510
3511 The command is capable of downloading deleted or inaccessible files.
3512
3513 Use "-" instead of a filename to read/write from stdin/stdout.
3514
3515 This command depends on the feature "sleuthkit". See also "feature-
3516 available".
3517
3518 download-offset
3519 download-offset remotefilename (filename|-) offset size
3520
3521 Download file remotefilename and save it as filename on the local
3522 machine.
3523
3524 remotefilename is read for "size" bytes starting at "offset" (this
3525 region must be within the file or device).
3526
3527 Note that there is no limit on the amount of data that can be
3528 downloaded with this call, unlike with "pread", and this call always
3529 reads the full amount unless an error occurs.
3530
3531 See also "download", "pread".
3532
3533 Use "-" instead of a filename to read/write from stdin/stdout.
3534
3535 drop-caches
3536 drop-caches whattodrop
3537
3538 This instructs the guest kernel to drop its page cache, and/or dentries
3539 and inode caches. The parameter "whattodrop" tells the kernel what
3540 precisely to drop, see https://linux-mm.org/Drop_Caches
3541
3542 Setting "whattodrop" to 3 should drop everything.
3543
3544 This automatically calls sync(2) before the operation, so that the
3545 maximum guest memory is freed.
3546
3547 du
3548 du path
3549
3550 This command runs the "du -s" command to estimate file space usage for
3551 "path".
3552
3553 "path" can be a file or a directory. If "path" is a directory then the
3554 estimate includes the contents of the directory and all subdirectories
3555 (recursively).
3556
3557 The result is the estimated size in kilobytes (ie. units of 1024
3558 bytes).
3559
3560 e2fsck
3561 e2fsck device [correct:true|false] [forceall:true|false]
3562
3563 This runs the ext2/ext3 filesystem checker on "device". It can take
3564 the following optional arguments:
3565
3566 "correct"
3567 Automatically repair the file system. This option will cause e2fsck
3568 to automatically fix any filesystem problems that can be safely
3569 fixed without human intervention.
3570
3571 This option may not be specified at the same time as the "forceall"
3572 option.
3573
3574 "forceall"
3575 Assume an answer of ‘yes’ to all questions; allows e2fsck to be
3576 used non-interactively.
3577
3578 This option may not be specified at the same time as the "correct"
3579 option.
3580
3581 This command has one or more optional arguments. See "OPTIONAL
3582 ARGUMENTS".
3583
3584 e2fsck-f
3585 e2fsck-f device
3586
3587 This runs "e2fsck -p -f device", ie. runs the ext2/ext3 filesystem
3588 checker on "device", noninteractively (-p), even if the filesystem
3589 appears to be clean (-f).
3590
3591 This function is deprecated. In new code, use the "e2fsck" call
3592 instead.
3593
3594 Deprecated functions will not be removed from the API, but the fact
3595 that they are deprecated indicates that there are problems with correct
3596 use of these functions.
3597
3598 echo-daemon
3599 echo-daemon 'words ...'
3600
3601 This command concatenates the list of "words" passed with single spaces
3602 between them and returns the resulting string.
3603
3604 You can use this command to test the connection through to the daemon.
3605
3606 See also "ping-daemon".
3607
3608 egrep
3609 egrep regex path
3610
3611 This calls the external egrep(1) program and returns the matching
3612 lines.
3613
3614 Because of the message protocol, there is a transfer limit of somewhere
3615 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3616
3617 This function is deprecated. In new code, use the "grep" call instead.
3618
3619 Deprecated functions will not be removed from the API, but the fact
3620 that they are deprecated indicates that there are problems with correct
3621 use of these functions.
3622
3623 egrepi
3624 egrepi regex path
3625
3626 This calls the external "egrep -i" program and returns the matching
3627 lines.
3628
3629 Because of the message protocol, there is a transfer limit of somewhere
3630 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3631
3632 This function is deprecated. In new code, use the "grep" call instead.
3633
3634 Deprecated functions will not be removed from the API, but the fact
3635 that they are deprecated indicates that there are problems with correct
3636 use of these functions.
3637
3638 equal
3639 equal file1 file2
3640
3641 This compares the two files file1 and file2 and returns true if their
3642 content is exactly equal, or false otherwise.
3643
3644 The external cmp(1) program is used for the comparison.
3645
3646 exists
3647 exists path
3648
3649 This returns "true" if and only if there is a file, directory (or
3650 anything) with the given "path" name.
3651
3652 See also "is-file", "is-dir", "stat".
3653
3654 extlinux
3655 extlinux directory
3656
3657 Install the SYSLINUX bootloader on the device mounted at directory.
3658 Unlike "syslinux" which requires a FAT filesystem, this can be used on
3659 an ext2/3/4 or btrfs filesystem.
3660
3661 The directory parameter can be either a mountpoint, or a directory
3662 within the mountpoint.
3663
3664 You also have to mark the partition as "active" ("part-set-bootable")
3665 and a Master Boot Record must be installed (eg. using "pwrite-device")
3666 on the first sector of the whole disk. The SYSLINUX package comes with
3667 some suitable Master Boot Records. See the extlinux(1) man page for
3668 further information.
3669
3670 Additional configuration can be supplied to SYSLINUX by placing a file
3671 called extlinux.conf on the filesystem under directory. For further
3672 information about the contents of this file, see extlinux(1).
3673
3674 See also "syslinux".
3675
3676 This command depends on the feature "extlinux". See also "feature-
3677 available".
3678
3679 f2fs-expand
3680 f2fs-expand device
3681
3682 This expands a f2fs filesystem to match the size of the underlying
3683 device.
3684
3685 This command depends on the feature "f2fs". See also "feature-
3686 available".
3687
3688 fallocate
3689 fallocate path len
3690
3691 This command preallocates a file (containing zero bytes) named "path"
3692 of size "len" bytes. If the file exists already, it is overwritten.
3693
3694 Do not confuse this with the guestfish-specific "alloc" command which
3695 allocates a file in the host and attaches it as a device.
3696
3697 This function is deprecated. In new code, use the "fallocate64" call
3698 instead.
3699
3700 Deprecated functions will not be removed from the API, but the fact
3701 that they are deprecated indicates that there are problems with correct
3702 use of these functions.
3703
3704 fallocate64
3705 fallocate64 path len
3706
3707 This command preallocates a file (containing zero bytes) named "path"
3708 of size "len" bytes. If the file exists already, it is overwritten.
3709
3710 Note that this call allocates disk blocks for the file. To create a
3711 sparse file use "truncate-size" instead.
3712
3713 The deprecated call "fallocate" does the same, but owing to an
3714 oversight it only allowed 30 bit lengths to be specified, effectively
3715 limiting the maximum size of files created through that call to 1GB.
3716
3717 Do not confuse this with the guestfish-specific "alloc" and "sparse"
3718 commands which create a file in the host and attach it as a device.
3719
3720 feature-available
3721 feature-available 'groups ...'
3722
3723 This is the same as "available", but unlike that call it returns a
3724 simple true/false boolean result, instead of throwing an exception if a
3725 feature is not found. For other documentation see "available".
3726
3727 fgrep
3728 fgrep pattern path
3729
3730 This calls the external fgrep(1) program and returns the matching
3731 lines.
3732
3733 Because of the message protocol, there is a transfer limit of somewhere
3734 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3735
3736 This function is deprecated. In new code, use the "grep" call instead.
3737
3738 Deprecated functions will not be removed from the API, but the fact
3739 that they are deprecated indicates that there are problems with correct
3740 use of these functions.
3741
3742 fgrepi
3743 fgrepi pattern path
3744
3745 This calls the external "fgrep -i" program and returns the matching
3746 lines.
3747
3748 Because of the message protocol, there is a transfer limit of somewhere
3749 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
3750
3751 This function is deprecated. In new code, use the "grep" call instead.
3752
3753 Deprecated functions will not be removed from the API, but the fact
3754 that they are deprecated indicates that there are problems with correct
3755 use of these functions.
3756
3757 file
3758 file path
3759
3760 This call uses the standard file(1) command to determine the type or
3761 contents of the file.
3762
3763 This call will also transparently look inside various types of
3764 compressed file.
3765
3766 The filename is not prepended to the output (like the file command -b
3767 option).
3768
3769 The output depends on the output of the underlying file(1) command and
3770 it can change in future in ways beyond our control. In other words,
3771 the output is not guaranteed by the ABI.
3772
3773 See also: file(1), "vfs-type", "lstat", "is-file", "is-blockdev" (etc),
3774 "is-zero".
3775
3776 file-architecture
3777 file-architecture filename
3778
3779 This detects the architecture of the binary filename, and returns it if
3780 known.
3781
3782 Currently defined architectures are:
3783
3784 "aarch64"
3785 64 bit ARM.
3786
3787 "arm"
3788 32 bit ARM.
3789
3790 "i386"
3791 This string is returned for all 32 bit i386, i486, i586, i686
3792 binaries irrespective of the precise processor requirements of the
3793 binary.
3794
3795 "ia64"
3796 Intel Itanium.
3797
3798 "ppc"
3799 32 bit Power PC.
3800
3801 "ppc64"
3802 64 bit Power PC (big endian).
3803
3804 "ppc64le"
3805 64 bit Power PC (little endian).
3806
3807 "riscv32"
3808 "riscv64"
3809 "riscv128"
3810 RISC-V 32-, 64- or 128-bit variants.
3811
3812 "s390"
3813 31 bit IBM S/390.
3814
3815 "s390x"
3816 64 bit IBM S/390.
3817
3818 "sparc"
3819 32 bit SPARC.
3820
3821 "sparc64"
3822 64 bit SPARC V9 and above.
3823
3824 "x86_64"
3825 64 bit x86-64.
3826
3827 Libguestfs may return other architecture strings in future.
3828
3829 The function works on at least the following types of files:
3830
3831 • many types of Un*x and Linux binary
3832
3833 • many types of Un*x and Linux shared library
3834
3835 • Windows Win32 and Win64 binaries
3836
3837 • Windows Win32 and Win64 DLLs
3838
3839 Win32 binaries and DLLs return "i386".
3840
3841 Win64 binaries and DLLs return "x86_64".
3842
3843 • Linux kernel modules
3844
3845 • Linux new-style initrd images
3846
3847 • some non-x86 Linux vmlinuz kernels
3848
3849 What it can't do currently:
3850
3851 • static libraries (libfoo.a)
3852
3853 • Linux old-style initrd as compressed ext2 filesystem (RHEL 3)
3854
3855 • x86 Linux vmlinuz kernels
3856
3857 x86 vmlinuz images (bzImage format) consist of a mix of 16-, 32-
3858 and compressed code, and are horribly hard to unpack. If you want
3859 to find the architecture of a kernel, use the architecture of the
3860 associated initrd or kernel module(s) instead.
3861
3862 filesize
3863 filesize file
3864
3865 This command returns the size of file in bytes.
3866
3867 To get other stats about a file, use "stat", "lstat", "is-dir", "is-
3868 file" etc. To get the size of block devices, use "blockdev-getsize64".
3869
3870 filesystem-available
3871 filesystem-available filesystem
3872
3873 Check whether libguestfs supports the named filesystem. The argument
3874 "filesystem" is a filesystem name, such as "ext3".
3875
3876 You must call "launch" before using this command.
3877
3878 This is mainly useful as a negative test. If this returns true, it
3879 doesn't mean that a particular filesystem can be created or mounted,
3880 since filesystems can fail for other reasons such as it being a later
3881 version of the filesystem, or having incompatible features, or lacking
3882 the right mkfs.<fs> tool.
3883
3884 See also "available", "feature-available", "AVAILABILITY" in
3885 guestfs(3).
3886
3887 filesystem-walk
3888 filesystem-walk device
3889
3890 Walk through the internal structures of a disk partition (eg.
3891 /dev/sda1) in order to return a list of all the files and directories
3892 stored within.
3893
3894 It is not necessary to mount the disk partition to run this command.
3895
3896 All entries in the filesystem are returned. This function can list
3897 deleted or unaccessible files. The entries are not sorted.
3898
3899 The "tsk_dirent" structure contains the following fields.
3900
3901 "tsk_inode"
3902 Filesystem reference number of the node. It might be 0 if the node
3903 has been deleted.
3904
3905 "tsk_type"
3906 Basic file type information. See below for a detailed list of
3907 values.
3908
3909 "tsk_size"
3910 File size in bytes. It might be -1 if the node has been deleted.
3911
3912 "tsk_name"
3913 The file path relative to its directory.
3914
3915 "tsk_flags"
3916 Bitfield containing extra information regarding the entry. It
3917 contains the logical OR of the following values:
3918
3919 0x0001
3920 If set to 1, the file is allocated and visible within the
3921 filesystem. Otherwise, the file has been deleted. Under
3922 certain circumstances, the function "download_inode" can be
3923 used to recover deleted files.
3924
3925 0x0002
3926 Filesystem such as NTFS and Ext2 or greater, separate the file
3927 name from the metadata structure. The bit is set to 1 when the
3928 file name is in an unallocated state and the metadata structure
3929 is in an allocated one. This generally implies the metadata
3930 has been reallocated to a new file. Therefore, information
3931 such as file type, file size, timestamps, number of links and
3932 symlink target might not correspond with the ones of the
3933 original deleted entry.
3934
3935 0x0004
3936 The bit is set to 1 when the file is compressed using
3937 filesystem native compression support (NTFS). The API is not
3938 able to detect application level compression.
3939
3940 "tsk_atime_sec"
3941 "tsk_atime_nsec"
3942 "tsk_mtime_sec"
3943 "tsk_mtime_nsec"
3944 "tsk_ctime_sec"
3945 "tsk_ctime_nsec"
3946 "tsk_crtime_sec"
3947 "tsk_crtime_nsec"
3948 Respectively, access, modification, last status change and creation
3949 time in Unix format in seconds and nanoseconds.
3950
3951 "tsk_nlink"
3952 Number of file names pointing to this entry.
3953
3954 "tsk_link"
3955 If the entry is a symbolic link, this field will contain the path
3956 to the target file.
3957
3958 The "tsk_type" field will contain one of the following characters:
3959
3960 'b' Block special
3961
3962 'c' Char special
3963
3964 'd' Directory
3965
3966 'f' FIFO (named pipe)
3967
3968 'l' Symbolic link
3969
3970 'r' Regular file
3971
3972 's' Socket
3973
3974 'h' Shadow inode (Solaris)
3975
3976 'w' Whiteout inode (BSD)
3977
3978 'u' Unknown file type
3979
3980 This command depends on the feature "libtsk". See also "feature-
3981 available".
3982
3983 fill
3984 fill c len path
3985
3986 This command creates a new file called "path". The initial content of
3987 the file is "len" octets of "c", where "c" must be a number in the
3988 range "[0..255]".
3989
3990 To fill a file with zero bytes (sparsely), it is much more efficient to
3991 use "truncate-size". To create a file with a pattern of repeating
3992 bytes use "fill-pattern".
3993
3994 fill-dir
3995 fill-dir dir nr
3996
3997 This function, useful for testing filesystems, creates "nr" empty files
3998 in the directory "dir" with names 00000000 through "nr-1" (ie. each
3999 file name is 8 digits long padded with zeroes).
4000
4001 fill-pattern
4002 fill-pattern pattern len path
4003
4004 This function is like "fill" except that it creates a new file of
4005 length "len" containing the repeating pattern of bytes in "pattern".
4006 The pattern is truncated if necessary to ensure the length of the file
4007 is exactly "len" bytes.
4008
4009 find
4010 find directory
4011
4012 This command lists out all files and directories, recursively, starting
4013 at directory. It is essentially equivalent to running the shell
4014 command "find directory -print" but some post-processing happens on the
4015 output, described below.
4016
4017 This returns a list of strings without any prefix. Thus if the
4018 directory structure was:
4019
4020 /tmp/a
4021 /tmp/b
4022 /tmp/c/d
4023
4024 then the returned list from "find" /tmp would be 4 elements:
4025
4026 a
4027 b
4028 c
4029 c/d
4030
4031 If directory is not a directory, then this command returns an error.
4032
4033 The returned list is sorted.
4034
4035 find0
4036 find0 directory (files|-)
4037
4038 This command lists out all files and directories, recursively, starting
4039 at directory, placing the resulting list in the external file called
4040 files.
4041
4042 This command works the same way as "find" with the following
4043 exceptions:
4044
4045 • The resulting list is written to an external file.
4046
4047 • Items (filenames) in the result are separated by "\0" characters.
4048 See find(1) option -print0.
4049
4050 • The result list is not sorted.
4051
4052 Use "-" instead of a filename to read/write from stdin/stdout.
4053
4054 find-inode
4055 find-inode device inode
4056
4057 Searches all the entries associated with the given inode.
4058
4059 For each entry, a "tsk_dirent" structure is returned. See
4060 "filesystem_walk" for more information about "tsk_dirent" structures.
4061
4062 This command depends on the feature "libtsk". See also "feature-
4063 available".
4064
4065 findfs-label
4066 findfs-label label
4067
4068 This command searches the filesystems and returns the one which has the
4069 given label. An error is returned if no such filesystem can be found.
4070
4071 To find the label of a filesystem, use "vfs-label".
4072
4073 findfs-uuid
4074 findfs-uuid uuid
4075
4076 This command searches the filesystems and returns the one which has the
4077 given UUID. An error is returned if no such filesystem can be found.
4078
4079 To find the UUID of a filesystem, use "vfs-uuid".
4080
4081 fsck
4082 fsck fstype device
4083
4084 This runs the filesystem checker (fsck) on "device" which should have
4085 filesystem type "fstype".
4086
4087 The returned integer is the status. See fsck(8) for the list of status
4088 codes from "fsck".
4089
4090 Notes:
4091
4092 • Multiple status codes can be summed together.
4093
4094 • A non-zero return code can mean "success", for example if errors
4095 have been corrected on the filesystem.
4096
4097 • Checking or repairing NTFS volumes is not supported (by linux-
4098 ntfs).
4099
4100 This command is entirely equivalent to running "fsck -a -t fstype
4101 device".
4102
4103 fstrim
4104 fstrim mountpoint [offset:N] [length:N] [minimumfreeextent:N]
4105
4106 Trim the free space in the filesystem mounted on "mountpoint". The
4107 filesystem must be mounted read-write.
4108
4109 The filesystem contents are not affected, but any free space in the
4110 filesystem is "trimmed", that is, given back to the host device, thus
4111 making disk images more sparse, allowing unused space in qcow2 files to
4112 be reused, etc.
4113
4114 This operation requires support in libguestfs, the mounted filesystem,
4115 the host filesystem, qemu and the host kernel. If this support isn't
4116 present it may give an error or even appear to run but do nothing.
4117
4118 In the case where the kernel vfs driver does not support trimming, this
4119 call will fail with errno set to "ENOTSUP". Currently this happens
4120 when trying to trim FAT filesystems.
4121
4122 See also "zero-free-space". That is a slightly different operation
4123 that turns free space in the filesystem into zeroes. It is valid to
4124 call "fstrim" either instead of, or after calling "zero-free-space".
4125
4126 This command has one or more optional arguments. See "OPTIONAL
4127 ARGUMENTS".
4128
4129 This command depends on the feature "fstrim". See also "feature-
4130 available".
4131
4132 get-append
4133 get-append
4134
4135 Return the additional kernel options which are added to the libguestfs
4136 appliance kernel command line.
4137
4138 If "NULL" then no options are added.
4139
4140 get-attach-method
4141 get-attach-method
4142
4143 Return the current backend.
4144
4145 See "set-backend" and "BACKEND" in guestfs(3).
4146
4147 This function is deprecated. In new code, use the "get-backend" call
4148 instead.
4149
4150 Deprecated functions will not be removed from the API, but the fact
4151 that they are deprecated indicates that there are problems with correct
4152 use of these functions.
4153
4154 get-autosync
4155 get-autosync
4156
4157 Get the autosync flag.
4158
4159 get-backend
4160 get-backend
4161
4162 Return the current backend.
4163
4164 This handle property was previously called the "attach method".
4165
4166 See "set-backend" and "BACKEND" in guestfs(3).
4167
4168 get-backend-setting
4169 get-backend-setting name
4170
4171 Find a backend setting string which is either "name" or begins with
4172 "name=". If "name", this returns the string "1". If "name=", this
4173 returns the part after the equals sign (which may be an empty string).
4174
4175 If no such setting is found, this function throws an error. The errno
4176 (see "last-errno") will be "ESRCH" in this case.
4177
4178 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
4179
4180 get-backend-settings
4181 get-backend-settings
4182
4183 Return the current backend settings.
4184
4185 This call returns all backend settings strings. If you want to find a
4186 single backend setting, see "get-backend-setting".
4187
4188 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
4189
4190 get-cachedir
4191 get-cachedir
4192
4193 Get the directory used by the handle to store the appliance cache.
4194
4195 get-direct
4196 get-direct
4197
4198 Return the direct appliance mode flag.
4199
4200 This function is deprecated. In new code, use the "internal-get-
4201 console-socket" call instead.
4202
4203 Deprecated functions will not be removed from the API, but the fact
4204 that they are deprecated indicates that there are problems with correct
4205 use of these functions.
4206
4207 get-e2attrs
4208 get-e2attrs file
4209
4210 This returns the file attributes associated with file.
4211
4212 The attributes are a set of bits associated with each inode which
4213 affect the behaviour of the file. The attributes are returned as a
4214 string of letters (described below). The string may be empty,
4215 indicating that no file attributes are set for this file.
4216
4217 These attributes are only present when the file is located on an
4218 ext2/3/4 filesystem. Using this call on other filesystem types will
4219 result in an error.
4220
4221 The characters (file attributes) in the returned string are currently:
4222
4223 'A' When the file is accessed, its atime is not modified.
4224
4225 'a' The file is append-only.
4226
4227 'c' The file is compressed on-disk.
4228
4229 'D' (Directories only.) Changes to this directory are written
4230 synchronously to disk.
4231
4232 'd' The file is not a candidate for backup (see dump(8)).
4233
4234 'E' The file has compression errors.
4235
4236 'e' The file is using extents.
4237
4238 'h' The file is storing its blocks in units of the filesystem blocksize
4239 instead of sectors.
4240
4241 'I' (Directories only.) The directory is using hashed trees.
4242
4243 'i' The file is immutable. It cannot be modified, deleted or renamed.
4244 No link can be created to this file.
4245
4246 'j' The file is data-journaled.
4247
4248 's' When the file is deleted, all its blocks will be zeroed.
4249
4250 'S' Changes to this file are written synchronously to disk.
4251
4252 'T' (Directories only.) This is a hint to the block allocator that
4253 subdirectories contained in this directory should be spread across
4254 blocks. If not present, the block allocator will try to group
4255 subdirectories together.
4256
4257 't' For a file, this disables tail-merging. (Not used by upstream
4258 implementations of ext2.)
4259
4260 'u' When the file is deleted, its blocks will be saved, allowing the
4261 file to be undeleted.
4262
4263 'X' The raw contents of the compressed file may be accessed.
4264
4265 'Z' The compressed file is dirty.
4266
4267 More file attributes may be added to this list later. Not all file
4268 attributes may be set for all kinds of files. For detailed
4269 information, consult the chattr(1) man page.
4270
4271 See also "set-e2attrs".
4272
4273 Don't confuse these attributes with extended attributes (see
4274 "getxattr").
4275
4276 get-e2generation
4277 get-e2generation file
4278
4279 This returns the ext2 file generation of a file. The generation (which
4280 used to be called the "version") is a number associated with an inode.
4281 This is most commonly used by NFS servers.
4282
4283 The generation is only present when the file is located on an ext2/3/4
4284 filesystem. Using this call on other filesystem types will result in
4285 an error.
4286
4287 See "set-e2generation".
4288
4289 get-e2label
4290 get-e2label device
4291
4292 This returns the ext2/3/4 filesystem label of the filesystem on
4293 "device".
4294
4295 This function is deprecated. In new code, use the "vfs-label" call
4296 instead.
4297
4298 Deprecated functions will not be removed from the API, but the fact
4299 that they are deprecated indicates that there are problems with correct
4300 use of these functions.
4301
4302 get-e2uuid
4303 get-e2uuid device
4304
4305 This returns the ext2/3/4 filesystem UUID of the filesystem on
4306 "device".
4307
4308 This function is deprecated. In new code, use the "vfs-uuid" call
4309 instead.
4310
4311 Deprecated functions will not be removed from the API, but the fact
4312 that they are deprecated indicates that there are problems with correct
4313 use of these functions.
4314
4315 get-hv
4316 get-hv
4317
4318 Return the current hypervisor binary.
4319
4320 This is always non-NULL. If it wasn't set already, then this will
4321 return the default qemu binary name.
4322
4323 get-identifier
4324 get-identifier
4325
4326 Get the handle identifier. See "set-identifier".
4327
4328 get-libvirt-requested-credential-challenge
4329 get-libvirt-requested-credential-challenge index
4330
4331 Get the challenge (provided by libvirt) for the "index"'th requested
4332 credential. If libvirt did not provide a challenge, this returns the
4333 empty string "".
4334
4335 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
4336 example code.
4337
4338 get-libvirt-requested-credential-defresult
4339 get-libvirt-requested-credential-defresult index
4340
4341 Get the default result (provided by libvirt) for the "index"'th
4342 requested credential. If libvirt did not provide a default result,
4343 this returns the empty string "".
4344
4345 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
4346 example code.
4347
4348 get-libvirt-requested-credential-prompt
4349 get-libvirt-requested-credential-prompt index
4350
4351 Get the prompt (provided by libvirt) for the "index"'th requested
4352 credential. If libvirt did not provide a prompt, this returns the
4353 empty string "".
4354
4355 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
4356 example code.
4357
4358 get-libvirt-requested-credentials
4359 get-libvirt-requested-credentials
4360
4361 This should only be called during the event callback for events of type
4362 "GUESTFS_EVENT_LIBVIRT_AUTH".
4363
4364 Return the list of credentials requested by libvirt. Possible values
4365 are a subset of the strings provided when you called "set-libvirt-
4366 supported-credentials".
4367
4368 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
4369 example code.
4370
4371 get-memsize
4372 get-memsize
4373
4374 This gets the memory size in megabytes allocated to the hypervisor.
4375
4376 If "set-memsize" was not called on this handle, and if
4377 "LIBGUESTFS_MEMSIZE" was not set, then this returns the compiled-in
4378 default value for memsize.
4379
4380 For more information on the architecture of libguestfs, see guestfs(3).
4381
4382 get-network
4383 get-network
4384
4385 This returns the enable network flag.
4386
4387 get-path
4388 get-path
4389
4390 Return the current search path.
4391
4392 This is always non-NULL. If it wasn't set already, then this will
4393 return the default path.
4394
4395 get-pgroup
4396 get-pgroup
4397
4398 This returns the process group flag.
4399
4400 get-pid
4401 pid
4402 get-pid
4403
4404 Return the process ID of the hypervisor. If there is no hypervisor
4405 running, then this will return an error.
4406
4407 This is an internal call used for debugging and testing.
4408
4409 get-program
4410 get-program
4411
4412 Get the program name. See "set-program".
4413
4414 get-qemu
4415 get-qemu
4416
4417 Return the current hypervisor binary (usually qemu).
4418
4419 This is always non-NULL. If it wasn't set already, then this will
4420 return the default qemu binary name.
4421
4422 This function is deprecated. In new code, use the "get-hv" call
4423 instead.
4424
4425 Deprecated functions will not be removed from the API, but the fact
4426 that they are deprecated indicates that there are problems with correct
4427 use of these functions.
4428
4429 get-recovery-proc
4430 get-recovery-proc
4431
4432 Return the recovery process enabled flag.
4433
4434 get-selinux
4435 get-selinux
4436
4437 This returns the current setting of the selinux flag which is passed to
4438 the appliance at boot time. See "set-selinux".
4439
4440 For more information on the architecture of libguestfs, see guestfs(3).
4441
4442 This function is deprecated. In new code, use the "selinux-relabel"
4443 call instead.
4444
4445 Deprecated functions will not be removed from the API, but the fact
4446 that they are deprecated indicates that there are problems with correct
4447 use of these functions.
4448
4449 get-smp
4450 get-smp
4451
4452 This returns the number of virtual CPUs assigned to the appliance.
4453
4454 get-sockdir
4455 get-sockdir
4456
4457 Get the directory used by the handle to store temporary socket and PID
4458 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. Furthermore, sockets and PID
4463 files must be accessible to such background services started by
4464 libguestfs that may not have permission to access the temporary
4465 directory returned by "get-tmpdir".
4466
4467 The environment variable "XDG_RUNTIME_DIR" controls the default value:
4468 If "XDG_RUNTIME_DIR" is set, then that is the default. Else /tmp is
4469 the default.
4470
4471 get-tmpdir
4472 get-tmpdir
4473
4474 Get the directory used by the handle to store temporary files.
4475
4476 get-trace
4477 get-trace
4478
4479 Return the command trace flag.
4480
4481 get-umask
4482 get-umask
4483
4484 Return the current umask. By default the umask is 022 unless it has
4485 been set by calling "umask".
4486
4487 get-verbose
4488 get-verbose
4489
4490 This returns the verbose messages flag.
4491
4492 getcon
4493 getcon
4494
4495 This gets the SELinux security context of the daemon.
4496
4497 See the documentation about SELINUX in guestfs(3), and "setcon"
4498
4499 This function is deprecated. In new code, use the "selinux-relabel"
4500 call instead.
4501
4502 Deprecated functions will not be removed from the API, but the fact
4503 that they are deprecated indicates that there are problems with correct
4504 use of these functions.
4505
4506 This command depends on the feature "selinux". See also "feature-
4507 available".
4508
4509 getxattr
4510 getxattr path name
4511
4512 Get a single extended attribute from file "path" named "name". This
4513 call follows symlinks. If you want to lookup an extended attribute for
4514 the symlink itself, use "lgetxattr".
4515
4516 Normally it is better to get all extended attributes from a file in one
4517 go by calling "getxattrs". However some Linux filesystem
4518 implementations are buggy and do not provide a way to list out
4519 attributes. For these filesystems (notably ntfs-3g) you have to know
4520 the names of the extended attributes you want in advance and call this
4521 function.
4522
4523 Extended attribute values are blobs of binary data. If there is no
4524 extended attribute named "name", this returns an error.
4525
4526 See also: "getxattrs", "lgetxattr", attr(5).
4527
4528 This command depends on the feature "linuxxattrs". See also "feature-
4529 available".
4530
4531 getxattrs
4532 getxattrs path
4533
4534 This call lists the extended attributes of the file or directory
4535 "path".
4536
4537 At the system call level, this is a combination of the listxattr(2) and
4538 getxattr(2) calls.
4539
4540 See also: "lgetxattrs", attr(5).
4541
4542 This command depends on the feature "linuxxattrs". See also "feature-
4543 available".
4544
4545 glob-expand
4546 glob-expand-opts
4547 glob-expand pattern [directoryslash:true|false]
4548
4549 This command searches for all the pathnames matching "pattern"
4550 according to the wildcard expansion rules used by the shell.
4551
4552 If no paths match, then this returns an empty list (note: not an
4553 error).
4554
4555 It is just a wrapper around the C glob(3) function with flags
4556 "GLOB_MARK|GLOB_BRACE". See that manual page for more details.
4557
4558 "directoryslash" controls whether use the "GLOB_MARK" flag for glob(3),
4559 and it defaults to true. It can be explicitly set as off to return no
4560 trailing slashes in filenames of directories.
4561
4562 Notice that there is no equivalent command for expanding a device name
4563 (eg. /dev/sd*). Use "list-devices", "list-partitions" etc functions
4564 instead.
4565
4566 This command has one or more optional arguments. See "OPTIONAL
4567 ARGUMENTS".
4568
4569 grep
4570 grep-opts
4571 grep regex path [extended:true|false] [fixed:true|false] [insensitive:true|false] [compressed:true|false]
4572
4573 This calls the external grep(1) program and returns the matching lines.
4574
4575 The optional flags are:
4576
4577 "extended"
4578 Use extended regular expressions. This is the same as using the -E
4579 flag.
4580
4581 "fixed"
4582 Match fixed (don't use regular expressions). This is the same as
4583 using the -F flag.
4584
4585 "insensitive"
4586 Match case-insensitive. This is the same as using the -i flag.
4587
4588 "compressed"
4589 Use zgrep(1) instead of grep(1). This allows the input to be
4590 compress- or gzip-compressed.
4591
4592 This command has one or more optional arguments. See "OPTIONAL
4593 ARGUMENTS".
4594
4595 Because of the message protocol, there is a transfer limit of somewhere
4596 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4597
4598 grepi
4599 grepi regex path
4600
4601 This calls the external "grep -i" program and returns the matching
4602 lines.
4603
4604 Because of the message protocol, there is a transfer limit of somewhere
4605 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4606
4607 This function is deprecated. In new code, use the "grep" call instead.
4608
4609 Deprecated functions will not be removed from the API, but the fact
4610 that they are deprecated indicates that there are problems with correct
4611 use of these functions.
4612
4613 grub-install
4614 grub-install root device
4615
4616 This command installs GRUB 1 (the Grand Unified Bootloader) on
4617 "device", with the root directory being "root".
4618
4619 Notes:
4620
4621 • There is currently no way in the API to install grub2, which is
4622 used by most modern Linux guests. It is possible to run the grub2
4623 command from the guest, although see the caveats in "RUNNING
4624 COMMANDS" in guestfs(3).
4625
4626 • This uses grub-install(8) from the host. Unfortunately grub is not
4627 always compatible with itself, so this only works in rather narrow
4628 circumstances. Careful testing with each guest version is
4629 advisable.
4630
4631 • If grub-install reports the error "No suitable drive was found in
4632 the generated device map." it may be that you need to create a
4633 /boot/grub/device.map file first that contains the mapping between
4634 grub device names and Linux device names. It is usually sufficient
4635 to create a file containing:
4636
4637 (hd0) /dev/vda
4638
4639 replacing /dev/vda with the name of the installation device.
4640
4641 This command depends on the feature "grub". See also "feature-
4642 available".
4643
4644 head
4645 head path
4646
4647 This command returns up to the first 10 lines of a file as a list of
4648 strings.
4649
4650 Because of the message protocol, there is a transfer limit of somewhere
4651 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4652
4653 head-n
4654 head-n nrlines path
4655
4656 If the parameter "nrlines" is a positive number, this returns the first
4657 "nrlines" lines of the file "path".
4658
4659 If the parameter "nrlines" is a negative number, this returns lines
4660 from the file "path", excluding the last "nrlines" lines.
4661
4662 If the parameter "nrlines" is zero, this returns an empty list.
4663
4664 Because of the message protocol, there is a transfer limit of somewhere
4665 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4666
4667 hexdump
4668 hexdump path
4669
4670 This runs "hexdump -C" on the given "path". The result is the human-
4671 readable, canonical hex dump of the file.
4672
4673 Because of the message protocol, there is a transfer limit of somewhere
4674 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4675
4676 hivex-close
4677 hivex-close
4678
4679 Close the current hivex handle.
4680
4681 This is a wrapper around the hivex(3) call of the same name.
4682
4683 This command depends on the feature "hivex". See also "feature-
4684 available".
4685
4686 hivex-commit
4687 hivex-commit filename
4688
4689 Commit (write) changes to the hive.
4690
4691 If the optional filename parameter is null, then the changes are
4692 written back to the same hive that was opened. If this is not null
4693 then they are written to the alternate filename given and the original
4694 hive is left untouched.
4695
4696 This is a wrapper around the hivex(3) call of the same name.
4697
4698 This command depends on the feature "hivex". See also "feature-
4699 available".
4700
4701 hivex-node-add-child
4702 hivex-node-add-child parent name
4703
4704 Add a child node to "parent" named "name".
4705
4706 This is a wrapper around the hivex(3) call of the same name.
4707
4708 This command depends on the feature "hivex". See also "feature-
4709 available".
4710
4711 hivex-node-children
4712 hivex-node-children nodeh
4713
4714 Return the list of nodes which are subkeys of "nodeh".
4715
4716 This is a wrapper around the hivex(3) call of the same name.
4717
4718 This command depends on the feature "hivex". See also "feature-
4719 available".
4720
4721 hivex-node-delete-child
4722 hivex-node-delete-child nodeh
4723
4724 Delete "nodeh", recursively if necessary.
4725
4726 This is a wrapper around the hivex(3) call of the same name.
4727
4728 This command depends on the feature "hivex". See also "feature-
4729 available".
4730
4731 hivex-node-get-child
4732 hivex-node-get-child nodeh name
4733
4734 Return the child of "nodeh" with the name "name", if it exists. This
4735 can return 0 meaning the name was not found.
4736
4737 This is a wrapper around the hivex(3) call of the same name.
4738
4739 This command depends on the feature "hivex". See also "feature-
4740 available".
4741
4742 hivex-node-get-value
4743 hivex-node-get-value nodeh key
4744
4745 Return the value attached to "nodeh" which has the name "key", if it
4746 exists. This can return 0 meaning the key was not found.
4747
4748 This is a wrapper around the hivex(3) call of the same name.
4749
4750 This command depends on the feature "hivex". See also "feature-
4751 available".
4752
4753 hivex-node-name
4754 hivex-node-name nodeh
4755
4756 Return the name of "nodeh".
4757
4758 This is a wrapper around the hivex(3) call of the same name.
4759
4760 This command depends on the feature "hivex". See also "feature-
4761 available".
4762
4763 hivex-node-parent
4764 hivex-node-parent nodeh
4765
4766 Return the parent node of "nodeh".
4767
4768 This is a wrapper around the hivex(3) call of the same name.
4769
4770 This command depends on the feature "hivex". See also "feature-
4771 available".
4772
4773 hivex-node-set-value
4774 hivex-node-set-value nodeh key t val
4775
4776 Set or replace a single value under the node "nodeh". The "key" is the
4777 name, "t" is the type, and "val" is the data.
4778
4779 This is a wrapper around the hivex(3) call of the same name.
4780
4781 This command depends on the feature "hivex". See also "feature-
4782 available".
4783
4784 hivex-node-values
4785 hivex-node-values nodeh
4786
4787 Return the array of (key, datatype, data) tuples attached to "nodeh".
4788
4789 This is a wrapper around the hivex(3) call of the same name.
4790
4791 This command depends on the feature "hivex". See also "feature-
4792 available".
4793
4794 hivex-open
4795 hivex-open filename [verbose:true|false] [debug:true|false] [write:true|false] [unsafe:true|false]
4796
4797 Open the Windows Registry hive file named filename. If there was any
4798 previous hivex handle associated with this guestfs session, then it is
4799 closed.
4800
4801 This is a wrapper around the hivex(3) call of the same name.
4802
4803 This command has one or more optional arguments. See "OPTIONAL
4804 ARGUMENTS".
4805
4806 This command depends on the feature "hivex". See also "feature-
4807 available".
4808
4809 hivex-root
4810 hivex-root
4811
4812 Return the root node of the hive.
4813
4814 This is a wrapper around the hivex(3) call of the same name.
4815
4816 This command depends on the feature "hivex". See also "feature-
4817 available".
4818
4819 hivex-value-key
4820 hivex-value-key valueh
4821
4822 Return the key (name) field of a (key, datatype, data) tuple.
4823
4824 This is a wrapper around the hivex(3) call of the same name.
4825
4826 This command depends on the feature "hivex". See also "feature-
4827 available".
4828
4829 hivex-value-string
4830 hivex-value-string valueh
4831
4832 This calls "hivex-value-value" (which returns the data field from a
4833 hivex value tuple). It then assumes that the field is a UTF-16LE
4834 string and converts the result to UTF-8 (or if this is not possible, it
4835 returns an error).
4836
4837 This is useful for reading strings out of the Windows registry.
4838 However it is not foolproof because the registry is not strongly-typed
4839 and fields can contain arbitrary or unexpected data.
4840
4841 This command depends on the feature "hivex". See also "feature-
4842 available".
4843
4844 hivex-value-type
4845 hivex-value-type valueh
4846
4847 Return the data type field from a (key, datatype, data) tuple.
4848
4849 This is a wrapper around the hivex(3) call of the same name.
4850
4851 This command depends on the feature "hivex". See also "feature-
4852 available".
4853
4854 hivex-value-utf8
4855 hivex-value-utf8 valueh
4856
4857 This calls "hivex-value-value" (which returns the data field from a
4858 hivex value tuple). It then assumes that the field is a UTF-16LE
4859 string and converts the result to UTF-8 (or if this is not possible, it
4860 returns an error).
4861
4862 This is useful for reading strings out of the Windows registry.
4863 However it is not foolproof because the registry is not strongly-typed
4864 and fields can contain arbitrary or unexpected data.
4865
4866 This function is deprecated. In new code, use the "hivex-value-string"
4867 call instead.
4868
4869 Deprecated functions will not be removed from the API, but the fact
4870 that they are deprecated indicates that there are problems with correct
4871 use of these functions.
4872
4873 This command depends on the feature "hivex". See also "feature-
4874 available".
4875
4876 hivex-value-value
4877 hivex-value-value valueh
4878
4879 Return the data field of a (key, datatype, data) tuple.
4880
4881 This is a wrapper around the hivex(3) call of the same name.
4882
4883 See also: "hivex-value-utf8".
4884
4885 This command depends on the feature "hivex". See also "feature-
4886 available".
4887
4888 initrd-cat
4889 initrd-cat initrdpath filename
4890
4891 This command unpacks the file filename from the initrd file called
4892 initrdpath. The filename must be given without the initial /
4893 character.
4894
4895 For example, in guestfish you could use the following command to
4896 examine the boot script (usually called /init) contained in a Linux
4897 initrd or initramfs image:
4898
4899 initrd-cat /boot/initrd-<version>.img init
4900
4901 See also "initrd-list".
4902
4903 Because of the message protocol, there is a transfer limit of somewhere
4904 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
4905
4906 initrd-list
4907 initrd-list path
4908
4909 This command lists out files contained in an initrd.
4910
4911 The files are listed without any initial / character. The files are
4912 listed in the order they appear (not necessarily alphabetical).
4913 Directory names are listed as separate items.
4914
4915 Old Linux kernels (2.4 and earlier) used a compressed ext2 filesystem
4916 as initrd. We only support the newer initramfs format (compressed cpio
4917 files).
4918
4919 inotify-add-watch
4920 inotify-add-watch path mask
4921
4922 Watch "path" for the events listed in "mask".
4923
4924 Note that if "path" is a directory then events within that directory
4925 are watched, but this does not happen recursively (in subdirectories).
4926
4927 Note for non-C or non-Linux callers: the inotify events are defined by
4928 the Linux kernel ABI and are listed in /usr/include/sys/inotify.h.
4929
4930 This command depends on the feature "inotify". See also "feature-
4931 available".
4932
4933 inotify-close
4934 inotify-close
4935
4936 This closes the inotify handle which was previously opened by
4937 inotify_init. It removes all watches, throws away any pending events,
4938 and deallocates all resources.
4939
4940 This command depends on the feature "inotify". See also "feature-
4941 available".
4942
4943 inotify-files
4944 inotify-files
4945
4946 This function is a helpful wrapper around "inotify-read" which just
4947 returns a list of pathnames of objects that were touched. The returned
4948 pathnames are sorted and deduplicated.
4949
4950 This command depends on the feature "inotify". See also "feature-
4951 available".
4952
4953 inotify-init
4954 inotify-init maxevents
4955
4956 This command creates a new inotify handle. The inotify subsystem can
4957 be used to notify events which happen to objects in the guest
4958 filesystem.
4959
4960 "maxevents" is the maximum number of events which will be queued up
4961 between calls to "inotify-read" or "inotify-files". If this is passed
4962 as 0, then the kernel (or previously set) default is used. For Linux
4963 2.6.29 the default was 16384 events. Beyond this limit, the kernel
4964 throws away events, but records the fact that it threw them away by
4965 setting a flag "IN_Q_OVERFLOW" in the returned structure list (see
4966 "inotify-read").
4967
4968 Before any events are generated, you have to add some watches to the
4969 internal watch list. See: "inotify-add-watch" and "inotify-rm-watch".
4970
4971 Queued up events should be read periodically by calling "inotify-read"
4972 (or "inotify-files" which is just a helpful wrapper around "inotify-
4973 read"). If you don't read the events out often enough then you risk
4974 the internal queue overflowing.
4975
4976 The handle should be closed after use by calling "inotify-close". This
4977 also removes any watches automatically.
4978
4979 See also inotify(7) for an overview of the inotify interface as exposed
4980 by the Linux kernel, which is roughly what we expose via libguestfs.
4981 Note that there is one global inotify handle per libguestfs instance.
4982
4983 This command depends on the feature "inotify". See also "feature-
4984 available".
4985
4986 inotify-read
4987 inotify-read
4988
4989 Return the complete queue of events that have happened since the
4990 previous read call.
4991
4992 If no events have happened, this returns an empty list.
4993
4994 Note: In order to make sure that all events have been read, you must
4995 call this function repeatedly until it returns an empty list. The
4996 reason is that the call will read events up to the maximum appliance-
4997 to-host message size and leave remaining events in the queue.
4998
4999 This command depends on the feature "inotify". See also "feature-
5000 available".
5001
5002 inotify-rm-watch
5003 inotify-rm-watch wd
5004
5005 Remove a previously defined inotify watch. See "inotify-add-watch".
5006
5007 This command depends on the feature "inotify". See also "feature-
5008 available".
5009
5010 inspect-get-arch
5011 inspect-get-arch root
5012
5013 This returns the architecture of the inspected operating system. The
5014 possible return values are listed under "file-architecture".
5015
5016 If the architecture could not be determined, then the string "unknown"
5017 is returned.
5018
5019 Please read "INSPECTION" in guestfs(3) for more details.
5020
5021 inspect-get-build-id
5022 inspect-get-build-id root
5023
5024 This returns the build ID of the system, or the string "unknown" if the
5025 system does not have a build ID.
5026
5027 For Windows, this gets the build number. Although it is returned as a
5028 string, it is (so far) always a number. See
5029 https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions for
5030 some possible values.
5031
5032 For Linux, this returns the "BUILD_ID" string from /etc/os-release,
5033 although this is not often used.
5034
5035 Please read "INSPECTION" in guestfs(3) for more details.
5036
5037 inspect-get-distro
5038 inspect-get-distro root
5039
5040 This returns the distro (distribution) of the inspected operating
5041 system.
5042
5043 Currently defined distros are:
5044
5045 "alpinelinux"
5046 Alpine Linux.
5047
5048 "altlinux"
5049 ALT Linux.
5050
5051 "archlinux"
5052 Arch Linux.
5053
5054 "buildroot"
5055 Buildroot-derived distro, but not one we specifically recognize.
5056
5057 "centos"
5058 CentOS.
5059
5060 "cirros"
5061 Cirros.
5062
5063 "coreos"
5064 CoreOS.
5065
5066 "debian"
5067 Debian.
5068
5069 "fedora"
5070 Fedora.
5071
5072 "freebsd"
5073 FreeBSD.
5074
5075 "freedos"
5076 FreeDOS.
5077
5078 "frugalware"
5079 Frugalware.
5080
5081 "gentoo"
5082 Gentoo.
5083
5084 "kalilinux"
5085 Kali Linux.
5086
5087 "kylin"
5088 Kylin.
5089
5090 "linuxmint"
5091 Linux Mint.
5092
5093 "mageia"
5094 Mageia.
5095
5096 "mandriva"
5097 Mandriva.
5098
5099 "meego"
5100 MeeGo.
5101
5102 "msdos"
5103 Microsoft DOS.
5104
5105 "neokylin"
5106 NeoKylin.
5107
5108 "netbsd"
5109 NetBSD.
5110
5111 "openbsd"
5112 OpenBSD.
5113
5114 "openmandriva"
5115 OpenMandriva Lx.
5116
5117 "opensuse"
5118 OpenSUSE.
5119
5120 "oraclelinux"
5121 Oracle Linux.
5122
5123 "pardus"
5124 Pardus.
5125
5126 "pldlinux"
5127 PLD Linux.
5128
5129 "redhat-based"
5130 Some Red Hat-derived distro.
5131
5132 "rhel"
5133 Red Hat Enterprise Linux.
5134
5135 "rocky"
5136 Rocky Linux.
5137
5138 "scientificlinux"
5139 Scientific Linux.
5140
5141 "slackware"
5142 Slackware.
5143
5144 "sles"
5145 SuSE Linux Enterprise Server or Desktop.
5146
5147 "suse-based"
5148 Some openSuSE-derived distro.
5149
5150 "ttylinux"
5151 ttylinux.
5152
5153 "ubuntu"
5154 Ubuntu.
5155
5156 "unknown"
5157 The distro could not be determined.
5158
5159 "voidlinux"
5160 Void Linux.
5161
5162 "windows"
5163 Windows does not have distributions. This string is returned if
5164 the OS type is Windows.
5165
5166 Future versions of libguestfs may return other strings here. The
5167 caller should be prepared to handle any string.
5168
5169 Please read "INSPECTION" in guestfs(3) for more details.
5170
5171 inspect-get-drive-mappings
5172 inspect-get-drive-mappings root
5173
5174 This call is useful for Windows which uses a primitive system of
5175 assigning drive letters (like C:\) to partitions. This inspection API
5176 examines the Windows Registry to find out how disks/partitions are
5177 mapped to drive letters, and returns a hash table as in the example
5178 below:
5179
5180 C => /dev/vda2
5181 E => /dev/vdb1
5182 F => /dev/vdc1
5183
5184 Note that keys are drive letters. For Windows, the key is case
5185 insensitive and just contains the drive letter, without the customary
5186 colon separator character.
5187
5188 In future we may support other operating systems that also used drive
5189 letters, but the keys for those might not be case insensitive and might
5190 be longer than 1 character. For example in OS-9, hard drives were
5191 named "h0", "h1" etc.
5192
5193 For Windows guests, currently only hard drive mappings are returned.
5194 Removable disks (eg. DVD-ROMs) are ignored.
5195
5196 For guests that do not use drive mappings, or if the drive mappings
5197 could not be determined, this returns an empty hash table.
5198
5199 Please read "INSPECTION" in guestfs(3) for more details. See also
5200 "inspect-get-mountpoints", "inspect-get-filesystems".
5201
5202 inspect-get-filesystems
5203 inspect-get-filesystems root
5204
5205 This returns a list of all the filesystems that we think are associated
5206 with this operating system. This includes the root filesystem, other
5207 ordinary filesystems, and non-mounted devices like swap partitions.
5208
5209 In the case of a multi-boot virtual machine, it is possible for a
5210 filesystem to be shared between operating systems.
5211
5212 Please read "INSPECTION" in guestfs(3) for more details. See also
5213 "inspect-get-mountpoints".
5214
5215 inspect-get-format
5216 inspect-get-format root
5217
5218 Before libguestfs 1.38, there was some unreliable support for detecting
5219 installer CDs. This API would return:
5220
5221 "installed"
5222 This is an installed operating system.
5223
5224 "installer"
5225 The disk image being inspected is not an installed operating
5226 system, but a bootable install disk, live CD, or similar.
5227
5228 "unknown"
5229 The format of this disk image is not known.
5230
5231 In libguestfs ≥ 1.38, this only returns "installed". Use libosinfo
5232 directly to detect installer CDs.
5233
5234 Please read "INSPECTION" in guestfs(3) for more details.
5235
5236 This function is deprecated. There is no replacement. Consult the API
5237 documentation in guestfs(3) for further information.
5238
5239 Deprecated functions will not be removed from the API, but the fact
5240 that they are deprecated indicates that there are problems with correct
5241 use of these functions.
5242
5243 inspect-get-hostname
5244 inspect-get-hostname root
5245
5246 This function returns the hostname of the operating system as found by
5247 inspection of the guest’s configuration files.
5248
5249 If the hostname could not be determined, then the string "unknown" is
5250 returned.
5251
5252 Please read "INSPECTION" in guestfs(3) for more details.
5253
5254 inspect-get-icon
5255 inspect-get-icon root [favicon:true|false] [highquality:true|false]
5256
5257 This function returns an icon corresponding to the inspected operating
5258 system. The icon is returned as a buffer containing a PNG image (re-
5259 encoded to PNG if necessary).
5260
5261 If it was not possible to get an icon this function returns a zero-
5262 length (non-NULL) buffer. Callers must check for this case.
5263
5264 Libguestfs will start by looking for a file called /etc/favicon.png or
5265 C:\etc\favicon.png and if it has the correct format, the contents of
5266 this file will be returned. You can disable favicons by passing the
5267 optional "favicon" boolean as false (default is true).
5268
5269 If finding the favicon fails, then we look in other places in the guest
5270 for a suitable icon.
5271
5272 If the optional "highquality" boolean is true then only high quality
5273 icons are returned, which means only icons of high resolution with an
5274 alpha channel. The default (false) is to return any icon we can, even
5275 if it is of substandard quality.
5276
5277 Notes:
5278
5279 • Unlike most other inspection API calls, the guest’s disks must be
5280 mounted up before you call this, since it needs to read information
5281 from the guest filesystem during the call.
5282
5283 • Security: The icon data comes from the untrusted guest, and should
5284 be treated with caution. PNG files have been known to contain
5285 exploits. Ensure that libpng (or other relevant libraries) are
5286 fully up to date before trying to process or display the icon.
5287
5288 • The PNG image returned can be any size. It might not be square.
5289 Libguestfs tries to return the largest, highest quality icon
5290 available. The application must scale the icon to the required
5291 size.
5292
5293 • Extracting icons from Windows guests requires the external
5294 wrestool(1) program from the "icoutils" package, and several
5295 programs (bmptopnm(1), pnmtopng(1), pamcut(1)) from the "netpbm"
5296 package. These must be installed separately.
5297
5298 • Operating system icons are usually trademarks. Seek legal advice
5299 before using trademarks in applications.
5300
5301 This command has one or more optional arguments. See "OPTIONAL
5302 ARGUMENTS".
5303
5304 inspect-get-major-version
5305 inspect-get-major-version root
5306
5307 This returns the major version number of the inspected operating
5308 system.
5309
5310 Windows uses a consistent versioning scheme which is not reflected in
5311 the popular public names used by the operating system. Notably the
5312 operating system known as "Windows 7" is really version 6.1 (ie. major
5313 = 6, minor = 1). You can find out the real versions corresponding to
5314 releases of Windows by consulting Wikipedia or MSDN.
5315
5316 If the version could not be determined, then 0 is returned.
5317
5318 Please read "INSPECTION" in guestfs(3) for more details.
5319
5320 inspect-get-minor-version
5321 inspect-get-minor-version root
5322
5323 This returns the minor version number of the inspected operating
5324 system.
5325
5326 If the version could not be determined, then 0 is returned.
5327
5328 Please read "INSPECTION" in guestfs(3) for more details. See also
5329 "inspect-get-major-version".
5330
5331 inspect-get-mountpoints
5332 inspect-get-mountpoints root
5333
5334 This returns a hash of where we think the filesystems associated with
5335 this operating system should be mounted. Callers should note that this
5336 is at best an educated guess made by reading configuration files such
5337 as /etc/fstab. In particular note that this may return filesystems
5338 which are non-existent or not mountable and callers should be prepared
5339 to handle or ignore failures if they try to mount them.
5340
5341 Each element in the returned hashtable has a key which is the path of
5342 the mountpoint (eg. /boot) and a value which is the filesystem that
5343 would be mounted there (eg. /dev/sda1).
5344
5345 Non-mounted devices such as swap devices are not returned in this list.
5346
5347 For operating systems like Windows which still use drive letters, this
5348 call will only return an entry for the first drive "mounted on" /. For
5349 information about the mapping of drive letters to partitions, see
5350 "inspect-get-drive-mappings".
5351
5352 Please read "INSPECTION" in guestfs(3) for more details. See also
5353 "inspect-get-filesystems".
5354
5355 inspect-get-osinfo
5356 inspect-get-osinfo root
5357
5358 This function returns a possible short ID for libosinfo corresponding
5359 to the guest.
5360
5361 Note: The returned ID is only a guess by libguestfs, and nothing
5362 ensures that it actually exists in osinfo-db.
5363
5364 If no ID could not be determined, then the string "unknown" is
5365 returned.
5366
5367 inspect-get-package-format
5368 inspect-get-package-format root
5369
5370 This function and "inspect-get-package-management" return the package
5371 format and package management tool used by the inspected operating
5372 system. For example for Fedora these functions would return "rpm"
5373 (package format), and "yum" or "dnf" (package management).
5374
5375 This returns the string "unknown" if we could not determine the package
5376 format or if the operating system does not have a real packaging system
5377 (eg. Windows).
5378
5379 Possible strings include: "rpm", "deb", "ebuild", "pisi", "pacman",
5380 "pkgsrc", "apk", "xbps". Future versions of libguestfs may return
5381 other strings.
5382
5383 Please read "INSPECTION" in guestfs(3) for more details.
5384
5385 inspect-get-package-management
5386 inspect-get-package-management root
5387
5388 "inspect-get-package-format" and this function return the package
5389 format and package management tool used by the inspected operating
5390 system. For example for Fedora these functions would return "rpm"
5391 (package format), and "yum" or "dnf" (package management).
5392
5393 This returns the string "unknown" if we could not determine the package
5394 management tool or if the operating system does not have a real
5395 packaging system (eg. Windows).
5396
5397 Possible strings include: "yum", "dnf", "up2date", "apt" (for all
5398 Debian derivatives), "portage", "pisi", "pacman", "urpmi", "zypper",
5399 "apk", "xbps". Future versions of libguestfs may return other strings.
5400
5401 Please read "INSPECTION" in guestfs(3) for more details.
5402
5403 inspect-get-product-name
5404 inspect-get-product-name root
5405
5406 This returns the product name of the inspected operating system. The
5407 product name is generally some freeform string which can be displayed
5408 to the user, but should not be parsed by programs.
5409
5410 If the product name could not be determined, then the string "unknown"
5411 is returned.
5412
5413 Please read "INSPECTION" in guestfs(3) for more details.
5414
5415 inspect-get-product-variant
5416 inspect-get-product-variant root
5417
5418 This returns the product variant of the inspected operating system.
5419
5420 For Windows guests, this returns the contents of the Registry key
5421 "HKLM\Software\Microsoft\Windows NT\CurrentVersion" "InstallationType"
5422 which is usually a string such as "Client" or "Server" (other values
5423 are possible). This can be used to distinguish consumer and enterprise
5424 versions of Windows that have the same version number (for example,
5425 Windows 7 and Windows 2008 Server are both version 6.1, but the former
5426 is "Client" and the latter is "Server").
5427
5428 For enterprise Linux guests, in future we intend this to return the
5429 product variant such as "Desktop", "Server" and so on. But this is not
5430 implemented at present.
5431
5432 If the product variant could not be determined, then the string
5433 "unknown" is returned.
5434
5435 Please read "INSPECTION" in guestfs(3) for more details. See also
5436 "inspect-get-product-name", "inspect-get-major-version".
5437
5438 inspect-get-roots
5439 inspect-get-roots
5440
5441 This function is a convenient way to get the list of root devices, as
5442 returned from a previous call to "inspect-os", but without redoing the
5443 whole inspection process.
5444
5445 This returns an empty list if either no root devices were found or the
5446 caller has not called "inspect-os".
5447
5448 Please read "INSPECTION" in guestfs(3) for more details.
5449
5450 inspect-get-type
5451 inspect-get-type root
5452
5453 This returns the type of the inspected operating system. Currently
5454 defined types are:
5455
5456 "linux"
5457 Any Linux-based operating system.
5458
5459 "windows"
5460 Any Microsoft Windows operating system.
5461
5462 "freebsd"
5463 FreeBSD.
5464
5465 "netbsd"
5466 NetBSD.
5467
5468 "openbsd"
5469 OpenBSD.
5470
5471 "hurd"
5472 GNU/Hurd.
5473
5474 "dos"
5475 MS-DOS, FreeDOS and others.
5476
5477 "minix"
5478 MINIX.
5479
5480 "unknown"
5481 The operating system type could not be determined.
5482
5483 Future versions of libguestfs may return other strings here. The
5484 caller should be prepared to handle any string.
5485
5486 Please read "INSPECTION" in guestfs(3) for more details.
5487
5488 inspect-get-windows-current-control-set
5489 inspect-get-windows-current-control-set root
5490
5491 This returns the Windows CurrentControlSet of the inspected guest. The
5492 CurrentControlSet is a registry key name such as "ControlSet001".
5493
5494 This call assumes that the guest is Windows and that the Registry could
5495 be examined by inspection. If this is not the case then an error is
5496 returned.
5497
5498 Please read "INSPECTION" in guestfs(3) for more details.
5499
5500 inspect-get-windows-software-hive
5501 inspect-get-windows-software-hive root
5502
5503 This returns the path to the hive (binary Windows Registry file)
5504 corresponding to HKLM\SOFTWARE.
5505
5506 This call assumes that the guest is Windows and that the guest has a
5507 software hive file with the right name. If this is not the case then
5508 an error is returned. This call does not check that the hive is a
5509 valid Windows Registry hive.
5510
5511 You can use "hivex-open" to read or write to the hive.
5512
5513 Please read "INSPECTION" in guestfs(3) for more details.
5514
5515 inspect-get-windows-system-hive
5516 inspect-get-windows-system-hive root
5517
5518 This returns the path to the hive (binary Windows Registry file)
5519 corresponding to HKLM\SYSTEM.
5520
5521 This call assumes that the guest is Windows and that the guest has a
5522 system hive file with the right name. If this is not the case then an
5523 error is returned. This call does not check that the hive is a valid
5524 Windows Registry hive.
5525
5526 You can use "hivex-open" to read or write to the hive.
5527
5528 Please read "INSPECTION" in guestfs(3) for more details.
5529
5530 inspect-get-windows-systemroot
5531 inspect-get-windows-systemroot root
5532
5533 This returns the Windows systemroot of the inspected guest. The
5534 systemroot is a directory path such as /WINDOWS.
5535
5536 This call assumes that the guest is Windows and that the systemroot
5537 could be determined by inspection. If this is not the case then an
5538 error is returned.
5539
5540 Please read "INSPECTION" in guestfs(3) for more details.
5541
5542 inspect-is-live
5543 inspect-is-live root
5544
5545 This is deprecated and always returns "false".
5546
5547 Please read "INSPECTION" in guestfs(3) for more details.
5548
5549 This function is deprecated. There is no replacement. Consult the API
5550 documentation in guestfs(3) for further information.
5551
5552 Deprecated functions will not be removed from the API, but the fact
5553 that they are deprecated indicates that there are problems with correct
5554 use of these functions.
5555
5556 inspect-is-multipart
5557 inspect-is-multipart root
5558
5559 This is deprecated and always returns "false".
5560
5561 Please read "INSPECTION" in guestfs(3) for more details.
5562
5563 This function is deprecated. There is no replacement. Consult the API
5564 documentation in guestfs(3) for further information.
5565
5566 Deprecated functions will not be removed from the API, but the fact
5567 that they are deprecated indicates that there are problems with correct
5568 use of these functions.
5569
5570 inspect-is-netinst
5571 inspect-is-netinst root
5572
5573 This is deprecated and always returns "false".
5574
5575 Please read "INSPECTION" in guestfs(3) for more details.
5576
5577 This function is deprecated. There is no replacement. Consult the API
5578 documentation in guestfs(3) for further information.
5579
5580 Deprecated functions will not be removed from the API, but the fact
5581 that they are deprecated indicates that there are problems with correct
5582 use of these functions.
5583
5584 inspect-list-applications
5585 inspect-list-applications root
5586
5587 Return the list of applications installed in the operating system.
5588
5589 Note: This call works differently from other parts of the inspection
5590 API. You have to call "inspect-os", then "inspect-get-mountpoints",
5591 then mount up the disks, before calling this. Listing applications is
5592 a significantly more difficult operation which requires access to the
5593 full filesystem. Also note that unlike the other "inspect-get-*" calls
5594 which are just returning data cached in the libguestfs handle, this
5595 call actually reads parts of the mounted filesystems during the call.
5596
5597 This returns an empty list if the inspection code was not able to
5598 determine the list of applications.
5599
5600 The application structure contains the following fields:
5601
5602 "app_name"
5603 The name of the application. For Linux guests, this is the package
5604 name.
5605
5606 "app_display_name"
5607 The display name of the application, sometimes localized to the
5608 install language of the guest operating system.
5609
5610 If unavailable this is returned as an empty string "". Callers
5611 needing to display something can use "app_name" instead.
5612
5613 "app_epoch"
5614 For package managers which use epochs, this contains the epoch of
5615 the package (an integer). If unavailable, this is returned as 0.
5616
5617 "app_version"
5618 The version string of the application or package. If unavailable
5619 this is returned as an empty string "".
5620
5621 "app_release"
5622 The release string of the application or package, for package
5623 managers that use this. If unavailable this is returned as an
5624 empty string "".
5625
5626 "app_install_path"
5627 The installation path of the application (on operating systems such
5628 as Windows which use installation paths). This path is in the
5629 format used by the guest operating system, it is not a libguestfs
5630 path.
5631
5632 If unavailable this is returned as an empty string "".
5633
5634 "app_trans_path"
5635 The install path translated into a libguestfs path. If unavailable
5636 this is returned as an empty string "".
5637
5638 "app_publisher"
5639 The name of the publisher of the application, for package managers
5640 that use this. If unavailable this is returned as an empty string
5641 "".
5642
5643 "app_url"
5644 The URL (eg. upstream URL) of the application. If unavailable this
5645 is returned as an empty string "".
5646
5647 "app_source_package"
5648 For packaging systems which support this, the name of the source
5649 package. If unavailable this is returned as an empty string "".
5650
5651 "app_summary"
5652 A short (usually one line) description of the application or
5653 package. If unavailable this is returned as an empty string "".
5654
5655 "app_description"
5656 A longer description of the application or package. If unavailable
5657 this is returned as an empty string "".
5658
5659 Please read "INSPECTION" in guestfs(3) for more details.
5660
5661 This function is deprecated. In new code, use the
5662 "inspect-list-applications2" call instead.
5663
5664 Deprecated functions will not be removed from the API, but the fact
5665 that they are deprecated indicates that there are problems with correct
5666 use of these functions.
5667
5668 inspect-list-applications2
5669 inspect-list-applications2 root
5670
5671 Return the list of applications installed in the operating system.
5672
5673 Note: This call works differently from other parts of the inspection
5674 API. You have to call "inspect-os", then "inspect-get-mountpoints",
5675 then mount up the disks, before calling this. Listing applications is
5676 a significantly more difficult operation which requires access to the
5677 full filesystem. Also note that unlike the other "inspect-get-*" calls
5678 which are just returning data cached in the libguestfs handle, this
5679 call actually reads parts of the mounted filesystems during the call.
5680
5681 This returns an empty list if the inspection code was not able to
5682 determine the list of applications.
5683
5684 The application structure contains the following fields:
5685
5686 "app2_name"
5687 The name of the application. For Linux guests, this is the package
5688 name.
5689
5690 "app2_display_name"
5691 The display name of the application, sometimes localized to the
5692 install language of the guest operating system.
5693
5694 If unavailable this is returned as an empty string "". Callers
5695 needing to display something can use "app2_name" instead.
5696
5697 "app2_epoch"
5698 For package managers which use epochs, this contains the epoch of
5699 the package (an integer). If unavailable, this is returned as 0.
5700
5701 "app2_version"
5702 The version string of the application or package. If unavailable
5703 this is returned as an empty string "".
5704
5705 "app2_release"
5706 The release string of the application or package, for package
5707 managers that use this. If unavailable this is returned as an
5708 empty string "".
5709
5710 "app2_arch"
5711 The architecture string of the application or package, for package
5712 managers that use this. If unavailable this is returned as an
5713 empty string "".
5714
5715 "app2_install_path"
5716 The installation path of the application (on operating systems such
5717 as Windows which use installation paths). This path is in the
5718 format used by the guest operating system, it is not a libguestfs
5719 path.
5720
5721 If unavailable this is returned as an empty string "".
5722
5723 "app2_trans_path"
5724 The install path translated into a libguestfs path. If unavailable
5725 this is returned as an empty string "".
5726
5727 "app2_publisher"
5728 The name of the publisher of the application, for package managers
5729 that use this. If unavailable this is returned as an empty string
5730 "".
5731
5732 "app2_url"
5733 The URL (eg. upstream URL) of the application. If unavailable this
5734 is returned as an empty string "".
5735
5736 "app2_source_package"
5737 For packaging systems which support this, the name of the source
5738 package. If unavailable this is returned as an empty string "".
5739
5740 "app2_summary"
5741 A short (usually one line) description of the application or
5742 package. If unavailable this is returned as an empty string "".
5743
5744 "app2_description"
5745 A longer description of the application or package. If unavailable
5746 this is returned as an empty string "".
5747
5748 Please read "INSPECTION" in guestfs(3) for more details.
5749
5750 inspect-os
5751 inspect-os
5752
5753 This function uses other libguestfs functions and certain heuristics to
5754 inspect the disk(s) (usually disks belonging to a virtual machine),
5755 looking for operating systems.
5756
5757 The list returned is empty if no operating systems were found.
5758
5759 If one operating system was found, then this returns a list with a
5760 single element, which is the name of the root filesystem of this
5761 operating system. It is also possible for this function to return a
5762 list containing more than one element, indicating a dual-boot or multi-
5763 boot virtual machine, with each element being the root filesystem of
5764 one of the operating systems.
5765
5766 You can pass the root string(s) returned to other "inspect-get-*"
5767 functions in order to query further information about each operating
5768 system, such as the name and version.
5769
5770 This function uses other libguestfs features such as "mount-ro" and
5771 "umount-all" in order to mount and unmount filesystems and look at the
5772 contents. This should be called with no disks currently mounted. The
5773 function may also use Augeas, so any existing Augeas handle will be
5774 closed.
5775
5776 This function cannot decrypt encrypted disks. The caller must do that
5777 first (supplying the necessary keys) if the disk is encrypted.
5778
5779 Please read "INSPECTION" in guestfs(3) for more details.
5780
5781 See also "list-filesystems".
5782
5783 is-blockdev
5784 is-blockdev-opts
5785 is-blockdev path [followsymlinks:true|false]
5786
5787 This returns "true" if and only if there is a block device with the
5788 given "path" name.
5789
5790 If the optional flag "followsymlinks" is true, then a symlink (or chain
5791 of symlinks) that ends with a block device also causes the function to
5792 return true.
5793
5794 This call only looks at files within the guest filesystem. Libguestfs
5795 partitions and block devices (eg. /dev/sda) cannot be used as the
5796 "path" parameter of this call.
5797
5798 See also "stat".
5799
5800 This command has one or more optional arguments. See "OPTIONAL
5801 ARGUMENTS".
5802
5803 is-chardev
5804 is-chardev-opts
5805 is-chardev path [followsymlinks:true|false]
5806
5807 This returns "true" if and only if there is a character device with the
5808 given "path" name.
5809
5810 If the optional flag "followsymlinks" is true, then a symlink (or chain
5811 of symlinks) that ends with a chardev also causes the function to
5812 return true.
5813
5814 See also "stat".
5815
5816 This command has one or more optional arguments. See "OPTIONAL
5817 ARGUMENTS".
5818
5819 is-config
5820 is-config
5821
5822 This returns true iff this handle is being configured (in the "CONFIG"
5823 state).
5824
5825 For more information on states, see guestfs(3).
5826
5827 is-dir
5828 is-dir-opts
5829 is-dir path [followsymlinks:true|false]
5830
5831 This returns "true" if and only if there is a directory with the given
5832 "path" name. Note that it returns false for other objects like files.
5833
5834 If the optional flag "followsymlinks" is true, then a symlink (or chain
5835 of symlinks) that ends with a directory also causes the function to
5836 return true.
5837
5838 See also "stat".
5839
5840 This command has one or more optional arguments. See "OPTIONAL
5841 ARGUMENTS".
5842
5843 is-fifo
5844 is-fifo-opts
5845 is-fifo path [followsymlinks:true|false]
5846
5847 This returns "true" if and only if there is a FIFO (named pipe) with
5848 the given "path" name.
5849
5850 If the optional flag "followsymlinks" is true, then a symlink (or chain
5851 of symlinks) that ends with a FIFO also causes the function to return
5852 true.
5853
5854 See also "stat".
5855
5856 This command has one or more optional arguments. See "OPTIONAL
5857 ARGUMENTS".
5858
5859 is-file
5860 is-file-opts
5861 is-file path [followsymlinks:true|false]
5862
5863 This returns "true" if and only if there is a regular file with the
5864 given "path" name. Note that it returns false for other objects like
5865 directories.
5866
5867 If the optional flag "followsymlinks" is true, then a symlink (or chain
5868 of symlinks) that ends with a file also causes the function to return
5869 true.
5870
5871 See also "stat".
5872
5873 This command has one or more optional arguments. See "OPTIONAL
5874 ARGUMENTS".
5875
5876 is-lv
5877 is-lv mountable
5878
5879 This command tests whether "mountable" is a logical volume, and returns
5880 true iff this is the case.
5881
5882 is-socket
5883 is-socket-opts
5884 is-socket path [followsymlinks:true|false]
5885
5886 This returns "true" if and only if there is a Unix domain socket with
5887 the given "path" name.
5888
5889 If the optional flag "followsymlinks" is true, then a symlink (or chain
5890 of symlinks) that ends with a socket also causes the function to return
5891 true.
5892
5893 See also "stat".
5894
5895 This command has one or more optional arguments. See "OPTIONAL
5896 ARGUMENTS".
5897
5898 is-symlink
5899 is-symlink path
5900
5901 This returns "true" if and only if there is a symbolic link with the
5902 given "path" name.
5903
5904 See also "stat".
5905
5906 is-whole-device
5907 is-whole-device device
5908
5909 This returns "true" if and only if "device" refers to a whole block
5910 device. That is, not a partition or a logical device.
5911
5912 is-zero
5913 is-zero path
5914
5915 This returns true iff the file exists and the file is empty or it
5916 contains all zero bytes.
5917
5918 is-zero-device
5919 is-zero-device device
5920
5921 This returns true iff the device exists and contains all zero bytes.
5922
5923 Note that for large devices this can take a long time to run.
5924
5925 isoinfo
5926 isoinfo isofile
5927
5928 This is the same as "isoinfo-device" except that it works for an ISO
5929 file located inside some other mounted filesystem. Note that in the
5930 common case where you have added an ISO file as a libguestfs device,
5931 you would not call this. Instead you would call "isoinfo-device".
5932
5933 isoinfo-device
5934 isoinfo-device device
5935
5936 "device" is an ISO device. This returns a struct of information read
5937 from the primary volume descriptor (the ISO equivalent of the
5938 superblock) of the device.
5939
5940 Usually it is more efficient to use the isoinfo(1) command with the -d
5941 option on the host to analyze ISO files, instead of going through
5942 libguestfs.
5943
5944 For information on the primary volume descriptor fields, see
5945 https://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor
5946
5947 journal-close
5948 journal-close
5949
5950 Close the journal handle.
5951
5952 This command depends on the feature "journal". See also "feature-
5953 available".
5954
5955 journal-get
5956 journal-get
5957
5958 Read the current journal entry. This returns all the fields in the
5959 journal as a set of "(attrname, attrval)" pairs. The "attrname" is the
5960 field name (a string).
5961
5962 The "attrval" is the field value (a binary blob, often but not always a
5963 string). Please note that "attrval" is a byte array, not a
5964 \0-terminated C string.
5965
5966 The length of data may be truncated to the data threshold (see:
5967 "journal-set-data-threshold", "journal-get-data-threshold").
5968
5969 If you set the data threshold to unlimited (0) then this call can read
5970 a journal entry of any size, ie. it is not limited by the libguestfs
5971 protocol.
5972
5973 This command depends on the feature "journal". See also "feature-
5974 available".
5975
5976 journal-get-data-threshold
5977 journal-get-data-threshold
5978
5979 Get the current data threshold for reading journal entries. This is a
5980 hint to the journal that it may truncate data fields to this size when
5981 reading them (note also that it may not truncate them). If this
5982 returns 0, then the threshold is unlimited.
5983
5984 See also "journal-set-data-threshold".
5985
5986 This command depends on the feature "journal". See also "feature-
5987 available".
5988
5989 journal-get-realtime-usec
5990 journal-get-realtime-usec
5991
5992 Get the realtime (wallclock) timestamp of the current journal entry.
5993
5994 This command depends on the feature "journal". See also "feature-
5995 available".
5996
5997 journal-next
5998 journal-next
5999
6000 Move to the next journal entry. You have to call this at least once
6001 after opening the handle before you are able to read data.
6002
6003 The returned boolean tells you if there are any more journal records to
6004 read. "true" means you can read the next record (eg. using "journal-
6005 get"), and "false" means you have reached the end of the journal.
6006
6007 This command depends on the feature "journal". See also "feature-
6008 available".
6009
6010 journal-open
6011 journal-open directory
6012
6013 Open the systemd journal located in directory. Any previously opened
6014 journal handle is closed.
6015
6016 The contents of the journal can be read using "journal-next" and
6017 "journal-get".
6018
6019 After you have finished using the journal, you should close the handle
6020 by calling "journal-close".
6021
6022 This command depends on the feature "journal". See also "feature-
6023 available".
6024
6025 journal-set-data-threshold
6026 journal-set-data-threshold threshold
6027
6028 Set the data threshold for reading journal entries. This is a hint to
6029 the journal that it may truncate data fields to this size when reading
6030 them (note also that it may not truncate them). If you set this to 0,
6031 then the threshold is unlimited.
6032
6033 See also "journal-get-data-threshold".
6034
6035 This command depends on the feature "journal". See also "feature-
6036 available".
6037
6038 journal-skip
6039 journal-skip skip
6040
6041 Skip forwards ("skip ≥ 0") or backwards ("skip < 0") in the journal.
6042
6043 The number of entries actually skipped is returned (note "rskip ≥ 0").
6044 If this is not the same as the absolute value of the skip parameter
6045 ("|skip|") you passed in then it means you have reached the end or the
6046 start of the journal.
6047
6048 This command depends on the feature "journal". See also "feature-
6049 available".
6050
6051 kill-subprocess
6052 kill-subprocess
6053
6054 This kills the hypervisor.
6055
6056 Do not call this. See: "shutdown" instead.
6057
6058 This function is deprecated. In new code, use the "shutdown" call
6059 instead.
6060
6061 Deprecated functions will not be removed from the API, but the fact
6062 that they are deprecated indicates that there are problems with correct
6063 use of these functions.
6064
6065 launch
6066 run
6067 launch
6068
6069 You should call this after configuring the handle (eg. adding drives)
6070 but before performing any actions.
6071
6072 Do not call "launch" twice on the same handle. Although it will not
6073 give an error (for historical reasons), the precise behaviour when you
6074 do this is not well defined. Handles are very cheap to create, so
6075 create a new one for each launch.
6076
6077 lchown
6078 lchown owner group path
6079
6080 Change the file owner to "owner" and group to "group". This is like
6081 "chown" but if "path" is a symlink then the link itself is changed, not
6082 the target.
6083
6084 Only numeric uid and gid are supported. If you want to use names, you
6085 will need to locate and parse the password file yourself (Augeas
6086 support makes this relatively easy).
6087
6088 ldmtool-create-all
6089 ldmtool-create-all
6090
6091 This function scans all block devices looking for Windows dynamic disk
6092 volumes and partitions, and creates devices for any that were found.
6093
6094 Call "list-ldm-volumes" and "list-ldm-partitions" to return all
6095 devices.
6096
6097 Note that you don't normally need to call this explicitly, since it is
6098 done automatically at "launch" time.
6099
6100 This command depends on the feature "ldm". See also "feature-
6101 available".
6102
6103 ldmtool-diskgroup-disks
6104 ldmtool-diskgroup-disks diskgroup
6105
6106 Return the disks in a Windows dynamic disk group. The "diskgroup"
6107 parameter should be the GUID of a disk group, one element from the list
6108 returned by "ldmtool-scan".
6109
6110 This command depends on the feature "ldm". See also "feature-
6111 available".
6112
6113 ldmtool-diskgroup-name
6114 ldmtool-diskgroup-name diskgroup
6115
6116 Return the name of a Windows dynamic disk group. The "diskgroup"
6117 parameter should be the GUID of a disk group, one element from the list
6118 returned by "ldmtool-scan".
6119
6120 This command depends on the feature "ldm". See also "feature-
6121 available".
6122
6123 ldmtool-diskgroup-volumes
6124 ldmtool-diskgroup-volumes diskgroup
6125
6126 Return the volumes in a Windows dynamic disk group. The "diskgroup"
6127 parameter should be the GUID of a disk group, one element from the list
6128 returned by "ldmtool-scan".
6129
6130 This command depends on the feature "ldm". See also "feature-
6131 available".
6132
6133 ldmtool-remove-all
6134 ldmtool-remove-all
6135
6136 This is essentially the opposite of "ldmtool-create-all". It removes
6137 the device mapper mappings for all Windows dynamic disk volumes
6138
6139 This command depends on the feature "ldm". See also "feature-
6140 available".
6141
6142 ldmtool-scan
6143 ldmtool-scan
6144
6145 This function scans for Windows dynamic disks. It returns a list of
6146 identifiers (GUIDs) for all disk groups that were found. These
6147 identifiers can be passed to other "ldmtool-*" functions.
6148
6149 This function scans all block devices. To scan a subset of block
6150 devices, call "ldmtool-scan-devices" instead.
6151
6152 This command depends on the feature "ldm". See also "feature-
6153 available".
6154
6155 ldmtool-scan-devices
6156 ldmtool-scan-devices 'devices ...'
6157
6158 This function scans for Windows dynamic disks. It returns a list of
6159 identifiers (GUIDs) for all disk groups that were found. These
6160 identifiers can be passed to other "ldmtool-*" functions.
6161
6162 The parameter "devices" is a list of block devices which are scanned.
6163 If this list is empty, all block devices are scanned.
6164
6165 This command depends on the feature "ldm". See also "feature-
6166 available".
6167
6168 ldmtool-volume-hint
6169 ldmtool-volume-hint diskgroup volume
6170
6171 Return the hint field of the volume named "volume" in the disk group
6172 with GUID "diskgroup". This may not be defined, in which case the
6173 empty string is returned. The hint field is often, though not always,
6174 the name of a Windows drive, eg. "E:".
6175
6176 This command depends on the feature "ldm". See also "feature-
6177 available".
6178
6179 ldmtool-volume-partitions
6180 ldmtool-volume-partitions diskgroup volume
6181
6182 Return the list of partitions in the volume named "volume" in the disk
6183 group with GUID "diskgroup".
6184
6185 This command depends on the feature "ldm". See also "feature-
6186 available".
6187
6188 ldmtool-volume-type
6189 ldmtool-volume-type diskgroup volume
6190
6191 Return the type of the volume named "volume" in the disk group with
6192 GUID "diskgroup".
6193
6194 Possible volume types that can be returned here include: "simple",
6195 "spanned", "striped", "mirrored", "raid5". Other types may also be
6196 returned.
6197
6198 This command depends on the feature "ldm". See also "feature-
6199 available".
6200
6201 lgetxattr
6202 lgetxattr path name
6203
6204 Get a single extended attribute from file "path" named "name". If
6205 "path" is a symlink, then this call returns an extended attribute from
6206 the symlink.
6207
6208 Normally it is better to get all extended attributes from a file in one
6209 go by calling "getxattrs". However some Linux filesystem
6210 implementations are buggy and do not provide a way to list out
6211 attributes. For these filesystems (notably ntfs-3g) you have to know
6212 the names of the extended attributes you want in advance and call this
6213 function.
6214
6215 Extended attribute values are blobs of binary data. If there is no
6216 extended attribute named "name", this returns an error.
6217
6218 See also: "lgetxattrs", "getxattr", attr(5).
6219
6220 This command depends on the feature "linuxxattrs". See also "feature-
6221 available".
6222
6223 lgetxattrs
6224 lgetxattrs path
6225
6226 This is the same as "getxattrs", but if "path" is a symbolic link, then
6227 it returns the extended attributes of the link itself.
6228
6229 This command depends on the feature "linuxxattrs". See also "feature-
6230 available".
6231
6232 list-9p
6233 list-9p
6234
6235 This call does nothing and returns an error.
6236
6237 This function is deprecated. There is no replacement. Consult the API
6238 documentation in guestfs(3) for further information.
6239
6240 Deprecated functions will not be removed from the API, but the fact
6241 that they are deprecated indicates that there are problems with correct
6242 use of these functions.
6243
6244 list-devices
6245 list-devices
6246
6247 List all the block devices.
6248
6249 The full block device names are returned, eg. /dev/sda.
6250
6251 See also "list-filesystems".
6252
6253 list-disk-labels
6254 list-disk-labels
6255
6256 If you add drives using the optional "label" parameter of "add-drive-
6257 opts", you can use this call to map between disk labels, and raw block
6258 device and partition names (like /dev/sda and /dev/sda1).
6259
6260 This returns a hashtable, where keys are the disk labels (without the
6261 /dev/disk/guestfs prefix), and the values are the full raw block device
6262 and partition names (eg. /dev/sda and /dev/sda1).
6263
6264 list-dm-devices
6265 list-dm-devices
6266
6267 List all device mapper devices.
6268
6269 The returned list contains /dev/mapper/* devices, eg. ones created by a
6270 previous call to "luks-open".
6271
6272 Device mapper devices which correspond to logical volumes are not
6273 returned in this list. Call "lvs" if you want to list logical volumes.
6274
6275 list-filesystems
6276 list-filesystems
6277
6278 This inspection command looks for filesystems on partitions, block
6279 devices and logical volumes, returning a list of "mountables"
6280 containing filesystems and their type.
6281
6282 The return value is a hash, where the keys are the devices containing
6283 filesystems, and the values are the filesystem types. For example:
6284
6285 "/dev/sda1" => "ntfs"
6286 "/dev/sda2" => "ext2"
6287 "/dev/vg_guest/lv_root" => "ext4"
6288 "/dev/vg_guest/lv_swap" => "swap"
6289
6290 The key is not necessarily a block device. It may also be an opaque
6291 ‘mountable’ string which can be passed to "mount".
6292
6293 The value can have the special value "unknown", meaning the content of
6294 the device is undetermined or empty. "swap" means a Linux swap
6295 partition.
6296
6297 In libguestfs ≤ 1.36 this command ran other libguestfs commands, which
6298 might have included "mount" and "umount", and therefore you had to use
6299 this soon after launch and only when nothing else was mounted. This
6300 restriction is removed in libguestfs ≥ 1.38.
6301
6302 Not all of the filesystems returned will be mountable. In particular,
6303 swap partitions are returned in the list. Also this command does not
6304 check that each filesystem found is valid and mountable, and some
6305 filesystems might be mountable but require special options.
6306 Filesystems may not all belong to a single logical operating system
6307 (use "inspect-os" to look for OSes).
6308
6309 list-ldm-partitions
6310 list-ldm-partitions
6311
6312 This function returns all Windows dynamic disk partitions that were
6313 found at launch time. It returns a list of device names.
6314
6315 This command depends on the feature "ldm". See also "feature-
6316 available".
6317
6318 list-ldm-volumes
6319 list-ldm-volumes
6320
6321 This function returns all Windows dynamic disk volumes that were found
6322 at launch time. It returns a list of device names.
6323
6324 This command depends on the feature "ldm". See also "feature-
6325 available".
6326
6327 list-md-devices
6328 list-md-devices
6329
6330 List all Linux md devices.
6331
6332 list-partitions
6333 list-partitions
6334
6335 List all the partitions detected on all block devices.
6336
6337 The full partition device names are returned, eg. /dev/sda1
6338
6339 This does not return logical volumes. For that you will need to call
6340 "lvs".
6341
6342 See also "list-filesystems".
6343
6344 ll
6345 ll directory
6346
6347 List the files in directory (relative to the root directory, there is
6348 no cwd) in the format of "ls -la".
6349
6350 This command is mostly useful for interactive sessions. It is not
6351 intended that you try to parse the output string.
6352
6353 llz
6354 llz directory
6355
6356 List the files in directory in the format of "ls -laZ".
6357
6358 This command is mostly useful for interactive sessions. It is not
6359 intended that you try to parse the output string.
6360
6361 This function is deprecated. In new code, use the "lgetxattrs" call
6362 instead.
6363
6364 Deprecated functions will not be removed from the API, but the fact
6365 that they are deprecated indicates that there are problems with correct
6366 use of these functions.
6367
6368 ln
6369 ln target linkname
6370
6371 This command creates a hard link.
6372
6373 ln-f
6374 ln-f target linkname
6375
6376 This command creates a hard link, removing the link "linkname" if it
6377 exists already.
6378
6379 ln-s
6380 ln-s target linkname
6381
6382 This command creates a symbolic link using the "ln -s" command.
6383
6384 ln-sf
6385 ln-sf target linkname
6386
6387 This command creates a symbolic link using the "ln -sf" command, The -f
6388 option removes the link ("linkname") if it exists already.
6389
6390 lremovexattr
6391 lremovexattr xattr path
6392
6393 This is the same as "removexattr", but if "path" is a symbolic link,
6394 then it removes an extended attribute of the link itself.
6395
6396 This command depends on the feature "linuxxattrs". See also "feature-
6397 available".
6398
6399 ls
6400 ls directory
6401
6402 List the files in directory (relative to the root directory, there is
6403 no cwd). The "." and ".." entries are not returned, but hidden files
6404 are shown.
6405
6406 ls0
6407 ls0 dir (filenames|-)
6408
6409 This specialized command is used to get a listing of the filenames in
6410 the directory "dir". The list of filenames is written to the local
6411 file filenames (on the host).
6412
6413 In the output file, the filenames are separated by "\0" characters.
6414
6415 "." and ".." are not returned. The filenames are not sorted.
6416
6417 Use "-" instead of a filename to read/write from stdin/stdout.
6418
6419 lsetxattr
6420 lsetxattr xattr val vallen path
6421
6422 This is the same as "setxattr", but if "path" is a symbolic link, then
6423 it sets an extended attribute of the link itself.
6424
6425 This command depends on the feature "linuxxattrs". See also "feature-
6426 available".
6427
6428 lstat
6429 lstat path
6430
6431 Returns file information for the given "path".
6432
6433 This is the same as "stat" except that if "path" is a symbolic link,
6434 then the link is stat-ed, not the file it refers to.
6435
6436 This is the same as the lstat(2) system call.
6437
6438 This function is deprecated. In new code, use the "lstatns" call
6439 instead.
6440
6441 Deprecated functions will not be removed from the API, but the fact
6442 that they are deprecated indicates that there are problems with correct
6443 use of these functions.
6444
6445 lstatlist
6446 lstatlist path 'names ...'
6447
6448 This call allows you to perform the "lstat" operation on multiple
6449 files, where all files are in the directory "path". "names" is the
6450 list of files from this directory.
6451
6452 On return you get a list of stat structs, with a one-to-one
6453 correspondence to the "names" list. If any name did not exist or could
6454 not be lstat'd, then the "st_ino" field of that structure is set to -1.
6455
6456 This call is intended for programs that want to efficiently list a
6457 directory contents without making many round-trips. See also
6458 "lxattrlist" for a similarly efficient call for getting extended
6459 attributes.
6460
6461 This function is deprecated. In new code, use the "lstatnslist" call
6462 instead.
6463
6464 Deprecated functions will not be removed from the API, but the fact
6465 that they are deprecated indicates that there are problems with correct
6466 use of these functions.
6467
6468 lstatns
6469 lstatns path
6470
6471 Returns file information for the given "path".
6472
6473 This is the same as "statns" except that if "path" is a symbolic link,
6474 then the link is stat-ed, not the file it refers to.
6475
6476 This is the same as the lstat(2) system call.
6477
6478 lstatnslist
6479 lstatnslist path 'names ...'
6480
6481 This call allows you to perform the "lstatns" operation on multiple
6482 files, where all files are in the directory "path". "names" is the
6483 list of files from this directory.
6484
6485 On return you get a list of stat structs, with a one-to-one
6486 correspondence to the "names" list. If any name did not exist or could
6487 not be lstat'd, then the "st_ino" field of that structure is set to -1.
6488
6489 This call is intended for programs that want to efficiently list a
6490 directory contents without making many round-trips. See also
6491 "lxattrlist" for a similarly efficient call for getting extended
6492 attributes.
6493
6494 luks-add-key
6495 luks-add-key device keyslot
6496
6497 This command adds a new key on LUKS device "device". "key" is any
6498 existing key, and is used to access the device. "newkey" is the new
6499 key to add. "keyslot" is the key slot that will be replaced.
6500
6501 Note that if "keyslot" already contains a key, then this command will
6502 fail. You have to use "luks-kill-slot" first to remove that key.
6503
6504 This command has one or more key or passphrase parameters. Guestfish
6505 will prompt for these separately.
6506
6507 This command depends on the feature "luks". See also "feature-
6508 available".
6509
6510 luks-close
6511 luks-close device
6512
6513 This closes a LUKS device that was created earlier by "luks-open" or
6514 "luks-open-ro". The "device" parameter must be the name of the LUKS
6515 mapping device (ie. /dev/mapper/mapname) and not the name of the
6516 underlying block device.
6517
6518 This function is deprecated. In new code, use the "cryptsetup-close"
6519 call instead.
6520
6521 Deprecated functions will not be removed from the API, but the fact
6522 that they are deprecated indicates that there are problems with correct
6523 use of these functions.
6524
6525 This command depends on the feature "luks". See also "feature-
6526 available".
6527
6528 luks-format
6529 luks-format device keyslot
6530
6531 This command erases existing data on "device" and formats the device as
6532 a LUKS encrypted device. "key" is the initial key, which is added to
6533 key slot "keyslot". (LUKS supports 8 key slots, numbered 0-7).
6534
6535 This command has one or more key or passphrase parameters. Guestfish
6536 will prompt for these separately.
6537
6538 This command depends on the feature "luks". See also "feature-
6539 available".
6540
6541 luks-format-cipher
6542 luks-format-cipher device keyslot cipher
6543
6544 This command is the same as "luks-format" but it also allows you to set
6545 the "cipher" used.
6546
6547 This command has one or more key or passphrase parameters. Guestfish
6548 will prompt for these separately.
6549
6550 This command depends on the feature "luks". See also "feature-
6551 available".
6552
6553 luks-kill-slot
6554 luks-kill-slot device keyslot
6555
6556 This command deletes the key in key slot "keyslot" from the encrypted
6557 LUKS device "device". "key" must be one of the other keys.
6558
6559 This command has one or more key or passphrase parameters. Guestfish
6560 will prompt for these separately.
6561
6562 This command depends on the feature "luks". See also "feature-
6563 available".
6564
6565 luks-open
6566 luks-open device mapname
6567
6568 This command opens a block device which has been encrypted according to
6569 the Linux Unified Key Setup (LUKS) standard.
6570
6571 "device" is the encrypted block device or partition.
6572
6573 The caller must supply one of the keys associated with the LUKS block
6574 device, in the "key" parameter.
6575
6576 This creates a new block device called /dev/mapper/mapname. Reads and
6577 writes to this block device are decrypted from and encrypted to the
6578 underlying "device" respectively.
6579
6580 If this block device contains LVM volume groups, then calling "lvm-
6581 scan" with the "activate" parameter "true" will make them visible.
6582
6583 Use "list-dm-devices" to list all device mapper devices.
6584
6585 This command has one or more key or passphrase parameters. Guestfish
6586 will prompt for these separately.
6587
6588 This function is deprecated. In new code, use the "cryptsetup-open"
6589 call instead.
6590
6591 Deprecated functions will not be removed from the API, but the fact
6592 that they are deprecated indicates that there are problems with correct
6593 use of these functions.
6594
6595 This command depends on the feature "luks". See also "feature-
6596 available".
6597
6598 luks-open-ro
6599 luks-open-ro device mapname
6600
6601 This is the same as "luks-open" except that a read-only mapping is
6602 created.
6603
6604 This command has one or more key or passphrase parameters. Guestfish
6605 will prompt for these separately.
6606
6607 This function is deprecated. In new code, use the "cryptsetup-open"
6608 call instead.
6609
6610 Deprecated functions will not be removed from the API, but the fact
6611 that they are deprecated indicates that there are problems with correct
6612 use of these functions.
6613
6614 This command depends on the feature "luks". See also "feature-
6615 available".
6616
6617 luks-uuid
6618 luks-uuid device
6619
6620 This returns the UUID of the LUKS device "device".
6621
6622 This command depends on the feature "luks". See also "feature-
6623 available".
6624
6625 lvcreate
6626 lvcreate logvol volgroup mbytes
6627
6628 This creates an LVM logical volume called "logvol" on the volume group
6629 "volgroup", with "size" megabytes.
6630
6631 This command depends on the feature "lvm2". See also "feature-
6632 available".
6633
6634 lvcreate-free
6635 lvcreate-free logvol volgroup percent
6636
6637 Create an LVM logical volume called /dev/volgroup/logvol, using
6638 approximately "percent" % of the free space remaining in the volume
6639 group. Most usefully, when "percent" is 100 this will create the
6640 largest possible LV.
6641
6642 This command depends on the feature "lvm2". See also "feature-
6643 available".
6644
6645 lvm-canonical-lv-name
6646 lvm-canonical-lv-name lvname
6647
6648 This converts alternative naming schemes for LVs that you might find to
6649 the canonical name. For example, /dev/mapper/VG-LV is converted to
6650 /dev/VG/LV.
6651
6652 This command returns an error if the "lvname" parameter does not refer
6653 to a logical volume. In this case errno will be set to "EINVAL".
6654
6655 See also "is-lv", "canonical-device-name".
6656
6657 lvm-clear-filter
6658 lvm-clear-filter
6659
6660 This undoes the effect of "lvm-set-filter". LVM will be able to see
6661 every block device.
6662
6663 This command also clears the LVM cache and performs a volume group
6664 scan.
6665
6666 lvm-remove-all
6667 lvm-remove-all
6668
6669 This command removes all LVM logical volumes, volume groups and
6670 physical volumes.
6671
6672 This command depends on the feature "lvm2". See also "feature-
6673 available".
6674
6675 lvm-scan
6676 lvm-scan true|false
6677
6678 This scans all block devices and rebuilds the list of LVM physical
6679 volumes, volume groups and logical volumes.
6680
6681 If the "activate" parameter is "true" then newly found volume groups
6682 and logical volumes are activated, meaning the LV /dev/VG/LV devices
6683 become visible.
6684
6685 When a libguestfs handle is launched it scans for existing devices, so
6686 you do not normally need to use this API. However it is useful when
6687 you have added a new device or deleted an existing device (such as when
6688 the "luks-open" API is used).
6689
6690 lvm-set-filter
6691 lvm-set-filter 'devices ...'
6692
6693 This sets the LVM device filter so that LVM will only be able to "see"
6694 the block devices in the list "devices", and will ignore all other
6695 attached block devices.
6696
6697 Where disk image(s) contain duplicate PVs or VGs, this command is
6698 useful to get LVM to ignore the duplicates, otherwise LVM can get
6699 confused. Note also there are two types of duplication possible:
6700 either cloned PVs/VGs which have identical UUIDs; or VGs that are not
6701 cloned but just happen to have the same name. In normal operation you
6702 cannot create this situation, but you can do it outside LVM, eg. by
6703 cloning disk images or by bit twiddling inside the LVM metadata.
6704
6705 This command also clears the LVM cache and performs a volume group
6706 scan.
6707
6708 You can filter whole block devices or individual partitions.
6709
6710 You cannot use this if any VG is currently in use (eg. contains a
6711 mounted filesystem), even if you are not filtering out that VG.
6712
6713 This command depends on the feature "lvm2". See also "feature-
6714 available".
6715
6716 lvremove
6717 lvremove device
6718
6719 Remove an LVM logical volume "device", where "device" is the path to
6720 the LV, such as /dev/VG/LV.
6721
6722 You can also remove all LVs in a volume group by specifying the VG
6723 name, /dev/VG.
6724
6725 This command depends on the feature "lvm2". See also "feature-
6726 available".
6727
6728 lvrename
6729 lvrename logvol newlogvol
6730
6731 Rename a logical volume "logvol" with the new name "newlogvol".
6732
6733 lvresize
6734 lvresize device mbytes
6735
6736 This resizes (expands or shrinks) an existing LVM logical volume to
6737 "mbytes". When reducing, data in the reduced part is lost.
6738
6739 This command depends on the feature "lvm2". See also "feature-
6740 available".
6741
6742 lvresize-free
6743 lvresize-free lv percent
6744
6745 This expands an existing logical volume "lv" so that it fills "pc" % of
6746 the remaining free space in the volume group. Commonly you would call
6747 this with pc = 100 which expands the logical volume as much as
6748 possible, using all remaining free space in the volume group.
6749
6750 This command depends on the feature "lvm2". See also "feature-
6751 available".
6752
6753 lvs
6754 lvs
6755
6756 List all the logical volumes detected. This is the equivalent of the
6757 lvs(8) command.
6758
6759 This returns a list of the logical volume device names (eg.
6760 /dev/VolGroup00/LogVol00).
6761
6762 See also "lvs-full", "list-filesystems".
6763
6764 This command depends on the feature "lvm2". See also "feature-
6765 available".
6766
6767 lvs-full
6768 lvs-full
6769
6770 List all the logical volumes detected. This is the equivalent of the
6771 lvs(8) command. The "full" version includes all fields.
6772
6773 This command depends on the feature "lvm2". See also "feature-
6774 available".
6775
6776 lvuuid
6777 lvuuid device
6778
6779 This command returns the UUID of the LVM LV "device".
6780
6781 lxattrlist
6782 lxattrlist path 'names ...'
6783
6784 This call allows you to get the extended attributes of multiple files,
6785 where all files are in the directory "path". "names" is the list of
6786 files from this directory.
6787
6788 On return you get a flat list of xattr structs which must be
6789 interpreted sequentially. The first xattr struct always has a zero-
6790 length "attrname". "attrval" in this struct is zero-length to indicate
6791 there was an error doing "lgetxattr" for this file, or is a C string
6792 which is a decimal number (the number of following attributes for this
6793 file, which could be "0"). Then after the first xattr struct are the
6794 zero or more attributes for the first named file. This repeats for the
6795 second and subsequent files.
6796
6797 This call is intended for programs that want to efficiently list a
6798 directory contents without making many round-trips. See also
6799 "lstatlist" for a similarly efficient call for getting standard stats.
6800
6801 This command depends on the feature "linuxxattrs". See also "feature-
6802 available".
6803
6804 max-disks
6805 max-disks
6806
6807 Return the maximum number of disks that may be added to a handle (eg.
6808 by "add-drive-opts" and similar calls).
6809
6810 This function was added in libguestfs 1.19.7. In previous versions of
6811 libguestfs the limit was 25.
6812
6813 See "MAXIMUM NUMBER OF DISKS" in guestfs(3) for additional information
6814 on this topic.
6815
6816 md-create
6817 md-create name 'devices ...' [missingbitmap:N] [nrdevices:N] [spare:N] [chunk:N] [level:..]
6818
6819 Create a Linux md (RAID) device named "name" on the devices in the list
6820 "devices".
6821
6822 The optional parameters are:
6823
6824 "missingbitmap"
6825 A bitmap of missing devices. If a bit is set it means that a
6826 missing device is added to the array. The least significant bit
6827 corresponds to the first device in the array.
6828
6829 As examples:
6830
6831 If "devices = ["/dev/sda"]" and "missingbitmap = 0x1" then the
6832 resulting array would be "[<missing>, "/dev/sda"]".
6833
6834 If "devices = ["/dev/sda"]" and "missingbitmap = 0x2" then the
6835 resulting array would be "["/dev/sda", <missing>]".
6836
6837 This defaults to 0 (no missing devices).
6838
6839 The length of "devices" + the number of bits set in "missingbitmap"
6840 must equal "nrdevices" + "spare".
6841
6842 "nrdevices"
6843 The number of active RAID devices.
6844
6845 If not set, this defaults to the length of "devices" plus the
6846 number of bits set in "missingbitmap".
6847
6848 "spare"
6849 The number of spare devices.
6850
6851 If not set, this defaults to 0.
6852
6853 "chunk"
6854 The chunk size in bytes.
6855
6856 The "chunk" parameter does not make sense, and should not be
6857 specified, when "level" is "raid1" (which is the default; see
6858 below).
6859
6860 "level"
6861 The RAID level, which can be one of: "linear", "raid0", 0,
6862 "stripe", "raid1", 1, "mirror", "raid4", 4, "raid5", 5, "raid6", 6,
6863 "raid10", 10. Some of these are synonymous, and more levels may be
6864 added in future.
6865
6866 If not set, this defaults to "raid1".
6867
6868 This command has one or more optional arguments. See "OPTIONAL
6869 ARGUMENTS".
6870
6871 This command depends on the feature "mdadm". See also "feature-
6872 available".
6873
6874 md-detail
6875 md-detail md
6876
6877 This command exposes the output of "mdadm -DY <md>". The following
6878 fields are usually present in the returned hash. Other fields may also
6879 be present.
6880
6881 "level"
6882 The raid level of the MD device.
6883
6884 "devices"
6885 The number of underlying devices in the MD device.
6886
6887 "metadata"
6888 The metadata version used.
6889
6890 "uuid"
6891 The UUID of the MD device.
6892
6893 "name"
6894 The name of the MD device.
6895
6896 This command depends on the feature "mdadm". See also "feature-
6897 available".
6898
6899 md-stat
6900 md-stat md
6901
6902 This call returns a list of the underlying devices which make up the
6903 single software RAID array device "md".
6904
6905 To get a list of software RAID devices, call "list-md-devices".
6906
6907 Each structure returned corresponds to one device along with additional
6908 status information:
6909
6910 "mdstat_device"
6911 The name of the underlying device.
6912
6913 "mdstat_index"
6914 The index of this device within the array.
6915
6916 "mdstat_flags"
6917 Flags associated with this device. This is a string containing (in
6918 no specific order) zero or more of the following flags:
6919
6920 "W" write-mostly
6921
6922 "F" device is faulty
6923
6924 "S" device is a RAID spare
6925
6926 "R" replacement
6927
6928 This command depends on the feature "mdadm". See also "feature-
6929 available".
6930
6931 md-stop
6932 md-stop md
6933
6934 This command deactivates the MD array named "md". The device is
6935 stopped, but it is not destroyed or zeroed.
6936
6937 This command depends on the feature "mdadm". See also "feature-
6938 available".
6939
6940 mkdir
6941 mkdir path
6942
6943 Create a directory named "path".
6944
6945 mkdir-mode
6946 mkdir-mode path mode
6947
6948 This command creates a directory, setting the initial permissions of
6949 the directory to "mode".
6950
6951 For common Linux filesystems, the actual mode which is set will be
6952 "mode & ~umask & 01777". Non-native-Linux filesystems may interpret
6953 the mode in other ways.
6954
6955 See also "mkdir", "umask"
6956
6957 mkdir-p
6958 mkdir-p path
6959
6960 Create a directory named "path", creating any parent directories as
6961 necessary. This is like the "mkdir -p" shell command.
6962
6963 mkdtemp
6964 mkdtemp tmpl
6965
6966 This command creates a temporary directory. The "tmpl" parameter
6967 should be a full pathname for the temporary directory name with the
6968 final six characters being "XXXXXX".
6969
6970 For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX", the second
6971 one being suitable for Windows filesystems.
6972
6973 The name of the temporary directory that was created is returned.
6974
6975 The temporary directory is created with mode 0700 and is owned by root.
6976
6977 The caller is responsible for deleting the temporary directory and its
6978 contents after use.
6979
6980 See also: mkdtemp(3)
6981
6982 mke2fs
6983 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]
6984
6985 "mke2fs" is used to create an ext2, ext3, or ext4 filesystem on
6986 "device".
6987
6988 The optional "blockscount" is the size of the filesystem in blocks. If
6989 omitted it defaults to the size of "device". Note if the filesystem is
6990 too small to contain a journal, "mke2fs" will silently create an ext2
6991 filesystem instead.
6992
6993 This command has one or more optional arguments. See "OPTIONAL
6994 ARGUMENTS".
6995
6996 mke2fs-J
6997 mke2fs-J fstype blocksize device journal
6998
6999 This creates an ext2/3/4 filesystem on "device" with an external
7000 journal on "journal". It is equivalent to the command:
7001
7002 mke2fs -t fstype -b blocksize -J device=<journal> <device>
7003
7004 See also "mke2journal".
7005
7006 This function is deprecated. In new code, use the "mke2fs" call
7007 instead.
7008
7009 Deprecated functions will not be removed from the API, but the fact
7010 that they are deprecated indicates that there are problems with correct
7011 use of these functions.
7012
7013 mke2fs-JL
7014 mke2fs-JL fstype blocksize device label
7015
7016 This creates an ext2/3/4 filesystem on "device" with an external
7017 journal on the journal labeled "label".
7018
7019 See also "mke2journal-L".
7020
7021 This function is deprecated. In new code, use the "mke2fs" call
7022 instead.
7023
7024 Deprecated functions will not be removed from the API, but the fact
7025 that they are deprecated indicates that there are problems with correct
7026 use of these functions.
7027
7028 mke2fs-JU
7029 mke2fs-JU fstype blocksize device uuid
7030
7031 This creates an ext2/3/4 filesystem on "device" with an external
7032 journal on the journal with UUID "uuid".
7033
7034 See also "mke2journal-U".
7035
7036 This function is deprecated. In new code, use the "mke2fs" call
7037 instead.
7038
7039 Deprecated functions will not be removed from the API, but the fact
7040 that they are deprecated indicates that there are problems with correct
7041 use of these functions.
7042
7043 This command depends on the feature "linuxfsuuid". See also "feature-
7044 available".
7045
7046 mke2journal
7047 mke2journal blocksize device
7048
7049 This creates an ext2 external journal on "device". It is equivalent to
7050 the command:
7051
7052 mke2fs -O journal_dev -b blocksize device
7053
7054 This function is deprecated. In new code, use the "mke2fs" call
7055 instead.
7056
7057 Deprecated functions will not be removed from the API, but the fact
7058 that they are deprecated indicates that there are problems with correct
7059 use of these functions.
7060
7061 mke2journal-L
7062 mke2journal-L blocksize label device
7063
7064 This creates an ext2 external journal on "device" with label "label".
7065
7066 This function is deprecated. In new code, use the "mke2fs" call
7067 instead.
7068
7069 Deprecated functions will not be removed from the API, but the fact
7070 that they are deprecated indicates that there are problems with correct
7071 use of these functions.
7072
7073 mke2journal-U
7074 mke2journal-U blocksize uuid device
7075
7076 This creates an ext2 external journal on "device" with UUID "uuid".
7077
7078 This function is deprecated. In new code, use the "mke2fs" call
7079 instead.
7080
7081 Deprecated functions will not be removed from the API, but the fact
7082 that they are deprecated indicates that there are problems with correct
7083 use of these functions.
7084
7085 This command depends on the feature "linuxfsuuid". See also "feature-
7086 available".
7087
7088 mkfifo
7089 mkfifo mode path
7090
7091 This call creates a FIFO (named pipe) called "path" with mode "mode".
7092 It is just a convenient wrapper around "mknod".
7093
7094 Unlike with "mknod", "mode" must contain only permissions bits.
7095
7096 The mode actually set is affected by the umask.
7097
7098 This command depends on the feature "mknod". See also "feature-
7099 available".
7100
7101 mkfs
7102 mkfs-opts
7103 mkfs fstype device [blocksize:N] [features:..] [inode:N] [sectorsize:N] [label:..]
7104
7105 This function creates a filesystem on "device". The filesystem type is
7106 "fstype", for example "ext3".
7107
7108 The optional arguments are:
7109
7110 "blocksize"
7111 The filesystem block size. Supported block sizes depend on the
7112 filesystem type, but typically they are 1024, 2048 or 4096 for
7113 Linux ext2/3 filesystems.
7114
7115 For VFAT and NTFS the "blocksize" parameter is treated as the
7116 requested cluster size.
7117
7118 For UFS block sizes, please see mkfs.ufs(8).
7119
7120 "features"
7121 This passes the -O parameter to the external mkfs program.
7122
7123 For certain filesystem types, this allows extra filesystem features
7124 to be selected. See mke2fs(8) and mkfs.ufs(8) for more details.
7125
7126 You cannot use this optional parameter with the "gfs" or "gfs2"
7127 filesystem type.
7128
7129 "inode"
7130 This passes the -I parameter to the external mke2fs(8) program
7131 which sets the inode size (only for ext2/3/4 filesystems at
7132 present).
7133
7134 "sectorsize"
7135 This passes the -S parameter to external mkfs.ufs(8) program, which
7136 sets sector size for ufs filesystem.
7137
7138 This command has one or more optional arguments. See "OPTIONAL
7139 ARGUMENTS".
7140
7141 mkfs-b
7142 mkfs-b fstype blocksize device
7143
7144 This call is similar to "mkfs", but it allows you to control the block
7145 size of the resulting filesystem. Supported block sizes depend on the
7146 filesystem type, but typically they are 1024, 2048 or 4096 only.
7147
7148 For VFAT and NTFS the "blocksize" parameter is treated as the requested
7149 cluster size.
7150
7151 This function is deprecated. In new code, use the "mkfs" call instead.
7152
7153 Deprecated functions will not be removed from the API, but the fact
7154 that they are deprecated indicates that there are problems with correct
7155 use of these functions.
7156
7157 mkfs-btrfs
7158 mkfs-btrfs 'devices ...' [allocstart:N] [bytecount:N] [datatype:..] [leafsize:N] [label:..] [metadata:..] [nodesize:N] [sectorsize:N]
7159
7160 Create a btrfs filesystem, allowing all configurables to be set. For
7161 more information on the optional arguments, see mkfs.btrfs(8).
7162
7163 Since btrfs filesystems can span multiple devices, this takes a non-
7164 empty list of devices.
7165
7166 To create general filesystems, use "mkfs".
7167
7168 This command has one or more optional arguments. See "OPTIONAL
7169 ARGUMENTS".
7170
7171 This command depends on the feature "btrfs". See also "feature-
7172 available".
7173
7174 mklost-and-found
7175 mklost-and-found mountpoint
7176
7177 Make the "lost+found" directory, normally in the root directory of an
7178 ext2/3/4 filesystem. "mountpoint" is the directory under which we try
7179 to create the "lost+found" directory.
7180
7181 mkmountpoint
7182 mkmountpoint exemptpath
7183
7184 "mkmountpoint" and "rmmountpoint" are specialized calls that can be
7185 used to create extra mountpoints before mounting the first filesystem.
7186
7187 These calls are only necessary in some very limited circumstances,
7188 mainly the case where you want to mount a mix of unrelated and/or read-
7189 only filesystems together.
7190
7191 For example, live CDs often contain a "Russian doll" nest of
7192 filesystems, an ISO outer layer, with a squashfs image inside, with an
7193 ext2/3 image inside that. You can unpack this as follows in guestfish:
7194
7195 add-ro Fedora-11-i686-Live.iso
7196 run
7197 mkmountpoint /cd
7198 mkmountpoint /sqsh
7199 mkmountpoint /ext3fs
7200 mount /dev/sda /cd
7201 mount-loop /cd/LiveOS/squashfs.img /sqsh
7202 mount-loop /sqsh/LiveOS/ext3fs.img /ext3fs
7203
7204 The inner filesystem is now unpacked under the /ext3fs mountpoint.
7205
7206 "mkmountpoint" is not compatible with "umount-all". You may get
7207 unexpected errors if you try to mix these calls. It is safest to
7208 manually unmount filesystems and remove mountpoints after use.
7209
7210 "umount-all" unmounts filesystems by sorting the paths longest first,
7211 so for this to work for manual mountpoints, you must ensure that the
7212 innermost mountpoints have the longest pathnames, as in the example
7213 code above.
7214
7215 For more details see https://bugzilla.redhat.com/show_bug.cgi?id=599503
7216
7217 Autosync [see "set-autosync", this is set by default on handles] can
7218 cause "umount-all" to be called when the handle is closed which can
7219 also trigger these issues.
7220
7221 mknod
7222 mknod mode devmajor devminor path
7223
7224 This call creates block or character special devices, or named pipes
7225 (FIFOs).
7226
7227 The "mode" parameter should be the mode, using the standard constants.
7228 "devmajor" and "devminor" are the device major and minor numbers, only
7229 used when creating block and character special devices.
7230
7231 Note that, just like mknod(2), the mode must be bitwise OR'd with
7232 S_IFBLK, S_IFCHR, S_IFIFO or S_IFSOCK (otherwise this call just creates
7233 a regular file). These constants are available in the standard Linux
7234 header files, or you can use "mknod-b", "mknod-c" or "mkfifo" which are
7235 wrappers around this command which bitwise OR in the appropriate
7236 constant for you.
7237
7238 The mode actually set is affected by the umask.
7239
7240 This command depends on the feature "mknod". See also "feature-
7241 available".
7242
7243 mknod-b
7244 mknod-b mode devmajor devminor path
7245
7246 This call creates a block device node called "path" with mode "mode"
7247 and device major/minor "devmajor" and "devminor". It is just a
7248 convenient wrapper around "mknod".
7249
7250 Unlike with "mknod", "mode" must contain only permissions bits.
7251
7252 The mode actually set is affected by the umask.
7253
7254 This command depends on the feature "mknod". See also "feature-
7255 available".
7256
7257 mknod-c
7258 mknod-c mode devmajor devminor path
7259
7260 This call creates a char device node called "path" with mode "mode" and
7261 device major/minor "devmajor" and "devminor". It is just a convenient
7262 wrapper around "mknod".
7263
7264 Unlike with "mknod", "mode" must contain only permissions bits.
7265
7266 The mode actually set is affected by the umask.
7267
7268 This command depends on the feature "mknod". See also "feature-
7269 available".
7270
7271 mksquashfs
7272 mksquashfs path (filename|-) [compress:..] [excludes:..]
7273
7274 Create a squashfs filesystem for the specified "path".
7275
7276 The optional "compress" flag controls compression. If not given, then
7277 the output compressed using "gzip". Otherwise one of the following
7278 strings may be given to select the compression type of the squashfs:
7279 "gzip", "lzma", "lzo", "lz4", "xz".
7280
7281 The other optional arguments are:
7282
7283 "excludes"
7284 A list of wildcards. Files are excluded if they match any of the
7285 wildcards.
7286
7287 Please note that this API may fail when used to compress directories
7288 with large files, such as the resulting squashfs will be over 3GB big.
7289
7290 Use "-" instead of a filename to read/write from stdin/stdout.
7291
7292 This command has one or more optional arguments. See "OPTIONAL
7293 ARGUMENTS".
7294
7295 This command depends on the feature "squashfs". See also "feature-
7296 available".
7297
7298 mkswap
7299 mkswap-opts
7300 mkswap device [label:..] [uuid:..]
7301
7302 Create a Linux swap partition on "device".
7303
7304 The option arguments "label" and "uuid" allow you to set the label
7305 and/or UUID of the new swap partition.
7306
7307 This command has one or more optional arguments. See "OPTIONAL
7308 ARGUMENTS".
7309
7310 mkswap-L
7311 mkswap-L label device
7312
7313 Create a swap partition on "device" with label "label".
7314
7315 Note that you cannot attach a swap label to a block device (eg.
7316 /dev/sda), just to a partition. This appears to be a limitation of the
7317 kernel or swap tools.
7318
7319 This function is deprecated. In new code, use the "mkswap" call
7320 instead.
7321
7322 Deprecated functions will not be removed from the API, but the fact
7323 that they are deprecated indicates that there are problems with correct
7324 use of these functions.
7325
7326 mkswap-U
7327 mkswap-U uuid device
7328
7329 Create a swap partition on "device" with UUID "uuid".
7330
7331 This function is deprecated. In new code, use the "mkswap" call
7332 instead.
7333
7334 Deprecated functions will not be removed from the API, but the fact
7335 that they are deprecated indicates that there are problems with correct
7336 use of these functions.
7337
7338 This command depends on the feature "linuxfsuuid". See also "feature-
7339 available".
7340
7341 mkswap-file
7342 mkswap-file path
7343
7344 Create a swap file.
7345
7346 This command just writes a swap file signature to an existing file. To
7347 create the file itself, use something like "fallocate".
7348
7349 mktemp
7350 mktemp tmpl [suffix:..]
7351
7352 This command creates a temporary file. The "tmpl" parameter should be
7353 a full pathname for the temporary directory name with the final six
7354 characters being "XXXXXX".
7355
7356 For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX", the second
7357 one being suitable for Windows filesystems.
7358
7359 The name of the temporary file that was created is returned.
7360
7361 The temporary file is created with mode 0600 and is owned by root.
7362
7363 The caller is responsible for deleting the temporary file after use.
7364
7365 If the optional "suffix" parameter is given, then the suffix (eg.
7366 ".txt") is appended to the temporary name.
7367
7368 See also: "mkdtemp".
7369
7370 This command has one or more optional arguments. See "OPTIONAL
7371 ARGUMENTS".
7372
7373 modprobe
7374 modprobe modulename
7375
7376 This loads a kernel module in the appliance.
7377
7378 This command depends on the feature "linuxmodules". See also
7379 "feature-available".
7380
7381 mount
7382 mount mountable mountpoint
7383
7384 Mount a guest disk at a position in the filesystem. Block devices are
7385 named /dev/sda, /dev/sdb and so on, as they were added to the guest.
7386 If those block devices contain partitions, they will have the usual
7387 names (eg. /dev/sda1). Also LVM /dev/VG/LV-style names can be used, or
7388 ‘mountable’ strings returned by "list-filesystems" or "inspect-get-
7389 mountpoints".
7390
7391 The rules are the same as for mount(2): A filesystem must first be
7392 mounted on / before others can be mounted. Other filesystems can only
7393 be mounted on directories which already exist.
7394
7395 The mounted filesystem is writable, if we have sufficient permissions
7396 on the underlying device.
7397
7398 Before libguestfs 1.13.16, this call implicitly added the options
7399 "sync" and "noatime". The "sync" option greatly slowed writes and
7400 caused many problems for users. If your program might need to work
7401 with older versions of libguestfs, use "mount-options" instead (using
7402 an empty string for the first parameter if you don't want any options).
7403
7404 mount-9p
7405 mount-9p mounttag mountpoint [options:..]
7406
7407 This call does nothing and returns an error.
7408
7409 This command has one or more optional arguments. See "OPTIONAL
7410 ARGUMENTS".
7411
7412 This function is deprecated. There is no replacement. Consult the API
7413 documentation in guestfs(3) for further information.
7414
7415 Deprecated functions will not be removed from the API, but the fact
7416 that they are deprecated indicates that there are problems with correct
7417 use of these functions.
7418
7419 mount-local
7420 mount-local localmountpoint [readonly:true|false] [options:..] [cachetimeout:N] [debugcalls:true|false]
7421
7422 This call exports the libguestfs-accessible filesystem to a local
7423 mountpoint (directory) called "localmountpoint". Ordinary reads and
7424 writes to files and directories under "localmountpoint" are redirected
7425 through libguestfs.
7426
7427 If the optional "readonly" flag is set to true, then writes to the
7428 filesystem return error "EROFS".
7429
7430 "options" is a comma-separated list of mount options. See
7431 guestmount(1) for some useful options.
7432
7433 "cachetimeout" sets the timeout (in seconds) for cached directory
7434 entries. The default is 60 seconds. See guestmount(1) for further
7435 information.
7436
7437 If "debugcalls" is set to true, then additional debugging information
7438 is generated for every FUSE call.
7439
7440 When "mount-local" returns, the filesystem is ready, but is not
7441 processing requests (access to it will block). You have to call
7442 "mount-local-run" to run the main loop.
7443
7444 See "MOUNT LOCAL" in guestfs(3) for full documentation.
7445
7446 This command has one or more optional arguments. See "OPTIONAL
7447 ARGUMENTS".
7448
7449 mount-local-run
7450 mount-local-run
7451
7452 Run the main loop which translates kernel calls to libguestfs calls.
7453
7454 This should only be called after "mount-local" returns successfully.
7455 The call will not return until the filesystem is unmounted.
7456
7457 Note you must not make concurrent libguestfs calls on the same handle
7458 from another thread.
7459
7460 You may call this from a different thread than the one which called
7461 "mount-local", subject to the usual rules for threads and libguestfs
7462 (see "MULTIPLE HANDLES AND MULTIPLE THREADS" in guestfs(3)).
7463
7464 See "MOUNT LOCAL" in guestfs(3) for full documentation.
7465
7466 mount-loop
7467 mount-loop file mountpoint
7468
7469 This command lets you mount file (a filesystem image in a file) on a
7470 mount point. It is entirely equivalent to the command "mount -o loop
7471 file mountpoint".
7472
7473 mount-options
7474 mount-options options mountable mountpoint
7475
7476 This is the same as the "mount" command, but it allows you to set the
7477 mount options as for the mount(8) -o flag.
7478
7479 If the "options" parameter is an empty string, then no options are
7480 passed (all options default to whatever the filesystem uses).
7481
7482 mount-ro
7483 mount-ro mountable mountpoint
7484
7485 This is the same as the "mount" command, but it mounts the filesystem
7486 with the read-only (-o ro) flag.
7487
7488 mount-vfs
7489 mount-vfs options vfstype mountable mountpoint
7490
7491 This is the same as the "mount" command, but it allows you to set both
7492 the mount options and the vfstype as for the mount(8) -o and -t flags.
7493
7494 mountable-device
7495 mountable-device mountable
7496
7497 Returns the device name of a mountable. In quite a lot of cases, the
7498 mountable is the device name.
7499
7500 However this doesn't apply for btrfs subvolumes, where the mountable is
7501 a combination of both the device name and the subvolume path (see also
7502 "mountable-subvolume" to extract the subvolume path of the mountable if
7503 any).
7504
7505 mountable-subvolume
7506 mountable-subvolume mountable
7507
7508 Returns the subvolume path of a mountable. Btrfs subvolumes mountables
7509 are a combination of both the device name and the subvolume path (see
7510 also "mountable-device" to extract the device of the mountable).
7511
7512 If the mountable does not represent a btrfs subvolume, then this
7513 function fails and the "errno" is set to "EINVAL".
7514
7515 mountpoints
7516 mountpoints
7517
7518 This call is similar to "mounts". That call returns a list of devices.
7519 This one returns a hash table (map) of device name to directory where
7520 the device is mounted.
7521
7522 mounts
7523 mounts
7524
7525 This returns the list of currently mounted filesystems. It returns the
7526 list of devices (eg. /dev/sda1, /dev/VG/LV).
7527
7528 Some internal mounts are not shown.
7529
7530 See also: "mountpoints"
7531
7532 mv
7533 mv src dest
7534
7535 This moves a file from "src" to "dest" where "dest" is either a
7536 destination filename or destination directory.
7537
7538 See also: "rename".
7539
7540 nr-devices
7541 nr-devices
7542
7543 This returns the number of whole block devices that were added. This
7544 is the same as the number of devices that would be returned if you
7545 called "list-devices".
7546
7547 To find out the maximum number of devices that could be added, call
7548 "max-disks".
7549
7550 ntfs-3g-probe
7551 ntfs-3g-probe true|false device
7552
7553 This command runs the ntfs-3g.probe(8) command which probes an NTFS
7554 "device" for mountability. (Not all NTFS volumes can be mounted read-
7555 write, and some cannot be mounted at all).
7556
7557 "rw" is a boolean flag. Set it to true if you want to test if the
7558 volume can be mounted read-write. Set it to false if you want to test
7559 if the volume can be mounted read-only.
7560
7561 The return value is an integer which 0 if the operation would succeed,
7562 or some non-zero value documented in the ntfs-3g.probe(8) manual page.
7563
7564 This command depends on the feature "ntfs3g". See also "feature-
7565 available".
7566
7567 ntfscat-i
7568 ntfscat-i device inode (filename|-)
7569
7570 Download a file given its inode from a NTFS filesystem and save it as
7571 filename on the local machine.
7572
7573 This allows to download some otherwise inaccessible files such as the
7574 ones within the $Extend folder.
7575
7576 The filesystem from which to extract the file must be unmounted,
7577 otherwise the call will fail.
7578
7579 Use "-" instead of a filename to read/write from stdin/stdout.
7580
7581 ntfsclone-in
7582 ntfsclone-in (backupfile|-) device
7583
7584 Restore the "backupfile" (from a previous call to "ntfsclone-out") to
7585 "device", overwriting any existing contents of this device.
7586
7587 Use "-" instead of a filename to read/write from stdin/stdout.
7588
7589 This command depends on the feature "ntfs3g". See also "feature-
7590 available".
7591
7592 ntfsclone-out
7593 ntfsclone-out device (backupfile|-) [metadataonly:true|false] [rescue:true|false] [ignorefscheck:true|false] [preservetimestamps:true|false] [force:true|false]
7594
7595 Stream the NTFS filesystem "device" to the local file "backupfile".
7596 The format used for the backup file is a special format used by the
7597 ntfsclone(8) tool.
7598
7599 If the optional "metadataonly" flag is true, then only the metadata is
7600 saved, losing all the user data (this is useful for diagnosing some
7601 filesystem problems).
7602
7603 The optional "rescue", "ignorefscheck", "preservetimestamps" and
7604 "force" flags have precise meanings detailed in the ntfsclone(8) man
7605 page.
7606
7607 Use "ntfsclone-in" to restore the file back to a libguestfs device.
7608
7609 Use "-" instead of a filename to read/write from stdin/stdout.
7610
7611 This command has one or more optional arguments. See "OPTIONAL
7612 ARGUMENTS".
7613
7614 This command depends on the feature "ntfs3g". See also "feature-
7615 available".
7616
7617 ntfsfix
7618 ntfsfix device [clearbadsectors:true|false]
7619
7620 This command repairs some fundamental NTFS inconsistencies, resets the
7621 NTFS journal file, and schedules an NTFS consistency check for the
7622 first boot into Windows.
7623
7624 This is not an equivalent of Windows "chkdsk". It does not scan the
7625 filesystem for inconsistencies.
7626
7627 The optional "clearbadsectors" flag clears the list of bad sectors.
7628 This is useful after cloning a disk with bad sectors to a new disk.
7629
7630 This command has one or more optional arguments. See "OPTIONAL
7631 ARGUMENTS".
7632
7633 This command depends on the feature "ntfs3g". See also "feature-
7634 available".
7635
7636 ntfsresize
7637 ntfsresize-opts
7638 ntfsresize device [size:N] [force:true|false]
7639
7640 This command resizes an NTFS filesystem, expanding or shrinking it to
7641 the size of the underlying device.
7642
7643 The optional parameters are:
7644
7645 "size"
7646 The new size (in bytes) of the filesystem. If omitted, the
7647 filesystem is resized to fit the container (eg. partition).
7648
7649 "force"
7650 If this option is true, then force the resize of the filesystem
7651 even if the filesystem is marked as requiring a consistency check.
7652
7653 After the resize operation, the filesystem is always marked as
7654 requiring a consistency check (for safety). You have to boot into
7655 Windows to perform this check and clear this condition. If you
7656 don't set the "force" option then it is not possible to call
7657 "ntfsresize" multiple times on a single filesystem without booting
7658 into Windows between each resize.
7659
7660 See also ntfsresize(8).
7661
7662 This command has one or more optional arguments. See "OPTIONAL
7663 ARGUMENTS".
7664
7665 This command depends on the feature "ntfsprogs". See also "feature-
7666 available".
7667
7668 ntfsresize-size
7669 ntfsresize-size device size
7670
7671 This command is the same as "ntfsresize" except that it allows you to
7672 specify the new size (in bytes) explicitly.
7673
7674 This function is deprecated. In new code, use the "ntfsresize" call
7675 instead.
7676
7677 Deprecated functions will not be removed from the API, but the fact
7678 that they are deprecated indicates that there are problems with correct
7679 use of these functions.
7680
7681 This command depends on the feature "ntfsprogs". See also "feature-
7682 available".
7683
7684 parse-environment
7685 parse-environment
7686
7687 Parse the program’s environment and set flags in the handle
7688 accordingly. For example if "LIBGUESTFS_DEBUG=1" then the ‘verbose’
7689 flag is set in the handle.
7690
7691 Most programs do not need to call this. It is done implicitly when you
7692 call "create".
7693
7694 See "ENVIRONMENT VARIABLES" in guestfs(3) for a list of environment
7695 variables that can affect libguestfs handles. See also
7696 "guestfs_create_flags" in guestfs(3), and "parse-environment-list".
7697
7698 parse-environment-list
7699 parse-environment-list 'environment ...'
7700
7701 Parse the list of strings in the argument "environment" and set flags
7702 in the handle accordingly. For example if "LIBGUESTFS_DEBUG=1" is a
7703 string in the list, then the ‘verbose’ flag is set in the handle.
7704
7705 This is the same as "parse-environment" except that it parses an
7706 explicit list of strings instead of the program's environment.
7707
7708 part-add
7709 part-add device prlogex startsect endsect
7710
7711 This command adds a partition to "device". If there is no partition
7712 table on the device, call "part-init" first.
7713
7714 The "prlogex" parameter is the type of partition. Normally you should
7715 pass "p" or "primary" here, but MBR partition tables also support "l"
7716 (or "logical") and "e" (or "extended") partition types.
7717
7718 "startsect" and "endsect" are the start and end of the partition in
7719 sectors. "endsect" may be negative, which means it counts backwards
7720 from the end of the disk (-1 is the last sector).
7721
7722 Creating a partition which covers the whole disk is not so easy. Use
7723 "part-disk" to do that.
7724
7725 part-del
7726 part-del device partnum
7727
7728 This command deletes the partition numbered "partnum" on "device".
7729
7730 Note that in the case of MBR partitioning, deleting an extended
7731 partition also deletes any logical partitions it contains.
7732
7733 part-disk
7734 part-disk device parttype
7735
7736 This command is simply a combination of "part-init" followed by "part-
7737 add" to create a single primary partition covering the whole disk.
7738
7739 "parttype" is the partition table type, usually "mbr" or "gpt", but
7740 other possible values are described in "part-init".
7741
7742 part-expand-gpt
7743 part-expand-gpt device
7744
7745 Move backup GPT data structures to the end of the disk. This is useful
7746 in case of in-place image expand since disk space after backup GPT
7747 header is not usable. This is equivalent to "sgdisk -e".
7748
7749 See also sgdisk(8).
7750
7751 This command depends on the feature "gdisk". See also "feature-
7752 available".
7753
7754 part-get-bootable
7755 part-get-bootable device partnum
7756
7757 This command returns true if the partition "partnum" on "device" has
7758 the bootable flag set.
7759
7760 See also "part-set-bootable".
7761
7762 part-get-disk-guid
7763 part-get-disk-guid device
7764
7765 Return the disk identifier (GUID) of a GPT-partitioned "device".
7766 Behaviour is undefined for other partition types.
7767
7768 This command depends on the feature "gdisk". See also "feature-
7769 available".
7770
7771 part-get-gpt-attributes
7772 part-get-gpt-attributes device partnum
7773
7774 Return the attribute flags of numbered GPT partition "partnum". An
7775 error is returned for MBR partitions.
7776
7777 This command depends on the feature "gdisk". See also "feature-
7778 available".
7779
7780 part-get-gpt-guid
7781 part-get-gpt-guid device partnum
7782
7783 Return the GUID of numbered GPT partition "partnum".
7784
7785 This command depends on the feature "gdisk". See also "feature-
7786 available".
7787
7788 part-get-gpt-type
7789 part-get-gpt-type device partnum
7790
7791 Return the type GUID of numbered GPT partition "partnum". For MBR
7792 partitions, return an appropriate GUID corresponding to the MBR type.
7793 Behaviour is undefined for other partition types.
7794
7795 This command depends on the feature "gdisk". See also "feature-
7796 available".
7797
7798 part-get-mbr-id
7799 part-get-mbr-id device partnum
7800
7801 Returns the MBR type byte (also known as the ID byte) from the numbered
7802 partition "partnum".
7803
7804 Note that only MBR (old DOS-style) partitions have type bytes. You
7805 will get undefined results for other partition table types (see "part-
7806 get-parttype").
7807
7808 part-get-mbr-part-type
7809 part-get-mbr-part-type device partnum
7810
7811 This returns the partition type of an MBR partition numbered "partnum"
7812 on device "device".
7813
7814 It returns "primary", "logical", or "extended".
7815
7816 part-get-name
7817 part-get-name device partnum
7818
7819 This gets the partition name on partition numbered "partnum" on device
7820 "device". Note that partitions are numbered from 1.
7821
7822 The partition name can only be read on certain types of partition
7823 table. This works on "gpt" but not on "mbr" partitions.
7824
7825 part-get-parttype
7826 part-get-parttype device
7827
7828 This command examines the partition table on "device" and returns the
7829 partition table type (format) being used.
7830
7831 Common return values include: "msdos" (a DOS/Windows style MBR
7832 partition table), "gpt" (a GPT/EFI-style partition table). Other
7833 values are possible, although unusual. See "part-init" for a full
7834 list.
7835
7836 part-init
7837 part-init device parttype
7838
7839 This creates an empty partition table on "device" of one of the
7840 partition types listed below. Usually "parttype" should be either
7841 "msdos" or "gpt" (for large disks).
7842
7843 Initially there are no partitions. Following this, you should call
7844 "part-add" for each partition required.
7845
7846 Possible values for "parttype" are:
7847
7848 "efi"
7849 "gpt"
7850 Intel EFI / GPT partition table.
7851
7852 This is recommended for >= 2 TB partitions that will be accessed
7853 from Linux and Intel-based Mac OS X. It also has limited backwards
7854 compatibility with the "mbr" format.
7855
7856 "mbr"
7857 "msdos"
7858 The standard PC "Master Boot Record" (MBR) format used by MS-DOS
7859 and Windows. This partition type will only work for device sizes
7860 up to 2 TB. For large disks we recommend using "gpt".
7861
7862 Other partition table types that may work but are not supported
7863 include:
7864
7865 "aix"
7866 AIX disk labels.
7867
7868 "amiga"
7869 "rdb"
7870 Amiga "Rigid Disk Block" format.
7871
7872 "bsd"
7873 BSD disk labels.
7874
7875 "dasd"
7876 DASD, used on IBM mainframes.
7877
7878 "dvh"
7879 MIPS/SGI volumes.
7880
7881 "mac"
7882 Old Mac partition format. Modern Macs use "gpt".
7883
7884 "pc98"
7885 NEC PC-98 format, common in Japan apparently.
7886
7887 "sun"
7888 Sun disk labels.
7889
7890 part-list
7891 part-list device
7892
7893 This command parses the partition table on "device" and returns the
7894 list of partitions found.
7895
7896 The fields in the returned structure are:
7897
7898 "part_num"
7899 Partition number, counting from 1.
7900
7901 "part_start"
7902 Start of the partition in bytes. To get sectors you have to divide
7903 by the device’s sector size, see "blockdev-getss".
7904
7905 "part_end"
7906 End of the partition in bytes.
7907
7908 "part_size"
7909 Size of the partition in bytes.
7910
7911 part-resize
7912 part-resize device partnum endsect
7913
7914 This command resizes the partition numbered "partnum" on "device" by
7915 moving the end position.
7916
7917 Note that this does not modify any filesystem present in the partition.
7918 If you wish to do this, you will need to use filesystem resizing
7919 commands like "resize2fs".
7920
7921 When growing a partition you will want to grow the filesystem
7922 afterwards, but when shrinking, you need to shrink the filesystem
7923 before the partition.
7924
7925 part-set-bootable
7926 part-set-bootable device partnum true|false
7927
7928 This sets the bootable flag on partition numbered "partnum" on device
7929 "device". Note that partitions are numbered from 1.
7930
7931 The bootable flag is used by some operating systems (notably Windows)
7932 to determine which partition to boot from. It is by no means
7933 universally recognized.
7934
7935 part-set-disk-guid
7936 part-set-disk-guid device guid
7937
7938 Set the disk identifier (GUID) of a GPT-partitioned "device" to "guid".
7939 Return an error if the partition table of "device" isn't GPT, or if
7940 "guid" is not a valid GUID.
7941
7942 This command depends on the feature "gdisk". See also "feature-
7943 available".
7944
7945 part-set-disk-guid-random
7946 part-set-disk-guid-random device
7947
7948 Set the disk identifier (GUID) of a GPT-partitioned "device" to a
7949 randomly generated value. Return an error if the partition table of
7950 "device" isn't GPT.
7951
7952 This command depends on the feature "gdisk". See also "feature-
7953 available".
7954
7955 part-set-gpt-attributes
7956 part-set-gpt-attributes device partnum attributes
7957
7958 Set the attribute flags of numbered GPT partition "partnum" to
7959 "attributes". Return an error if the partition table of "device" isn't
7960 GPT.
7961
7962 See
7963 https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries
7964 for a useful list of partition attributes.
7965
7966 This command depends on the feature "gdisk". See also "feature-
7967 available".
7968
7969 part-set-gpt-guid
7970 part-set-gpt-guid device partnum guid
7971
7972 Set the GUID of numbered GPT partition "partnum" to "guid". Return an
7973 error if the partition table of "device" isn't GPT, or if "guid" is not
7974 a valid GUID.
7975
7976 This command depends on the feature "gdisk". See also "feature-
7977 available".
7978
7979 part-set-gpt-type
7980 part-set-gpt-type device partnum guid
7981
7982 Set the type GUID of numbered GPT partition "partnum" to "guid". Return
7983 an error if the partition table of "device" isn't GPT, or if "guid" is
7984 not a valid GUID.
7985
7986 See
7987 https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
7988 for a useful list of type GUIDs.
7989
7990 This command depends on the feature "gdisk". See also "feature-
7991 available".
7992
7993 part-set-mbr-id
7994 part-set-mbr-id device partnum idbyte
7995
7996 Sets the MBR type byte (also known as the ID byte) of the numbered
7997 partition "partnum" to "idbyte". Note that the type bytes quoted in
7998 most documentation are in fact hexadecimal numbers, but usually
7999 documented without any leading "0x" which might be confusing.
8000
8001 Note that only MBR (old DOS-style) partitions have type bytes. You
8002 will get undefined results for other partition table types (see "part-
8003 get-parttype").
8004
8005 part-set-name
8006 part-set-name device partnum name
8007
8008 This sets the partition name on partition numbered "partnum" on device
8009 "device". Note that partitions are numbered from 1.
8010
8011 The partition name can only be set on certain types of partition table.
8012 This works on "gpt" but not on "mbr" partitions.
8013
8014 part-to-dev
8015 part-to-dev partition
8016
8017 This function takes a partition name (eg. "/dev/sdb1") and removes the
8018 partition number, returning the device name (eg. "/dev/sdb").
8019
8020 The named partition must exist, for example as a string returned from
8021 "list-partitions".
8022
8023 See also "part-to-partnum", "device-index".
8024
8025 part-to-partnum
8026 part-to-partnum partition
8027
8028 This function takes a partition name (eg. "/dev/sdb1") and returns the
8029 partition number (eg. 1).
8030
8031 The named partition must exist, for example as a string returned from
8032 "list-partitions".
8033
8034 See also "part-to-dev".
8035
8036 ping-daemon
8037 ping-daemon
8038
8039 This is a test probe into the guestfs daemon running inside the
8040 libguestfs appliance. Calling this function checks that the daemon
8041 responds to the ping message, without affecting the daemon or attached
8042 block device(s) in any other way.
8043
8044 pread
8045 pread path count offset
8046
8047 This command lets you read part of a file. It reads "count" bytes of
8048 the file, starting at "offset", from file "path".
8049
8050 This may read fewer bytes than requested. For further details see the
8051 pread(2) system call.
8052
8053 See also "pwrite", "pread-device".
8054
8055 Because of the message protocol, there is a transfer limit of somewhere
8056 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
8057
8058 pread-device
8059 pread-device device count offset
8060
8061 This command lets you read part of a block device. It reads "count"
8062 bytes of "device", starting at "offset".
8063
8064 This may read fewer bytes than requested. For further details see the
8065 pread(2) system call.
8066
8067 See also "pread".
8068
8069 Because of the message protocol, there is a transfer limit of somewhere
8070 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
8071
8072 pvchange-uuid
8073 pvchange-uuid device
8074
8075 Generate a new random UUID for the physical volume "device".
8076
8077 This command depends on the feature "lvm2". See also "feature-
8078 available".
8079
8080 pvchange-uuid-all
8081 pvchange-uuid-all
8082
8083 Generate new random UUIDs for all physical volumes.
8084
8085 This command depends on the feature "lvm2". See also "feature-
8086 available".
8087
8088 pvcreate
8089 pvcreate device
8090
8091 This creates an LVM physical volume on the named "device", where
8092 "device" should usually be a partition name such as /dev/sda1.
8093
8094 This command depends on the feature "lvm2". See also "feature-
8095 available".
8096
8097 pvremove
8098 pvremove device
8099
8100 This wipes a physical volume "device" so that LVM will no longer
8101 recognise it.
8102
8103 The implementation uses the pvremove(8) command which refuses to wipe
8104 physical volumes that contain any volume groups, so you have to remove
8105 those first.
8106
8107 This command depends on the feature "lvm2". See also "feature-
8108 available".
8109
8110 pvresize
8111 pvresize device
8112
8113 This resizes (expands or shrinks) an existing LVM physical volume to
8114 match the new size of the underlying device.
8115
8116 This command depends on the feature "lvm2". See also "feature-
8117 available".
8118
8119 pvresize-size
8120 pvresize-size device size
8121
8122 This command is the same as "pvresize" except that it allows you to
8123 specify the new size (in bytes) explicitly.
8124
8125 This command depends on the feature "lvm2". See also "feature-
8126 available".
8127
8128 pvs
8129 pvs
8130
8131 List all the physical volumes detected. This is the equivalent of the
8132 pvs(8) command.
8133
8134 This returns a list of just the device names that contain PVs (eg.
8135 /dev/sda2).
8136
8137 See also "pvs-full".
8138
8139 This command depends on the feature "lvm2". See also "feature-
8140 available".
8141
8142 pvs-full
8143 pvs-full
8144
8145 List all the physical volumes detected. This is the equivalent of the
8146 pvs(8) command. The "full" version includes all fields.
8147
8148 This command depends on the feature "lvm2". See also "feature-
8149 available".
8150
8151 pvuuid
8152 pvuuid device
8153
8154 This command returns the UUID of the LVM PV "device".
8155
8156 pwrite
8157 pwrite path content offset
8158
8159 This command writes to part of a file. It writes the data buffer
8160 "content" to the file "path" starting at offset "offset".
8161
8162 This command implements the pwrite(2) system call, and like that system
8163 call it may not write the full data requested. The return value is the
8164 number of bytes that were actually written to the file. This could
8165 even be 0, although short writes are unlikely for regular files in
8166 ordinary circumstances.
8167
8168 See also "pread", "pwrite-device".
8169
8170 Because of the message protocol, there is a transfer limit of somewhere
8171 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
8172
8173 pwrite-device
8174 pwrite-device device content offset
8175
8176 This command writes to part of a device. It writes the data buffer
8177 "content" to "device" starting at offset "offset".
8178
8179 This command implements the pwrite(2) system call, and like that system
8180 call it may not write the full data requested (although short writes to
8181 disk devices and partitions are probably impossible with standard Linux
8182 kernels).
8183
8184 See also "pwrite".
8185
8186 Because of the message protocol, there is a transfer limit of somewhere
8187 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
8188
8189 read-file
8190 read-file path
8191
8192 This calls returns the contents of the file "path" as a buffer.
8193
8194 Unlike "cat", this function can correctly handle files that contain
8195 embedded ASCII NUL characters.
8196
8197 read-lines
8198 read-lines path
8199
8200 Return the contents of the file named "path".
8201
8202 The file contents are returned as a list of lines. Trailing "LF" and
8203 "CRLF" character sequences are not returned.
8204
8205 Note that this function cannot correctly handle binary files
8206 (specifically, files containing "\0" character which is treated as end
8207 of string). For those you need to use the "read-file" function and
8208 split the buffer into lines yourself.
8209
8210 readdir
8211 readdir dir
8212
8213 This returns the list of directory entries in directory "dir".
8214
8215 All entries in the directory are returned, including "." and "..". The
8216 entries are not sorted, but returned in the same order as the
8217 underlying filesystem.
8218
8219 Also this call returns basic file type information about each file.
8220 The "ftyp" field will contain one of the following characters:
8221
8222 'b' Block special
8223
8224 'c' Char special
8225
8226 'd' Directory
8227
8228 'f' FIFO (named pipe)
8229
8230 'l' Symbolic link
8231
8232 'r' Regular file
8233
8234 's' Socket
8235
8236 'u' Unknown file type
8237
8238 '?' The readdir(3) call returned a "d_type" field with an unexpected
8239 value
8240
8241 This function is primarily intended for use by programs. To get a
8242 simple list of names, use "ls". To get a printable directory for human
8243 consumption, use "ll".
8244
8245 readlink
8246 readlink path
8247
8248 This command reads the target of a symbolic link.
8249
8250 readlinklist
8251 readlinklist path 'names ...'
8252
8253 This call allows you to do a "readlink" operation on multiple files,
8254 where all files are in the directory "path". "names" is the list of
8255 files from this directory.
8256
8257 On return you get a list of strings, with a one-to-one correspondence
8258 to the "names" list. Each string is the value of the symbolic link.
8259
8260 If the readlink(2) operation fails on any name, then the corresponding
8261 result string is the empty string "". However the whole operation is
8262 completed even if there were readlink(2) errors, and so you can call
8263 this function with names where you don't know if they are symbolic
8264 links already (albeit slightly less efficient).
8265
8266 This call is intended for programs that want to efficiently list a
8267 directory contents without making many round-trips.
8268
8269 realpath
8270 realpath path
8271
8272 Return the canonicalized absolute pathname of "path". The returned
8273 path has no ".", ".." or symbolic link path elements.
8274
8275 remount
8276 remount mountpoint [rw:true|false]
8277
8278 This call allows you to change the "rw" (readonly/read-write) flag on
8279 an already mounted filesystem at "mountpoint", converting a readonly
8280 filesystem to be read-write, or vice-versa.
8281
8282 Note that at the moment you must supply the "optional" "rw" parameter.
8283 In future we may allow other flags to be adjusted.
8284
8285 This command has one or more optional arguments. See "OPTIONAL
8286 ARGUMENTS".
8287
8288 remove-drive
8289 remove-drive label
8290
8291 This call does nothing and returns an error.
8292
8293 This function is deprecated. There is no replacement. Consult the API
8294 documentation in guestfs(3) for further information.
8295
8296 Deprecated functions will not be removed from the API, but the fact
8297 that they are deprecated indicates that there are problems with correct
8298 use of these functions.
8299
8300 removexattr
8301 removexattr xattr path
8302
8303 This call removes the extended attribute named "xattr" of the file
8304 "path".
8305
8306 See also: "lremovexattr", attr(5).
8307
8308 This command depends on the feature "linuxxattrs". See also "feature-
8309 available".
8310
8311 rename
8312 rename oldpath newpath
8313
8314 Rename a file to a new place on the same filesystem. This is the same
8315 as the Linux rename(2) system call. In most cases you are better to
8316 use "mv" instead.
8317
8318 resize2fs
8319 resize2fs device
8320
8321 This resizes an ext2, ext3 or ext4 filesystem to match the size of the
8322 underlying device.
8323
8324 See also "RESIZE2FS ERRORS" in guestfs(3).
8325
8326 resize2fs-M
8327 resize2fs-M device
8328
8329 This command is the same as "resize2fs", but the filesystem is resized
8330 to its minimum size. This works like the -M option to the resize2fs(8)
8331 command.
8332
8333 To get the resulting size of the filesystem you should call "tune2fs-l"
8334 and read the "Block size" and "Block count" values. These two numbers,
8335 multiplied together, give the resulting size of the minimal filesystem
8336 in bytes.
8337
8338 See also "RESIZE2FS ERRORS" in guestfs(3).
8339
8340 resize2fs-size
8341 resize2fs-size device size
8342
8343 This command is the same as "resize2fs" except that it allows you to
8344 specify the new size (in bytes) explicitly.
8345
8346 See also "RESIZE2FS ERRORS" in guestfs(3).
8347
8348 rm
8349 rm path
8350
8351 Remove the single file "path".
8352
8353 rm-f
8354 rm-f path
8355
8356 Remove the file "path".
8357
8358 If the file doesn't exist, that error is ignored. (Other errors, eg.
8359 I/O errors or bad paths, are not ignored)
8360
8361 This call cannot remove directories. Use "rmdir" to remove an empty
8362 directory, or "rm-rf" to remove directories recursively.
8363
8364 rm-rf
8365 rm-rf path
8366
8367 Remove the file or directory "path", recursively removing the contents
8368 if its a directory. This is like the "rm -rf" shell command.
8369
8370 rmdir
8371 rmdir path
8372
8373 Remove the single directory "path".
8374
8375 rmmountpoint
8376 rmmountpoint exemptpath
8377
8378 This call removes a mountpoint that was previously created with
8379 "mkmountpoint". See "mkmountpoint" for full details.
8380
8381 rsync
8382 rsync src dest [archive:true|false] [deletedest:true|false]
8383
8384 This call may be used to copy or synchronize two directories under the
8385 same libguestfs handle. This uses the rsync(1) program which uses a
8386 fast algorithm that avoids copying files unnecessarily.
8387
8388 "src" and "dest" are the source and destination directories. Files are
8389 copied from "src" to "dest".
8390
8391 The optional arguments are:
8392
8393 "archive"
8394 Turns on archive mode. This is the same as passing the --archive
8395 flag to "rsync".
8396
8397 "deletedest"
8398 Delete files at the destination that do not exist at the source.
8399
8400 This command has one or more optional arguments. See "OPTIONAL
8401 ARGUMENTS".
8402
8403 This command depends on the feature "rsync". See also "feature-
8404 available".
8405
8406 rsync-in
8407 rsync-in remote dest [archive:true|false] [deletedest:true|false]
8408
8409 This call may be used to copy or synchronize the filesystem on the host
8410 or on a remote computer with the filesystem within libguestfs. This
8411 uses the rsync(1) program which uses a fast algorithm that avoids
8412 copying files unnecessarily.
8413
8414 This call only works if the network is enabled. See "set-network" or
8415 the --network option to various tools like guestfish(1).
8416
8417 Files are copied from the remote server and directory specified by
8418 "remote" to the destination directory "dest".
8419
8420 The format of the remote server string is defined by rsync(1). Note
8421 that there is no way to supply a password or passphrase so the target
8422 must be set up not to require one.
8423
8424 The optional arguments are the same as those of "rsync".
8425
8426 This command has one or more optional arguments. See "OPTIONAL
8427 ARGUMENTS".
8428
8429 This command depends on the feature "rsync". See also "feature-
8430 available".
8431
8432 rsync-out
8433 rsync-out src remote [archive:true|false] [deletedest:true|false]
8434
8435 This call may be used to copy or synchronize the filesystem within
8436 libguestfs with a filesystem on the host or on a remote computer. This
8437 uses the rsync(1) program which uses a fast algorithm that avoids
8438 copying files unnecessarily.
8439
8440 This call only works if the network is enabled. See "set-network" or
8441 the --network option to various tools like guestfish(1).
8442
8443 Files are copied from the source directory "src" to the remote server
8444 and directory specified by "remote".
8445
8446 The format of the remote server string is defined by rsync(1). Note
8447 that there is no way to supply a password or passphrase so the target
8448 must be set up not to require one.
8449
8450 The optional arguments are the same as those of "rsync".
8451
8452 Globbing does not happen on the "src" parameter. In programs which use
8453 the API directly you have to expand wildcards yourself (see "glob-
8454 expand"). In guestfish you can use the "glob" command (see "glob"),
8455 for example:
8456
8457 ><fs> glob rsync-out /* rsync://remote/
8458
8459 This command has one or more optional arguments. See "OPTIONAL
8460 ARGUMENTS".
8461
8462 This command depends on the feature "rsync". See also "feature-
8463 available".
8464
8465 scrub-device
8466 scrub-device device
8467
8468 This command writes patterns over "device" to make data retrieval more
8469 difficult.
8470
8471 It is an interface to the scrub(1) program. See that manual page for
8472 more details.
8473
8474 This command depends on the feature "scrub". See also "feature-
8475 available".
8476
8477 scrub-file
8478 scrub-file file
8479
8480 This command writes patterns over a file to make data retrieval more
8481 difficult.
8482
8483 The file is removed after scrubbing.
8484
8485 It is an interface to the scrub(1) program. See that manual page for
8486 more details.
8487
8488 This command depends on the feature "scrub". See also "feature-
8489 available".
8490
8491 scrub-freespace
8492 scrub-freespace dir
8493
8494 This command creates the directory "dir" and then fills it with files
8495 until the filesystem is full, and scrubs the files as for "scrub-file",
8496 and deletes them. The intention is to scrub any free space on the
8497 partition containing "dir".
8498
8499 It is an interface to the scrub(1) program. See that manual page for
8500 more details.
8501
8502 This command depends on the feature "scrub". See also "feature-
8503 available".
8504
8505 selinux-relabel
8506 selinux-relabel specfile path [force:true|false]
8507
8508 SELinux relabel parts of the filesystem.
8509
8510 The "specfile" parameter controls the policy spec file used. You have
8511 to parse "/etc/selinux/config" to find the correct SELinux policy and
8512 then pass the spec file, usually: "/etc/selinux/" + selinuxtype +
8513 "/contexts/files/file_contexts".
8514
8515 The required "path" parameter is the top level directory where
8516 relabelling starts. Normally you should pass "path" as "/" to relabel
8517 the whole guest filesystem.
8518
8519 The optional "force" boolean controls whether the context is reset for
8520 customizable files, and also whether the user, role and range parts of
8521 the file context is changed.
8522
8523 This command has one or more optional arguments. See "OPTIONAL
8524 ARGUMENTS".
8525
8526 This command depends on the feature "selinuxrelabel". See also
8527 "feature-available".
8528
8529 set-append
8530 append
8531 set-append append
8532
8533 This function is used to add additional options to the libguestfs
8534 appliance kernel command line.
8535
8536 The default is "NULL" unless overridden by setting "LIBGUESTFS_APPEND"
8537 environment variable.
8538
8539 Setting "append" to "NULL" means no additional options are passed
8540 (libguestfs always adds a few of its own).
8541
8542 set-attach-method
8543 attach-method
8544 set-attach-method backend
8545
8546 Set the method that libguestfs uses to connect to the backend guestfsd
8547 daemon.
8548
8549 See "BACKEND" in guestfs(3).
8550
8551 This function is deprecated. In new code, use the "set-backend" call
8552 instead.
8553
8554 Deprecated functions will not be removed from the API, but the fact
8555 that they are deprecated indicates that there are problems with correct
8556 use of these functions.
8557
8558 set-autosync
8559 autosync
8560 set-autosync true|false
8561
8562 If "autosync" is true, this enables autosync. Libguestfs will make a
8563 best effort attempt to make filesystems consistent and synchronized
8564 when the handle is closed (also if the program exits without closing
8565 handles).
8566
8567 This is enabled by default (since libguestfs 1.5.24, previously it was
8568 disabled by default).
8569
8570 set-backend
8571 backend
8572 set-backend backend
8573
8574 Set the method that libguestfs uses to connect to the backend guestfsd
8575 daemon.
8576
8577 This handle property was previously called the "attach method".
8578
8579 See "BACKEND" in guestfs(3).
8580
8581 set-backend-setting
8582 set-backend-setting name val
8583
8584 Append "name=value" to the backend settings string list. However if a
8585 string already exists matching "name" or beginning with "name=", then
8586 that setting is replaced.
8587
8588 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
8589
8590 set-backend-settings
8591 set-backend-settings 'settings ...'
8592
8593 Set a list of zero or more settings which are passed through to the
8594 current backend. Each setting is a string which is interpreted in a
8595 backend-specific way, or ignored if not understood by the backend.
8596
8597 The default value is an empty list, unless the environment variable
8598 "LIBGUESTFS_BACKEND_SETTINGS" was set when the handle was created.
8599 This environment variable contains a colon-separated list of settings.
8600
8601 This call replaces all backend settings. If you want to replace a
8602 single backend setting, see "set-backend-setting". If you want to
8603 clear a single backend setting, see "clear-backend-setting".
8604
8605 See "BACKEND" in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
8606
8607 set-cachedir
8608 cachedir
8609 set-cachedir cachedir
8610
8611 Set the directory used by the handle to store the appliance cache, when
8612 using a supermin appliance. The appliance is cached and shared between
8613 all handles which have the same effective user ID.
8614
8615 The environment variables "LIBGUESTFS_CACHEDIR" and "TMPDIR" control
8616 the default value: If "LIBGUESTFS_CACHEDIR" is set, then that is the
8617 default. Else if "TMPDIR" is set, then that is the default. Else
8618 /var/tmp is the default.
8619
8620 set-direct
8621 direct
8622 set-direct true|false
8623
8624 If the direct appliance mode flag is enabled, then stdin and stdout are
8625 passed directly through to the appliance once it is launched.
8626
8627 One consequence of this is that log messages aren't caught by the
8628 library and handled by "set-log-message-callback", but go straight to
8629 stdout.
8630
8631 You probably don't want to use this unless you know what you are doing.
8632
8633 The default is disabled.
8634
8635 This function is deprecated. In new code, use the "internal-get-
8636 console-socket" call instead.
8637
8638 Deprecated functions will not be removed from the API, but the fact
8639 that they are deprecated indicates that there are problems with correct
8640 use of these functions.
8641
8642 set-e2attrs
8643 set-e2attrs file attrs [clear:true|false]
8644
8645 This sets or clears the file attributes "attrs" associated with the
8646 inode file.
8647
8648 "attrs" is a string of characters representing file attributes. See
8649 "get-e2attrs" for a list of possible attributes. Not all attributes
8650 can be changed.
8651
8652 If optional boolean "clear" is not present or false, then the "attrs"
8653 listed are set in the inode.
8654
8655 If "clear" is true, then the "attrs" listed are cleared in the inode.
8656
8657 In both cases, other attributes not present in the "attrs" string are
8658 left unchanged.
8659
8660 These attributes are only present when the file is located on an
8661 ext2/3/4 filesystem. Using this call on other filesystem types will
8662 result in an error.
8663
8664 This command has one or more optional arguments. See "OPTIONAL
8665 ARGUMENTS".
8666
8667 set-e2generation
8668 set-e2generation file generation
8669
8670 This sets the ext2 file generation of a file.
8671
8672 See "get-e2generation".
8673
8674 set-e2label
8675 set-e2label device label
8676
8677 This sets the ext2/3/4 filesystem label of the filesystem on "device"
8678 to "label". Filesystem labels are limited to 16 characters.
8679
8680 You can use either "tune2fs-l" or "get-e2label" to return the existing
8681 label on a filesystem.
8682
8683 This function is deprecated. In new code, use the "set-label" call
8684 instead.
8685
8686 Deprecated functions will not be removed from the API, but the fact
8687 that they are deprecated indicates that there are problems with correct
8688 use of these functions.
8689
8690 set-e2uuid
8691 set-e2uuid device uuid
8692
8693 This sets the ext2/3/4 filesystem UUID of the filesystem on "device" to
8694 "uuid". The format of the UUID and alternatives such as "clear",
8695 "random" and "time" are described in the tune2fs(8) manpage.
8696
8697 You can use "vfs-uuid" to return the existing UUID of a filesystem.
8698
8699 This function is deprecated. In new code, use the "set-uuid" call
8700 instead.
8701
8702 Deprecated functions will not be removed from the API, but the fact
8703 that they are deprecated indicates that there are problems with correct
8704 use of these functions.
8705
8706 set-hv
8707 hv
8708 set-hv hv
8709
8710 Set the hypervisor binary that we will use. The hypervisor depends on
8711 the backend, but is usually the location of the qemu/KVM hypervisor.
8712
8713 The default is chosen when the library was compiled by the configure
8714 script.
8715
8716 You can also override this by setting the "LIBGUESTFS_HV" environment
8717 variable.
8718
8719 Note that you should call this function as early as possible after
8720 creating the handle. This is because some pre-launch operations depend
8721 on testing qemu features (by running "qemu -help"). If the qemu binary
8722 changes, we don't retest features, and so you might see inconsistent
8723 results. Using the environment variable "LIBGUESTFS_HV" is safest of
8724 all since that picks the qemu binary at the same time as the handle is
8725 created.
8726
8727 set-identifier
8728 identifier
8729 set-identifier identifier
8730
8731 This is an informative string which the caller may optionally set in
8732 the handle. It is printed in various places, allowing the current
8733 handle to be identified in debugging output.
8734
8735 One important place is when tracing is enabled. If the identifier
8736 string is not an empty string, then trace messages change from this:
8737
8738 libguestfs: trace: get_tmpdir
8739 libguestfs: trace: get_tmpdir = "/tmp"
8740
8741 to this:
8742
8743 libguestfs: trace: ID: get_tmpdir
8744 libguestfs: trace: ID: get_tmpdir = "/tmp"
8745
8746 where "ID" is the identifier string set by this call.
8747
8748 The identifier must only contain alphanumeric ASCII characters,
8749 underscore and minus sign. The default is the empty string.
8750
8751 See also "set-program", "set-trace", "get-identifier".
8752
8753 set-label
8754 set-label mountable label
8755
8756 Set the filesystem label on "mountable" to "label".
8757
8758 Only some filesystem types support labels, and libguestfs supports
8759 setting labels on only a subset of these.
8760
8761 ext2, ext3, ext4
8762 Labels are limited to 16 bytes.
8763
8764 NTFS
8765 Labels are limited to 128 unicode characters.
8766
8767 XFS The label is limited to 12 bytes. The filesystem must not be
8768 mounted when trying to set the label.
8769
8770 btrfs
8771 The label is limited to 255 bytes and some characters are not
8772 allowed. Setting the label on a btrfs subvolume will set the label
8773 on its parent filesystem. The filesystem must not be mounted when
8774 trying to set the label.
8775
8776 fat The label is limited to 11 bytes.
8777
8778 swap
8779 The label is limited to 16 bytes.
8780
8781 If there is no support for changing the label for the type of the
8782 specified filesystem, set_label will fail and set errno as ENOTSUP.
8783
8784 To read the label on a filesystem, call "vfs-label".
8785
8786 set-libvirt-requested-credential
8787 set-libvirt-requested-credential index cred
8788
8789 After requesting the "index"'th credential from the user, call this
8790 function to pass the answer back to libvirt.
8791
8792 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
8793 example code.
8794
8795 set-libvirt-supported-credentials
8796 set-libvirt-supported-credentials 'creds ...'
8797
8798 Call this function before setting an event handler for
8799 "GUESTFS_EVENT_LIBVIRT_AUTH", to supply the list of credential types
8800 that the program knows how to process.
8801
8802 The "creds" list must be a non-empty list of strings. Possible strings
8803 are:
8804
8805 "username"
8806 "authname"
8807 "language"
8808 "cnonce"
8809 "passphrase"
8810 "echoprompt"
8811 "noechoprompt"
8812 "realm"
8813 "external"
8814
8815 See libvirt documentation for the meaning of these credential types.
8816
8817 See "LIBVIRT AUTHENTICATION" in guestfs(3) for documentation and
8818 example code.
8819
8820 set-memsize
8821 memsize
8822 set-memsize memsize
8823
8824 This sets the memory size in megabytes allocated to the hypervisor.
8825 This only has any effect if called before "launch".
8826
8827 You can also change this by setting the environment variable
8828 "LIBGUESTFS_MEMSIZE" before the handle is created.
8829
8830 For more information on the architecture of libguestfs, see guestfs(3).
8831
8832 set-network
8833 network
8834 set-network true|false
8835
8836 If "network" is true, then the network is enabled in the libguestfs
8837 appliance. The default is false.
8838
8839 This affects whether commands are able to access the network (see
8840 "RUNNING COMMANDS" in guestfs(3)).
8841
8842 You must call this before calling "launch", otherwise it has no effect.
8843
8844 set-path
8845 path
8846 set-path searchpath
8847
8848 Set the path that libguestfs searches for kernel and initrd.img.
8849
8850 The default is "$libdir/guestfs" unless overridden by setting
8851 "LIBGUESTFS_PATH" environment variable.
8852
8853 Setting "path" to "NULL" restores the default path.
8854
8855 set-pgroup
8856 pgroup
8857 set-pgroup true|false
8858
8859 If "pgroup" is true, child processes are placed into their own process
8860 group.
8861
8862 The practical upshot of this is that signals like "SIGINT" (from users
8863 pressing "^C") won't be received by the child process.
8864
8865 The default for this flag is false, because usually you want "^C" to
8866 kill the subprocess. Guestfish sets this flag to true when used
8867 interactively, so that "^C" can cancel long-running commands gracefully
8868 (see "user-cancel").
8869
8870 set-program
8871 program
8872 set-program program
8873
8874 Set the program name. This is an informative string which the main
8875 program may optionally set in the handle.
8876
8877 When the handle is created, the program name in the handle is set to
8878 the basename from "argv[0]". The program name can never be "NULL".
8879
8880 set-qemu
8881 qemu
8882 set-qemu hv
8883
8884 Set the hypervisor binary (usually qemu) that we will use.
8885
8886 The default is chosen when the library was compiled by the configure
8887 script.
8888
8889 You can also override this by setting the "LIBGUESTFS_HV" environment
8890 variable.
8891
8892 Setting "hv" to "NULL" restores the default qemu binary.
8893
8894 Note that you should call this function as early as possible after
8895 creating the handle. This is because some pre-launch operations depend
8896 on testing qemu features (by running "qemu -help"). If the qemu binary
8897 changes, we don't retest features, and so you might see inconsistent
8898 results. Using the environment variable "LIBGUESTFS_HV" is safest of
8899 all since that picks the qemu binary at the same time as the handle is
8900 created.
8901
8902 This function is deprecated. In new code, use the "set-hv" call
8903 instead.
8904
8905 Deprecated functions will not be removed from the API, but the fact
8906 that they are deprecated indicates that there are problems with correct
8907 use of these functions.
8908
8909 set-recovery-proc
8910 recovery-proc
8911 set-recovery-proc true|false
8912
8913 If this is called with the parameter "false" then "launch" does not
8914 create a recovery process. The purpose of the recovery process is to
8915 stop runaway hypervisor processes in the case where the main program
8916 aborts abruptly.
8917
8918 This only has any effect if called before "launch", and the default is
8919 true.
8920
8921 About the only time when you would want to disable this is if the main
8922 process will fork itself into the background ("daemonize" itself). In
8923 this case the recovery process thinks that the main program has
8924 disappeared and so kills the hypervisor, which is not very helpful.
8925
8926 set-selinux
8927 selinux
8928 set-selinux true|false
8929
8930 This sets the selinux flag that is passed to the appliance at boot
8931 time. The default is "selinux=0" (disabled).
8932
8933 Note that if SELinux is enabled, it is always in Permissive mode
8934 ("enforcing=0").
8935
8936 For more information on the architecture of libguestfs, see guestfs(3).
8937
8938 This function is deprecated. In new code, use the "selinux-relabel"
8939 call instead.
8940
8941 Deprecated functions will not be removed from the API, but the fact
8942 that they are deprecated indicates that there are problems with correct
8943 use of these functions.
8944
8945 set-smp
8946 smp
8947 set-smp smp
8948
8949 Change the number of virtual CPUs assigned to the appliance. The
8950 default is 1. Increasing this may improve performance, though often it
8951 has no effect.
8952
8953 This function must be called before "launch".
8954
8955 set-tmpdir
8956 tmpdir
8957 set-tmpdir tmpdir
8958
8959 Set the directory used by the handle to store temporary files.
8960
8961 The environment variables "LIBGUESTFS_TMPDIR" and "TMPDIR" control the
8962 default value: If "LIBGUESTFS_TMPDIR" is set, then that is the default.
8963 Else if "TMPDIR" is set, then that is the default. Else /tmp is the
8964 default.
8965
8966 set-trace
8967 trace
8968 set-trace true|false
8969
8970 If the command trace flag is set to 1, then libguestfs calls,
8971 parameters and return values are traced.
8972
8973 If you want to trace C API calls into libguestfs (and other libraries)
8974 then possibly a better way is to use the external ltrace(1) command.
8975
8976 Command traces are disabled unless the environment variable
8977 "LIBGUESTFS_TRACE" is defined and set to 1.
8978
8979 Trace messages are normally sent to "stderr", unless you register a
8980 callback to send them somewhere else (see "set-event-callback").
8981
8982 set-uuid
8983 set-uuid device uuid
8984
8985 Set the filesystem UUID on "device" to "uuid". If this fails and the
8986 errno is ENOTSUP, means that there is no support for changing the UUID
8987 for the type of the specified filesystem.
8988
8989 Only some filesystem types support setting UUIDs.
8990
8991 To read the UUID on a filesystem, call "vfs-uuid".
8992
8993 set-uuid-random
8994 set-uuid-random device
8995
8996 Set the filesystem UUID on "device" to a random UUID. If this fails
8997 and the errno is ENOTSUP, means that there is no support for changing
8998 the UUID for the type of the specified filesystem.
8999
9000 Only some filesystem types support setting UUIDs.
9001
9002 To read the UUID on a filesystem, call "vfs-uuid".
9003
9004 set-verbose
9005 verbose
9006 set-verbose true|false
9007
9008 If "verbose" is true, this turns on verbose messages.
9009
9010 Verbose messages are disabled unless the environment variable
9011 "LIBGUESTFS_DEBUG" is defined and set to 1.
9012
9013 Verbose messages are normally sent to "stderr", unless you register a
9014 callback to send them somewhere else (see "set-event-callback").
9015
9016 setcon
9017 setcon context
9018
9019 This sets the SELinux security context of the daemon to the string
9020 "context".
9021
9022 See the documentation about SELINUX in guestfs(3).
9023
9024 This function is deprecated. In new code, use the "selinux-relabel"
9025 call instead.
9026
9027 Deprecated functions will not be removed from the API, but the fact
9028 that they are deprecated indicates that there are problems with correct
9029 use of these functions.
9030
9031 This command depends on the feature "selinux". See also "feature-
9032 available".
9033
9034 setxattr
9035 setxattr xattr val vallen path
9036
9037 This call sets the extended attribute named "xattr" of the file "path"
9038 to the value "val" (of length "vallen"). The value is arbitrary 8 bit
9039 data.
9040
9041 See also: "lsetxattr", attr(5).
9042
9043 This command depends on the feature "linuxxattrs". See also "feature-
9044 available".
9045
9046 sfdisk
9047 sfdisk device cyls heads sectors 'lines ...'
9048
9049 This is a direct interface to the sfdisk(8) program for creating
9050 partitions on block devices.
9051
9052 "device" should be a block device, for example /dev/sda.
9053
9054 "cyls", "heads" and "sectors" are the number of cylinders, heads and
9055 sectors on the device, which are passed directly to sfdisk(8) as the
9056 -C, -H and -S parameters. If you pass 0 for any of these, then the
9057 corresponding parameter is omitted. Usually for ‘large’ disks, you can
9058 just pass 0 for these, but for small (floppy-sized) disks, sfdisk(8)
9059 (or rather, the kernel) cannot work out the right geometry and you will
9060 need to tell it.
9061
9062 "lines" is a list of lines that we feed to sfdisk(8). For more
9063 information refer to the sfdisk(8) manpage.
9064
9065 To create a single partition occupying the whole disk, you would pass
9066 "lines" as a single element list, when the single element being the
9067 string "," (comma).
9068
9069 See also: "sfdisk-l", "sfdisk-N", "part-init"
9070
9071 This function is deprecated. In new code, use the "part-add" call
9072 instead.
9073
9074 Deprecated functions will not be removed from the API, but the fact
9075 that they are deprecated indicates that there are problems with correct
9076 use of these functions.
9077
9078 sfdiskM
9079 sfdiskM device 'lines ...'
9080
9081 This is a simplified interface to the "sfdisk" command, where partition
9082 sizes are specified in megabytes only (rounded to the nearest cylinder)
9083 and you don't need to specify the cyls, heads and sectors parameters
9084 which were rarely if ever used anyway.
9085
9086 See also: "sfdisk", the sfdisk(8) manpage and "part-disk"
9087
9088 This function is deprecated. In new code, use the "part-add" call
9089 instead.
9090
9091 Deprecated functions will not be removed from the API, but the fact
9092 that they are deprecated indicates that there are problems with correct
9093 use of these functions.
9094
9095 sfdisk-N
9096 sfdisk-N device partnum cyls heads sectors line
9097
9098 This runs sfdisk(8) option to modify just the single partition "n"
9099 (note: "n" counts from 1).
9100
9101 For other parameters, see "sfdisk". You should usually pass 0 for the
9102 cyls/heads/sectors parameters.
9103
9104 See also: "part-add"
9105
9106 This function is deprecated. In new code, use the "part-add" call
9107 instead.
9108
9109 Deprecated functions will not be removed from the API, but the fact
9110 that they are deprecated indicates that there are problems with correct
9111 use of these functions.
9112
9113 sfdisk-disk-geometry
9114 sfdisk-disk-geometry device
9115
9116 This displays the disk geometry of "device" read from the partition
9117 table. Especially in the case where the underlying block device has
9118 been resized, this can be different from the kernel’s idea of the
9119 geometry (see "sfdisk-kernel-geometry").
9120
9121 The result is in human-readable format, and not designed to be parsed.
9122
9123 sfdisk-kernel-geometry
9124 sfdisk-kernel-geometry device
9125
9126 This displays the kernel’s idea of the geometry of "device".
9127
9128 The result is in human-readable format, and not designed to be parsed.
9129
9130 sfdisk-l
9131 sfdisk-l device
9132
9133 This displays the partition table on "device", in the human-readable
9134 output of the sfdisk(8) command. It is not intended to be parsed.
9135
9136 See also: "part-list"
9137
9138 This function is deprecated. In new code, use the "part-list" call
9139 instead.
9140
9141 Deprecated functions will not be removed from the API, but the fact
9142 that they are deprecated indicates that there are problems with correct
9143 use of these functions.
9144
9145 sh
9146 sh command
9147
9148 This call runs a command from the guest filesystem via the guest’s
9149 /bin/sh.
9150
9151 This is like "command", but passes the command to:
9152
9153 /bin/sh -c "command"
9154
9155 Depending on the guest’s shell, this usually results in wildcards being
9156 expanded, shell expressions being interpolated and so on.
9157
9158 All the provisos about "command" apply to this call.
9159
9160 sh-lines
9161 sh-lines command
9162
9163 This is the same as "sh", but splits the result into a list of lines.
9164
9165 See also: "command-lines"
9166
9167 shutdown
9168 shutdown
9169
9170 This is the opposite of "launch". It performs an orderly shutdown of
9171 the backend process(es). If the autosync flag is set (which is the
9172 default) then the disk image is synchronized.
9173
9174 If the subprocess exits with an error then this function will return an
9175 error, which should not be ignored (it may indicate that the disk image
9176 could not be written out properly).
9177
9178 It is safe to call this multiple times. Extra calls are ignored.
9179
9180 This call does not close or free up the handle. You still need to call
9181 "close" afterwards.
9182
9183 "close" will call this if you don't do it explicitly, but note that any
9184 errors are ignored in that case.
9185
9186 sleep
9187 sleep secs
9188
9189 Sleep for "secs" seconds.
9190
9191 stat
9192 stat path
9193
9194 Returns file information for the given "path".
9195
9196 This is the same as the stat(2) system call.
9197
9198 This function is deprecated. In new code, use the "statns" call
9199 instead.
9200
9201 Deprecated functions will not be removed from the API, but the fact
9202 that they are deprecated indicates that there are problems with correct
9203 use of these functions.
9204
9205 statns
9206 statns path
9207
9208 Returns file information for the given "path".
9209
9210 This is the same as the stat(2) system call.
9211
9212 statvfs
9213 statvfs path
9214
9215 Returns file system statistics for any mounted file system. "path"
9216 should be a file or directory in the mounted file system (typically it
9217 is the mount point itself, but it doesn't need to be).
9218
9219 This is the same as the statvfs(2) system call.
9220
9221 strings
9222 strings path
9223
9224 This runs the strings(1) command on a file and returns the list of
9225 printable strings found.
9226
9227 The "strings" command has, in the past, had problems with parsing
9228 untrusted files. These are mitigated in the current version of
9229 libguestfs, but see "CVE-2014-8484" in guestfs(3).
9230
9231 Because of the message protocol, there is a transfer limit of somewhere
9232 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
9233
9234 strings-e
9235 strings-e encoding path
9236
9237 This is like the "strings" command, but allows you to specify the
9238 encoding of strings that are looked for in the source file "path".
9239
9240 Allowed encodings are:
9241
9242 s Single 7-bit-byte characters like ASCII and the ASCII-compatible
9243 parts of ISO-8859-X (this is what "strings" uses).
9244
9245 S Single 8-bit-byte characters.
9246
9247 b 16-bit big endian strings such as those encoded in UTF-16BE or
9248 UCS-2BE.
9249
9250 l (lower case letter L)
9251 16-bit little endian such as UTF-16LE and UCS-2LE. This is useful
9252 for examining binaries in Windows guests.
9253
9254 B 32-bit big endian such as UCS-4BE.
9255
9256 L 32-bit little endian such as UCS-4LE.
9257
9258 The returned strings are transcoded to UTF-8.
9259
9260 The "strings" command has, in the past, had problems with parsing
9261 untrusted files. These are mitigated in the current version of
9262 libguestfs, but see "CVE-2014-8484" in guestfs(3).
9263
9264 Because of the message protocol, there is a transfer limit of somewhere
9265 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
9266
9267 swapoff-device
9268 swapoff-device device
9269
9270 This command disables the libguestfs appliance swap device or partition
9271 named "device". See "swapon-device".
9272
9273 swapoff-file
9274 swapoff-file file
9275
9276 This command disables the libguestfs appliance swap on file.
9277
9278 swapoff-label
9279 swapoff-label label
9280
9281 This command disables the libguestfs appliance swap on labeled swap
9282 partition.
9283
9284 swapoff-uuid
9285 swapoff-uuid uuid
9286
9287 This command disables the libguestfs appliance swap partition with the
9288 given UUID.
9289
9290 This command depends on the feature "linuxfsuuid". See also "feature-
9291 available".
9292
9293 swapon-device
9294 swapon-device device
9295
9296 This command enables the libguestfs appliance to use the swap device or
9297 partition named "device". The increased memory is made available for
9298 all commands, for example those run using "command" or "sh".
9299
9300 Note that you should not swap to existing guest swap partitions unless
9301 you know what you are doing. They may contain hibernation information,
9302 or other information that the guest doesn't want you to trash. You
9303 also risk leaking information about the host to the guest this way.
9304 Instead, attach a new host device to the guest and swap on that.
9305
9306 swapon-file
9307 swapon-file file
9308
9309 This command enables swap to a file. See "swapon-device" for other
9310 notes.
9311
9312 swapon-label
9313 swapon-label label
9314
9315 This command enables swap to a labeled swap partition. See "swapon-
9316 device" for other notes.
9317
9318 swapon-uuid
9319 swapon-uuid uuid
9320
9321 This command enables swap to a swap partition with the given UUID. See
9322 "swapon-device" for other notes.
9323
9324 This command depends on the feature "linuxfsuuid". See also "feature-
9325 available".
9326
9327 sync
9328 sync
9329
9330 This syncs the disk, so that any writes are flushed through to the
9331 underlying disk image.
9332
9333 You should always call this if you have modified a disk image, before
9334 closing the handle.
9335
9336 syslinux
9337 syslinux device [directory:..]
9338
9339 Install the SYSLINUX bootloader on "device".
9340
9341 The device parameter must be either a whole disk formatted as a FAT
9342 filesystem, or a partition formatted as a FAT filesystem. In the
9343 latter case, the partition should be marked as "active" ("part-set-
9344 bootable") and a Master Boot Record must be installed (eg. using
9345 "pwrite-device") on the first sector of the whole disk. The SYSLINUX
9346 package comes with some suitable Master Boot Records. See the
9347 syslinux(1) man page for further information.
9348
9349 The optional arguments are:
9350
9351 directory
9352 Install SYSLINUX in the named subdirectory, instead of in the root
9353 directory of the FAT filesystem.
9354
9355 Additional configuration can be supplied to SYSLINUX by placing a file
9356 called syslinux.cfg on the FAT filesystem, either in the root
9357 directory, or under directory if that optional argument is being used.
9358 For further information about the contents of this file, see
9359 syslinux(1).
9360
9361 See also "extlinux".
9362
9363 This command has one or more optional arguments. See "OPTIONAL
9364 ARGUMENTS".
9365
9366 This command depends on the feature "syslinux". See also "feature-
9367 available".
9368
9369 tail
9370 tail path
9371
9372 This command returns up to the last 10 lines of a file as a list of
9373 strings.
9374
9375 Because of the message protocol, there is a transfer limit of somewhere
9376 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
9377
9378 tail-n
9379 tail-n nrlines path
9380
9381 If the parameter "nrlines" is a positive number, this returns the last
9382 "nrlines" lines of the file "path".
9383
9384 If the parameter "nrlines" is a negative number, this returns lines
9385 from the file "path", starting with the "-nrlines"'th line.
9386
9387 If the parameter "nrlines" is zero, this returns an empty list.
9388
9389 Because of the message protocol, there is a transfer limit of somewhere
9390 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
9391
9392 tar-in
9393 tar-in-opts
9394 tar-in (tarfile|-) directory [compress:..] [xattrs:true|false] [selinux:true|false] [acls:true|false]
9395
9396 This command uploads and unpacks local file "tarfile" into directory.
9397
9398 The optional "compress" flag controls compression. If not given, then
9399 the input should be an uncompressed tar file. Otherwise one of the
9400 following strings may be given to select the compression type of the
9401 input file: "compress", "gzip", "bzip2", "xz", "lzop", "lzma", "zstd".
9402 (Note that not all builds of libguestfs will support all of these
9403 compression types).
9404
9405 The other optional arguments are:
9406
9407 "xattrs"
9408 If set to true, extended attributes are restored from the tar file.
9409
9410 "selinux"
9411 If set to true, SELinux contexts are restored from the tar file.
9412
9413 "acls"
9414 If set to true, POSIX ACLs are restored from the tar file.
9415
9416 Use "-" instead of a filename to read/write from stdin/stdout.
9417
9418 This command has one or more optional arguments. See "OPTIONAL
9419 ARGUMENTS".
9420
9421 tar-out
9422 tar-out-opts
9423 tar-out directory (tarfile|-) [compress:..] [numericowner:true|false] [excludes:..] [xattrs:true|false] [selinux:true|false] [acls:true|false]
9424
9425 This command packs the contents of directory and downloads it to local
9426 file "tarfile".
9427
9428 The optional "compress" flag controls compression. If not given, then
9429 the output will be an uncompressed tar file. Otherwise one of the
9430 following strings may be given to select the compression type of the
9431 output file: "compress", "gzip", "bzip2", "xz", "lzop", "lzma", "zstd".
9432 (Note that not all builds of libguestfs will support all of these
9433 compression types).
9434
9435 The other optional arguments are:
9436
9437 "excludes"
9438 A list of wildcards. Files are excluded if they match any of the
9439 wildcards.
9440
9441 "numericowner"
9442 If set to true, the output tar file will contain UID/GID numbers
9443 instead of user/group names.
9444
9445 "xattrs"
9446 If set to true, extended attributes are saved in the output tar.
9447
9448 "selinux"
9449 If set to true, SELinux contexts are saved in the output tar.
9450
9451 "acls"
9452 If set to true, POSIX ACLs are saved in the output tar.
9453
9454 Use "-" instead of a filename to read/write from stdin/stdout.
9455
9456 This command has one or more optional arguments. See "OPTIONAL
9457 ARGUMENTS".
9458
9459 tgz-in
9460 tgz-in (tarball|-) directory
9461
9462 This command uploads and unpacks local file "tarball" (a gzip
9463 compressed tar file) into directory.
9464
9465 Use "-" instead of a filename to read/write from stdin/stdout.
9466
9467 This function is deprecated. In new code, use the "tar-in" call
9468 instead.
9469
9470 Deprecated functions will not be removed from the API, but the fact
9471 that they are deprecated indicates that there are problems with correct
9472 use of these functions.
9473
9474 tgz-out
9475 tgz-out directory (tarball|-)
9476
9477 This command packs the contents of directory and downloads it to local
9478 file "tarball".
9479
9480 Use "-" instead of a filename to read/write from stdin/stdout.
9481
9482 This function is deprecated. In new code, use the "tar-out" call
9483 instead.
9484
9485 Deprecated functions will not be removed from the API, but the fact
9486 that they are deprecated indicates that there are problems with correct
9487 use of these functions.
9488
9489 touch
9490 touch path
9491
9492 Touch acts like the touch(1) command. It can be used to update the
9493 timestamps on a file, or, if the file does not exist, to create a new
9494 zero-length file.
9495
9496 This command only works on regular files, and will fail on other file
9497 types such as directories, symbolic links, block special etc.
9498
9499 truncate
9500 truncate path
9501
9502 This command truncates "path" to a zero-length file. The file must
9503 exist already.
9504
9505 truncate-size
9506 truncate-size path size
9507
9508 This command truncates "path" to size "size" bytes. The file must
9509 exist already.
9510
9511 If the current file size is less than "size" then the file is extended
9512 to the required size with zero bytes. This creates a sparse file (ie.
9513 disk blocks are not allocated for the file until you write to it). To
9514 create a non-sparse file of zeroes, use "fallocate64" instead.
9515
9516 tune2fs
9517 tune2fs device [force:true|false] [maxmountcount:N] [mountcount:N] [errorbehavior:..] [group:N] [intervalbetweenchecks:N] [reservedblockspercentage:N] [lastmounteddirectory:..] [reservedblockscount:N] [user:N]
9518
9519 This call allows you to adjust various filesystem parameters of an
9520 ext2/ext3/ext4 filesystem called "device".
9521
9522 The optional parameters are:
9523
9524 "force"
9525 Force tune2fs to complete the operation even in the face of errors.
9526 This is the same as the tune2fs(8) "-f" option.
9527
9528 "maxmountcount"
9529 Set the number of mounts after which the filesystem is checked by
9530 e2fsck(8). If this is 0 then the number of mounts is disregarded.
9531 This is the same as the tune2fs(8) "-c" option.
9532
9533 "mountcount"
9534 Set the number of times the filesystem has been mounted. This is
9535 the same as the tune2fs(8) "-C" option.
9536
9537 "errorbehavior"
9538 Change the behavior of the kernel code when errors are detected.
9539 Possible values currently are: "continue", "remount-ro", "panic".
9540 In practice these options don't really make any difference,
9541 particularly for write errors.
9542
9543 This is the same as the tune2fs(8) "-e" option.
9544
9545 "group"
9546 Set the group which can use reserved filesystem blocks. This is
9547 the same as the tune2fs(8) "-g" option except that it can only be
9548 specified as a number.
9549
9550 "intervalbetweenchecks"
9551 Adjust the maximal time between two filesystem checks (in seconds).
9552 If the option is passed as 0 then time-dependent checking is
9553 disabled.
9554
9555 This is the same as the tune2fs(8) "-i" option.
9556
9557 "reservedblockspercentage"
9558 Set the percentage of the filesystem which may only be allocated by
9559 privileged processes. This is the same as the tune2fs(8) "-m"
9560 option.
9561
9562 "lastmounteddirectory"
9563 Set the last mounted directory. This is the same as the tune2fs(8)
9564 "-M" option.
9565
9566 "reservedblockscount" Set the number of reserved filesystem blocks.
9567 This is the same as the tune2fs(8) "-r" option.
9568 "user"
9569 Set the user who can use the reserved filesystem blocks. This is
9570 the same as the tune2fs(8) "-u" option except that it can only be
9571 specified as a number.
9572
9573 To get the current values of filesystem parameters, see "tune2fs-l".
9574 For precise details of how tune2fs works, see the tune2fs(8) man page.
9575
9576 This command has one or more optional arguments. See "OPTIONAL
9577 ARGUMENTS".
9578
9579 tune2fs-l
9580 tune2fs-l device
9581
9582 This returns the contents of the ext2, ext3 or ext4 filesystem
9583 superblock on "device".
9584
9585 It is the same as running "tune2fs -l device". See tune2fs(8) manpage
9586 for more details. The list of fields returned isn't clearly defined,
9587 and depends on both the version of "tune2fs" that libguestfs was built
9588 against, and the filesystem itself.
9589
9590 txz-in
9591 txz-in (tarball|-) directory
9592
9593 This command uploads and unpacks local file "tarball" (an xz compressed
9594 tar file) into directory.
9595
9596 Use "-" instead of a filename to read/write from stdin/stdout.
9597
9598 This function is deprecated. In new code, use the "tar-in" call
9599 instead.
9600
9601 Deprecated functions will not be removed from the API, but the fact
9602 that they are deprecated indicates that there are problems with correct
9603 use of these functions.
9604
9605 This command depends on the feature "xz". See also "feature-
9606 available".
9607
9608 txz-out
9609 txz-out directory (tarball|-)
9610
9611 This command packs the contents of directory and downloads it to local
9612 file "tarball" (as an xz compressed tar archive).
9613
9614 Use "-" instead of a filename to read/write from stdin/stdout.
9615
9616 This function is deprecated. In new code, use the "tar-out" call
9617 instead.
9618
9619 Deprecated functions will not be removed from the API, but the fact
9620 that they are deprecated indicates that there are problems with correct
9621 use of these functions.
9622
9623 This command depends on the feature "xz". See also "feature-
9624 available".
9625
9626 umask
9627 umask mask
9628
9629 This function sets the mask used for creating new files and device
9630 nodes to "mask & 0777".
9631
9632 Typical umask values would be 022 which creates new files with
9633 permissions like "-rw-r--r--" or "-rwxr-xr-x", and 002 which creates
9634 new files with permissions like "-rw-rw-r--" or "-rwxrwxr-x".
9635
9636 The default umask is 022. This is important because it means that
9637 directories and device nodes will be created with 0644 or 0755 mode
9638 even if you specify 0777.
9639
9640 See also "get-umask", umask(2), "mknod", "mkdir".
9641
9642 This call returns the previous umask.
9643
9644 umount
9645 unmount
9646 umount-opts
9647 umount pathordevice [force:true|false] [lazyunmount:true|false]
9648
9649 This unmounts the given filesystem. The filesystem may be specified
9650 either by its mountpoint (path) or the device which contains the
9651 filesystem.
9652
9653 This command has one or more optional arguments. See "OPTIONAL
9654 ARGUMENTS".
9655
9656 umount-all
9657 unmount-all
9658 umount-all
9659
9660 This unmounts all mounted filesystems.
9661
9662 Some internal mounts are not unmounted by this call.
9663
9664 umount-local
9665 umount-local [retry:true|false]
9666
9667 If libguestfs is exporting the filesystem on a local mountpoint, then
9668 this unmounts it.
9669
9670 See "MOUNT LOCAL" in guestfs(3) for full documentation.
9671
9672 This command has one or more optional arguments. See "OPTIONAL
9673 ARGUMENTS".
9674
9675 upload
9676 upload (filename|-) remotefilename
9677
9678 Upload local file filename to remotefilename on the filesystem.
9679
9680 filename can also be a named pipe.
9681
9682 See also "download".
9683
9684 Use "-" instead of a filename to read/write from stdin/stdout.
9685
9686 upload-offset
9687 upload-offset (filename|-) remotefilename offset
9688
9689 Upload local file filename to remotefilename on the filesystem.
9690
9691 remotefilename is overwritten starting at the byte "offset" specified.
9692 The intention is to overwrite parts of existing files or devices,
9693 although if a non-existent file is specified then it is created with a
9694 "hole" before "offset". The size of the data written is implicit in
9695 the size of the source filename.
9696
9697 Note that there is no limit on the amount of data that can be uploaded
9698 with this call, unlike with "pwrite", and this call always writes the
9699 full amount unless an error occurs.
9700
9701 See also "upload", "pwrite".
9702
9703 Use "-" instead of a filename to read/write from stdin/stdout.
9704
9705 user-cancel
9706 user-cancel
9707
9708 This function cancels the current upload or download operation.
9709
9710 Unlike most other libguestfs calls, this function is signal safe and
9711 thread safe. You can call it from a signal handler or from another
9712 thread, without needing to do any locking.
9713
9714 The transfer that was in progress (if there is one) will stop shortly
9715 afterwards, and will return an error. The errno (see
9716 "guestfs_last_errno") is set to "EINTR", so you can test for this to
9717 find out if the operation was cancelled or failed because of another
9718 error.
9719
9720 No cleanup is performed: for example, if a file was being uploaded then
9721 after cancellation there may be a partially uploaded file. It is the
9722 caller’s responsibility to clean up if necessary.
9723
9724 There are two common places that you might call "user-cancel":
9725
9726 In an interactive text-based program, you might call it from a "SIGINT"
9727 signal handler so that pressing "^C" cancels the current operation.
9728 (You also need to call "set-pgroup" so that child processes don't
9729 receive the "^C" signal).
9730
9731 In a graphical program, when the main thread is displaying a progress
9732 bar with a cancel button, wire up the cancel button to call this
9733 function.
9734
9735 utimens
9736 utimens path atsecs atnsecs mtsecs mtnsecs
9737
9738 This command sets the timestamps of a file with nanosecond precision.
9739
9740 "atsecs", "atnsecs" are the last access time (atime) in secs and
9741 nanoseconds from the epoch.
9742
9743 "mtsecs", "mtnsecs" are the last modification time (mtime) in secs and
9744 nanoseconds from the epoch.
9745
9746 If the *nsecs field contains the special value -1 then the
9747 corresponding timestamp is set to the current time. (The *secs field
9748 is ignored in this case).
9749
9750 If the *nsecs field contains the special value -2 then the
9751 corresponding timestamp is left unchanged. (The *secs field is ignored
9752 in this case).
9753
9754 utsname
9755 utsname
9756
9757 This returns the kernel version of the appliance, where this is
9758 available. This information is only useful for debugging. Nothing in
9759 the returned structure is defined by the API.
9760
9761 version
9762 version
9763
9764 Return the libguestfs version number that the program is linked
9765 against.
9766
9767 Note that because of dynamic linking this is not necessarily the
9768 version of libguestfs that you compiled against. You can compile the
9769 program, and then at runtime dynamically link against a completely
9770 different libguestfs.so library.
9771
9772 This call was added in version 1.0.58. In previous versions of
9773 libguestfs there was no way to get the version number. From C code you
9774 can use dynamic linker functions to find out if this symbol exists (if
9775 it doesn't, then it’s an earlier version).
9776
9777 The call returns a structure with four elements. The first three
9778 ("major", "minor" and "release") are numbers and correspond to the
9779 usual version triplet. The fourth element ("extra") is a string and is
9780 normally empty, but may be used for distro-specific information.
9781
9782 To construct the original version string:
9783 "$major.$minor.$release$extra"
9784
9785 See also: "LIBGUESTFS VERSION NUMBERS" in guestfs(3).
9786
9787 Note: Don't use this call to test for availability of features. In
9788 enterprise distributions we backport features from later versions into
9789 earlier versions, making this an unreliable way to test for features.
9790 Use "available" or "feature-available" instead.
9791
9792 vfs-label
9793 vfs-label mountable
9794
9795 This returns the label of the filesystem on "mountable".
9796
9797 If the filesystem is unlabeled, this returns the empty string.
9798
9799 To find a filesystem from the label, use "findfs-label".
9800
9801 vfs-minimum-size
9802 vfs-minimum-size mountable
9803
9804 Get the minimum size of filesystem in bytes. This is the minimum
9805 possible size for filesystem shrinking.
9806
9807 If getting minimum size of specified filesystem is not supported, this
9808 will fail and set errno as ENOTSUP.
9809
9810 See also ntfsresize(8), resize2fs(8), btrfs(8), xfs_info(8).
9811
9812 vfs-type
9813 vfs-type mountable
9814
9815 This command gets the filesystem type corresponding to the filesystem
9816 on "mountable".
9817
9818 For most filesystems, the result is the name of the Linux VFS module
9819 which would be used to mount this filesystem if you mounted it without
9820 specifying the filesystem type. For example a string such as "ext3" or
9821 "ntfs".
9822
9823 vfs-uuid
9824 get-uuid
9825 vfs-uuid mountable
9826
9827 This returns the filesystem UUID of the filesystem on "mountable".
9828
9829 If the filesystem does not have a UUID, this returns the empty string.
9830
9831 To find a filesystem from the UUID, use "findfs-uuid".
9832
9833 vg-activate
9834 vg-activate true|false 'volgroups ...'
9835
9836 This command activates or (if "activate" is false) deactivates all
9837 logical volumes in the listed volume groups "volgroups".
9838
9839 This command is the same as running "vgchange -a y|n volgroups..."
9840
9841 Note that if "volgroups" is an empty list then all volume groups are
9842 activated or deactivated.
9843
9844 This command depends on the feature "lvm2". See also "feature-
9845 available".
9846
9847 vg-activate-all
9848 vg-activate-all true|false
9849
9850 This command activates or (if "activate" is false) deactivates all
9851 logical volumes in all volume groups.
9852
9853 This command is the same as running "vgchange -a y|n"
9854
9855 This command depends on the feature "lvm2". See also "feature-
9856 available".
9857
9858 vgchange-uuid
9859 vgchange-uuid vg
9860
9861 Generate a new random UUID for the volume group "vg".
9862
9863 This command depends on the feature "lvm2". See also "feature-
9864 available".
9865
9866 vgchange-uuid-all
9867 vgchange-uuid-all
9868
9869 Generate new random UUIDs for all volume groups.
9870
9871 This command depends on the feature "lvm2". See also "feature-
9872 available".
9873
9874 vgcreate
9875 vgcreate volgroup 'physvols ...'
9876
9877 This creates an LVM volume group called "volgroup" from the non-empty
9878 list of physical volumes "physvols".
9879
9880 This command depends on the feature "lvm2". See also "feature-
9881 available".
9882
9883 vglvuuids
9884 vglvuuids vgname
9885
9886 Given a VG called "vgname", this returns the UUIDs of all the logical
9887 volumes created in this volume group.
9888
9889 You can use this along with "lvs" and "lvuuid" calls to associate
9890 logical volumes and volume groups.
9891
9892 See also "vgpvuuids".
9893
9894 vgmeta
9895 vgmeta vgname
9896
9897 "vgname" is an LVM volume group. This command examines the volume
9898 group and returns its metadata.
9899
9900 Note that the metadata is an internal structure used by LVM, subject to
9901 change at any time, and is provided for information only.
9902
9903 This command depends on the feature "lvm2". See also "feature-
9904 available".
9905
9906 vgpvuuids
9907 vgpvuuids vgname
9908
9909 Given a VG called "vgname", this returns the UUIDs of all the physical
9910 volumes that this volume group resides on.
9911
9912 You can use this along with "pvs" and "pvuuid" calls to associate
9913 physical volumes and volume groups.
9914
9915 See also "vglvuuids".
9916
9917 vgremove
9918 vgremove vgname
9919
9920 Remove an LVM volume group "vgname", (for example "VG").
9921
9922 This also forcibly removes all logical volumes in the volume group (if
9923 any).
9924
9925 This command depends on the feature "lvm2". See also "feature-
9926 available".
9927
9928 vgrename
9929 vgrename volgroup newvolgroup
9930
9931 Rename a volume group "volgroup" with the new name "newvolgroup".
9932
9933 vgs
9934 vgs
9935
9936 List all the volumes groups detected. This is the equivalent of the
9937 vgs(8) command.
9938
9939 This returns a list of just the volume group names that were detected
9940 (eg. "VolGroup00").
9941
9942 See also "vgs-full".
9943
9944 This command depends on the feature "lvm2". See also "feature-
9945 available".
9946
9947 vgs-full
9948 vgs-full
9949
9950 List all the volumes groups detected. This is the equivalent of the
9951 vgs(8) command. The "full" version includes all fields.
9952
9953 This command depends on the feature "lvm2". See also "feature-
9954 available".
9955
9956 vgscan
9957 vgscan
9958
9959 This rescans all block devices and rebuilds the list of LVM physical
9960 volumes, volume groups and logical volumes.
9961
9962 This function is deprecated. In new code, use the "lvm-scan" call
9963 instead.
9964
9965 Deprecated functions will not be removed from the API, but the fact
9966 that they are deprecated indicates that there are problems with correct
9967 use of these functions.
9968
9969 vguuid
9970 vguuid vgname
9971
9972 This command returns the UUID of the LVM VG named "vgname".
9973
9974 wc-c
9975 wc-c path
9976
9977 This command counts the characters in a file, using the "wc -c"
9978 external command.
9979
9980 wc-l
9981 wc-l path
9982
9983 This command counts the lines in a file, using the "wc -l" external
9984 command.
9985
9986 wc-w
9987 wc-w path
9988
9989 This command counts the words in a file, using the "wc -w" external
9990 command.
9991
9992 wipefs
9993 wipefs device
9994
9995 This command erases filesystem or RAID signatures from the specified
9996 "device" to make the filesystem invisible to libblkid.
9997
9998 This does not erase the filesystem itself nor any other data from the
9999 "device".
10000
10001 Compare with "zero" which zeroes the first few blocks of a device.
10002
10003 This command depends on the feature "wipefs". See also "feature-
10004 available".
10005
10006 write
10007 write path content
10008
10009 This call creates a file called "path". The content of the file is the
10010 string "content" (which can contain any 8 bit data).
10011
10012 See also "write-append".
10013
10014 write-append
10015 write-append path content
10016
10017 This call appends "content" to the end of file "path". If "path" does
10018 not exist, then a new file is created.
10019
10020 See also "write".
10021
10022 write-file
10023 write-file path content size
10024
10025 This call creates a file called "path". The contents of the file is
10026 the string "content" (which can contain any 8 bit data), with length
10027 "size".
10028
10029 As a special case, if "size" is 0 then the length is calculated using
10030 "strlen" (so in this case the content cannot contain embedded ASCII
10031 NULs).
10032
10033 NB. Owing to a bug, writing content containing ASCII NUL characters
10034 does not work, even if the length is specified.
10035
10036 Because of the message protocol, there is a transfer limit of somewhere
10037 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10038
10039 This function is deprecated. In new code, use the "write" call
10040 instead.
10041
10042 Deprecated functions will not be removed from the API, but the fact
10043 that they are deprecated indicates that there are problems with correct
10044 use of these functions.
10045
10046 xfs-admin
10047 xfs-admin device [extunwritten:true|false] [imgfile:true|false] [v2log:true|false] [projid32bit:true|false] [lazycounter:true|false] [label:..] [uuid:..]
10048
10049 Change the parameters of the XFS filesystem on "device".
10050
10051 Devices that are mounted cannot be modified. Administrators must
10052 unmount filesystems before this call can modify parameters.
10053
10054 Some of the parameters of a mounted filesystem can be examined and
10055 modified using the "xfs-info" and "xfs-growfs" calls.
10056
10057 Beginning with XFS version 5, it is no longer possible to modify the
10058 lazy-counters setting (ie. "lazycounter" parameter has no effect).
10059
10060 This command has one or more optional arguments. See "OPTIONAL
10061 ARGUMENTS".
10062
10063 This command depends on the feature "xfs". See also "feature-
10064 available".
10065
10066 xfs-growfs
10067 xfs-growfs path [datasec:true|false] [logsec:true|false] [rtsec:true|false] [datasize:N] [logsize:N] [rtsize:N] [rtextsize:N] [maxpct:N]
10068
10069 Grow the XFS filesystem mounted at "path".
10070
10071 The returned struct contains geometry information. Missing fields are
10072 returned as -1 (for numeric fields) or empty string.
10073
10074 This command has one or more optional arguments. See "OPTIONAL
10075 ARGUMENTS".
10076
10077 This command depends on the feature "xfs". See also "feature-
10078 available".
10079
10080 xfs-info
10081 xfs-info pathordevice
10082
10083 "pathordevice" is a mounted XFS filesystem or a device containing an
10084 XFS filesystem. This command returns the geometry of the filesystem.
10085
10086 The returned struct contains geometry information. Missing fields are
10087 returned as -1 (for numeric fields) or empty string.
10088
10089 This command depends on the feature "xfs". See also "feature-
10090 available".
10091
10092 xfs-repair
10093 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:..]
10094
10095 Repair corrupt or damaged XFS filesystem on "device".
10096
10097 The filesystem is specified using the "device" argument which should be
10098 the device name of the disk partition or volume containing the
10099 filesystem. If given the name of a block device, "xfs_repair" will
10100 attempt to find the raw device associated with the specified block
10101 device and will use the raw device instead.
10102
10103 Regardless, the filesystem to be repaired must be unmounted, otherwise,
10104 the resulting filesystem may be inconsistent or corrupt.
10105
10106 The returned status indicates whether filesystem corruption was
10107 detected (returns 1) or was not detected (returns 0).
10108
10109 This command has one or more optional arguments. See "OPTIONAL
10110 ARGUMENTS".
10111
10112 This command depends on the feature "xfs". See also "feature-
10113 available".
10114
10115 yara-destroy
10116 yara-destroy
10117
10118 Destroy previously loaded Yara rules in order to free libguestfs
10119 resources.
10120
10121 This command depends on the feature "libyara". See also "feature-
10122 available".
10123
10124 yara-load
10125 yara-load (filename|-)
10126
10127 Upload a set of Yara rules from local file filename.
10128
10129 Yara rules allow to categorize files based on textual or binary
10130 patterns within their content. See "yara-scan" to see how to scan
10131 files with the loaded rules.
10132
10133 Rules can be in binary format, as when compiled with yarac command, or
10134 in source code format. In the latter case, the rules will be first
10135 compiled and then loaded.
10136
10137 Rules in source code format cannot include external files. In such
10138 cases, it is recommended to compile them first.
10139
10140 Previously loaded rules will be destroyed.
10141
10142 Use "-" instead of a filename to read/write from stdin/stdout.
10143
10144 This command depends on the feature "libyara". See also "feature-
10145 available".
10146
10147 yara-scan
10148 yara-scan path
10149
10150 Scan a file with the previously loaded Yara rules.
10151
10152 For each matching rule, a "yara_detection" structure is returned.
10153
10154 The "yara_detection" structure contains the following fields.
10155
10156 "yara_name"
10157 Path of the file matching a Yara rule.
10158
10159 "yara_rule"
10160 Identifier of the Yara rule which matched against the given file.
10161
10162 This command depends on the feature "libyara". See also "feature-
10163 available".
10164
10165 zegrep
10166 zegrep regex path
10167
10168 This calls the external "zegrep" program and returns the matching
10169 lines.
10170
10171 Because of the message protocol, there is a transfer limit of somewhere
10172 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10173
10174 This function is deprecated. In new code, use the "grep" call instead.
10175
10176 Deprecated functions will not be removed from the API, but the fact
10177 that they are deprecated indicates that there are problems with correct
10178 use of these functions.
10179
10180 zegrepi
10181 zegrepi regex path
10182
10183 This calls the external "zegrep -i" program and returns the matching
10184 lines.
10185
10186 Because of the message protocol, there is a transfer limit of somewhere
10187 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10188
10189 This function is deprecated. In new code, use the "grep" call instead.
10190
10191 Deprecated functions will not be removed from the API, but the fact
10192 that they are deprecated indicates that there are problems with correct
10193 use of these functions.
10194
10195 zero
10196 zero device
10197
10198 This command writes zeroes over the first few blocks of "device".
10199
10200 How many blocks are zeroed isn't specified (but it’s not enough to
10201 securely wipe the device). It should be sufficient to remove any
10202 partition tables, filesystem superblocks and so on.
10203
10204 If blocks are already zero, then this command avoids writing zeroes.
10205 This prevents the underlying device from becoming non-sparse or growing
10206 unnecessarily.
10207
10208 See also: "zero-device", "scrub-device", "is-zero-device"
10209
10210 zero-device
10211 zero-device device
10212
10213 This command writes zeroes over the entire "device". Compare with
10214 "zero" which just zeroes the first few blocks of a device.
10215
10216 If blocks are already zero, then this command avoids writing zeroes.
10217 This prevents the underlying device from becoming non-sparse or growing
10218 unnecessarily.
10219
10220 zero-free-space
10221 zero-free-space directory
10222
10223 Zero the free space in the filesystem mounted on directory. The
10224 filesystem must be mounted read-write.
10225
10226 The filesystem contents are not affected, but any free space in the
10227 filesystem is freed.
10228
10229 Free space is not "trimmed". You may want to call "fstrim" either as
10230 an alternative to this, or after calling this, depending on your
10231 requirements.
10232
10233 zerofree
10234 zerofree device
10235
10236 This runs the zerofree program on "device". This program claims to
10237 zero unused inodes and disk blocks on an ext2/3 filesystem, thus making
10238 it possible to compress the filesystem more effectively.
10239
10240 You should not run this program if the filesystem is mounted.
10241
10242 It is possible that using this program can damage the filesystem or
10243 data on the filesystem.
10244
10245 This command depends on the feature "zerofree". See also "feature-
10246 available".
10247
10248 zfgrep
10249 zfgrep pattern path
10250
10251 This calls the external "zfgrep" program and returns the matching
10252 lines.
10253
10254 Because of the message protocol, there is a transfer limit of somewhere
10255 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10256
10257 This function is deprecated. In new code, use the "grep" call instead.
10258
10259 Deprecated functions will not be removed from the API, but the fact
10260 that they are deprecated indicates that there are problems with correct
10261 use of these functions.
10262
10263 zfgrepi
10264 zfgrepi pattern path
10265
10266 This calls the external "zfgrep -i" program and returns the matching
10267 lines.
10268
10269 Because of the message protocol, there is a transfer limit of somewhere
10270 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10271
10272 This function is deprecated. In new code, use the "grep" call instead.
10273
10274 Deprecated functions will not be removed from the API, but the fact
10275 that they are deprecated indicates that there are problems with correct
10276 use of these functions.
10277
10278 zfile
10279 zfile meth path
10280
10281 This command runs file(1) after first decompressing "path" using
10282 "meth".
10283
10284 "meth" must be one of "gzip", "compress" or "bzip2".
10285
10286 Since 1.0.63, use "file" instead which can now process compressed
10287 files.
10288
10289 This function is deprecated. In new code, use the "file" call instead.
10290
10291 Deprecated functions will not be removed from the API, but the fact
10292 that they are deprecated indicates that there are problems with correct
10293 use of these functions.
10294
10295 zgrep
10296 zgrep regex path
10297
10298 This calls the external zgrep(1) program and returns the matching
10299 lines.
10300
10301 Because of the message protocol, there is a transfer limit of somewhere
10302 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10303
10304 This function is deprecated. In new code, use the "grep" call instead.
10305
10306 Deprecated functions will not be removed from the API, but the fact
10307 that they are deprecated indicates that there are problems with correct
10308 use of these functions.
10309
10310 zgrepi
10311 zgrepi regex path
10312
10313 This calls the external "zgrep -i" program and returns the matching
10314 lines.
10315
10316 Because of the message protocol, there is a transfer limit of somewhere
10317 between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).
10318
10319 This function is deprecated. In new code, use the "grep" call instead.
10320
10321 Deprecated functions will not be removed from the API, but the fact
10322 that they are deprecated indicates that there are problems with correct
10323 use of these functions.
10324
10326 guestfish returns 0 if the commands completed without error, or 1 if
10327 there was an error.
10328
10330 EDITOR
10331 The "edit" command uses $EDITOR as the editor. If not set, it uses
10332 "vi".
10333
10334 GUESTFISH_DISPLAY_IMAGE
10335 The "display" command uses $GUESTFISH_DISPLAY_IMAGE to display
10336 images. If not set, it uses display(1).
10337
10338 GUESTFISH_INIT
10339 Printed when guestfish starts. See "PROMPT".
10340
10341 GUESTFISH_OUTPUT
10342 Printed before guestfish output. See "PROMPT".
10343
10344 GUESTFISH_PID
10345 Used with the --remote option to specify the remote guestfish
10346 process to control. See section "REMOTE CONTROL GUESTFISH OVER A
10347 SOCKET".
10348
10349 GUESTFISH_PS1
10350 Set the command prompt. See "PROMPT".
10351
10352 GUESTFISH_RESTORE
10353 Printed before guestfish exits. See "PROMPT".
10354
10355 HEXEDITOR
10356 The "hexedit" command uses $HEXEDITOR as the external hex editor.
10357 If not specified, the external hexedit(1) program is used.
10358
10359 HOME
10360 If compiled with GNU readline support, various files in the home
10361 directory can be used. See "FILES".
10362
10363 LIBGUESTFS_APPEND
10364 Pass additional options to the guest kernel.
10365
10366 LIBGUESTFS_ATTACH_METHOD
10367 This is the old way to set "LIBGUESTFS_BACKEND".
10368
10369 LIBGUESTFS_BACKEND
10370 Choose the default way to create the appliance. See
10371 "guestfs_set_backend" in guestfs(3).
10372
10373 LIBGUESTFS_BACKEND_SETTINGS
10374 A colon-separated list of backend-specific settings. See "BACKEND"
10375 in guestfs(3), "BACKEND SETTINGS" in guestfs(3).
10376
10377 LIBGUESTFS_CACHEDIR
10378 The location where libguestfs will cache its appliance, when using
10379 a supermin appliance. The appliance is cached and shared between
10380 all handles which have the same effective user ID.
10381
10382 If "LIBGUESTFS_CACHEDIR" is not set, then "TMPDIR" is used. If
10383 "TMPDIR" is not set, then /var/tmp is used.
10384
10385 See also "LIBGUESTFS_TMPDIR", "set-cachedir".
10386
10387 LIBGUESTFS_DEBUG
10388 Set "LIBGUESTFS_DEBUG=1" to enable verbose messages. This has the
10389 same effect as using the -v option.
10390
10391 LIBGUESTFS_HV
10392 Set the default hypervisor (usually qemu) binary that libguestfs
10393 uses. If not set, then the qemu which was found at compile time by
10394 the configure script is used.
10395
10396 LIBGUESTFS_MEMSIZE
10397 Set the memory allocated to the qemu process, in megabytes. For
10398 example:
10399
10400 LIBGUESTFS_MEMSIZE=700
10401
10402 LIBGUESTFS_PATH
10403 Set the path that guestfish uses to search for kernel and
10404 initrd.img. See the discussion of paths in guestfs(3).
10405
10406 LIBGUESTFS_QEMU
10407 This is the old way to set "LIBGUESTFS_HV".
10408
10409 LIBGUESTFS_TMPDIR
10410 The location where libguestfs will store temporary files used by
10411 each handle.
10412
10413 If "LIBGUESTFS_TMPDIR" is not set, then "TMPDIR" is used. If
10414 "TMPDIR" is not set, then /tmp is used.
10415
10416 See also "LIBGUESTFS_CACHEDIR", "set-tmpdir".
10417
10418 LIBGUESTFS_TRACE
10419 Set "LIBGUESTFS_TRACE=1" to enable command traces.
10420
10421 PAGER
10422 The "more" command uses $PAGER as the pager. If not set, it uses
10423 "more".
10424
10425 PATH
10426 Libguestfs and guestfish may run some external programs, and rely
10427 on $PATH being set to a reasonable value. If using the libvirt
10428 backend, libvirt will not work at all unless $PATH contains the
10429 path of qemu/KVM.
10430
10431 SUPERMIN_KERNEL
10432 SUPERMIN_KERNEL_VERSION
10433 SUPERMIN_MODULES
10434 These three environment variables allow the kernel that libguestfs
10435 uses in the appliance to be selected. If $SUPERMIN_KERNEL is not
10436 set, then the most recent host kernel is chosen. For more
10437 information about kernel selection, see supermin(1).
10438
10439 TMPDIR
10440 See "LIBGUESTFS_CACHEDIR", "LIBGUESTFS_TMPDIR".
10441
10442 XDG_RUNTIME_DIR
10443 This directory represents a user-specific directory for storing
10444 non-essential runtime files.
10445
10446 If it is set, then is used to store temporary sockets and PID
10447 files. Otherwise, /tmp is used.
10448
10449 See also "get-sockdir",
10450 http://www.freedesktop.org/wiki/Specifications/basedir-spec/.
10451
10453 $XDG_CONFIG_HOME/libguestfs/libguestfs-tools.conf
10454 $HOME/.libguestfs-tools.rc
10455 $XDG_CONFIG_DIRS/libguestfs/libguestfs-tools.conf
10456 /etc/libguestfs-tools.conf
10457 This configuration file controls the default read-only or read-
10458 write mode (--ro or --rw).
10459
10460 See libguestfs-tools.conf(5).
10461
10462 $HOME/.guestfish
10463 If compiled with GNU readline support, then the command history is
10464 saved in this file.
10465
10466 $HOME/.inputrc
10467 /etc/inputrc
10468 If compiled with GNU readline support, then these files can be used
10469 to configure readline. For further information, please see
10470 "INITIALIZATION FILE" in readline(3).
10471
10472 To write rules which only apply to guestfish, use:
10473
10474 $if guestfish
10475 ...
10476 $endif
10477
10478 Variables that you can set in inputrc that change the behaviour of
10479 guestfish in useful ways include:
10480
10481 completion-ignore-case (default: on)
10482 By default, guestfish will ignore case when tab-completing
10483 paths on the disk. Use:
10484
10485 set completion-ignore-case off
10486
10487 to make guestfish case sensitive.
10488
10489 test1.img
10490 test2.img (etc)
10491 When using the -N or --new option, the prepared disk or filesystem
10492 will be created in the file test1.img in the current directory.
10493 The second use of -N will use test2.img and so on. Any existing
10494 file with the same name will be overwritten. You can use a
10495 different filename by using the "filename=" prefix.
10496
10498 guestfs(3), http://libguestfs.org/, virt-alignment-scan(1),
10499 virt-builder(1), virt-builder-repository(1), virt-cat(1),
10500 virt-copy-in(1), virt-copy-out(1), virt-customize(1), virt-df(1),
10501 virt-diff(1), virt-edit(1), virt-filesystems(1), virt-inspector(1),
10502 virt-list-filesystems(1), virt-list-partitions(1), virt-log(1),
10503 virt-ls(1), virt-make-fs(1), virt-p2v(1), virt-rescue(1),
10504 virt-resize(1), virt-sparsify(1), virt-sysprep(1), virt-tail(1),
10505 virt-tar(1), virt-tar-in(1), virt-tar-out(1), virt-v2v(1),
10506 virt-win-reg(1), libguestfs-tools.conf(5), display(1), hexedit(1),
10507 supermin(1).
10508
10510 Richard W.M. Jones ("rjones at redhat dot com")
10511
10513 Copyright (C) 2009-2023 Red Hat Inc.
10514
10516 This program is free software; you can redistribute it and/or modify it
10517 under the terms of the GNU General Public License as published by the
10518 Free Software Foundation; either version 2 of the License, or (at your
10519 option) any later version.
10520
10521 This program is distributed in the hope that it will be useful, but
10522 WITHOUT ANY WARRANTY; without even the implied warranty of
10523 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10524 General Public License for more details.
10525
10526 You should have received a copy of the GNU General Public License along
10527 with this program; if not, write to the Free Software Foundation, Inc.,
10528 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
10529
10531 To get a list of bugs against libguestfs, use this link:
10532 https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
10533
10534 To report a new bug against libguestfs, use this link:
10535 https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
10536
10537 When reporting a bug, please supply:
10538
10539 • The version of libguestfs.
10540
10541 • Where you got libguestfs (eg. which Linux distro, compiled from
10542 source, etc)
10543
10544 • Describe the bug accurately and give a way to reproduce it.
10545
10546 • Run libguestfs-test-tool(1) and paste the complete, unedited output
10547 into the bug report.
10548
10549
10550
10551libguestfs-1.51.9 2023-12-09 guestfish(1)