title: When installing Ubuntu on Hyper-V, disk becomes read-only
body: <p>I am trying to install Ubuntu 12.04.5 Server (64-bit) on Windows Server 2012 R2, in a Hyper-V Gen1-based VM. The installation will randomly hang, with <code>dmesg</code> eventually showing errors like:</p>
  
  <pre><code>sd 2:0:0:0: rejecting I/O to offline device
  </code></pre>
  
  <p>I have a very similar VM that's been working fine. The <code>dmesg</code> output on the two systems first diverges at about 126 seconds after boot-up (although this may be due to it being an installer boot, as opposed to a standard boot):</p>
  
  <pre><code>[  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 &lt;bio-1&gt; 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
  </code></pre>
  
  <p>And after some time, </p>
  
  <pre><code>[  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
  </code></pre>
  
  <p>Which eventually percolates up to the EXT4 driver.
  With EXT3, similar error messages show up, but the driver never calls it quits, so the install just hangs.</p>
  
  <hr>
  
  <p>Notes:</p>
  
  <p>Something similar seems to happen on <a href="https://social.msdn.microsoft.com/Forums/azure/en-US/cae5d9d5-65a3-41b7-83d6-3cc24c418c18/vm-becomes-unresponsive-or-disk-becomes-readonly?forum=WAVirtualMachinesforWindows" rel="nofollow">Windows Azure-based (cloud) VMs</a>. The linked page suggests that you stop and start the VM, which is implied to move it to a different host.</p>
  
  <p><a href="http://lkml.iu.edu/hypermail/linux/kernel/1304.3/02995.html" rel="nofollow">This thread</a> mentions that Hyper-V will stall I/O when the underlying disk returns an error, and that this stall causes weird behavior.</p>
  
  <ul>
  <li>The VHDX disk image is located on a Windows Storage Space device (Microsoft RAID-ish technology).</li>
  </ul>
  
  <p><a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1157952" rel="nofollow">This thread</a> suggests that it is specific to using the <code>storvsc</code> driver with ext4 file systems, with SCSI <code>WRITE_SAME</code> commands being unsupported. This would have been checked in to Linux kernel 3.9-rc1, and definitely included in the Linux 3.13 kernel shipped with Ubuntu 12.04.5.</p>