I would like to have a folder mounted as temporary, which is actually my RAM. This is so that, for example, I could copy a movie into my RAM, unplug my external drive, and then watch it. Can this be done? Thank you :)
1 Answer
Yes, it is possible. Follow this procedure.
To make the folder you want to mount the ram disk to:
mkdir /mnt/ramdisk
Execute the following line to create a ram disk. The size can be whatever you like as long as it fits into your available memory.
mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
If you want this to be permanent do the following steps:
Open this file in nano or in whatever your preferred editor is.
nano /etc/fstab
Add the following line to that file and save the file.
tmpfs /mnt/ramdisk tmpfs nodev,nosuid,noexec,nodiratime,size=1024M 0 0
This line is supposed to be one uninterrupted line. Again size can be whatever you see fit.
Now reboot and you will have a ram disk.
-
-
Yes, that's entirely possible. Just change the'/mnt/ramdisk' part to /tmp and change size to an appropriate value. Note that if you run out of space, problems may happen. If you've lots of memory you can leave out the size parameter and it will be set to the default value.– wie5OomaMar 22, 2015 at 23:29
-
Thank you so much :) Very quick question - how can I add that line on the end in bash? I have a script I use to move back onto machines, and I would like this to be automatic c:– PatrickMar 23, 2015 at 8:32
-
I've never tried this idea. You can try to put the line starting with mount, mentioned above, in a script and call that script in the file /etc/rc.local but using the etc/fstab file is the usual method.– wie5OomaMar 23, 2015 at 19:29
-
I was thinking I could just have a line such as
echo "tmpfs /mnt/ramdisk tmpfs nodev,nosuid,noexec,nodiratime,size=1024M 0 0" > /etc/fstab
but I wasn't sure if this was a safe method (or even if I used the correct operator...)– PatrickMar 24, 2015 at 9:15