Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Setting up a ram disk to speed things up
New Posts  All Forums:Forum Nav:

Setting up a ram disk to speed things up

post #1 of 57
Thread Starter 
Ok, so repeatedly rookie has mentioned the ramdisk he has on his spare ram. I don't know who else has this, but it got me thinking. My ram use never tops 1.5gbs under normal use, 3gb when vming. I was thinking making a 4-5gb ram disk out of the leftover ram and using it to store things. /tmp, I guess is a good one. I can set up programs to load in the ram disk correct? How would I go about setting it all up? This will be my first time dealig with ram disks so stay with me smile.gif
post #2 of 57
just add an entry in your fstab with tmpfs as the file system.

Remember though: RAM disk is volatile. So don't go crazy and assign your home directory unless you have some kind of background syncing daemon to a HDD
post #3 of 57
Thread Starter 
Quote:
Originally Posted by Plan9 View Post

just add an entry in your fstab with tmpfs as the file system.

Remember though: RAM disk is volatile. So don't go crazy and assign your home directory unless you have some kind of background syncing daemon to a HDD

I was hoping I would just assign a couple of programs to it. so should I find the mount points of said programs? and tell it to mount them there? how exactly does that work? heres my fstab
Code:

#
# /etc/fstab
# Created by anaconda on Thu Sep 13 20:27:09 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=f51263ad-939a-4b92-ac52-3d45cd5b8dd4 /                       ext4    defaults        1 1
UUID=956d8229-7da1-4b7d-805e-346b6ac340d2 /boot                   ext4    defaults        1 2
UUID=B11D-BCA7          /boot/efi               vfat    umask=0077,shortname=winnt 0 0
UUID=f8ecdd77-84dd-48c0-8562-3640384c2288 /home                   ext4    defaults        1 2
UUID=04730f27-e199-4e99-b7db-c6110ef64b4b swap                    swap    defaults        0 0


basically I'd like to have the tmp files, firefox, openoffice and nautilus use the ramdisk. setting it in the fstab should mount the disk on boot yes? the size I'm going for is 4gb. so, would it be something like this:
Code:
tmpfs   {where the disk is mounted}  tmpfs  size=4092mb       0 0

what would I set for the dump/pass? and will I need to have different ramdisks for each thing to mount? and if I say mount /example in the tmpfs will all stuff on the part of the disk that is /example be loaded onto the tmpfs so that if I need to access it it comes first off the ramdisk?
post #4 of 57
Hey don't make me sound like I know what I'm talking about on this subject. biggrin.gif
Seriously, in Linux this is a pain and a half and I have no idea if what I'm doing is right. Especially since my goal is to have copies of everything my programs need to access in RAM all the time. The more I read the more I'm finding out this is not possible considering the fundamental difference Linux has to Windows in this regard. IF I even grasp it correctly; in windows the exe and the libs are all in the same place and so you can just move them/install to a RAMdisk no problem. In Linux it seems everything is all over the place with symlinks keeping the harmony/connections. Someone please correct me if I'm wrong because this is an area that is making my head spin.

Basically, I've got two scripts setup right now for two different methods to try and speed things up. One doesn't sound like it should work which is symlinking (though it seems to) and the other is rsyncing certain folders that I think the programs read and write to when in use and sending them to RAM locations. Either way, I don't have a clue which one actually does anything and how to test the speed improvements. If you want I can post the scripts for you to modify and try out but don't blame me if things go crunch bang(not that they have on my computer but that might just be because they don't do anything). redface.gif
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
post #5 of 57
Thread Starter 
sure. that would be great. where should I then mount it? what should I put in fstab? or could I just create multiple ramdisks mounted to the branches I need and list them in fstab?

one of my biggest question is this: if /example on hdd has files on it, will the files be there if I put a ramfs or tmpfs on /example?
post #6 of 57
Using tmpfs is the correct route to go. You can symlink your /tmp directory and any other directories you wish to the tmpfs on boot. From there, if you need to move any applications and such to tmpfs you can write a script to do so, there are some large implementations that have been done, where people copy all of /opt, /sys etc to the tmpfs and chroot into the ramdisk install, its pretty impressive.

So I just looked into this a little more since its been a long time since I did it.
Read this wiki entry on archwiki:
https://wiki.archlinux.org/index.php/Ramdisk
It seems the proper filesystem is ramfs, and because of the nature of ramdisks you can make a /tmp partition that is ramfs. Also suggested is moving the package manager cache to ramfs and other potentially disk-bottlenecked directories. Anyways, that wiki is a good starting point.
Edited by Xaero252 - 9/23/12 at 7:08pm
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
post #7 of 57
@Xaero: Can you tell me whether this would do anything?
Code:
#!/bin/bash
#Chmod +x first. This script will create symlinks of programs and place them in tmpfs-
#the goal is to make those programs more responsive/faster once opened.

cd /run/shm #or your tmpfs location as given from df -h
ln -s /opt/google/chrome/google-chrome chrome
#ln -s /usr/bin/audacious audacious
#ln -s /usr/bin/libreoffice libreoffice
#ln -s /usr/bin/dolphin dolphin
#ln -s /usr/bin/xbmc xbmc
#ln -s /usr/bin/pidgin pidgin
#ln -s /usr/bin/vlc vlc
#ln -s /usr/bin/amarok amarok
#ln -s /usr/bin/ark ark
#ln -s /usr/bin/ktorrent ktorrent
#ln -s /usr/bin/skype skype
#ln -s /usr/bin/mumble mumble
#ln -s /usr/bin/bleachbit bleachbit

ln -s /usr/bin/ bin
ln -s /home/rez/.cache/ cache
ln -s /usr/share/ share
ln -s /tmp/ tmp 


ls /run/shm/

I commented out the other directories because I thought they were redundant but I'm not sure I got all of them in the symlinking method. And the thing is everything I've read is that symlinking didn't do anything!? So...did I get everything/will this help or is that whole script pointless.

@Jrl1357: If you want that's the symlinking script example I have. I'll give the rsync one later if you want to try it as well but again still don't know if it did anything.
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
post #8 of 57
Thread Starter 
so, following the arch wiki I should add this
Code:
none        /tmp         ramfs   defaults              0 0
none        /mnt/ramdisk ramfs   defaults              0 0

to /etc/fstab, this
Code:
chmod 777 /tmp
touch /etc/ramdisk.sh

/bin/cat - >> /etc/ramdisk.sh << EOT
#!/bin/sh

{no idea, please fill me in}

/bin/mkdir /mnt/ramdisk/var/
/bin/mkdir /mnt/ramdisk/var/cache/
/bin/mkdir /mnt/ramdisk/var/lib/

{directories to cache} 

/bin/ln -s /tmp /mnt/ramdisk/tmp
/bin/chmod 777 /mnt/ramdisk/tmp
EOT

/etc/ramdisk.sh &

to /etc/rc.local

and this:
Code:
echo "Saving contents of ramdisk to harddrive"
rm { cached files}
rm
rm 
mv 
mv 
mv

to /etc/rc.local.shutdown?
post #9 of 57
My question is why go through doing all of that if you're just symlinking everything to a tmpfs? Why not use the one you already have? Or does whatever distro you're using not have a tmpfs already?
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
     
CPUGraphicsRAMHard Drive
Intel Core m3-6Y30 Intel HD515 8GB 1866DDR3L Micron M600 MTFDDAV256MBF M.2, 256 GB 
CoolingOSOSMonitor
Fanless Win10 Home x64 Kubuntu 16.04 (requires Linux kernel 4.5/4.6) 13.3 inch 16:9, 1920x1080 pixel, AU Optronics A... 
CPUMotherboardGraphicsRAM
AthlonIIX4 640 3.62GHz (250x14.5) 2.5GHz NB Asus M4A785TD-M EVO MSI GTX275 (Stock 666) 8GBs of GSkill 1600 
RAMHard DriveHard DriveHard Drive
4GBs of Adata 1333 Kingston HyperX 3k 120GB WD Caviar Black 500GB Hitachi Deskstar 1TB 
Optical DriveCoolingOSOS
LG 8X BDR (WHL08S20) Cooler Master Hyper 212+ Kubuntu x64 Windows 7 x64 
OSMonitorPowerCase
Bodhi Linux x64 Acer G215H (1920x1080) Seasonic 520 HAF912 
CPUMotherboardGraphicsRAM
N450 1.8GHz AC and 1.66GHz batt ASUS proprietary for 1001P GMA3150 (can play bluray now!?) 1GB DDR2 
Hard DriveOptical DriveOSOS
160GB LGLHDLBDRE32X Bodhi Linux Fedora LXDE 
OSOSMonitorKeyboard
Kubuntu SLAX 1280x600 + Dell 15inch Excellent! 
PowerCase
6 cells=6-12hrs and a charger 1001P MU17 Black 
  hide details  
Reply
post #10 of 57
To answer the question - Symlinking is just like creating a shortcut in Windows, in other words, it won't do anything, its going to place a pointer in your Ramdisk pointing to the binary file on your hard drive.
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Setting up a ram disk to speed things up