Windows – Automatically mount volume on EC2

amazon ec2amazon-web-serviceswindowswindows-server-2008-r2

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?

Best Answer

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.

Related Topic