使用 LVM 在 QEMU 中运行 Windows 会导致磁盘访问速度非常慢

使用 LVM 在 QEMU 中运行 Windows 会导致磁盘访问速度非常慢

我遇到的问题是,每当我尝试在 QEMU 中运行 Windows 时,磁盘访问似乎在短时间后变得非常慢。令人惊讶的是,无论是从 VM 内部还是从 VM 外部访问磁盘,似乎都变得很慢。

我的家庭驱动器和 QEMU Windows 驱动器都位于同一磁盘上(这是一台笔记本电脑,因此我无法使用多个磁盘),但位于不同的 LVM 卷上(没有 qcow 或任何东西,只有原始 LV)。几分钟后,Windows 变得无法使用,主机也变得很慢。一旦我禁用虚拟机,主机就会再次可用。我已经使用资源监视器追溯到 Windows 中磁盘访问缓慢的问题。但问题似乎出在主机的 LVM 端。如果我运行,iostat -xz我会得到以下内容:

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          17,36   10,14    5,41   38,51    0,00   28,58

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
dm-0             7,63     82,81     0,00   0,00   84,37    10,85   22,74    209,61     0,00   0,00  121,53     9,22    0,00      0,00     0,00   0,00    0,00     0,00    3,41   3,32
dm-1             0,05      0,27     0,00   0,00    5,05     5,49    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-2             0,00      0,09     0,00   0,00    6,10    21,75    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-3             2,28      9,12     0,00   0,00   21,28     4,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,05   0,53
dm-4             0,02      0,09     0,00   0,00    4,95     4,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-5             0,00      0,00     0,00   0,00   31,64     4,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-6             0,02      0,09     0,00   0,00    4,94     4,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-7             0,00      0,09     0,00   0,00    6,85    21,75    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-8            36,13   1454,39     0,00   0,00   46,74    40,25  528,37   2107,50     0,00   0,00  122,58     3,99    0,00      0,00     0,00   0,00    0,00     0,00   66,46  12,66
dm-9             7,63     82,77     0,00   0,00   84,49    10,85   22,74    213,86     0,00   0,00 1578,74     9,40    0,00      0,00     0,00   0,00    0,00     0,00   36,55   3,18
nvme0n1          4,49    176,13     5,82  56,45    0,19    39,26  101,54    445,00     0,07   0,07    0,95     4,38    0,00      0,00     0,00   0,00    0,00     0,00    0,07   0,38
sda             41,89   1547,29     4,19   9,10   46,21    36,93   41,60   2317,08   509,51  92,45  158,29    55,70    0,00      0,00     0,00   0,00    0,00     0,00    8,40  15,35

dm-8 是 Windows LV,dm-9 是我的主驱动器。因此,出于某种原因,似乎数据正在排队等待这两个驱动器。写入速度不是很快,系统运行缓慢,最多大约 1-5MB/s,这对于我系统中的驱动器来说非常慢。

VM 运行时 CPU 使用率非常低(无论是在 VM 内部使用资源监视器,还是在主机上)。通常只有 10% 左右。

我正在使用 Virtio 作为存储适配器,并且已经尝试了不同的配置(线程、缓存等),但似乎没有什么可以改变这个问题。

是否有其他配置可以帮助我获得更好的磁盘访问?

编辑

以下是输出smartctl -a /dev/sda

smartctl 7.0 2018-12-30 r4883 [x86_64-linux-5.4.48-gentoo-20200819] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate FireCuda 2.5
Device Model:     ST2000LX001-1RG174
Serial Number:    ZDZ9N2W8
LU WWN Device Id: 5 000c50 0c4905536
Firmware Version: SDM1
User Capacity:    2.000.398.934.016 bytes [2,00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 3b
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Tue Sep  1 10:07:55 2020 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever 
                                        been run.
Total time to complete Offline 
data collection:                (    0) seconds.
Offline data collection
capabilities:                    (0x71) SMART execute Offline immediate.
                                        No Auto Offline data collection support.
                                        Suspend Offline collection upon new
                                        command.
                                        No Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine 
recommended polling time:        (   1) minutes.
Extended self-test routine
recommended polling time:        ( 328) minutes.
Conveyance self-test routine
recommended polling time:        (   2) minutes.
SCT capabilities:              (0x3035) SCT Status supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   078   064   006    Pre-fail  Always       -       66205122
  3 Spin_Up_Time            0x0003   099   099   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       161
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   075   060   045    Pre-fail  Always       -       29488074
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       527 (193 175 0)
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       151
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   100   099   000    Old_age   Always       -       4
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   058   048   040    Old_age   Always       -       42 (Min/Max 22/43)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       1
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       22
193 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       1116
194 Temperature_Celsius     0x0022   042   052   000    Old_age   Always       -       42 (0 19 0 0 0)
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       523h+48m+09.290s
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      -       2770583284
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      -       713825407
254 Free_Fall_Sensor        0x0032   100   100   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%       523         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

相关内容