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 To create blank disks, use virt-format(1). To create complex layouts,
24 use guestfish(1).
25
26 Basic usage is:
27
28 virt-make-fs input output.img
29
30 where "input" is either a directory containing files that you want to
31 add, or a tar archive (either uncompressed tar or gzip-compressed tar);
32 and output.img is a disk image. The input type is detected
33 automatically. The output disk image defaults to a raw ext2 sparse
34 image unless you specify extra flags (see "OPTIONS" below).
35
36 FILESYSTEM TYPE
37 The default filesystem type is "ext2". Just about any filesystem type
38 that libguestfs supports can be used (but not read-only formats like
39 ISO9660). Here are some of the more common choices:
40
41 ext3
42 Note that ext3 filesystems contain a journal, typically 1-32 MB in
43 size. If you are not going to use the filesystem in a way that
44 requires the journal, then this is just wasted overhead.
45
46 ntfs or vfat
47 Useful if exporting data to a Windows guest.
48
49 minix
50 Lower overhead than "ext2", but certain limitations on filename
51 length and total filesystem size.
52
53 EXAMPLE
54
55 virt-make-fs --type=minix input minixfs.img
56
57 TO PARTITION OR NOT TO PARTITION
58 Optionally virt-make-fs can add a partition table to the output disk.
59
60 Adding a partition can make the disk image more compatible with certain
61 virtualized operating systems which don't expect to see a filesystem
62 directly located on a block device (Linux doesn't care and will happily
63 handle both types).
64
65 On the other hand, if you have a partition table then the output image
66 is no longer a straight filesystem. For example you cannot run fsck(8)
67 directly on a partitioned disk image. (However libguestfs tools such
68 as guestfish(1) and virt-resize(1) can still be used).
69
70 EXAMPLE
71
72 Add an MBR partition:
73
74 virt-make-fs --partition -- input disk.img
75
76 If the output disk image could be terabyte-sized or larger, it's better
77 to use an EFI/GPT-compatible partition table:
78
79 virt-make-fs --partition=gpt --size=+4T --format=qcow2 input disk.img
80
81 EXTRA SPACE
82 Unlike formats such as tar and squashfs, a filesystem does not "just
83 fit" the files that it contains, but might have extra space. Depending
84 on how you are going to use the output, you might think this extra
85 space is wasted and want to minimize it, or you might want to leave
86 space so that more files can be added later. Virt-make-fs defaults to
87 minimizing the extra space, but you can use the --size flag to leave
88 space in the filesystem if you want it.
89
90 An alternative way to leave extra space but not make the output image
91 any bigger is to use an alternative disk image format (instead of the
92 default "raw" format). Using --format=qcow2 will use the native
93 qemu/KVM qcow2 image format (check your hypervisor supports this before
94 using it). This allows you to choose a large --size but the extra
95 space won't actually be allocated in the image until you try to store
96 something in it.
97
98 Don’t forget that you can also use local commands including
99 resize2fs(8) and virt-resize(1) to resize existing filesystems, or
100 rerun virt-make-fs to build another image from scratch.
101
102 EXAMPLE
103
104 virt-make-fs --format=qcow2 --size=+200M input output.img
105
107 --help
108 Display brief help.
109
110 --floppy
111 Create a virtual floppy disk.
112
113 Currently this preselects the size (1440K), partition type (MBR)
114 and filesystem type (VFAT). In future it may also choose the
115 geometry.
116
117 --size=N
118 --size=+N
119 -s N
120 -s +N
121 Use the --size (or -s) option to choose the size of the output
122 image.
123
124 If this option is not given, then the output image will be just
125 large enough to contain all the files, with not much wasted space.
126
127 To choose a fixed size output disk, specify an absolute number
128 followed by b/K/M/G/T/P/E to mean bytes, Kilobytes, Megabytes,
129 Gigabytes, Terabytes, Petabytes or Exabytes. This must be large
130 enough to contain all the input files, else you will get an error.
131
132 To leave extra space, specify "+" (plus sign) and a number followed
133 by b/K/M/G/T/P/E to mean bytes, Kilobytes, Megabytes, Gigabytes,
134 Terabytes, Petabytes or Exabytes. For example: --size=+200M means
135 enough space for the input files, and (approximately) an extra 200
136 MB free space.
137
138 Note that virt-make-fs estimates free space, and therefore will not
139 produce filesystems containing precisely the free space requested.
140 (It is much more expensive and time-consuming to produce a
141 filesystem which has precisely the desired free space).
142
143 --format=FMT
144 -F FMT
145 Choose the output disk image format.
146
147 The default is "raw" (raw sparse disk image).
148
149 --type=FS
150 -t FS
151 Choose the output filesystem type.
152
153 The default is "ext2".
154
155 Any filesystem which is supported read-write by libguestfs can be
156 used here.
157
158 --label=LABEL
159 Set the filesystem label.
160
161 --partition
162 --partition=PARTTYPE
163 If specified, this flag adds an MBR partition table to the output
164 disk image.
165
166 You can change the partition table type, eg. --partition=gpt for
167 large disks.
168
169 For MBR, virt-make-fs sets the partition type byte automatically.
170
171 -v
172 --verbose
173 Enable debugging information.
174
175 -V
176 --version
177 Display version number and exit.
178
179 -x Enable libguestfs trace.
180
182 guestfish(1), virt-format(1), virt-resize(1), virt-tar-in(1),
183 mkisofs(1), genisoimage(1), mksquashfs(1), mke2fs(8), resize2fs(8),
184 guestfs(3), http://libguestfs.org/.
185
187 Richard W.M. Jones http://people.redhat.com/~rjones/
188
190 Copyright (C) 2010-2019 Red Hat Inc.
191
193 This program is free software; you can redistribute it and/or modify it
194 under the terms of the GNU General Public License as published by the
195 Free Software Foundation; either version 2 of the License, or (at your
196 option) any later version.
197
198 This program is distributed in the hope that it will be useful, but
199 WITHOUT ANY WARRANTY; without even the implied warranty of
200 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
201 General Public License for more details.
202
203 You should have received a copy of the GNU General Public License along
204 with this program; if not, write to the Free Software Foundation, Inc.,
205 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
206
208 To get a list of bugs against libguestfs, use this link:
209 https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
210
211 To report a new bug against libguestfs, use this link:
212 https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
213
214 When reporting a bug, please supply:
215
216 · The version of libguestfs.
217
218 · Where you got libguestfs (eg. which Linux distro, compiled from
219 source, etc)
220
221 · Describe the bug accurately and give a way to reproduce it.
222
223 · Run libguestfs-test-tool(1) and paste the complete, unedited output
224 into the bug report.
225
226
227
228libguestfs-1.40.1 2019-01-17 virt-make-fs(1)