1virt-alignment-scan(1)      Virtualization Support      virt-alignment-scan(1)
2
3
4

NAME

6       virt-alignment-scan - Check alignment of virtual machine partitions
7

SYNOPSIS

9        virt-alignment-scan [--options] -d domname
10
11        virt-alignment-scan [--options] -a disk.img [-a disk.img ...]
12
13        virt-alignment-scan [--options]
14

DESCRIPTION

16       When older operating systems install themselves, the partitioning tools
17       place partitions at a sector misaligned with the underlying storage
18       (commonly the first partition starts on sector 63).  Misaligned
19       partitions can result in an operating system issuing more I/O than
20       should be necessary.
21
22       The virt-alignment-scan tool checks the alignment of partitions in
23       virtual machines and disk images and warns you if there are alignment
24       problems.
25
26       Currently there is no virt tool for fixing alignment problems.  You can
27       only reinstall the guest operating system.  The following NetApp
28       document summarises the problem and possible solutions:
29       http://media.netapp.com/documents/tr-3747.pdf
30

OUTPUT

32       To run this tool on a disk image directly, use the -a option:
33
34        $ virt-alignment-scan -a winxp.img
35        /dev/sda1        32256          512    bad (alignment < 4K)
36
37        $ virt-alignment-scan -a fedora16.img
38        /dev/sda1      1048576         1024K   ok
39        /dev/sda2      2097152         2048K   ok
40        /dev/sda3    526385152         2048K   ok
41
42       To run the tool on a guest known to libvirt, use the -d option and
43       possibly the -c option:
44
45        # virt-alignment-scan -d RHEL5
46        /dev/sda1        32256          512    bad (alignment < 4K)
47        /dev/sda2    106928640          512    bad (alignment < 4K)
48
49        $ virt-alignment-scan -c qemu:///system -d Win7TwoDisks
50        /dev/sda1      1048576         1024K   ok
51        /dev/sda2    105906176         1024K   ok
52        /dev/sdb1        65536           64K   ok
53
54       Run virt-alignment-scan without any -a or -d options to scan all
55       libvirt domains.
56
57        # virt-alignment-scan
58        F16x64:/dev/sda1      1048576         1024K   ok
59        F16x64:/dev/sda2      2097152         2048K   ok
60        F16x64:/dev/sda3    526385152         2048K   ok
61
62       The output consists of 4 or more whitespace-separated columns.  Only
63       the first 4 columns are significant if you want to parse this from a
64       program.  The columns are:
65
66       col 1
67           The device and partition name (eg. "/dev/sda1" meaning the first
68           partition on the first block device).
69
70           When listing all libvirt domains (no -a or -d option given) this
71           column is prefixed by the libvirt name or UUID (if --uuid is
72           given).  eg: "WinXP:/dev/sda1"
73
74       col 2
75           the start of the partition in bytes
76
77       col 3
78           the alignment in bytes or Kbytes (eg. 512 or "4K")
79
80       col 4
81           "ok" if the alignment is best for performance, or "bad" if the
82           alignment can cause performance problems
83
84       cols 5+
85           optional free-text explanation.
86
87       The exit code from the program changes depending on whether poorly
88       aligned partitions were found.  See "EXIT STATUS" below.
89
90       If you just want the exit code with no output, use the -q option.
91

OPTIONS

93       --help
94           Display brief help.
95
96       -a file
97       --add file
98           Add file which should be a disk image from a virtual machine.
99
100           The format of the disk image is auto-detected.  To override this
101           and force a particular format use the --format=.. option.
102
103       -c URI
104       --connect URI
105           If using libvirt, connect to the given URI.  If omitted, then we
106           connect to the default libvirt hypervisor.
107
108           If you specify guest block devices directly (-a), then libvirt is
109           not used at all.
110
111       -d guest
112       --domain guest
113           Add all the disks from the named libvirt guest.  Domain UUIDs can
114           be used instead of names.
115
116       --format=raw|qcow2|..
117       --format
118           The default for the -a option is to auto-detect the format of the
119           disk image.  Using this forces the disk format for -a options which
120           follow on the command line.  Using --format with no argument
121           switches back to auto-detection for subsequent -a options.
122
123           For example:
124
125            virt-alignment-scan --format=raw -a disk.img
126
127           forces raw format (no auto-detection) for "disk.img".
128
129            virt-alignment-scan --format=raw -a disk.img --format -a another.img
130
131           forces raw format (no auto-detection) for "disk.img" and reverts to
132           auto-detection for "another.img".
133
134           If you have untrusted raw-format guest disk images, you should use
135           this option to specify the disk format.  This avoids a possible
136           security problem with malicious guests (CVE-2010-3851).
137
138       -q
139       --quiet
140           Don't produce any output.  Just set the exit code (see "EXIT
141           STATUS" below).
142
143       --uuid
144           Print UUIDs instead of names.  This is useful for following a guest
145           even when the guest is migrated or renamed, or when two guests
146           happen to have the same name.
147
148           This option only applies when listing all libvirt domains (when no
149           -a or -d options are specified).
150
151       -v
152       --verbose
153           Enable verbose messages for debugging.
154
155       -V
156       --version
157           Display version number and exit.
158
159       -x  Enable tracing of libguestfs API calls.
160
162       Operating systems older than Windows 2008 and Linux before ca.2010
163       place the first sector of the first partition at sector 63, with a 512
164       byte sector size.  This happens because of a historical accident.
165       Drives have to report a cylinder / head / sector (CHS) geometry to the
166       BIOS.  The geometry is completely meaningless on modern drives, but it
167       happens that the geometry reported always has 63 sectors per track.
168       The operating system therefore places the first partition at the start
169       of the second "track", at sector 63.
170
171       When the guest OS is virtualized, the host operating system and
172       hypervisor may prefer accesses aligned to one of:
173
174       ·   512 bytes
175
176           if the host OS uses local storage directly on hard drive
177           partitions, and the hard drive has 512 byte physical sectors.
178
179       ·   4 Kbytes
180
181           for local storage on new hard drives with 4Kbyte physical sectors;
182           for file-backed storage on filesystems with 4Kbyte block size; or
183           for some types of network-attached storage.
184
185       ·   64 Kbytes
186
187           for high-end network-attached storage.  This is the optimal block
188           size for some NetApp hardware.
189
190       ·   1 Mbyte
191
192           see "1 MB PARTITION ALIGNMENT" below.
193
194       Partitions which are not aligned correctly to the underlying storage
195       cause extra I/O.  For example:
196
197                              sect#63
198                              +--------------------------+------
199                              |         guest            |
200                              |    filesystem block      |
201        ---+------------------+------+-------------------+-----+---
202           |  host block             |  host block             |
203           |                         |                         |
204        ---+-------------------------+-------------------------+---
205
206       In this example, each time a 4K guest block is read, two blocks on the
207       host must be accessed (so twice as much I/O is done).  When a 4K guest
208       block is written, two host blocks must first be read, the old and new
209       data combined, and the two blocks written back (4x I/O).
210
211   LINUX HOST BLOCK AND I/O SIZE
212       New versions of the Linux kernel expose the physical and logical block
213       size, and minimum and recommended I/O size.
214
215       For a typical consumer hard drive with 512 byte sectors:
216
217        $ cat /sys/block/sda/queue/hw_sector_size
218        512
219        $ cat /sys/block/sda/queue/physical_block_size
220        512
221        $ cat /sys/block/sda/queue/logical_block_size
222        512
223        $ cat /sys/block/sda/queue/minimum_io_size
224        512
225        $ cat /sys/block/sda/queue/optimal_io_size
226        0
227
228       For a new consumer hard drive with 4Kbyte sectors:
229
230        $ cat /sys/block/sda/queue/hw_sector_size
231        4096
232        $ cat /sys/block/sda/queue/physical_block_size
233        4096
234        $ cat /sys/block/sda/queue/logical_block_size
235        4096
236        $ cat /sys/block/sda/queue/minimum_io_size
237        4096
238        $ cat /sys/block/sda/queue/optimal_io_size
239        0
240
241       For a NetApp LUN:
242
243        $ cat /sys/block/sdc/queue/logical_block_size
244        512
245        $ cat /sys/block/sdc/queue/physical_block_size
246        512
247        $ cat /sys/block/sdc/queue/minimum_io_size
248        4096
249        $ cat /sys/block/sdc/queue/optimal_io_size
250        65536
251
252       The NetApp allows 512 byte accesses (but they will be very
253       inefficient), prefers a minimum 4K I/O size, but the optimal I/O size
254       is 64K.
255
256       For detailed information about what these numbers mean, see
257       http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/newstorage-iolimits.html
258
259       [Thanks to Matt Booth for providing 4K drive data.  Thanks to Mike
260       Snitzer for providing NetApp data and additional information.]
261
262   1 MB PARTITION ALIGNMENT
263       Microsoft picked 1 MB as the default alignment for all partitions
264       starting with Windows 2008 Server, and Linux has followed this.
265
266       Assuming 512 byte sectors in the guest, you will now see the first
267       partition starting at sector 2048, and subsequent partitions (if any)
268       will start at a multiple of 2048 sectors.
269
270       1 MB alignment is compatible with all current alignment requirements
271       (4K, 64K) and provides room for future growth in physical block sizes.
272
273   SETTING ALIGNMENT
274       virt-resize(1) can change the alignment of the partitions of some
275       guests.  Currently it can fully align all the partitions of all Windows
276       guests, and it will fix the bootloader where necessary.  For Linux
277       guests, it can align the second and subsequent partitions, so the
278       majority of OS accesses except at boot will be aligned.
279
280       Another way to correct partition alignment problems is to reinstall
281       your guest operating systems.  If you install operating systems from
282       templates, ensure these have correct partition alignment too.
283
284       For older versions of Windows, the following NetApp document contains
285       useful information: http://media.netapp.com/documents/tr-3747.pdf
286
287       For Red Hat Enterprise Linux ≤ 5, use a Kickstart script that contains
288       an explicit %pre section that creates aligned partitions using
289       parted(8).  Do not use the Kickstart "part" command.  The NetApp
290       document above contains an example.
291

SHELL QUOTING

293       Libvirt guest names can contain arbitrary characters, some of which
294       have meaning to the shell such as "#" and space.  You may need to quote
295       or escape these characters on the command line.  See the shell manual
296       page sh(1) for details.
297

EXIT STATUS

299       This program returns:
300
301       ·   0
302
303           successful exit, all partitions are aligned ≥ 64K for best
304           performance
305
306       ·   1
307
308           an error scanning the disk image or guest
309
310       ·   2
311
312           successful exit, some partitions have alignment < 64K which can
313           result in poor performance on high end network storage
314
315       ·   3
316
317           successful exit, some partitions have alignment < 4K which can
318           result in poor performance on most hypervisors
319

SEE ALSO

321       guestfs(3), guestfish(1), virt-filesystems(1), virt-rescue(1),
322       virt-resize(1), http://libguestfs.org/.
323

AUTHOR

325       Richard W.M. Jones http://people.redhat.com/~rjones/
326
328       Copyright (C) 2011 Red Hat Inc.
329

LICENSE

331       This program is free software; you can redistribute it and/or modify it
332       under the terms of the GNU General Public License as published by the
333       Free Software Foundation; either version 2 of the License, or (at your
334       option) any later version.
335
336       This program is distributed in the hope that it will be useful, but
337       WITHOUT ANY WARRANTY; without even the implied warranty of
338       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
339       General Public License for more details.
340
341       You should have received a copy of the GNU General Public License along
342       with this program; if not, write to the Free Software Foundation, Inc.,
343       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
344

BUGS

346       To get a list of bugs against libguestfs, use this link:
347       https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
348
349       To report a new bug against libguestfs, use this link:
350       https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
351
352       When reporting a bug, please supply:
353
354       ·   The version of libguestfs.
355
356       ·   Where you got libguestfs (eg. which Linux distro, compiled from
357           source, etc)
358
359       ·   Describe the bug accurately and give a way to reproduce it.
360
361       ·   Run libguestfs-test-tool(1) and paste the complete, unedited output
362           into the bug report.
363
364
365
366libguestfs-1.20.11                2013-08-27            virt-alignment-scan(1)
Impressum