123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Windows Server 2012 2016 2019 2022 RAM Disk Setup Guide</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="UTF-8">
- <meta name="keywords" content="Windows,RAM Disk,Microsoft,iSCSI,PowerShell,Windows Server,Windows Server 2012,Windows Server 2016,Windows Server 2019,Windows Server 2022,How To,Tutorial,i12bretro">
- <meta name="author" content="i12bretro">
- <meta name="description" content="Windows Server 2012 2016 2019 2022 RAM Disk Setup Guide">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
- <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
- <script type="text/javascript" src="includes/js/steps.js"></script>
- <link href="css/steps.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="gridContainer">
- <div class="topMargin"></div>
- <div id="listName" class="topMargin">
- <h1>Windows Server 2012 2016 2019 2022 RAM Disk Setup Guide</h1>
- </div>
- <div></div>
- <div id="content">
- <p><em>NOTE: RAM disks by their very nature are cleared on reboot. Do not use them to store any data that cannot be lost. A suitable use case would be temporary session files for a web server</em></p>
- <h2>Installing iSCSI Target Server</h2>
- <ol>
- <li>Launch Server Manager if it does not automatically load
- <ol>
- <li>Click the Start button > Server Manager</li>
- </ol>
- </li>
- <li>Click Manage > Add roles and features</li>
- <li>Click Next on the Before you begin screen</li>
- <li>Select Role-based or feature-based installation > Next</li>
- <li>Leave Select a server from the server pool selected and select the current server > Next</li>
- <li>Expand File and Storage Services > Expand File and iSCSI Services > Select iSCSI Target Server</li>
- <li>A popup will appear with additional required roles and features, click the Add Features button</li>
- <li>Click Next</li>
- <li>Click Next on the Select features screen</li>
- <li>Click Install on the confirmation screen</li>
- <li>Leave the installation progress screen open until the install completes</li>
- </ol>
- <h2>Creating the RAM Disk</h2>
- <ol>
- <li>Launch Powershell as administrator</li>
- <li>Enter the following commands to create the RAM disk, replacing the IP address with the current server's IP address
- <div class="codeBlock PS"># allow iSCSI loopback registry setting<br />
- Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\iSCSI Target' -Name AllowLoopBack -Value 1<br />
- # start the iscsi initiator service<br />
- Start-Service -Name MSiSCSI<br />
- # set the iscsi initiator service to start automatically<br />
- Set-Service -Name MSiSCSI -StartupType Automatic<br />
- # create the ram disk, changing size as needed<br />
- New-IscsiVirtualDisk -Path "ramdisk:RAMDisk.vhdx" -Size 256MB<br />
- # initialize iSCSI target<br />
- New-IscsiServerTarget -TargetName RAMDisk -InitiatorIds @("IPAddress:192.168.0.65")<br />
- # connect to the ram disk<br />
- Add-IscsiVirtualDiskTargetMapping -TargetName RAMDisk -DevicePath "ramdisk:RAMDisk.vhdx"</div>
- </li>
- <li>Back in Server Manager, select Tools > iSCSI Initiator</li>
- <li>Enter the IP address in the Target field > Click Quick Connect...</li>
- <li>Click Done</li>
- <li>Back in Powershell, run the following command
- <div class="codeBlock PS"># initialize the disk as NTFS<br />
- Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -DriveLetter R -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "RAMDisk" -Confirm:$false</div>
- </li>
- <li>Open File Explorer and the new RAM disk should be listed as a usable NTFS drive</li>
- </ol>
- <h2>Re-creating the RAM Disk on Boot</h2>
- <p><em>After the RAM disk has been setup initially, follow the steps below to have it recreated on system boot.</em></p>
- <ol>
- <li>Open a text editor</li>
- <li>Paste the following Powershell commands, changing the size as needed
- <p>New-IscsiVirtualDisk -Path "ramdisk:RAMDisk.vhdx" -Size 256MB<br />
- Add-IscsiVirtualDiskTargetMapping -TargetName RAMDisk -DevicePath "ramdisk:RAMDisk.vhdx"<br />
- Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -DriveLetter R -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "RAMDisk" -Confirm:$false</p>
- </li>
- <li>Save the file as ramdisk.ps1 to a safe location to run from, c:\scripts for example</li>
- <li>Click on the Start Button > Type task > Launch Task Scheduler</li>
- <li>Right click the Task Scheduler Library folder in the left pane > Create Basic Task...</li>
- <li>Set the name to RAM Disk and optionally set a Description > Click Next</li>
- <li>For the Trigger, select When the computer starts > Click Next</li>
- <li>For the Action, select Start a program > Click Next</li>
- <li>In the Program/script field, paste the following:
- <p>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</p>
- </li>
- <li>In the Add arguments field, paste the following, editing the path to the .ps1 file if necessary:
- <p>"C:\Scripts\ramdisk.ps1"</p>
- </li>
- <li>Click Next</li>
- <li>Check the Open the Properties dialog for this task when I click Finish box</li>
- <li>Click Finish</li>
- <li>In the Properties dialog, click the Change User or Group... button</li>
- <li>Type system > Press Enter</li>
- <li>Check the Run with highest privileges box</li>
- <li>Click OK to create the scheduled task</li>
- <li>Reboot the server to verify the RAM disk is re-created automatically</li>
- </ol>
- </div>
- </div>
- </body>
- </html>
-
|