Jump to content
XPEnology Community

Tutorial: RAMDISK in DSM


smileyworld

Recommended Posts

@amikot was asking me how to implement a RAMDISK in DSM and I found this guide. So many thanks to mark and as usual I don't accept any liability for any data loss or damage caused by using this tutorial(s).

 

I wrote a little script which adapts to your environment and asks if you would like to

  • specify the amount of RAM in percent or GB
  • the amount of RAM which should be used for the Ramdisk
  • an existing folder where your RAMDISK should be created. E.g. /volume1/ramdisk

 

You have to save the following lines as "create_ramdisk.sh" run it, answer the questions and add two tasks (which is demonstrated in the gif) to the task scheduler:

 

#!/bin/bash
echo Do you want to specify the amount of RAM, which should be used for the RAMDISK, in percent or in GB?
read ram_unit

if [ $ram_unit = 'percent' ]; then
echo Please type in the amount of RAM which should be used. E.g. 2 for 2GB or 2 percent depending on your former choice
read ram_amount

elif [ $ram_unit = 'GB' ]; then
read ram_amount

else
echo "Please enter percent or GB"
read ram_unit
echo Please type in the amount of RAM which should be used. E.g. 2 for 2GB or 2 percent depending on your former choice
read ram_amount
fi

echo Please type in an existing folder where your RAMDISK should be created. E.g. /volume1/ramdisk
read path

mkdir $path/ramdisk
mkdir $path/ramdisk-local

if [ $ram_unit = 'percent' ]; then

echo "#!/bin/sh
mount -t tmpfs -o size="$ram_amount"% ramdisk $path/ramdisk
sleep 1
rsync -ahW --no-compress  $path/ramdisk-local/  $path">| $path/mount-ramdisk.sh

else

echo "#!/bin/sh
mount -t tmpfs -o size="$ram_amount"G ramdisk $path/ramdisk
sleep 1
rsync -ahW --no-compress  $path/ramdisk-local/  $path">| $path/mount-ramdisk.sh

fi

echo "#!/bin/sh
rsync -ahW --no-compress --delete $path/ramdisk/ $path/ramdisk-local/">| $path/sync-ramdisk.sh

 

  • one for mounting the ramdisk when booting your NAS
  • the second is a rsync job to copy the files from the ramdisk to a ssd/hdd

 

ramdisk.thumb.gif.d79639ed828f9ce4a96f3f273f70af38.gif

 

 

here is the command for listing your ramdisk after creating and mounting it

df | grep "ramdisk"

image.thumb.png.49fd8e59fbf9454730a030a4b4df16ec.png

 

 

here is the command for testing speed but keep in mind to adapt your path and RAM amount to your environment

sudo dd if=/dev/zero of=/volume1/ramdisk/ramdisk/test1.img bs=30G count=1 oflag=dsync

 

ramdisk_speed.thumb.png.36072d9b8d70c6df54a8d5318afe811a.png

For anyone wondering:

ramdisk refers to the content which is temporarily saved in your ram

ramdisk-local is the copied content from the ramdisk to your hdd/ssd

 

Unmounting the ramdisk is possible via rebooting your NAS or running this command:

umount ramdisk

 

Edited by smileyworld
extending
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...