1virt-make-fs(1) Virtualization Support virt-make-fs(1)
2
3
4
6 virt-make-fs - Make a filesystem from a tar archive or files
7
9 virt-make-fs [--options] input.tar output.img
10
11 virt-make-fs [--options] input.tar.gz output.img
12
13 virt-make-fs [--options] directory output.img
14
16 Virt-make-fs is a command line tool for creating a filesystem from a
17 tar archive or some files in a directory. It is similar to tools like
18 mkisofs(1), genisoimage(1) and mksquashfs(1). Unlike those tools, it
19 can create common filesystem types like ext2/3 or NTFS, which can be
20 useful if you want to attach these filesystems to existing virtual
21 machines (eg. to import large amounts of read-only data to a VM).
22
23 Basic usage is:
24
25 virt-make-fs input output
26
27 where "input" is either a directory containing files that you want to
28 add, or a tar archive (either uncompressed tar or gzip-compressed tar);
29 and "output" is a disk image. The input type is detected
30 automatically. The output disk image defaults to a raw ext2 image
31 unless you specify extra flags (see "OPTIONS" below).
32
33 EXTRA SPACE
34 Unlike formats such as tar and squashfs, a filesystem does not "just
35 fit" the files that it contains, but might have extra space. Depending
36 on how you are going to use the output, you might think this extra
37 space is wasted and want to minimize it, or you might want to leave
38 space so that more files can be added later. Virt-make-fs defaults to
39 minimizing the extra space, but you can use the "--size" flag to leave
40 space in the filesystem if you want it.
41
42 An alternative way to leave extra space but not make the output image
43 any bigger is to use an alternative disk image format (instead of the
44 default "raw" format). Using "--format=qcow2" will use the native
45 QEmu/KVM qcow2 image format (check your hypervisor supports this before
46 using it). This allows you to choose a large "--size" but the extra
47 space won't actually be allocated in the image until you try to store
48 something in it.
49
50 Don't forget that you can also use local commands including
51 resize2fs(8) and virt-resize(1) to resize existing filesystems, or
52 rerun virt-make-fs to build another image from scratch.
53
54 EXAMPLE
55
56 virt-make-fs --format=qcow2 --size=+200M input output.img
57
58 FILESYSTEM TYPE
59 The default filesystem type is "ext2". Just about any filesystem type
60 that libguestfs supports can be used (but not read-only formats like
61 ISO9660). Here are some of the more common choices:
62
63 ext3
64 Note that ext3 filesystems contain a journal, typically 1-32 MB in
65 size. If you are not going to use the filesystem in a way that
66 requires the journal, then this is just wasted overhead.
67
68 ntfs or vfat
69 Useful if exporting data to a Windows guest.
70
71 Note for vfat: The tar archive or local directory must only contain
72 files which are owned by root (ie. UID:GID = 0:0). The reason is
73 that the tar program running within libguestfs is unable to change
74 the ownership of non-root files, since vfat itself does not support
75 this.
76
77 minix
78 Lower overhead than "ext2", but certain limitations on filename
79 length and total filesystem size.
80
81 EXAMPLE
82
83 virt-make-fs --type=minix input minixfs.img
84
85 TO PARTITION OR NOT TO PARTITION
86 Optionally virt-make-fs can add a partition table to the output disk.
87
88 Adding a partition can make the disk image more compatible with certain
89 virtualized operating systems which don't expect to see a filesystem
90 directly located on a block device (Linux doesn't care and will happily
91 handle both types).
92
93 On the other hand, if you have a partition table then the output image
94 is no longer a straight filesystem. For example you cannot run fsck(8)
95 directly on a partitioned disk image. (However libguestfs tools such
96 as guestfish(1) and virt-resize(1) can still be used).
97
98 EXAMPLE
99
100 Add an MBR partition:
101
102 virt-make-fs --partition -- input disk.img
103
104 If the output disk image could be terabyte-sized or larger, it's better
105 to use an EFI/GPT-compatible partition table:
106
107 virt-make-fs --partition=gpt --size=+4T --format=qcow2 input disk.img
108
110 --help
111 Display brief help.
112
113 --version
114 Display version number and exit.
115
116 --debug
117 Enable debugging information.
118
119 --size=<N>
120 --size=+<N>
121 -s <N>
122 -s +<N>
123 Use the "--size" (or "-s") option to choose the size of the output
124 image.
125
126 If this option is not given, then the output image will be just
127 large enough to contain all the files, with not much wasted space.
128
129 To choose a fixed size output disk, specify an absolute number
130 followed by b/K/M/G/T/P/E to mean bytes, Kilobytes, Megabytes,
131 Gigabytes, Terabytes, Petabytes or Exabytes. This must be large
132 enough to contain all the input files, else you will get an error.
133
134 To leave extra space, specify "+" (plus sign) and a number followed
135 by b/K/M/G/T/P/E to mean bytes, Kilobytes, Megabytes, Gigabytes,
136 Terabytes, Petabytes or Exabytes. For example: "--size=+200M"
137 means enough space for the input files, and (approximately) an
138 extra 200 MB free space.
139
140 Note that virt-make-fs estimates free space, and therefore will not
141 produce filesystems containing precisely the free space requested.
142 (It is much more expensive and time-consuming to produce a
143 filesystem which has precisely the desired free space).
144
145 --format=<fmt>
146 -F <fmt>
147 Choose the output disk image format.
148
149 The default is "raw" (raw disk image).
150
151 For other choices, see the qemu-img(1) manpage. The only other
152 choice that would really make sense here is "qcow2".
153
154 --type=<fs>
155 -t <fs>
156 Choose the output filesystem type.
157
158 The default is "ext2".
159
160 Any filesystem which is supported read-write by libguestfs can be
161 used here.
162
163 --partition
164 --partition=<parttype>
165 If specified, this flag adds an MBR partition table to the output
166 disk image.
167
168 You can change the partition table type, eg. "--partition=gpt" for
169 large disks.
170
171 Note that if you just use a lonesome "--partition", the Perl option
172 parser might consider the next parameter to be the partition type.
173 For example:
174
175 virt-make-fs --partition input.tar ...
176
177 would cause virt-make-fs to think you wanted to use a partition
178 type of "input.tar" which is completely wrong. To avoid this, use
179 "--" (a double dash) between options and the input file argument:
180
181 virt-make-fs --partition -- input.tar ...
182
184 Libvirt guest names can contain arbitrary characters, some of which
185 have meaning to the shell such as "#" and space. You may need to quote
186 or escape these characters on the command line. See the shell manual
187 page sh(1) for details.
188
190 guestfish(1), virt-resize(1), virt-tar(1), mkisofs(1), genisoimage(1),
191 mksquashfs(1), mke2fs(8), resize2fs(8), guestfs(3), Sys::Guestfs(3),
192 <http://libguestfs.org/>.
193
195 When reporting bugs, please enable debugging and capture the complete
196 output:
197
198 export LIBGUESTFS_DEBUG=1
199 virt-make-fs --debug [...] > /tmp/virt-make-fs.log 2>&1
200
201 Attach /tmp/virt-make-fs.log to a new bug report at
202 <https://bugzilla.redhat.com/>
203
205 Richard W.M. Jones <http://people.redhat.com/~rjones/>
206
208 Copyright (C) 2010 Red Hat Inc.
209
210 This program is free software; you can redistribute it and/or modify it
211 under the terms of the GNU General Public License as published by the
212 Free Software Foundation; either version 2 of the License, or (at your
213 option) any later version.
214
215 This program is distributed in the hope that it will be useful, but
216 WITHOUT ANY WARRANTY; without even the implied warranty of
217 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
218 General Public License for more details.
219
220 You should have received a copy of the GNU General Public License along
221 with this program; if not, write to the Free Software Foundation, Inc.,
222 675 Mass Ave, Cambridge, MA 02139, USA.
223
224
225
226libguestfs-1.8.15 2011-11-10 virt-make-fs(1)