How to create a in-memory RAM disk on my Linux VM instance that's on google cloud?

0 votes
Sep 25, 2019 in GCP by Sam
• 6,250 points
326 views

1 answer to this question.

0 votes

You can create a RAM disk with the tmpfs tool, which is installed by default on many Linux Operating Systems.

  1. your instance does not have enough available memory, you can optionally change the instance machine type to a machine type with more memory.

  2. Connect to your instance through SSH. For this example, go to the VM instances page and click the SSH button next the instance where you want to add a RAM disk.

  3. Create a mount point for your RAM disk.

    $ sudo mkdir /mnt/ram-disk
  4. Create and mount a new tmpfs RAM disk. You must determine a value for the size property that meets your storage requirements without competing with your applications for memory or expending all of the available memory. For this example, the instance has a n1-highmem-32 machine type with 208 GB of memory, so a 50g RAM disk size is appropriate.

    $sudo mount -t tmpfs -o size=50g tmpfs /mnt/ram-disk
  5. Add the RAM disk to the /etc/fstab file so that the device automatically mounts again if you restart the instance:

    $echo 'tmpfs /mnt/ram-disk tmpfs nodev,nosuid,noexec,nodiratime,size=50G 0 0' | sudo tee -a /etc/fstab
answered Sep 25, 2019 by Sirajul
• 58,210 points

Related Questions In GCP

0 votes
1 answer

How to add a regional persistent disk to a VM instance on GCP?

You must first create the regional persistent ...READ MORE

answered Oct 18, 2019 in GCP by Sirajul
• 58,210 points
619 views
0 votes
1 answer

How do i delete a RAM disk from my instance on GCP?

You can unmount a tmpfs RAM disk just like ...READ MORE

answered Oct 22, 2019 in GCP by Sirajul
• 58,210 points
157 views
0 votes
1 answer

How to create a Google Cloud Filestore instance?

Create an instance by running the instances create command, ...READ MORE

answered Oct 23, 2019 in GCP by Sirajul
• 58,210 points
332 views
0 votes
1 answer
0 votes
1 answer

Create a Windows VM instance using Google Compute Engine (GCE).

To create a Windows virtual machine instance ...READ MORE

answered Sep 20, 2019 in GCP by Sirajul
• 58,210 points
1,040 views
0 votes
1 answer

Creating a SQL Server instance using Google Compute engine.

Google Compute Engine provides public images preconfigured with ...READ MORE

answered Sep 23, 2019 in GCP by Sirajul
• 58,210 points
597 views
0 votes
1 answer
0 votes
1 answer

How to add a PTR record to my VM instance on gcp?

If your VM instance uses the primary ...READ MORE

answered Sep 26, 2019 in GCP by Sirajul
• 58,210 points
512 views