.\" Automatically generated by Podwrapper::Man 1.44.0 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "guestfs-recipes 1" .TH guestfs-recipes 1 "2021-01-05" "libguestfs-1.44.0" "Virtualization Support" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "名前" .IX Header "名前" guestfs-recipes \- libguestfs, guestfish および仮想化ツールのレシピ .SH "説明" .IX Header "説明" このページには libguestfs, \fBguestfish\fR\|(1) および仮想化ツールを使用してできることのレシピとリンクがあります。 .SH "Access a remote disk image using guestfish" .IX Header "Access a remote disk image using guestfish" If the disk image is on a remote server which is accessible using \s-1SSH, HTTP, FTP, NBD,\s0 iSCSI, or similar, then you can open it directly. See \&\*(L"\s-1ADDING REMOTE STORAGE\*(R"\s0 in \fBguestfish\fR\|(1) for several examples. This requires libguestfs ≥ 1.22 and qemu ≥ 1.5. .SH "仮想マシンの setuid ファイルを監査します" .IX Header "仮想マシンの setuid ファイルを監査します" 関連項目: \*(L"例\*(R" in \fBvirt\-ls\fR\|(1)。 .SH "Audit a virtual machine for vulnerabilities and security problems" .IX Header "Audit a virtual machine for vulnerabilities and security problems" See: https://rwmj.wordpress.com/2013/05/16/scanning\-offline\-guests\-using\-openscap\-and\-guestmount/#content .SH "Windows XP 仮想マシンの背景画像を変更します" .IX Header "Windows XP 仮想マシンの背景画像を変更します" 以下のリンクは、Windows \s-1XP\s0 仮想マシンのユーザーの背景画像を変更するために \fBguestfish\fR\|(1) を使用する方法について説明しています。残念ながら、このテクニックは Windows のバージョンによりわずかに異なります。 .PP https://lists.fedoraproject.org/pipermail/virt/2011\-May/002655.html https://lists.fedoraproject.org/pipermail/virt/2011\-May/002658.html .SH "ディスクイメージの中にあるファイルまたはデバイスのチェックサム" .IX Header "ディスクイメージの中にあるファイルまたはデバイスのチェックサム" デバイス全体、またはディスクイメージの中にあるパーティションや論理ボリュームなどについてチェックサムを確認するには: .PP .Vb 1 \& guestfish \-\-ro \-a disk.img run : checksum\-device md5 /dev/sda1 .Ve .PP Replace \f(CW\*(C`md5\*(C'\fR with the type of checksum you want. See \&\*(L"guestfs_checksum_device\*(R" in \fBguestfs\fR\|(3) for a list of supported types. .PP \&\fI/dev/sda1\fR means \*(L"the first partition\*(R". You could use \fI/dev/sda\fR to checksum the whole disk image, or the name of a logical volume or \s-1RAID\s0 device. .PP 単一サポートをチェックサムするには: .PP .Vb 1 \& guestfish \-\-ro \-a disk.img \-i checksum sha256 /etc/passwd .Ve .PP または、Windows ゲストには: .PP .Vb 2 \& guestfish \-\-ro \-a disk.img \-i \e \& checksum sha256 \*(Aqwin:\ewindows\esystem32\econfig\eSOFTWARE\*(Aq .Ve .SH "仮想マシンのクローン方法" .IX Header "仮想マシンのクローン方法" \&\fBcp\fR\|(1), \fBdd\fR\|(1), and virt tools like \fBvirt\-sysprep\fR\|(1), \&\fBvirt\-sparsify\fR\|(1) および \fBvirt\-resize\fR\|(1) のようなツールの組み合わせを使用します。 .PP 詳細は次を参照してください: \*(L"コピー方法およびクローン方法\*(R" in \fBvirt\-sysprep\fR\|(1)。 .SH "CD-ROM / DVD / ISO を tar ファイルに変換します" .IX Header "CD-ROM / DVD / ISO を tar ファイルに変換します" This converts input \fIcd.iso\fR to output \fIcd.tar.gz\fR: .PP .Vb 1 \& guestfish \-\-ro \-a cd.iso \-m /dev/sda tgz\-out / cd.tar.gz .Ve .PP To export just a subdirectory, eg. \fI/files\fR, do: .PP .Vb 1 \& guestfish \-\-ro \-a cd.iso \-m /dev/sda tgz\-out /files cd.tar.gz .Ve .SH "Convert from one format/filesystem to another" .IX Header "Convert from one format/filesystem to another" If you have a data disk in one format / filesystem / partition / volume manager, you can convert it another using this technique. .PP In this example, we start with a data disk that has a single partition containing a filesystem, and we want to create another disk that contains the same files but on an ext3 filesystem embedded in a logical volume on a sparse raw-format disk. .PP First create the formatted-but-empty target disk: .PP .Vb 2 \& truncate \-s 10G target.img \& virt\-format \-a target.img \-\-partition=mbr \-\-lvm \-\-filesystem=ext3 .Ve .PP Now, pipe two guestfish instances together to transfer the old data to the new disk: .PP .Vb 2 \& guestfish \-\-ro \-a source.img \-m /dev/sda1 \-\- tar\-out / \- | \e \& guestfish \-\-rw \-a target.img \-m /dev/VG/LV \-\- tar\-in \- / .Ve .PP To browse the final disk image, do: .PP .Vb 2 \& guestfish \-\-ro \-a target.img \-m /dev/VG/LV \& > ll / .Ve .PP This technique is quite powerful, allowing you for example to split up source directories over the target filesystems. .PP Note this won’t work (at least, not directly) for bootable virtual machine disks because it doesn't copy over the boot loader. .SH "Convert Windows DVD to bootable USB key" .IX Header "Convert Windows DVD to bootable USB key" http://rwmj.wordpress.com/2013/05/09/tip\-convert\-a\-windows\-dvd\-iso\-to\-a\-bootable\-usb\-key\-using\-guestfish/#content .SH "Convert Xen-style partitionless image to partitioned disk image" .IX Header "Convert Xen-style partitionless image to partitioned disk image" Xen disk images are often partitionless, meaning that the filesystem starts directly at the beginning of the disk with no partition table. You can in fact use these directly in \s-1KVM\s0 (provided the guest isn't Windows), but some people like to convert them to regular partitioned disk images, and this is required for Windows guests. Here is how to use guestfish to do this: .PP .Vb 12 \& guestfish \& > add\-ro input.img \& > sparse output.img 10G # adjust the output size \& > run \& # Create a partition table on the output disk: \& > part\-init /dev/sdb mbr \& > part\-add /dev/sdb p 2048 \-2048 \& # Copy the data to the target partition: \& > copy\-device\-to\-device /dev/sda /dev/sdb1 sparse:true \& # Optionally resize the target filesystem. Use ntfsresize \& # for Windows guests: \& > resize2fs /dev/sdb1 .Ve .PP Such a disk image won’t be directly bootable. You may need to boot it with an external kernel and initramfs (see below). Or you can use the guestfish commands \f(CW\*(C`syslinux\*(C'\fR or \f(CW\*(C`extlinux\*(C'\fR to install a \s-1SYSLINUX\s0 bootloader. .SH "空のディスクイメージを作成します" .IX Header "空のディスクイメージを作成します" \&\fBvirt\-format\fR\|(1) ツールは直接これを実行できます。 .PP 中身のあるディスクイメージを作成するには \fBvirt\-make\-fs\fR\|(1) を使用します。仮想フロッピーディスク (\s-1VFD\s0) のような、いくつかの標準的なディスクイメージを作成することもできます。 .PP 空のディスクイメージを作成するには \fBguestfish\fR\|(1) の \fI\-N\fR オプションを使用することもできます。以下の有用なガイドが利用可能なオプションを説明しています。 .PP https://rwmj.wordpress.com/2010/09/08/new\-guestfish\-n\-options\-in\-1\-5\-9/#content .PP \&\fBvirt\-builder\fR\|(1) can create minimal guests. .SH "ファイルを削除します (または、他の簡単なファイル操作)" .IX Header "ファイルを削除します (または、他の簡単なファイル操作)" guestfish を使用します。ファイルを削除するには: .PP .Vb 1 \& guestfish \-a disk.img \-i rm /file/to/delete .Ve .PP ファイルをタッチする (ファイルの日付を更新する、または作成する) には: .PP .Vb 1 \& guestfish \-a disk.img \-i touch /file/to/touch .Ve .PP To stat a file. Since this is a read-only operation, we can make it safer by adding the \fI\-\-ro\fR flag. .PP .Vb 1 \& guestfish \-\-ro \-a disk.img \-i stat /file/to/stat .Ve .PP There are dozens of these commands. See \fBguestfish\fR\|(1) or the output of \&\f(CW\*(C`guestfish \-h\*(C'\fR .SH "Diff two guests; compare a snapshot to the current version" .IX Header "Diff two guests; compare a snapshot to the current version" Since libguestfs ≥ 1.26, use \fBvirt\-diff\fR\|(1) to look for differences between two guests (for example if they were originally cloned from the same source), or between two snapshots from the same guest. In earlier versions of libguestfs, use \fBvirt\-ls\fR\|(1). .SH "Disable a systemd service" .IX Header "Disable a systemd service" The following is the equivalent of \f(CW\*(C`systemctl mask ...\*(C'\fR. To disable the \&\f(CW\*(C`cloud\-init\*(C'\fR service so it doesn't start at next boot: .PP .Vb 2 \& guestfish \-a disk.img \-i \e \& ln\-sf /dev/null /etc/systemd/system/cloud\-init.service .Ve .PP To disable tmp-on-tmpfs: .PP .Vb 2 \& guestfish \-a disk.img \-i \e \& ln\-sf /dev/null /etc/systemd/system/tmp.mount .Ve .PP One problem with the commands above is there is no feedback if you get the name of the service you are trying to mask wrong. But you can use \&\fBvirt\-ls\fR\|(1) to list the available systemd services like this: .PP .Vb 1 \& virt\-ls \-a /tmp/fedora\-19.img \-R /lib/systemd/system .Ve .SH "Drive letters over FUSE" .IX Header "Drive letters over FUSE" You have a Windows guest, and you want to expose the drive letters as \s-1FUSE\s0 mountpoints (\fI/C/...\fR, \fI/D/...\fR etc). Instead of \fBguestmount\fR\|(1), use this Perl script: .PP .Vb 10 \& #!/usr/bin/perl \-w \& use strict; \& use Sys::Guestfs; \& $| = 1; \& die "usage: $0 mountpoint disk.img" if @ARGV < 2; \& my $mp = shift @ARGV; \& my $g = new Sys::Guestfs; \& $g\->add_drive_opts ($_) foreach @ARGV; \& $g\->launch; \& my @roots = $g\->inspect_os; \& die "$0: no operating system found" if @roots != 1; \& my $root = $roots[0]; \& die "$0: not Windows" if $g\->inspect_get_type ($root) ne "windows"; \& my %map = $g\->inspect_get_drive_mappings ($root); \& foreach (keys %map) { \& $g\->mkmountpoint ("/$_"); \& eval { $g\->mount ($map{$_}, "/$_") }; \& warn "$@ (ignored)\en" if $@; \& } \& $g\->mount_local ($mp); \& print "filesystem ready on $mp\en"; \& $g\->mount_local_run; \& $g\->shutdown; .Ve .PP You can use the script like this: .PP .Vb 3 \& $ mkdir /tmp/mnt \& $ ./drive\-letters.pl /tmp/mnt windows7.img \& filesystem ready on /tmp/mnt .Ve .PP In another window: .PP .Vb 12 \& $ cd /tmp/mnt \& $ ls \& C D \& $ cd C \& $ ls \& Documents and Settings \& PerfLogs \& ProgramData \& Program Files \& [etc] \& $ cd ../.. \& $ guestunmount /tmp/mnt .Ve .SH "ディスクイメージまたは仮想マシンの中にあるファイルシステムの内容をそのままダンプします" .IX Header "ディスクイメージまたは仮想マシンの中にあるファイルシステムの内容をそのままダンプします" You can use the \fBguestfish\fR\|(1) \f(CW\*(C`download\*(C'\fR command to extract the raw filesystem content from any filesystem in a disk image or a \s-1VM\s0 (even one which is encrypted or buried inside an \s-1LV\s0 or \s-1RAID\s0 device): .PP .Vb 1 \& guestfish \-\-ro \-a disk.img run : download /dev/sda1 sda1.img \& \& guestfish \-\-ro \-d Guest run : download /dev/vg_guest/lv_root lv.img .Ve .PP 標準出力にダウンロードするには、ファイル名を \f(CW\*(C`\-\*(C'\fR 文字に置き換えます: .PP .Vb 1 \& guestfish \-\-ro \-a disk.img run : download /dev/sda1 \- | gzip > sda1.gz .Ve .PP ディスクイメージにあるファイルシステムを一覧表示するには \fBvirt\-filesystems\fR\|(1) を使用します。 .PP See also \*(L"Uploading raw filesystem content\*(R". .SH "仮想マシンの GRUB 設定を編集します" .IX Header "仮想マシンの GRUB 設定を編集します" 次の目的のために実行できます: .IP "\(bu" 4 起動しない仮想マシンを修正します。 .IP "\(bu" 4 仮想マシンの起動時に使用するカーネルを変更します。 .IP "\(bu" 4 カーネルのコマンドラインオプションを変更します。 .PP \&\s-1GRUB\s0 設定を編集するには \fBvirt\-edit\fR\|(1) を使用します: .PP .Vb 1 \& virt\-edit \-d BrokenGuest /boot/grub2/grub.cfg .Ve .PP もしくは、起動不可能な仮想マシンの中から一般的に修復するために、このように \fBvirt\-rescue\fR\|(1) を使用します: .PP .Vb 1 \& virt\-rescue \-d BrokenGuest .Ve .SH "仮想マシンから任意のディレクトリをエクスポートします" .IX Header "仮想マシンから任意のディレクトリをエクスポートします" To export \fI/home\fR from a \s-1VM\s0 into a local directory use \fBvirt\-copy\-out\fR\|(1): .PP .Vb 1 \& virt\-copy\-out \-d Guest /home . .Ve .PP 注: .IP "\(bu" 4 コマンドの最後のドットは表示エラーではありません。現在のディレクトリーにコピーしたいことを意味します。 .IP "\(bu" 4 これは現在のディレクトリーに \f(CW\*(C`home\*(C'\fR というディレクトリーを作成します。 .PP 仮想マシンが Windows ならば、ドライブレターとバックスラッシュを使用できます。しかし、パスを \f(CW\*(C`win:\*(C'\fR で始める必要があり、シェルから保護するために引用符でくくる必要があります。このようにします: .PP .Vb 1 \& virt\-copy\-out \-d WinGuest \*(Aqwin:c:\ewindows\esystem32\econfig\*(Aq . .Ve .PP 圧縮された tar ファイルとして出力を取得するには: .PP .Vb 1 \& virt\-tar\-out \-d Guest /home \- | gzip \-\-best > home.tar.gz .Ve .PP Although it sounds tempting, this is usually not a reliable way to get a backup from a running guest. See the entry in the \s-1FAQ:\s0 http://libguestfs.org/FAQ.html#backup .SH "Export external kernel and initramfs (initrd)" .IX Header "Export external kernel and initramfs (initrd)" If a Linux guest doesn't have a boot loader or it is broken, then you can usually boot it using an external kernel and initramfs. In this configuration, the hypervisor acts like a bootloader, loading the kernel from the host disk into guest memory and jumping straight into the kernel. .PP However you may wonder how to get the right kernel corresponding to the disk image you have. Since libguestfs ≥ 1.24 \fBvirt\-builder\fR\|(1) can get the latest kernel and corresponding initramfs for you: .PP .Vb 3 \& mkdir outputdir \& virt\-builder \-\-get\-kernel disk.img \-o outputdir \& ls \-lh outputdir .Ve .SH "もっとも領域を使用しているユーザーを検索します" .IX Header "もっとも領域を使用しているユーザーを検索します" この簡単なスクリプトは、ホームディレクトリーにおいてもっとも領域を使用しているユーザーを検索するために、Linux 仮想マシンを検査します。 .PP .Vb 1 \& #!/bin/sh \- \& \& set \-e \& \& vm="$1" \& dir=/home \& \& eval $(guestfish \-\-ro \-d "$vm" \-i \-\-listen) \& \& for d in $(guestfish \-\-remote ls "$dir"); do \& echo \-n "$dir/$d" \& echo \-ne \*(Aq\et\*(Aq \& guestfish \-\-remote du "$dir/$d"; \& done | sort \-nr \-k 2 \& \& guestfish \-\-remote exit .Ve .SH "仮想マシンから DHCP アドレスを取得します" .IX Header "仮想マシンから DHCP アドレスを取得します" 以下のリンクは、仮想マシンに対して最後に割り当てられた \s-1DHCP\s0 アドレスを取得するために、多くの異なる利用可能なテクニックを説明しています。 .PP https://rwmj.wordpress.com/2011/03/31/tip\-code\-for\-getting\-dhcp\-address\-from\-a\-virtual\-machine\-disk\-image/#content .PP In the libguestfs source examples directory you will find the latest version of the \fIvirt\-dhcp\-address.c\fR program. .SH "オペレーティングシステムの製品名を取得します" .IX Header "オペレーティングシステムの製品名を取得します" Save the following script into a file called \fIproduct\-name.sh\fR: .PP .Vb 6 \& #!/bin/sh \- \& set \-e \& eval "$(guestfish \-\-ro \-d "$1" \-\-i \-\-listen)" \& root="$(guestfish \-\-remote inspect\-get\-roots)" \& guestfish \-\-remote inspect\-get\-product\-name "$root" \& guestfish \-\-remote exit .Ve .PP スクリプトを実行可能にして、名前付き仮想マシンにおいて実行します: .PP .Vb 2 \& # product\-name.sh RHEL60x64 \& Red Hat Enterprise Linux Server release 6.0 (Santiago) .Ve .PP \&\f(CW\*(C`xpath\*(C'\fR コマンドラインツールを使用して、またはお気に入りのプログラミング言語から、\fBvirt\-inspector\fR\|(1) \s-1XML\s0 において XPath クエリーを使用することもできます: .PP .Vb 5 \& # virt\-inspector RHEL60x64 > xml \& # xpath \*(Aq//product_name\*(Aq < xml \& Found 1 nodes: \& \-\- NODE \-\- \& Red Hat Enterprise Linux Server release 6.0 (Santiago) .Ve .SH "Linux 仮想マシンのデフォルトの起動カーネルを取得します" .IX Header "Linux 仮想マシンのデフォルトの起動カーネルを取得します" 以下のリンクに Linux 仮想マシンのデフォルトの起動カーネルを表示するためのプログラムがあります。 .PP https://rwmj.wordpress.com/2010/10/30/tip\-use\-augeas\-to\-get\-the\-default\-boot\-kernel\-for\-a\-vm/#content .PP Augeas を使用します。また、以下のように、多くのさまざまな作業に対して適用可能な一般的なテクニックがあります: .IP "\(bu" 4 仮想マシンのユーザーアカウントの一覧 .IP "\(bu" 4 使用するよう設定されたリポジトリー .IP "\(bu" 4 接続する \s-1NTP\s0 サーバー .IP "\(bu" 4 前回起動時の起動メッセージ .IP "\(bu" 4 最近ログインしたユーザーの一覧 .PP http://augeas.net/ .SH "Hanging guests" .IX Header "Hanging guests" There are various ways to use libguestfs to find out why a guest is hanging or unresponsive: .IP "1." 4 virt-cat を使用してログファイルを読むには: .Sp .Vb 1 \& virt\-cat Guest /var/log/messages | less .Ve .IP "2." 4 Windows イベントログ (Windows Vista またはそれ以降) を読むには: .Sp https://rwmj.wordpress.com/2011/04/17/decoding\-the\-windows\-event\-log\-using\-guestfish/#content .IP "3." 4 Find out which files were last updated in a guest: .Sp https://rwmj.wordpress.com/2012/02/27/using\-libguestfs\-to\-find\-out\-why\-a\-windows\-guest\-was\-hanging/#content .Sp This might give you a clue as to what program is running. .SH "仮想マシンからセクターを 16 進ダンプします" .IX Header "仮想マシンからセクターを 16 進ダンプします" Hex-dump the boot partition (Master Boot Record / first sector): .PP .Vb 2 \& guestfish \-\-ro \-a disk.img run : pread\-device /dev/sda 0x200 0 | \& hexdump \-C .Ve .PP (\f(CW0x200\fR = 512 bytes which is the size of traditional \s-1PC\s0 sectors) .PP To hexdump the N'th partition, substitute a number for \f(CW\*(C`N\*(C'\fR in the following command: .PP .Vb 3 \& guestfish \-\-ro \-a disk.img \e \& run : pread\-device /dev/sda 0x200 $((N*0x200)) | \& hexdump \-C .Ve .SH "仮想マシンにおいてセクターを 16 進ダンプします" .IX Header "仮想マシンにおいてセクターを 16 進ダンプします" Hex-edit the boot partition (Master Boot Record / first sector): .PP .Vb 1 \& guestfish \-\-rw \-a disk.img run : hexedit /dev/sda 0x200 .Ve .SH "Install packages (RPMs, Debian packages) in a guest" .IX Header "Install packages (RPMs, Debian packages) in a guest" Since libguestfs 1.26, \fBvirt\-builder\fR\|(1), \fBvirt\-customize\fR\|(1) and \&\fBvirt\-sysprep\fR\|(1) have an \fI\-\-install\fR option for installing packages in Linux guests. (Use virt-customize if you have an existing guest, or virt-builder if you want to create a guest from scratch). .PP 例: .PP .Vb 1 \& virt\-builder fedora\-20 \-\-install emacs .Ve .SH "Install packages from an alternate repository" .IX Header "Install packages from an alternate repository" Since libguestfs 1.26, you can use \fBvirt\-builder\fR\|(1), \fBvirt\-customize\fR\|(1) or \fBvirt\-sysprep\fR\|(1) \fI\-\-edit\fR option to edit repository metadata before installing packages .PP For example this would install packages from the updates-testing repository in Fedora: .PP .Vb 4 \& virt\-builder fedora\-20 \e \& \-\-edit \*(Aq/etc/yum.repos.d/fedora\-updates\-testing.repo: \& s/enabled=0/enabled=1/\*(Aq \e \& \-\-install emacs .Ve .SH "Install SYSLINUX bootloader in a guest" .IX Header "Install SYSLINUX bootloader in a guest" \&\s-1SYSLINUX\s0 is a small, easy to configure bootloader for Linux and Windows guests. If your guest is not bootable, you can install the \s-1SYSLINUX\s0 bootloader using either the guestfish commands \f(CW\*(C`syslinux\*(C'\fR (for FAT-based guests) or \f(CW\*(C`extlinux\*(C'\fR (for ext2/3/4 and btrfs-based guests). .PP This guide assumes a Linux guest where \fI/dev/sda1\fR is \fI/boot\fR, \&\fI/boot/vmlinuz\fR is the guest kernel, and \fI/dev/sda3\fR is the root partition. For a Windows guest you would need a FAT-formatted boot partition and you would need to use the \f(CW\*(C`syslinux\*(C'\fR command instead. .PP Create a \fIsyslinux.cfg\fR configuration file. You should check the \s-1SYSLINUX\s0 documentation at http://www.syslinux.org but it may look something like this: .PP .Vb 6 \& DEFAULT linux \& LABEL linux \& SAY Booting the kernel \& KERNEL vmlinuz \& INITRD initrd \& APPEND ro root=/dev/sda3 .Ve .PP Locate the syslinux master boot record (a file called something like \&\fI/usr/share/syslinux/mbr.bin\fR). .PP .Vb 10 \& guestfish \-a disk.img \-i \& # Upload the master boot record and configuration file: \& > upload ..../mbr.bin /boot/mbr.bin \& > upload ..../syslinux.cfg /boot/syslinux.cfg \& # Put the MBR into the boot sector: \& > copy\-file\-to\-device /boot/mbr.bin /dev/sda size:440 \& # Install syslinux on the first partition: \& > extlinux /boot \& # Set the first partition as bootable: \& > part\-set\-bootable /dev/sda 1 true .Ve .PP See also: http://rwmj.wordpress.com/2013/04/04/new\-in\-libguestfs\-use\-syslinux\-or\-extlinux\-to\-make\-bootable\-guests/#content .SH "仮想マシンにインストールされているアプリケーションを一覧表示します" .IX Header "仮想マシンにインストールされているアプリケーションを一覧表示します" Save the following to a file \fIlist\-apps.sh\fR: .PP .Vb 6 \& #!/bin/sh \- \& set \-e \& eval "$(guestfish \-\-ro \-d "$1" \-\-i \-\-listen)" \& root="$(guestfish \-\-remote inspect\-get\-roots)" \& guestfish \-\-remote inspect\-list\-applications "$root" \& guestfish \-\-remote exit .Ve .PP ファイルを実行可能にして、あらゆる名前付き仮想マシンにおいて実行できます: .PP .Vb 10 \& # list\-apps.sh WinGuest \& [0] = { \& app_name: Mozilla Firefox (3.6.12) \& app_display_name: Mozilla Firefox (3.6.12) \& app_epoch: 0 \& app_version: 3.6.12 (en\-GB) \& app_release: \& app_install_path: C:\eProgram Files\eMozilla Firefox \& app_trans_path: \& app_publisher: Mozilla \& app_url: http://www.mozilla.com/en\-GB/ \& app_source_package: \& app_summary: \& app_description: Mozilla Firefox \& } \& [1] = { \& app_name: VLC media player \& app_display_name: VLC media player 1.1.5 \& app_epoch: 0 \& app_version: 1.1.5 \& app_release: \& app_install_path: C:\eProgram Files\eVideoLAN\eVLC \& app_trans_path: \& app_publisher: VideoLAN \& app_url: http://www.videolan.org/ \& app_source_package: \& app_summary: \& app_description: \& } .Ve .PP (libvirt 仮想マシンの代わりに)ディスクイメージにおいてスクリプトを実行したいならば、\f(CW\*(C`\-d "$1"\*(C'\fR を \f(CW\*(C`\-a "$1"\*(C'\fR に変更します。\fBvirt\-inspector\fR\|(1) 参照。 .SH "仮想マシンのファイルおよびディレクトリを一覧表示します" .IX Header "仮想マシンのファイルおよびディレクトリを一覧表示します" \&\fBvirt\-ls\fR\|(1) を使用します。 .SH "Windows 仮想マシンのサービスを一覧表示します" .IX Header "Windows 仮想マシンのサービスを一覧表示します" 以下のリンクは、Windows 仮想マシンからサービスを、およびそれらのサービスが起動時に実行されるか必要に応じて読み込まれるかを一覧化するために使用できるスクリプトがあります。 .PP https://rwmj.wordpress.com/2010/12/10/tip\-list\-services\-in\-a\-windows\-guest/#content .SH "ディスクイメージをスパースにします" .IX Header "ディスクイメージをスパースにします" \&\fBvirt\-sparsify\fR\|(1) を使用します。 .SH "ディスク使用量を時系列に監視します" .IX Header "ディスク使用量を時系列に監視します" 時系列で仮想マシンのディスク使用量を監視するために \fBvirt\-df\fR\|(1) を使用できます。以下のリンクは仮想マシンを含みます。 .PP http://web.archive.org/web/20130214073726/http://virt\-tools.org/learning/advanced\-virt\-df/ .SH "Windows Vista (またそれ以降)から Windows のイベントログを読み出します" .IX Header "Windows Vista (またそれ以降)から Windows のイベントログを読み出します" \&\fBguestfish\fR\|(1) に加えて以下のリンクに示されるツールは、実行中の Windows Vista およびそれ以降のあらゆる仮想マシンから Windows イベントログを読み出すために使用できます。 .PP https://rwmj.wordpress.com/2011/04/17/decoding\-the\-windows\-event\-log\-using\-guestfish/#content .SH "root のパスワードを削除します (Linux)" .IX Header "root のパスワードを削除します (Linux)" \&\fBvirt\-edit\fR\|(1) \fI\-e\fR を使用することにより、ファイルの内容を簡単に置き換えることができます。一つの使用方法は Linux 仮想マシンから root パスワードを削除することです。 .PP .Vb 1 \& virt\-edit \-d domname /etc/passwd \-e \*(Aqs/^root:.*?:/root::/\*(Aq \& \& virt\-edit \-a disk.img /etc/passwd \-e \*(Aqs/^root:.*?:/root::/\*(Aq .Ve .SH "Administrator のパスワードを削除します (Windows)" .IX Header "Administrator のパスワードを削除します (Windows)" 以下のリンクは、Windows 仮想マシンから管理者パスワードを削除するためのテクニックを含みます。または、より精細にするために、セキュリティを迂回するために使用でき、次回ログイン時にコマンドプロンプトを出します: .PP https://mdbooth.wordpress.com/2010/10/18/resetting\-a\-windows\-guests\-administrator\-password\-with\-guestfish/ .SH "仮想マシンの sysprep 方法 (Windows)" .IX Header "仮想マシンの sysprep 方法 (Windows)" It is possible to do a \*(L"sysprep\*(R" using libguestfs alone, although not straightforward. Currently there is code in the Aeolus Oz project which does this (using libguestfs). It is likely we will add this to \&\fBvirt\-sysprep\fR\|(1) in future. .PP https://github.com/clalancette/oz https://www.redhat.com/archives/virt\-tools\-list/2011\-May/msg00019.html .SH "Live CD を展開します" .IX Header "Live CD を展開します" Linux live \s-1CD\s0 は、ロシア人形のように覆われた複数の層のディスクイメージを含みます。以下のガイドに概要が示されたように、これらの複数の層の内側を見るために \&\fBguestfish\fR\|(1) を使用できます。 .PP https://rwmj.wordpress.com/2009/07/15/unpack\-the\-russian\-doll\-of\-a\-f11\-live\-cd/#content .SH "ファイルのアップロード方法およびダウンロード方法" .IX Header "ファイルのアップロード方法およびダウンロード方法" 以下のリンクは、仮想マシンにファイルをアップロード、および仮想マシンからファイルをダウンロードすることに関する、一般的なヒントがあります。 .PP https://rwmj.wordpress.com/2010/12/02/tip\-uploading\-and\-downloading/#content .SH "Uploading raw filesystem content" .IX Header "Uploading raw filesystem content" You can use \fBguestfish\fR\|(1) to upload whole filesystems into a \s-1VM,\s0 even into a filesystem which is encrypted or buried inside an \s-1LV\s0 or \s-1RAID\s0 device: .PP .Vb 1 \& guestfish \-\-rw \-a disk.img run : upload sda1.img /dev/sda1 \& \& guestfish \-\-rw \-d Guest run : upload lv.img /dev/vg_guest/lv_root .Ve .PP One common problem is that the filesystem isn't the right size for the target. If it is too large, there’s not much you can do with libguestfs \- you have to prepare the filesystem differently. But if the filesystem needs to expand into the target, you can use guestfish to resize it to the right size: .PP .Vb 3 \& guestfish \-\-rw \-d Guest run : \e \& upload lv.img /dev/vg_guest/lv_root : \e \& resize2fs /dev/vg_guest/lv_root .Ve .PP (or use \f(CW\*(C`ntfsresize\*(C'\fR if the filesystem is \s-1NTFS\s0). .SH "VMware ESX 仮想マシンにおいて libguestfs ツールを使用します" .IX Header "VMware ESX 仮想マシンにおいて libguestfs ツールを使用します" 以下のリンクは、まず最初に sshfs 経由で VMware \s-1VMFS\s0 を共有することにより、VMware \s-1ESX\s0 仮想マシンにおいて libguestfs, \fBguestfish\fR\|(1) および virt ツールを使用する方法を説明しています。 .PP https://rwmj.wordpress.com/2011/05/10/tip\-use\-libguestfs\-on\-vmware\-esx\-guests/#content .SH "関連項目" .IX Header "関連項目" \&\fBguestfs\fR\|(3), \fBguestfish\fR\|(1), \fBguestfs\-examples\fR\|(3), \&\fBguestfs\-erlang\fR\|(3), \fBguestfs\-gobject\fR\|(3), \fBguestfs\-golang\fR\|(3), \&\fBguestfs\-java\fR\|(3), \fBguestfs\-lua\fR\|(3), \fBguestfs\-ocaml\fR\|(3), \&\fBguestfs\-perl\fR\|(3), \fBguestfs\-python\fR\|(3), \fBguestfs\-ruby\fR\|(3), http://libguestfs.org/. .SH "著者" .IX Header "著者" Richard W.M. Jones (\f(CW\*(C`rjones at redhat dot com\*(C'\fR) .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2009\-2020 Red Hat Inc. .SH "LICENSE" .IX Header "LICENSE" .SH "BUGS" .IX Header "BUGS" To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools .PP To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools .PP When reporting a bug, please supply: .IP "\(bu" 4 The version of libguestfs. .IP "\(bu" 4 Where you got libguestfs (eg. which Linux distro, compiled from source, etc) .IP "\(bu" 4 Describe the bug accurately and give a way to reproduce it. .IP "\(bu" 4 Run \fBlibguestfs\-test\-tool\fR\|(1) and paste the \fBcomplete, unedited\fR output into the bug report.