RESCAN
SELECT DISK n
CREATE PART PRIMARY ALIGN=32
ASSIGN LETTER x:
EXIT
Now we've added some Windows 2008 servers, and this no longer works. Specifically, the create partition command fails, with diskpart saying the "media is write protected." Now, I know that we now have to execute ONLINE DISK, as disks initially are visible in an offline state. That's not sufficient. I can't create a partition until I go into Computer Management/Storage/Disk Management, select the new disk, and choose "initialize" from the right click menu. If I don't, the disk has no signature and the OS sees it as read only. Writing a signature always seemed to be implicit in Windows 2003, as we've run our process hundreds of times and never initialized a disk.
How can I initialize a disk within DISKPART? Alternately, is there a command line command to initialize? If we have to use a GUI tool, it will fatally break our automated process.
This should be possible to automate in your script and hence not break your automated process.
RESCAN
SELECT DISK n
ONLINE DISK
UNIQUEID DISK ID=12345678
and then you partition commands
HTH,
Edwin.
PS full explanation of diskpart.exe on 2008 is here: http://technet2.microsoft.com/windowsserver2008/en/library/26a4a166-95fa-4faf-95bc-2d5345f4a57a1033.mspx?mfr=true
- Marked as answer by David Shen Friday, August 01, 2008 7:20 AM
RESCAN
SELECT DISK n
ONLINE DISK
UNIQUEID DISK ID=12345678
and then you partition commands
HTH,
Edwin.
PS full explanation of diskpart.exe on 2008 is here: http://technet2.microsoft.com/windowsserver2008/en/library/26a4a166-95fa-4faf-95bc-2d5345f4a57a1033.mspx?mfr=true
- Marked as answer by David Shen Friday, August 01, 2008 7:20 AM
I had the same problem when creating a cluster in Server Core. The command I used to remove the write protection wasdiskpart > select disk n > ATTRIBUTES DISK CLEAR READONLY
As the kids say, WIN!
Given the new emphasis Windows 2008 has on everything-you-can-do-in-the-GUI-you-can-do-in-the-command-line, the omission of a well-defined method of initializing a disk within DISKPART seems particularly glaring.
- Proposed as answer by Steve Jenness Friday, August 01, 2008 8:16 PM
I had the same problem when creating a cluster in Server Core. The command I used to remove the write protection wasdiskpart > select disk n > ATTRIBUTES DISK CLEAR READONLY
As the kids say, WIN!
Given the new emphasis Windows 2008 has on everything-you-can-do-in-the-GUI-you-can-do-in-the-command-line, the omission of a well-defined method of initializing a disk within DISKPART seems particularly glaring.
- Proposed as answer by Steve Jenness Friday, August 01, 2008 8:16 PM
Diskpart (CLI) and Disk Management (GUI) functionality is not mapped one to one. This is by design. The GUI is designed to be easier to use for common usage patternsso it compounds fundamental operations into few clicks. Diskpart gives more granular control. So, sometimes you have to use multiple diskpart commands to get the functionality that you get from a single menu item in Disk Management.
For instance, onlining a disk in Disk Management also clears the readonly attribute. In diskpart, you have to do those two operations separately.
You don't have to explicitly set the disk signature (even on Windows Server 2008).
The suggested sequence for initializing a newly discovered disk that is offline is:
DISKPART> SELECT DISK n
DISKPART> ATTRIBUTES DISK CLEAR READONLY
DISKPART> ONLINE DISK
DISKPART> CONVERT MBR
This makes the disk read/write, online and with aMBR partition layout. The "CONVERT" command is equivalent to the "Initialize Disk" Operation in the Disk Management GUI.
If you use"DISKPART> CREATE PARTITION PRIMARY" in the place of "DISKPART> CONVERT MBR", the MBR initialization is done implicitly.
The equivalent Disk Management operations would be:
Right click on the disk in the bottom pane (click where it shows "Disk 1")
Select "Online"
(This brings the disk online and clears the readonly attribute making the disk read/write)
Right click in the same place again
Select "Initialize Disk"
Select the "MBR (Master Boot Record)" radio button and the "OK" button
(This creates the MBR partition layout)
Also, on Windows Server 2008, I'd suggest not specifying the ALIGN parameter on the CREATE PARTITION command unless you really need to. Windows Server 2008 has much better default alignment rules that prior releases. The default for most partitions is to create them on 1Mbyte alignment boundaries. This default alignment is good for all of the performance and large sector alignment scenarios that we currently know about.
Steve
- Proposed as answer by Steve Jenness Friday, August 01, 2008 8:39 PM
- Marked as answer by Malu Menezes Friday, August 01, 2008 11:19 PM
Diskpart (CLI) and Disk Management (GUI) functionality is not mapped one to one. This is by design. The GUI is designed to be easier to use for common usage patternsso it compounds fundamental operations into few clicks. Diskpart gives more granular control. So, sometimes you have to use multiple diskpart commands to get the functionality that you get from a single menu item in Disk Management.
For instance, onlining a disk in Disk Management also clears the readonly attribute. In diskpart, you have to do those two operations separately.
You don't have to explicitly set the disk signature (even on Windows Server 2008).
The suggested sequence for initializing a newly discovered disk that is offline is:
DISKPART> SELECT DISK n
DISKPART> ATTRIBUTES DISK CLEAR READONLY
DISKPART> ONLINE DISK
DISKPART> CONVERT MBR
This makes the disk read/write, online and with aMBR partition layout. The "CONVERT" command is equivalent to the "Initialize Disk" Operation in the Disk Management GUI.
If you use"DISKPART> CREATE PARTITION PRIMARY" in the place of "DISKPART> CONVERT MBR", the MBR initialization is done implicitly.
The equivalent Disk Management operations would be:
Right click on the disk in the bottom pane (click where it shows "Disk 1")
Select "Online"
(This brings the disk online and clears the readonly attribute making the disk read/write)
Right click in the same place again
Select "Initialize Disk"
Select the "MBR (Master Boot Record)" radio button and the "OK" button
(This creates the MBR partition layout)
Also, on Windows Server 2008, I'd suggest not specifying the ALIGN parameter on the CREATE PARTITION command unless you really need to. Windows Server 2008 has much better default alignment rules that prior releases. The default for most partitions is to create them on 1Mbyte alignment boundaries. This default alignment is good for all of the performance and large sector alignment scenarios that we currently know about.
Steve
- Proposed as answer by Steve Jenness Friday, August 01, 2008 8:39 PM
- Marked as answer by Malu Menezes Friday, August 01, 2008 11:19 PM
In multiple attempts to "Attributes disk clear readonly" the disk never cleared the flag... So i did:
DISKPART> List Volume
DISKPART> Select VOLUMENAME
DISKPART>Attributes Volume Clear Readonly
After doing that, the volume & not disk cleared the read only attribute and fixed my write-protected problem. Good luck to all.
Followed the "equivalent Disk Management operations" verbatim.
When it comes to the section "Select "Initialize Disk""...there is no command "initialize" in the right click menu. The command is not "grayed-out" either. I am running Windows 2008 STD build and it is patched up to SP2. I was in "dsikpart" but did not see a similar command.
This makes me curious if I missed something in the initial installation of the OS on the system. Is this usnique to the differences of 2008 and 2008 R2?
Hi Steve,
I have a similar case here. I have 5 disk's mapped to the host all the disk are in Offline state. I was supposed to bring all the disk online one by one. I tried to set the SAN POLICY onlineall. But this is not working for me.
Is it possible to bring all the disk's mapped to the host to online with out doing it manually. Can you add your comments on this.
Thanks
Elangovv
Just a heads up, we use EVA's as well (5000, 8000, 8100, 8400) and everything I have been told has been to do align=64, not align=32.
I didnt read the whole thread, but the diskpart command for initializing a disk is select disk x then ONLINE disk, then create partition primary align=64 (or 32 if you want)
Son.Le almost has the answer above. However you need to use the command -
Attributes disk clear readonly
This will clear the readonly attribute equivelant of an initilise, you are then free to partition, format and do what ever, enjoy :o)
- Proposed as answer by FurryMonkey Tuesday, May 01, 2012 8:23 AM
Son.Le almost has the answer above. However you need to use the command -
Attributes disk clear readonly
This will clear the readonly attribute equivelant of an initilise, you are then free to partition, format and do what ever, enjoy :o)
- Proposed as answer by FurryMonkey Tuesday, May 01, 2012 8:23 AM
if you set
diskpart> san onlineall
it should by default online the disk
you can use
diskpart> online disk
to online the disk. you can create a batch script to do the same.
Regards
satish
Does this work for Windows 7 and 8?
I need a DOS script that will initialize and format up to 6 external USB drives at a time to NTFS. And, I need a similar script for exFAT.
Currently, I am using the following for exFAT;
<<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>>
Is there a way to condense this redundant code to maybe some like the following?
<<drive letter through drive letter>>: /y/q/fs:exFAT/v:<<drive name-drive name>> && label <<drive letter through drive letter>>: <<label name>>
Thank you!!
- Edited by technigeekulum 6 hours 27 minutes ago
Does this work for Windows 7 and 8?
I need a DOS script that will initialize and format up to 6 external USB drives at a time to NTFS. And, I need a similar script for exFAT.
Currently, I am using the following for exFAT;
<<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>> & <<drive letter>>: /y/q/fs:exFAT/v:<<drive name>> && label <<drive letter>>: <<label name>>
Is there a way to condense this redundant code to maybe some like the following?
<<drive letter through drive letter>>: /y/q/fs:exFAT/v:<<drive name-drive name>> && label <<drive letter through drive letter>>: <<label name>>
Thank you!!
- Edited by technigeekulum Tuesday, March 17, 2015 12:35 AM