Nov
17
Having problems using diskpart in Windows 7 or Windows 2008? Do you get errors such as “Disk is offline because of policy set by administrator” or “media is write protected” when trying to create partitions in Windows, especially for SAN storage volumes or LUNs? Have no fear, there are easy fixes for both. These usually occur on SAN disks presented to Windows servers, either physical or virtual.
Issuing the following commands will solve both problems per incident. Below that I posted an option to avoid the offline disk problem on each server for the future by changing the policy per server.
Warning! Be sure to do this on the right disk since the diskpart command can do serious damage if you run it on the wrong disk.
Get to a command prompt and issue the following:
DISKPART.EXEDISKPART> LIST DISK
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 149 GB 1024 KB
Disk 1 Offline 465 GB 465 GB
-------- ------------- ------- ------- --- ---
Disk 0 Online 149 GB 1024 KB
Disk 1 Offline 465 GB 465 GB
Select the disk you are going to modify
DISKPART> SELECT DISK 1
You have now selected disk 1DISKPART> ONLINE DISK
DISKPART> LIST DISK
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 149 GB 1024 KB
* Disk 1 Online 465 GB 465 GB
-------- ------------- ------- ------- --- ---
Disk 0 Online 149 GB 1024 KB
* Disk 1 Online 465 GB 465 GB
DISKPART> DISK DETAIL
You will see that it is listed as READ-ONLY which can help identify the correct disk is selected as shown by the asterisk seen above.
Clear the Read-Only attribute on the selected disk
Clear the Read-Only attribute on the selected disk
DISKPART> ATTRIBUTES DISK CLEAR READONLY
The disk is no longer Read-Only protected.
If necessary to readonly the partition you can also issue the following:
DISKPART> ATTRIBUTES VOLUME CLEAR READONLY
When you are done modifying the disk attributes just issue the exit command
DISKPART> EXIT
Changing the SAN Policy for Offlining Disks
DISKPART> SAN
SAN Policy : Offline Shared
Once you have verified that the applied policy is Offline Shared and you know you want to change it for all future disks presented to this server, issue the following:
DISKPART> SAN POLICY=ONLINEALL
DiskPart successfully changed the SAN policy for the current operating system.



