There is a procedure given by Amazon to make a volume available for use that has been attached as a block device. Given that I am attaching an EBS volume that is already ready to be used, is there a way in Windows Server 2008 R2 to either automatically mount or follow the procedure beforehand linked through the commandline rather than the GUI so that it can be automated?
Asked
Active
Viewed 1,096 times
6
3 Answers
5
You can use diskpart to do this. Open up cmd.exe and run diskpart. This allows you to execute commands. First, run san policy=onlineall
. Then, type list disk
. Because of the nature of EC2, you should consistently be able to mount the same disk. It appears it should be disk 1. Then, type select disk 1
and online disk
.
To script this, make a file called diskpart.txt and add these lines:
san policy=onlineall
select disk 1
online disk
Then you can execute DISKPART /s diskpart.txt
to automatically mount the drive.

Keith R
- 166
- 2
-
Is there a way to run in line as a single command, if I am not able to store a text file? – Jake Sep 09 '14 at 20:12
-
can't thank you enough :) - please also add to the answer - in DISKPART do `ATTRIBUTE DISK CLEAR READONLY` – Manish Mishra Oct 22 '16 at 20:52
1

gtirloni
- 5,746
- 3
- 25
- 52
-
I tried running the command, but it did not appear to cause the disk to mount. Here is a screenshot where I first ran the command and then opened disk manager and explorer: http://i.imgur.com/brayXa7.png – Jake Sep 09 '14 at 19:39
-
-
Although I now get feedback about the SAN policy changing, it still does not cause the drive to mount: http://i.imgur.com/aM7zJCh.png – Jake Sep 09 '14 at 19:49
-1
You can use the Set-Disk
cmdlet to make the disk online:
NAME
Set-Disk
SYNOPSIS
Takes a Disk object or unique disk identifiers and a set of attributes, and updates
the physical disk on the system.
To get a list of all disks:
Get-Disk
To enable disk #2:
Set-Disk -Number 2 -IsOffline $False
To enable all offline disks:
Get-Disk | Where-Object IsOffline –Eq $True | Set-Disk –IsOffline $False

gtirloni
- 5,746
- 3
- 25
- 52
-
1It seems get-disk and set-disk are not available under Windows Server 2008 R2 (only 2012 and newer include the disk module according to [this SO question](http://stackoverflow.com/questions/14838967/windows-2008-r2-powershell-the-term-get-disk-is-not-recognized-as-the-name-of) ) – Jake Sep 09 '14 at 18:45
-
Correct. You might need to consider installing PowerShell 4.0 in that case. Or using the workaround proposed in the SO question you link (diskpart script). – gtirloni Sep 09 '14 at 19:02