Posey's Tips & Tricks

How To Fix the Hyper-V Read Only Disk Problem

DOS might seem like a relic now, but sometimes it's the only way to fix a problem that Windows seems ill-equipped to deal with -- like this one.

A few weeks ago, I ran into a really weird problem on one of my lab Hyper-V servers. I was in the process of creating a video-based course and had to create a number of nested Hyper-V servers. As I got further into what I was doing, I began to deplete the Hyper-V server of physical resources.

At one point, the nested Hyper-V servers (which were all configured to act as a Storage Spaces Direct cluster) began experiencing I/O problems because they were flooding the underlying physical disks with more IOPS requests then they could handle. I also ran into a problem because I depleted my server of physical disk space.

I'm honestly not sure which of these issues caused the problem, but for some reason, the physical disk on which the Hyper-V servers resided became flagged as Read Only. You can see what this looks like in Figure 1. As you can see in the figure, Disk 1 is listed as Read Only.

[Click on image for larger view.] Figure 1: Disk 1 became flagged as Read Only.

Unfortunately, the Windows Disk Management Console does not seem to have a way to change the disk's Read Only attribute. However, I remembered a technique from many, many years ago that I was able to use to get the job done.

One of the things that I find somewhat surprising about the Windows operating system is that it contains elements of the DOS and Windows operating systems from the 1980s. Every once in a while, I have found that it is possible to use one of these obscure tools to fix a problem that Windows seems ill-equipped to deal with. In this particular case, I used an old DOS command called DiskPart.

To remove the Read Only attribute from a disk, open a Command Prompt window on the Hyper-V server that is experiencing the problem, then enter the DiskPart command. You can see what this looks like in Figure 2.

Figure 2: This is what it looks like when you run the DiskPart command on Windows Server.

The next step in the process is to get DiskPart to display a list of the system's disks. To do so, just enter the List Disk command.

If you look at Figure 3, you can see that my Hyper-V server has two disk: a boot disk and a data disk. Incidentally, the data disk (Disk 1) actually consists of several disks arranged as a parity array. Even so, the technique that I am about to show you still works because Windows Server treats the disk as though it were a single physical disk rather than a collection of disks collectively acting as one.

Figure 3: I listed the disks within my server.

So with the disks displayed, make note of the disk number associated with the disk that has been flagged as Read Only. Again, it's Disk 1 on my server.

Now that I know the disk number, the next step is to select it. To do so, just type Select Disk, followed by the disk number (Select Disk 1). When you do, you should see a message indicating that the disk has been selected, as shown in Figure 4.

Figure 4: I have selected the disk.

Now, enter the Detail Disk command. This will display all of the disk's pertinent information and will confirm that the disk is indeed flagged as Read Only.

[Click on image for larger view.] Figure 5: This disk continues to be reported as Read Only.

Now it's time to use another obscure DOS command to fix the problem: Attrib. Attrib was originally used to change the attributes on files. For example, you could use the Attrib command to make a file Read Only or to flag a file as hidden.

Back in the days of DOS, if you wanted to use the Attrib command to remove the Read Only attribute from a file, you would have to specify the -R parameter. However, when you use the Attrib command within the DiskPart utility, it works a little bit differently. Instead of using Attrib Disk -R, you have to use the command Attrib Disk Clear ReadOnly. You can see what this looks like in Figure 6.

Figure 6: The Read Only attribute has been cleared.

As you can see in Figure 7, the disk is no longer Read Only. Now my Hyper-V virtual machines once again work the way that they are supposed to.

[Click on image for larger view.] Figure 7:The Read Only Attribute is no longer in effect.

About the Author

Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.

Featured

comments powered by Disqus

Subscribe on YouTube