6

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?

3 Answers 3

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.

2
  • Is there a way to run in line as a single command, if I am not able to store a text file?
    – Jake
    Commented Sep 9, 2014 at 20:12
  • can't thank you enough :) - please also add to the answer - in DISKPART do ATTRIBUTE DISK CLEAR READONLY Commented Oct 22, 2016 at 20:52
1

You could consider changing the disk policy to "OnlineAll":

DISKPART> san policy=OnlineAll

enter image description here

3
  • 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: i.imgur.com/brayXa7.png
    – Jake
    Commented Sep 9, 2014 at 19:39
  • You have to enter diskpart first, then issue the san command.
    – anon
    Commented Sep 9, 2014 at 19:41
  • Although I now get feedback about the SAN policy changing, it still does not cause the drive to mount: i.imgur.com/aM7zJCh.png
    – Jake
    Commented Sep 9, 2014 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
2
  • 1
    It 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 )
    – Jake
    Commented Sep 9, 2014 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).
    – anon
    Commented Sep 9, 2014 at 19:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .