mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
238 lines
6.4 KiB
Plaintext
238 lines
6.4 KiB
Plaintext
=encoding utf8
|
|
|
|
=head1 NAME
|
|
|
|
virt-make-fs - Make a filesystem from a tar archive or files
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
virt-make-fs [--options] input.tar output.img
|
|
|
|
virt-make-fs [--options] input.tar.gz output.img
|
|
|
|
virt-make-fs [--options] directory output.img
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
Virt-make-fs is a command line tool for creating a filesystem from a
|
|
tar archive or some files in a directory. It is similar to tools like
|
|
L<mkisofs(1)>, L<genisoimage(1)> and L<mksquashfs(1)>. Unlike those
|
|
tools, it can create common filesystem types like ext2/3 or NTFS,
|
|
which can be useful if you want to attach these filesystems to
|
|
existing virtual machines (eg. to import large amounts of read-only
|
|
data to a VM).
|
|
|
|
To create blank disks, use L<virt-format(1)>. To create complex
|
|
layouts, use L<guestfish(1)>.
|
|
|
|
Basic usage is:
|
|
|
|
virt-make-fs input output.img
|
|
|
|
where C<input> is either a directory containing files that you want to
|
|
add, or a tar archive (either uncompressed tar or gzip-compressed
|
|
tar); and C<output.img> is a disk image. The input type is detected
|
|
automatically. The output disk image defaults to a raw ext2 sparse
|
|
image unless you specify extra flags (see L</OPTIONS> below).
|
|
|
|
=head2 FILESYSTEM TYPE
|
|
|
|
The default filesystem type is C<ext2>. Just about any filesystem
|
|
type that libguestfs supports can be used (but I<not> read-only
|
|
formats like ISO9660). Here are some of the more common choices:
|
|
|
|
=over 4
|
|
|
|
=item I<ext3>
|
|
|
|
Note that ext3 filesystems contain a journal, typically 1-32 MB in size.
|
|
If you are not going to use the filesystem in a way that requires the
|
|
journal, then this is just wasted overhead.
|
|
|
|
=item I<ntfs> or I<vfat>
|
|
|
|
Useful if exporting data to a Windows guest.
|
|
|
|
=item I<minix>
|
|
|
|
Lower overhead than C<ext2>, but certain limitations on filename
|
|
length and total filesystem size.
|
|
|
|
=back
|
|
|
|
=head3 EXAMPLE
|
|
|
|
virt-make-fs --type=minix input minixfs.img
|
|
|
|
=head2 TO PARTITION OR NOT TO PARTITION
|
|
|
|
Optionally virt-make-fs can add a partition table to the output disk.
|
|
|
|
Adding a partition can make the disk image more compatible with
|
|
certain virtualized operating systems which don't expect to see a
|
|
filesystem directly located on a block device (Linux doesn't care and
|
|
will happily handle both types).
|
|
|
|
On the other hand, if you have a partition table then the output image
|
|
is no longer a straight filesystem. For example you cannot run
|
|
L<fsck(8)> directly on a partitioned disk image. (However libguestfs
|
|
tools such as L<guestfish(1)> and L<virt-resize(1)> can still be
|
|
used).
|
|
|
|
=head3 EXAMPLE
|
|
|
|
Add an MBR partition:
|
|
|
|
virt-make-fs --partition -- input disk.img
|
|
|
|
If the output disk image could be terabyte-sized or larger, it's
|
|
better to use an EFI/GPT-compatible partition table:
|
|
|
|
virt-make-fs --partition=gpt --size=+4T --format=qcow2 input disk.img
|
|
|
|
=head2 EXTRA SPACE
|
|
|
|
Unlike formats such as tar and squashfs, a filesystem does not "just
|
|
fit" the files that it contains, but might have extra space.
|
|
Depending on how you are going to use the output, you might think this
|
|
extra space is wasted and want to minimize it, or you might want to
|
|
leave space so that more files can be added later. Virt-make-fs
|
|
defaults to minimizing the extra space, but you can use the I<--size>
|
|
flag to leave space in the filesystem if you want it.
|
|
|
|
An alternative way to leave extra space but not make the output image
|
|
any bigger is to use an alternative disk image format (instead of the
|
|
default "raw" format). Using I<--format=qcow2> will use the native
|
|
QEmu/KVM qcow2 image format (check your hypervisor supports this
|
|
before using it). This allows you to choose a large I<--size> but the
|
|
extra space won't actually be allocated in the image until you try to
|
|
store something in it.
|
|
|
|
Don't forget that you can also use local commands including
|
|
L<resize2fs(8)> and L<virt-resize(1)> to resize existing filesystems,
|
|
or rerun virt-make-fs to build another image from scratch.
|
|
|
|
=head3 EXAMPLE
|
|
|
|
virt-make-fs --format=qcow2 --size=+200M input output.img
|
|
|
|
=head1 OPTIONS
|
|
|
|
=over 4
|
|
|
|
=item B<--help>
|
|
|
|
Display brief help.
|
|
|
|
=item B<--floppy>
|
|
|
|
Create a virtual floppy disk.
|
|
|
|
Currently this preselects the size (1440K), partition type (MBR) and
|
|
filesystem type (VFAT). In future it may also choose the geometry.
|
|
|
|
=item B<--size=E<lt>NE<gt>>
|
|
|
|
=item B<--size=+E<lt>NE<gt>>
|
|
|
|
=item B<-s E<lt>NE<gt>>
|
|
|
|
=item B<-s +E<lt>NE<gt>>
|
|
|
|
Use the I<--size> (or I<-s>) option to choose the size of the output
|
|
image.
|
|
|
|
If this option is I<not> given, then the output image will be just
|
|
large enough to contain all the files, with not much wasted space.
|
|
|
|
To choose a fixed size output disk, specify an absolute number
|
|
followed by b/K/M/G/T/P/E to mean bytes, Kilobytes, Megabytes,
|
|
Gigabytes, Terabytes, Petabytes or Exabytes. This must be large
|
|
enough to contain all the input files, else you will get an error.
|
|
|
|
To leave extra space, specify C<+> (plus sign) and a number followed
|
|
by b/K/M/G/T/P/E to mean bytes, Kilobytes, Megabytes, Gigabytes,
|
|
Terabytes, Petabytes or Exabytes. For example: I<--size=+200M> means
|
|
enough space for the input files, and (approximately) an extra 200 MB
|
|
free space.
|
|
|
|
Note that virt-make-fs estimates free space, and therefore will not
|
|
produce filesystems containing precisely the free space requested.
|
|
(It is much more expensive and time-consuming to produce a filesystem
|
|
which has precisely the desired free space).
|
|
|
|
=item B<--format=E<lt>fmtE<gt>>
|
|
|
|
=item B<-F E<lt>fmtE<gt>>
|
|
|
|
Choose the output disk image format.
|
|
|
|
The default is C<raw> (raw sparse disk image).
|
|
|
|
=item B<--type=E<lt>fsE<gt>>
|
|
|
|
=item B<-t E<lt>fsE<gt>>
|
|
|
|
Choose the output filesystem type.
|
|
|
|
The default is C<ext2>.
|
|
|
|
Any filesystem which is supported read-write by libguestfs can be used
|
|
here.
|
|
|
|
=item B<--label=E<lt>LABELE<gt>>
|
|
|
|
Set the filesystem label.
|
|
|
|
=item B<--partition>
|
|
|
|
=item B<--partition=E<lt>parttypeE<gt>>
|
|
|
|
If specified, this flag adds an MBR partition table to the output disk
|
|
image.
|
|
|
|
You can change the partition table type, eg. I<--partition=gpt> for
|
|
large disks.
|
|
|
|
For MBR, virt-make-fs sets the partition type byte automatically.
|
|
|
|
=item B<-v>
|
|
|
|
=item B<--verbose>
|
|
|
|
Enable debugging information.
|
|
|
|
=item B<-V>
|
|
|
|
=item B<--version>
|
|
|
|
Display version number and exit.
|
|
|
|
=item B<-x>
|
|
|
|
Enable libguestfs trace.
|
|
|
|
=back
|
|
|
|
=head1 SEE ALSO
|
|
|
|
L<guestfish(1)>,
|
|
L<virt-format(1)>,
|
|
L<virt-resize(1)>,
|
|
L<virt-tar-in(1)>,
|
|
L<mkisofs(1)>,
|
|
L<genisoimage(1)>,
|
|
L<mksquashfs(1)>,
|
|
L<mke2fs(8)>,
|
|
L<resize2fs(8)>,
|
|
L<guestfs(3)>,
|
|
L<http://libguestfs.org/>.
|
|
|
|
=head1 AUTHOR
|
|
|
|
Richard W.M. Jones L<http://people.redhat.com/~rjones/>
|
|
|
|
=head1 COPYRIGHT
|
|
|
|
Copyright (C) 2010-2014 Red Hat Inc.
|