simple GUI ramdisk script

Filemanagers, partitioning tools, etc.
Post Reply
Message
Author
User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

simple GUI ramdisk script

#1 Post by Pizzasgood »

This is just a simple little GUI program for creating a ramdisk. Somebody requested that I throw one together, so here it is. I didn't bother making a .pet package or a menu or desktop icon for it. It's just a gzipped script.

Usage:
  • 1) Click it.
    2) Input the size of the ramdisk you want, then press "Okay".
    3) It mounts the ramdisk and opens a window inside it, as well as a dialog with an "Unmount" button.
    *** This is when you do whatever you want to do inside the ramdisk
    4) When finished, click the "Unmount" button on the dialog it popped up, and it will be umounted. All data within it will go *poof*.
If you don't want the unmount dialog to hang around, click the 'x' on the title bar to close it. If you do this you'll have to manually unmount the ramdisk when you're finished. This is done by either moving up a notch in ROX-Filer and having ROX-Filer umount it (via right-click option), or by using the following command:

Code: Select all

umount /mnt/ramdisk
Of course, you could just leave the ramdisk there and not unmount it, but it will use however much ram it's using until you either unmount it, delete everything inside it, or reboot. (Note that tmpfs is smart enough to not just allocate the ram you give it immediately. The size you set is used as the upper limit, but it only allocates as much ram as it needs at any given point. So, even if you create a 1gb ramdisk, if there is only 10mb of stuff in it, only about 10mb of ram will be used.)
Attachments
ramdisk_gui.gz
gui for making ramdisks
(551 Bytes) Downloaded 1506 times
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
Q5sys
Posts: 1105
Joined: Thu 11 Dec 2008, 19:49
Contact:

#2 Post by Q5sys »

sweet thanks for this!

User avatar
puppyluvr
Posts: 3470
Joined: Sun 06 Jan 2008, 23:14
Location: Chickasha Oklahoma
Contact:

#3 Post by puppyluvr »

:D Helo,
Just had to change permissions to run it....
Cool idea...
Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!

Puppy since 2.15CE...

User avatar
Q5sys
Posts: 1105
Joined: Thu 11 Dec 2008, 19:49
Contact:

#4 Post by Q5sys »

EDIT: This does not apply to slacko533

For all those wanting to use this on a frugal install... you need to change line 4 of the script from

Code: Select all

MOUNTPOINT="/mnt/ramdisk"
to

Code: Select all

MOUNTPOINT="/tmp/ramdisk"
to explain why... I'll copy/paste part of the IRC convo here:
http://puppy-linux.org/screenshot.png


<q5sys> now let me explain.
<q5sys> I have a 1.4gb safe file on this system. I have 16gb ram. I run VMs all the time. and I do so completely from ram. so I'll create a ramdisk and load a 4 to 8gb VM file into it and then run it from there. I do delete it before shutdown
<q5sys> but it still has to sit in memory so I can use it
<q5sys> http://puppy-linux.org/screenshot.png
<q5sys> thats using the script pizza posted with ramdisks saved in /mnt
<q5sys> and LOOK. the graphical map of the safe file shows /mnt/ramdisk sitting in there
<q5sys> I tried to copy /mnt/home over to my ramdisk just to fill it uo
<q5sys> I made a 4gb ramdisk and tried to copy 1900mb of files into it
<q5sys> but as you can see from the rox window with /mnt/ramdisk in it... only 438mb copied
mama21mama 0/
<q5sys> why? becuase that was all the freespace I had left in /initrd/pup_rw.
<q5sys> now yes I'll delete that ramdisk before i shut down...
<q5sys> but while Im using my system.... my /initrd/pup_rw is filled and cant accept anymore data. which means that at least while Im currently using my system... my savefile is full (until I delete the ramdisk)
<q5sys> like I've said about 4 times now... on a frugral install changes to /mnt are saved to /initrd/pup_rw
<slue_gniffer> how much ram do you have?
<q5sys> /initrd /pup_rw is the contents of your save file that have been changed since last boot.
<q5sys> slue_gniffer: I have 16gb ram
<tlc> WHy The F would anyone use such a huge save file?
<tlc> er ram disk
Rupp shrugs
tlc SO did Atlas
<q5sys> tlc... to run a VM completely from RAM
<tlc> Why would you do that?
<q5sys> so its not having to read the hard disk to run.
<q5sys> it makes it faster.
<bignono1> wb Brown_Mouse
<q5sys> I've got the ram... I might as well use it for something useful
<q5sys> puppy will never use that much on its own. lol

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#5 Post by Smithy »

Made a little ramdisk pet from info.
The Puppy Ram system is a bit of a mystery and personally hate going in /tmp, it's always full of junk and stuff.

Edit sfs was always running out of ram in its operation and frequently ommited to offer the partition option. I assumed it was lack of system ram. Wrong!
This one is solid and in combination with Uxtract and Packit, does the job nicely.
Attachments
Ramdisk.pet
(3.11 KiB) Downloaded 600 times

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#6 Post by SFR »

Hey Smithy

RE: UExtract

I just stumbled across your post and tested a case when there's not enough available space to extract an SFS.
It turned out that unsquashfs (used by UExtract) exits with code 0 (i.e. "All is OK"), even if there was insufficient free space available and some files weren't extracted, so, in effect, UExtract also reports successful extraction.
I've applied a workaround - if there's 0 free bytes on a destination device after extraction, an error is automatically assumed.

If the ramdisk wasn't big enough then there's a chance you've experienced this flaw, so it would be safer if you upgrade to v3.9.

Thanks &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#7 Post by Smithy »

Thanks for the heads up on that SFR, I will upgrade it to that version.
Certainly is a good visual app that lets you know what it is doing.

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#8 Post by Smithy »

Hmm, this ramdisk is now broken in newer puppies.

For example I make a 3500mb ramdisk, UExtract something into it and the puppy ram just gets sucked out and puppy crashes with no ram left.

This doesn't happen in Dpup. It will squash up again with no problem (4gb ram)
Is the initrd/mount area not a viable spot for ramdisks now?

If someone could point to a suitable place now where it doesn't suck up and crash the puppy that would be good. Tried temp/ tempfs, same problem.
Just sucking up that ram.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#9 Post by musher0 »

Smithy wrote:Hmm, this ramdisk is now broken in newer puppies.

For example I make a 3500mb ramdisk, UExtract something into it and the puppy ram just gets sucked out and puppy crashes with no ram left.

This doesn't happen in Dpup. It will squash up again with no problem (4gb ram)
Is the initrd/mount area not a viable spot for ramdisks now?

If someone could point to a suitable place now where it doesn't suck up and crash the puppy that would be good. Tried temp/ tempfs, same problem.
Just sucking up that ram.
Hi Smithy.

Do you mean the old DPup-4.82 or the new DpupStretch-7? TIA.

Have you tried to see what's wrong with the script?

BFN.

~~~~~~~~~~~~~
Edit, 15 min. later.

I tried Pizza'sGood original script (2011) and it works fine on this
DpupStretch-7fr (2017).

I was able to
-- create a 1G ramdisk
-- unpack a MynotEX deb archive to it with SFR's UExtract, and
-- read its PDF doc from it.
-- PG's ramdisk script also sustained a refresh ram action like this:

Code: Select all

sync ; echo 3 > /proc/sys/vm/drop_caches;wait 
So everything is fine here with PG's original script.
I can't see where your problem is, sorry.

Please see summary in attached pic. Sorry for the head tilting, but otherwise
the info would have been unreadable.

BFN.
Attachments
PGs-ramdisk-OK.jpg
(212.96 KiB) Downloaded 703 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#10 Post by musher0 »

Anyway, thanks for bringing PG's script back to the surface, Smithy.

I'll keep trying it for a couple of days, and if it continues behaving ok, I'll leave
it in my /root/Startup sequence.

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#11 Post by musher0 »

Hello again, people.

Since we're going to symlink this script in /root/Startup, we need to check
if the ramdisk already exists and do nothing if it exists when we recycle X.

This is what I am proposing:

Code: Select all

#!/bin/sh
#This is a simple GUI to mount a ramdisk on $MOUNTPOINT.
#
# by Pizza'sGood, 27 Dec. 2011.
# Source : http://murga-linux.com/puppy/viewtopic.php?p=592060&sort=lastpost#592060
# Downloaded and edited Oct. 14 2017 by musher0.
####
ChecK="`df | awk '$NF ~ /ramdisk/'`" # musher0, 17-10-14
if [ "$ChecK" = "" ];then # musher0, 17-10-14

	MOUNTPOINT="/mnt/ramdisk"

#Prompt the user for a size
	SIZE="$(Xdialog --title "Ramdisk" --spinbox "How many megabytes do you\nwant the ramdisk to use?" 0 0 1 2147483647 200 MB 2>&1)"
	if [ $? -ne 0 ]; then
		Xdialog --title "Ramdisk" --infobox "Aborted" 0 0 5000
		echo "Aborted";exit
	fi

#make sure the mountpoint exists
	mkdir -p "$MOUNTPOINT"
#mount the ramdisk
	mount -t tmpfs -o size=${SIZE}m tmpfs "$MOUNTPOINT"
#pop open a window to the ramdisk
	which rox >/dev/null 2>&1 && rox "$MOUNTPOINT"

#Let the user know where it was mounted, and wait for him/her to tell us to unmount it.
	Xdialog --title "Ramdisk" --ok-label "Unmount" --msgbox "The $SIZE MB ramdisk has been created and mounted on\n$MOUNTPOINT\n\nWhen finished, click 'Unmount' to unmount it,\nor 'x' out of this window and do it manually." 0 0

	if [ $? -eq 0 ]; then
#close any windows open to the ramdisk
		which rox >/dev/null 2>&1 && rox -D "$MOUNTPOINT"
#unmount the ramdisk
		umount "$MOUNTPOINT"
	fi

else # This section by musher0, 17-10-14

	Xdialog --title "Exists" --ok-label "Exit" --msgbox "A ramdisk already exists." 0 0

fi # End of section by musher0, 17-10-14
##########
# Add-ins by musher0
# Various one-liners to do checks on this ramdisk.
# 1a) # echo -e "Location\tUsed\tAvail.\t%\tName";df -h | awk '$NF ~ /ramdisk/ { print $1"\t\t"$3"\t"$4"\t"$5"\t"$6}'
# OR
# 1b) echo;df | head -1;df | grep ramdisk
# The above lines will tell you the size and occupancy.
#
##
# 2) df | head -1;df | grep ram
#
# 3) df | awk '$2=="1024000" && $NF ~ /ramdisk/'
# These two just tell you if there is a "ramdisk".
####
Please test. TIA.

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#12 Post by Smithy »

Hello Musher,
Could you try a 3500mb ramdisk if you have 4gb ram and then try extracting something substantial to the init/mount ramdisk made by the script?

Possibly the puppy stretch sfs ? Then tell me what happens with the ram indicator
on the taskbar.

BTW I don't think I monkeyed around with pizza'sgoods script, just added it as a pet with a desktop icon so it was easy to use. Much praise, it was he who made Retrovol.
Last edited by Smithy on Sun 15 Oct 2017, 13:12, edited 1 time in total.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#13 Post by musher0 »

Hi Smithy.

Yeah, Pizza'sGood was an outstanding dev, I wonder why he's not around
anymore. I hope everything's ok with him.

~~~~~~~~~~~~~~
About your test, I wish I could do it but I cannot, sorry.

I cannot create a 3.5 Gb on my rig because...
-- my kernel is a non-PAE kernel, and maximum RAM available with a non-
PAE kernel is 2.85 Gb's (maybe 2,9 Gb)
-- although I do have 4 Gb's of RAM, technically on this computer
~~~~~~~~~~~~~~

That said, I upped the size of the ramdisk to 1.5 Gb. Then I copied the
Chromium and aOO-4 sfs's to it and unpacked them with SFR's UExtract.
Successfully!!! :) (Please see pic.)

IHTH.
~~~~~~~~~~~~~~

Finally, here's a companion script to PG's ramdisk_gui. This little script will
show you the occupancy of the ramdisk.

Code: Select all

#!/bin/sh
# ramdisk_check.sh # Companion script to Pizza'sGood ramdisk_gui script.
#
# Requires the real less utility by Greenwood software.
# The busybox less won't cut it.
#
# Oct. 14 2017, musher0.
####
echo -e ".
`df | head -1`
\e[33m`df | grep ramdisk`\e[0m
." > /tmp/ramdisk_check

# variables
FONT="fn xft:LiberationMono:pixelsize=15:autohint=true:antialias=true"
FadE="fade 70 -fadecolor "#94A495""
COLR="bg sienna4 -fg cornsilk -bd firebrick4 -b 4 -cr white"
########### couleurs ############## bordure  ##### curseur #
TRNSP="tr -tint snow -sh 42"
###########  transparence
# couleurs avec effets de transparence
Title="                     Ramdisk_Check                          "
Geom="g 65x5-250-250"

rxvt -$FONT -$COLR -$TRNSP -$Geom -T "$Title" -$FadE +sb -sr +st +tcw -bc -e less -~ -R -P "$Title" /tmp/ramdisk_check
I hope it's useful to someone.

BFN.
Attachments
Test-for-Smithy.jpg
After copying and unsquashing chromium and apache OpenOffice sfs's
(80.52 KiB) Downloaded 660 times
CompanionScript.jpg
Previously
(44.39 KiB) Downloaded 658 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#14 Post by Smithy »

Hi musher,

You can make the ramdisk whatever size you like, that just sets the upper limit.
It doesn't actually use anything until you put stuff in it.
And I always believed it is kind of outside the puppy file system.

I'm just wondering if it is the pae kernels that are having trouble with this ramdisk.

I am using dpup wheezy but with a pupjibaro wheezy kernel.
I have no idea if that is pae or not, but it works fine.
And I know that it works fine with the original 3.5.2. kernel (non-pae).

And you are using a non pae and I'll bet that extra 1gb is happily available to the ramdisk.
Anyways when you did the transfer, what was the indicator on the ram?
Had it gone down a bit?
When I do a 2.5gb or so ramdisk and transfer a big 1600mb (extracted) sfs the actual ram indicator still says 1.9G tmpfs, free space =1.9G.
The ramdisk is evidently living in its own ram space and not fck** up the pup ram.

Maybe it's time to edit the fstab/shm initrc or something and just force the puppy to use all the memory when it boots, not just the conservative half..
How to do that though?

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#15 Post by musher0 »

Smithy wrote:Hi musher,

You can make the ramdisk whatever size you like, that just sets the upper limit.
It doesn't actually use anything until you put stuff in it.
And I always believed it is kind of outside the puppy file system.

I'm just wondering if it is the pae kernels that are having trouble with this ramdisk.

I am using dpup wheezy but with a pupjibaro wheezy kernel.
I have no idea if that is pae or not, but it works fine.
And I know that it works fine with the original 3.5.2. kernel (non-pae).

And you are using a non pae and I'll bet that extra 1gb is happily available to the ramdisk.
Anyways when you did the transfer, what was the indicator on the ram?
Had it gone down a bit?
When I do a 2.5gb or so ramdisk and transfer a big 1600mb (extracted) sfs the actual ram indicator still says 1.9G tmpfs, free space =1.9G.
The ramdisk is evidently living in its own ram space and not fck** up the pup ram.

Maybe it's time to edit the fstab/shm initrc or something and just force the puppy to use all the memory when it boots, not just the conservative half..
How to do that though?
Hi Smithy.

I don't think I know Linux enough to answer all your questions.

About the indicator on the RAM: this is what I get with the < free > utility:
[~]>free -m
---- total used free shared buffers
Mem: 2907 709 2198 0 18
-/+ buffers: 690 2217
(in Mg's), after creation of a 1.45 Gb ramdisk.
If I right-click on /mnt/ramdisk, and then click on "properties", it says that
the ramdisk total size is 1,45Gb.

It would be nice to have the ramdisk outside the RAM Puppy uses, but It
can't because the Puppy Linux non-PAE kernel controls 2.9 Gb's maximum.
Yes there is 1.1 Gb of RAM left if your rig has 4 Gb's RAM in total but that
1.1 Gb is out of reach for the non-PAE kernel.

Only with a PAE kernel can you use the full 4 Gb's of RAM (or more).

You can see the "occupancy" on the ramdisk after the transfer and unpack
operations in the smaller picture above. Yes it had gone down.

~~~~~~~~~~
About registering the ramdisk in fstab, I wish I could help you, but I simply
don't know if one can register a ramdisk in fstab. More info is required,
I think.

IHTH.

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#16 Post by musher0 »

Hello all.

There is now an off-shoot of this thread here.

Thanks to Smithy and Pizza's_Good for the inspiration.

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#17 Post by Smithy »

I've updated the simple ramdisk pet.
This one now works in newer puppies like Stretch.
Thanks Musher, looking at your new ones I could work out what was going wrong!
Attachments
RamdiskV2.pet
(2.97 KiB) Downloaded 270 times
image-1.png
(34.06 KiB) Downloaded 200 times

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#18 Post by musher0 »

My pleasure! :)
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply