#!/bin/bash

# Check if /mnt/ramdisk is already mounted as tmpfs
if mount | grep -q "/mnt/ramdisk type tmpfs"; then
    echo "RAM disk is already mounted at /mnt/ramdisk"
else
    # Create directory if it doesn't exist
    if [ ! -d "/mnt/ramdisk" ]; then
        echo "Creating directory /mnt/ramdisk"
        sudo mkdir -p /mnt/ramdisk
    fi
    
    # Mount the tmpfs
    echo "Mounting 200GB RAM disk at /mnt/ramdisk"
    sudo mount -t tmpfs -o size=200G,mode=1777 tmpfs /mnt/ramdisk
    
    if [ $? -eq 0 ]; then
        echo "RAM disk successfully mounted"
        df -h /mnt/ramdisk
    else
        echo "Failed to mount RAM disk"
    fi
fi
