在 Hyper-V 上安装 Ubuntu 时,磁盘变为只读

When installing Ubuntu on Hyper-V, disk becomes read-only

我正在尝试在基于 Hyper-V Gen1 的虚拟机中的 Windows Server 2012 R2 上安装 Ubuntu 12.04.5 Server(64 位)。安装将随机挂起,dmesg 最终显示如下错误:

sd 2:0:0:0: rejecting I/O to offline device

我有一个非常相似的 VM,一直运行良好。两个系统上的 dmesg 输出在启动后大约 126 秒时首先出现分歧(尽管这可能是因为它是安装程序启动,而不是标准启动):

[  126.482972] NTFS driver 2.1.30 [Flags: R/O MODULE].
xor: measuring software checksum speed
   prefetch64-sse: 16009.000 MB/sec
   generic_sse: 15008.000 MB/sec
xor: using function: prefetch64-sse (16009.000 MB/sec)
raid6: sse2x1    9322 MB/s
raid6: sse2x2   11511 MB/s
raid6: sse2x4   13061 MB/s
raid6: using algorithm sse2x4 (13061 M/s)
raid6: using intx recovery algorithm
bio: create slab <bio-1> at 1
Btrfs loaded
JFS: nTxBlock = 7892, nTxLock = 63140
SGI XFS with ACLs, security attributes, realtime, large block/inode, numbers, no debug enabled
EXT4-fs (sda1): couldn't mount as ext3 due to feature incompatibilities
EXT4-fs (sda1): couldn't mount as ext2 due to feature incompatibilities
EXT4-fs (sda1): INFO: recovery required on readonly filesystem
EXT4-fs (sda1): write access unavailable, cannot proceed
EXT4-fs (sda1): couldn't mount as ext3 due to feature incompatibilities
EXT4-fs (sda1): couldn't mount as ext2 due to feature incompatibilities
EXT4-fs (sda1): INFO: recovery required on readonly filesystem
[  127.334559] EXT4-fs (sda1): write access unavailable, cannot proceed

一段时间后,

[  182.830804] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: errors=remount-ro
[  230.779000] hv_storvsc vmbus_0_1: cmd 0x2a scsi status 0x2 srb status 0xa
               (repeated x times...)
[  241.151746] hv_storvsc vmbus_0_1: cmd 0x3 scsi status 0x2 srb status 0x8
               (also repeated x times)
[  251.155963] hv_storvsc vmbus_0_1: cmd 0x0 scsi status 0x2 srb status 0x8
[  251.155973] sd 2:0:0:0: Device offlined - not ready after error recovery
               (repeated x times again)
[  251.155987] sd 2:0:0:0: [sda] Unhandled error code
[  251.155988] sd 2:0:0:0: [sda]
[  251.155989] Result: hostbyte=DID_OK driverbyte=DRIVER_OK
[  251.155991] sd 2:0:0:0: [sda] CDB:
[  251.155992] Write(10): 2a 00 04 c1 09 00 00 00 08 00
[  251.155996] end_request: I/O error, dev sda, sector 79759616
[  251.155999] Buffer I/O error on device sda1, logical block 9969696
[  251.156000] lost page write due to I/O error on sda1
[  251.156011] sd 2:0:0:0: rejecting I/O to offline device

最终渗透到 EXT4 驱动程序。 对于 EXT3,会出现类似的错误消息,但驱动程序不会调用它退出,因此安装会挂起。


备注:

Windows Azure-based (cloud) VMs 上似乎发生了类似的事情。链接页面建议您停止并启动 VM,这意味着将其移动到不同的主机。

This thread 提到 Hyper-V 会在基础磁盘 returns 出错时停止 I/O,并且这种停止会导致奇怪的行为。

This thread 表明它特定于将 storvsc 驱动程序与 ext4 文件系统一起使用,不支持 SCSI WRITE_SAME 命令。这将被签入 Linux 内核 3.9-rc1,并且肯定包含在 Linux 3.13 内核中 Ubuntu 12.04.5.

事实证明,主机 Hyper-V 服务器 运行 磁盘不足 space。

由于之间有多个间接级别:

  1. 真实物理磁盘
  2. 虚拟磁盘(由 Windows 物理磁盘上的存储空间托管)
  3. 磁盘映像(托管在虚拟磁盘上的动态 .vhdx 文件)
  4. Linux 文件系统(托管在动态磁盘映像上)

各个级别实际填满并将错误传递到下一个级别需要一些时间。最终表明问题的是另一台 VM 抱怨磁盘不足 space(但仅在完成 ​​~4 GB Ubuntu 安装后!)。

我更换了其中一个磁盘(500 GB => 4 TB),并将其添加到存储池中,这让一切都恢复正常。然后我用一些 PowerShell commands 重建了磁盘池(Windows 服务器 UI 不工作):

Get-PhysicalDisk
$missingDisk = Get-PhysicalDisk | Where-Object { $_.OperationalStatus -eq 'Lost Communication' }
$missingDisk | Set-PhysicalDisk -Usage Retired
Repair-VirtualDisk –FriendlyName <VolumeName>