Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows Server 2012 R2 / How to Create a RAM Disk on Windows Server?

August 7, 2019 PowerShellWindows Server 2012 R2Windows Server 2016

How to Create a RAM Disk on Windows Server?

A RAM disk is a virtual disk created in a free area of the memory (RAM) that it sees by the OS as a separate physical disk. Due to the RAM disk being stored in the fast RAM, all read/write operations on this disk are performed almost instantaneously, even faster than when using an SSD (the data transfer speed of the most productive SSDs is about 560 MB/s, while DDR4 memory – 12,000-25,000 MB/s.)

It is recommended to use a RAM disk in systems with an excess of free memory. You can use the RAM disk to place the cache or temporary files of apps/system, temporary SQL databases. Thus you can achieve a significant increase in the applications and databases performance.

In Windows OS, there are no integrated tools to create RAM disks, so you have to use third-party software to do it (AMD RAMDisk, ImDisk, PassMark OSFMount, StarWind RAM Disk, etc.).

However, you can create a RAM disk in Windows Server without using any third-party apps. To do it, you can use the iSCSI driver.

First, install the iSCSI Target Server component (it is the part of the File and Storage Services role).

If you have Windows Firewall enabled, you must allow iSCSI Service traffic.

To allow traffic to the loopback interface for iSCSI, change the value of the DWORD parameter AllowLoopBack to 1 in the HKLM\Software\Microsoft\iSCSI Target registry key. You can change the registry parameter from PowerShell using a single command:

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\iSCSI Target' -Name AllowLoopBack -Value 1

Now open the PowerShell console and create a 5 GB virtual RAM disk using this command:

New-IscsiVirtualDisk -Path "ramdisk:testRAM.vhdx" -Size 5GB

Now you need to create an iSCSI target pointing to the IP address of your server (not localhost!):

New-IscsiServerTarget -TargetName targetRAMDisk -InitiatorIds @("IPAddress:10.1.1.200")

Connect the RAM disk to the created iSCSI target:

Add-IscsiVirtualDiskTargetMapping -TargetName targetRAMDisk -DevicePath "ramdisk:testRAM.vhdx"

Run the iSCSI Initiator management console through Server Manager.

Specify the IP address of your server in the Targets tab and click Quick Connect to add your iSCSI target.

You can connect the iSCSI Target with the command:

Get-IscsiTarget | Connect-IscsiTarget

Open the Disk Management console and make sure that the new 5 GB disk appeared there. This is the RAM disk we created. Initialize the disk, create a partition and format it. Assign a disk letter to it.

You can initialize a RAM disk and assign it a drive letter using the PowerShell cmdlets from the built-in disk and partition management module Storage with a following one-liner:

Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "disk2" -Confirm:$false

Now you can move app files to the RAM disk and reconfigure your software to use it.

After rebooting the server, the RAM disk is removed with all its contents and you will have to re-create it again.

Some third-party programs that create RAM disks allow saving RAM disk data as a file on your hard drive. When the system is restarted, the data are extracted and moved to the RAM disk.

To remove your RAM disk, use the following commands:

Remove-IscsiVirtualDiskTargetMapping -TargetName targetRAMDisk -DevicePath "ramdisk:testRAM.vhdx"
Remove-IscsiServerTarget -TargetName targetRAMDisk
Remove-IscsiVirtualDisk -Path "ramdisk:testRAM.vhdx"

5 comments
2
Facebook Twitter Google + Pinterest
previous post
How to Add, Edit, Deploy and Import Registry Keys through GPO?
next post
How to Deploy SSL Certificate on a Computers Using GPO?

Related Reading

Using PowerShell Behind a Proxy Server

July 1, 2022

Checking Windows Activation Status on Active Directory Computers

June 27, 2022

Configuring Multiple VLAN Interfaces on Windows

June 24, 2022

How to Disable or Enable USB Drives in...

June 24, 2022

FAQ: Licensing Microsoft Exchange Server 2019/2016

June 14, 2022

5 comments

Adrian August 15, 2020 - 10:05 am

Great tutorial. I was able to create my ram disk.

“After rebooting the server, the RAM disk is removed with all its contents and you will have to re-create it again.”

Is there a way to make the RAM disk perpetual on a Windows Server?
I have an automatic service that starts automatically and I need to make sure that the drive is mounted at system boot up so that the service can make use of the disk.

Reply
Matteo September 2, 2020 - 7:48 pm

Adrian, maybe running the power shell script at startup and setting the app service with automatic delayed start.

Reply
Guillermo January 7, 2021 - 10:31 pm

Excellent!

Reply
Andrzej March 24, 2021 - 11:53 am

very slow for me on vm: C: FC SSD, M: ramdisk
C:\chudy\test1>winsat disk -drive m
Windows System Assessment Tool
> Running: Feature Enumeration ”
> Run Time 00:00:00.00
> Running: Storage Assessment ‘-drive m -ran -read’
> Run Time 00:00:00.38
> Running: Storage Assessment ‘-drive m -seq -read’
> Run Time 00:00:01.44
> Running: Storage Assessment ‘-drive m -seq -write’
> Run Time 00:00:02.55
> Running: Storage Assessment ‘-drive m -flush -seq’
> Run Time 00:00:00.44
> Running: Storage Assessment ‘-drive m -flush -ran’
> Run Time 00:00:00.47
> Disk Random 16.0 Read 110.98 MB/s 7.2
> Disk Sequential 64.0 Read 273.13 MB/s 7.6
> Disk Sequential 64.0 Write 546.02 MB/s 8.1
> Average Read Time with Sequential Writes 0.082 ms 8.8
> Latency: 95th Percentile 0.141 ms 8.9
> Latency: Maximum 0.865 ms 8.9
> Average Read Time with Random Writes 0.090 ms 8.9
> Total Run Time 00:00:05.36

C:\chudy\test1>winsat disk -drive c
Windows System Assessment Tool
> Running: Feature Enumeration ”
> Run Time 00:00:00.00
> Running: Storage Assessment ‘-drive c -ran -read’
> Run Time 00:00:00.23
> Running: Storage Assessment ‘-drive c -seq -read’
> Run Time 00:00:02.61
> Running: Storage Assessment ‘-drive c -seq -write’
> Run Time 00:00:01.84
> Running: Storage Assessment ‘-drive c -flush -seq’
> Run Time 00:00:01.55
> Running: Storage Assessment ‘-drive c -flush -ran’
> Run Time 00:00:01.67
> Disk Random 16.0 Read 188.32 MB/s 7.7
> Disk Sequential 64.0 Read 3377.72 MB/s 9.3
> Disk Sequential 64.0 Write 754.20 MB/s 8.3
> Average Read Time with Sequential Writes 0.558 ms 7.9
> Latency: 95th Percentile 1.368 ms 8.1
> Latency: Maximum 7.964 ms 8.2
> Average Read Time with Random Writes 0.580 ms 8.6
> Total Run Time 00:00:08.03

C:\chudy\test1>

Reply
Rajesh Kolagatla May 14, 2022 - 2:03 pm

Why copy a thought process

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows 7
  • Windows Server 2019
  • Windows Server 2016
  • Windows Server 2012 R2
  • PowerShell
  • VMWare
  • Hyper-V
  • MS Office

Recent Posts

  • Using PowerShell Behind a Proxy Server

    July 1, 2022
  • How to Access VMFS Datastore from Linux, Windows, or ESXi?

    July 1, 2022
  • How to Deploy Windows 10 (11) with PXE Network Boot?

    June 27, 2022
  • Checking Windows Activation Status on Active Directory Computers

    June 27, 2022
  • Configuring Multiple VLAN Interfaces on Windows

    June 24, 2022
  • How to Disable or Enable USB Drives in Windows using Group Policy?

    June 24, 2022
  • Adding Domain Users to the Local Administrators Group in Windows

    June 23, 2022
  • Viewing a Remote User’s Desktop Session with Shadow Mode in Windows

    June 23, 2022
  • How to Create a Wi-Fi Hotspot on your Windows PC?

    June 23, 2022
  • Configuring SSH Public Key Authentication on Windows

    June 15, 2022

Follow us

woshub.com

ad

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • How to Find the Source of Account Lockouts in Active Directory domain?
  • Get-ADComputer: Find Computer Details in Active Directory with PowerShell
  • How to Create a UEFI Bootable USB Drive to Install Windows 10 or 7?
  • Managing Printers and Drivers with PowerShell in Windows 10 / Server 2016
  • Adding Third-Party Drivers into VMWare ESXi 6.7 ISO Image
  • How to Delete Old User Profiles Using GPO and PowerShell?
  • Deploy PowerShell Active Directory Module without Installing RSAT
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top