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