Copying files to large ramdisk

Using applications, configuring, problems
Message
Author
moonskin
Posts: 38
Joined: Sat 18 Oct 2008, 05:25
Location: Wollongong, Australia

#16 Post by moonskin »

gcmartin wrote:Question
  • Does the program that will use this folder expect something that looks like an HDD with a filesystem?
  • Or is it just looking for a folder with files?
  • And is the mount command simply a means of carving out a slice of RAM set aside permanently for Music which does NOT swap versus allowing the folder to be dynamic or mounted to backstore in SWAP when not in use? For example

    Code: Select all

    #mount the ramdisk
    mount -F tmpfs -o size=${SIZE}m SWAP "$MOUNTPOINT" 
Curious
It just needs a folder with files.

The Linuxsampler software loads its configuration from a text file which sets up all the channels and loads the paths of the .gig files for that instrument. Linuxsampler then pre-caches a part of each file. (My instrument will have 20 channels but some can get much larger.)

As the instrument is played, if the particular note that is needed is not already cached, it is streamed from the file on disk. This allows sample sets which are much larger than available RAM to be used. My advantage is that my files are under 2GB. Some sample sets are MUCH larger. It is this streaming time which can be sometimes problematic.

So there is never any writes to the files and they need to be available at all times. Having them in RAM means that the HDD would not be needed (apart from a small save file) after startup and copying. So the first part of you last point is what I need.

Cheers
GrahamW

gcmartin

#17 Post by gcmartin »

Hi @Moonskin

You might consider this: there is no need to configure a file system or to do a mount. All you need to is create your directory

Code: Select all

mkdir /tmp/ranks
and rsync your files into it. Then tell Linuxsampler software the /tmp/ranks pathname (which you have already done).

This will not tie up a chuck of RAM and samples will be "RAM available" when used. when you make the directory, "/tmp/ranks" is a RAM directory on Live/Frugal distros. It does NOT have to be mounted or a filesystem defined for it use. In fact, your setup script is now only 2 lines.

Also, if instead you created "/root/ranks", when you shutdown, your PUP distro will save to the DVD or to USB/HDD and you will NOT EVER have to rerun your script, except to add additional samples.

I think the 2 comands are everything you are wanting.

Here to help
P.S. THANKS for this thread. You given me an idea for a separate task I have a need for, while helping me on a KVM use, as well.

moonskin
Posts: 38
Joined: Sat 18 Oct 2008, 05:25
Location: Wollongong, Australia

#18 Post by moonskin »

gcmartin wrote:Hi @Moonskin

You might consider this: there is no need to configure a file system or to do a mount. All you need to is create your directory

Code: Select all

mkdir /tmp/ranks
and rsync your files into it. Then tell Linuxsampler software the /tmp/ranks pathname (which you have already done).
Now I understand. /tmp is already held in ram on a frugal install. Thanks for persevering with me :D That makes things easy.
Also, if instead you created "/root/ranks", when you shutdown, your PUP distro will save to the DVD or to USB/HDD and you will NOT EVER have to rerun your script, except to add additional samples.
Won't this mean the ranks are held in the save file which is not in ram? I was under the impression that any changes you make with a savefile active on a HDD, are read from, and written to, the disk directly and that only a flash drive has a save interval where things are moved in and out of cache.
Here to help
P.S. THANKS for this thread. You given me an idea for a separate task I have a need for, while helping me on a KVM use, as well.
Glad I could be of use. Everyone has given me great help here. THANKS

Regards
GrahamW

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#19 Post by mikeb »

If /tmp is a tmpfs (not universally adopted in pupland) make sure its big enough.

the df -h and mount commands in the terminal will tell you if its present and how large.... it could always be remounted larger if needed just for simplicity.

mike

gcmartin

#20 Post by gcmartin »

hello @Moonskin
Moonskin wrote:... Won't this mean the ranks are held in the save file which is not in ram? ...
No. Assuming you have enough RAM (and in your case you do), the save-session file(s) is ONLY read once at boot time for DVD and Frugal PUPs.

Enjoy your system. Assuming you save your samples in /root/ranks, Puppy will load your /root directoryat boot time including all of the files it saved in the save-session. The /tmp is a directory that Puppy save-session does NOT save at shutdown. This is why the recommendation is to save to /root your samples. Anything and everything you place in /tmp will NOT be saved for future use. /root is one of those directories that save-session does save the items you place there for future reloading.

Here to help

moonskin
Posts: 38
Joined: Sat 18 Oct 2008, 05:25
Location: Wollongong, Australia

#21 Post by moonskin »

Hi everyone.

Tried ranks in /root. Worse than on the HDD for some reason :cry: .

Used a cut down set of ranks that would fit into /tmp and that worked brilliantly. So that is the way I will go.

Did some searching and found that /tmp is set up in /etc/rc.d/rc.sysint from line 208

Code: Select all

##v2.20 some apps need shm (shared memory) (ex: xfdiff)... 100319 do this always...
FREERAM=`free | grep -o 'Mem: .*' | tr -s ' ' | cut -f 4 -d ' '` #w481 110405
QTRFREERAM=`expr $FREERAM \/ 4`
mkdir -p /dev/shm #120503 if kernel mounts a f.s. on /dev, removes my skeleton /dev
mount -t tmpfs -o size=${QTRFREERAM}k shmfs /dev/shm ;STATUS=$((STATUS+$?))

if [ ! -d /initrd ];then
 #130630 restore tmpfs on /tmp...
 #120717 this is not so good on raspi with only 256MB RAM, but saves flash writes and faster...
 mount -t tmpfs -o size=${QTRFREERAM}k tmpfs /tmp ;STATUS=$((STATUS+$?))
Seems all I would need to do is to replace QTRFREERAM in line 217 with the amount I need.

Cheers
Graham

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#22 Post by MochiMoppel »

gcmartin wrote: /root is one of those directories that save-session does save the items you place there for future reloading.
Well, just for the record: There are a few exceptions. A /root/tmp directory will also not be saved.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#23 Post by mikeb »

well /root is in the filesystem of puppy and therefore would end up in the save file on disk....no gain there...I assumed it was suggested for storage rather than use.

by the way this is how you resize tmpfs on the fly

Code: Select all

mount -t tmpfs -o remount,size=500m tmpfs /path/to/folder
adjust to suit.

mike

moonskin
Posts: 38
Joined: Sat 18 Oct 2008, 05:25
Location: Wollongong, Australia

#24 Post by moonskin »

Thanks Mike

That will save me customising rc.sysinit which I don't like doing.

Cheers
Graham

gcmartin

#25 Post by gcmartin »

WOW!!! What started as complex problem turns out to be a simple 1 liner in Puppy because all the needed components are already present.

"@MikeB scores a winning goal."

moonskin
Posts: 38
Joined: Sat 18 Oct 2008, 05:25
Location: Wollongong, Australia

#26 Post by moonskin »

Thanks for all the help. Here is the next iteration of my script. I'm just waiting to get some extra RAM for the organ computer so I can test this fully.

Cheers
Graham

Code: Select all

#!/bin/sh

#MOUNTPOINT="/tmp/ranks"
# Find the size of the "ranks" folder
SIZE=$(du -mcs /mnt/home/ranks | grep -w "total" | awk '{print $1}')


# check for free memory
FREERAM="$(free -mt | grep Mem | awk '{print $4}')"

Calculate how much I can afford to use - trying two thirds as a starting point
PARTFREERAM=`expr $FREERAM \/3 \*2`

if (("$PARTFREERAM" < "$SIZE")); then

	#let the user know there is not enough
	Xdialog --title "Ranks" --ok-label "OK" --msgbox "Sorry!\n\nThere was not enough Free Memory\n to load the samples\nThey will be streamed from disk." 0 0

	# create symlink in /tmp to point to the "ranks" folder
	ln -s /mnt/home/ranks /tmp/ranks
	
else

#find out how  much /tmp is using
TMPUSED=$(df /tmp | grep -w "tmpfs" | awk '{print $3}')
#Calculate the new /tmp size adding already used space to what "ranks" needs plus a little extra
NEWTMPSIZE=`expr $TMPUSED \+ $SIZE \+ 100`
#resize  /tmp
mount -t tmpfs -o remount,size=${NEWTMPSIZE}m tmpfs /tmp

#make the "ranks" directory in /tmp
mkdir -p /tmp/ranks

#Open a Terminal so that rsync can show its progress & copy the files
Terminal -e "rsync -av --progress /mnt/home/ranks/ /tmp/ranks/"
fi

Post Reply