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

EXIT STATUS

316       This program returns:
317
318       •   0
319
320           successful exit, all partitions are aligned ≥ 64K for best
321           performance
322
323       •   1
324
325           an error scanning the disk image or guest
326
327       •   2
328
329           successful exit, some partitions have alignment < 64K which can
330           result in poor performance on high end network storage
331
332       •   3
333
334           successful exit, some partitions have alignment < 4K which can
335           result in poor performance on most hypervisors
336

SEE ALSO

338       guestfs(3), guestfish(1), virt-filesystems(1), virt-rescue(1),
339       virt-resize(1), http://libguestfs.org/.
340

AUTHOR

342       Richard W.M. Jones http://people.redhat.com/~rjones/
343
345       Copyright (C) 2011 Red Hat Inc.
346

LICENSE

348       This program is free software; you can redistribute it and/or modify it
349       under the terms of the GNU General Public License as published by the
350       Free Software Foundation; either version 2 of the License, or (at your
351       option) any later version.
352
353       This program is distributed in the hope that it will be useful, but
354       WITHOUT ANY WARRANTY; without even the implied warranty of
355       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
356       General Public License for more details.
357
358       You should have received a copy of the GNU General Public License along
359       with this program; if not, write to the Free Software Foundation, Inc.,
360       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
361

BUGS

363       To get a list of bugs against libguestfs, use this link:
364       https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
365
366       To report a new bug against libguestfs, use this link:
367       https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
368
369       When reporting a bug, please supply:
370
371       •   The version of libguestfs.
372
373       •   Where you got libguestfs (eg. which Linux distro, compiled from
374           source, etc)
375
376       •   Describe the bug accurately and give a way to reproduce it.
377
378       •   Run libguestfs-test-tool(1) and paste the complete, unedited output
379           into the bug report.
380
381
382
383guestfs-tools-1.51.6              2023-12-09            virt-alignment-scan(1)
Impressum