Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 13 Dec 2018, 23:20
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Filesystem
Four scripts to create, fill, check and back-up /mnt/ram1
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
musher0

Joined: 04 Jan 2009
Posts: 13162
Location: Gatineau (Qc), Canada

PostPosted: Sun 15 Oct 2017, 20:25    Post subject:  Four scripts to create, fill, check and back-up /mnt/ram1
Subject description: Ramdisk creator, filler, back-up and checker
 

On trouvera la version française de ce fil ici.
~~~~~~~~~~~~~~
Hello all.

Nothing beats a ramdisk for speedy copy and save operations, even in this
age of fast hard disks and USB drives.

As the name of the archive suggests, the creation script takes 2/3 of your
free RAM and creates a ramdisk out of it. "2/3 of free RAM" means that
your apps should still have lots of room to run after /mnt/ram1 is created.

Edit 11 Dec. 2018 --
Actually this has been reduced to 11/20ths, to avoid any snafus. Please
use the main script below. Do download this package, but please replace
the RAMdisk creating script with the one below.
Thanks.
-- End of edit


It is strongly recommended that YOU DO NOT USE THESE SCRIPTS
if you have less than 3 Gb's of RAM on your machine.
Use
Pizza'sGood original script instead (URL below). Are we clear about this?

The attached pet archive includes 4 ramdisk bash scripts to
create,
fill,
check and
back-up /mnt/ram1.

The creation and filling at boot-up, and the back-up at shutdown are
automatic. The checking is up to you (but you don't normally need to).

The back-up script is located in /etc/init.d. It uses a shut-down technique
developed by BarryK, as I understand it. It copies (aka back-up) the
contents of an active ramdisk at /mnt/ram1 to /mnt/home/ramdisk.

Conversely, at boot-up, if there is some content in /mnt/home/ramdisk,
the zzz-ramdisk script in /root/Startup creates /mnt/ram1 and copies that
content there.

The Start-up filler script checks the size of the contents vs the capacity of
the ramdisk. If the contents' overall size is too big to fit on the ramdisk,
nothing is copied. In such a case you will have to choose what to copy to
your ramdisk manually. But normally you don't have to do this.

Reserve directory /mnt/home/ramdisk only to the shuttle with /mnt/ram1.
Don't put anything else in it.


Basically, I made it to run so that you, the user, don't have to worry
about it. The ramdisk's content is saved at boot-down and re-copied at
boot-up.

If for some reason, you need to recycle X or your window manager, it
just displays a 5-seconds message that the ramdisk is there; it doesn't
reformat or destroy anything in an existing ramdisk during your session.

Please note that hard shut-downs are not protected, meaning: if you
ever need to do an emergency shut-down with your computer's reset
button, your ramdisk contents will be lost.


But with regular power-offs and re-boots, you should find the contents of
your ramdisk in /mnt/ram1 from one session to the next.

Inspired by Pizza's Good original script and a discussion with Smithy
on that thread. Thanks to both of them.

I tested it extensively, and I decided to make it a permanent feature of
my current and future Pups -- because it's so handy. But please test it too
and get back to me if it needs improvements. I'll try to accommodate.

Enjoy.
~~~~~~~~~~
PS. The tree of the pet archive is as follows:
Quote:
[4.0K] ./etc
[4.0K] ./etc/init.d
[ 431] ./etc/init.d/stop_ramdisk-0.1
[4.0K] ./opt
[4.0K] ./opt/local
[4.0K] ./opt/local/bin
[1.6K] ./opt/local/bin/ramdisk_2thirds.sh
[ 834] ./opt/local/bin/ramdisk_check.sh
[ 610] ./opt/local/bin/ramdisk_cp.sh
[ 158] ./pet.specs
[4.0K] ./root
[4.0K] ./root/Startup
[ 33] ./root/Startup/zzz_ramdisk.sh -> /opt/local/bin/ramdisk_2thirds.sh
7 directories, 6 files
RamDisk_2thirds-0.1.pet
Description 
pet

 Download 
Filename  RamDisk_2thirds-0.1.pet 
Filesize  2.9 KB 
Downloaded  112 Time(s) 

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)

Last edited by musher0 on Tue 11 Dec 2018, 17:56; edited 1 time in total
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13162
Location: Gatineau (Qc), Canada

PostPosted: Mon 10 Dec 2018, 17:17    Post subject:  

Hi, all.

No replies, but 109 downloads! Many thanks.

I'm here this afternoon to present a variation of the above:
this script you put in /root/my-applications/bin, /opt/local/bin or
/usr/local/bin. Then make a symlink of it in /root/Startup.

This script creates, on startup, a ramdisk 55% the size of the RAM that's
left after the pup has loaded. Only kicks in if you have more than 2G of
RAM.

Please do not play with that 55%, aka < int(($4/20)*11) >, in the awk
command on line 15. I tested and re-tested various percentages, and I
believe this 55% to be optimal. If you don't believe me, expect a freeze,
or the zram utility occupying all the pupsave, making it kaput (that's
really no fun and a tough one to get out of). In short, fiddle with this
figure and you're on your own.

A RAMdisk is very handy to speed up downloads, store temporary files,
even compile source code. RAM is reputedly 120 x faster than a solid
state HD, so... if you're looking for speed, this is it.

Remember to make periodical back-ups on a thumb-drive or a HD.
Otherwise, upon shutdown, bye-bye forever to that hard-won compilation
or that beautiful collection of family pictures.

However, no worries on soft reboot, the ramdisk stays put on soft reboot,
i.e. on reboot of X, or change of WM. It will tell you, too.

~~~~~~~~

As I said, I have tested and retested it, and this is revision 3a. But still
feel free to report any bug you encounter below. I'll try to provide an
answer.

TWYL.

Code:
#!/bin/bash
# start_dv-zram-3a.sh # Copie de /opt/local/bin/DV-zram-3a.sh
# Créer un disque virtuel de type zram, par "Mute Ant".
# Source : https://forums.linuxmint.com/viewtopic.php?t=203420
# Relevé le 2017/10/24 à 04:30 par musher0
# (c) musher0 for original lines. Rév. : 26 oct. et 1er nov. 2017; 10 déc. 2018.
####
MEVTotal="`free -m | awk '$1 ~ /Mem/ { print $2 }'`"
if [ "$MEVTotal" -gt "1999" ];then
# To avoid headaches, if the computer has less than 2Gb of RAM, we pass. /
# Pour éviter les maux de tête, si l'ordi a moins de 2 Go de MEV, on passe.
     ChecK="`df | awk '$NF ~ /ram1/'`" # musher0, 17-10-14
     if [ "$ChecK" = "" ];then # musher0, 17-10-14
          MOUNTPOINT="/mnt/ram1"
          SIZE="`free -m | awk '/Mem/ {print int(($4/20)*11) }'`" # musher0, 18-12-10
          mkdir -p "$MOUNTPOINT" # s'assurer que le point de montage existe
          sleep 0.1s
          modprobe zram  # Tell the kernel to create device zram0
          sleep 0.1s
          echo 1 > /sys/block/zram0/reset # Réinitialiser # Playing it safe.
          sleep 0.1s
          echo "${SIZE}"m > /sys/block/zram0/disksize  # Set the size of zram0 ...
          sleep 0.1s
          mkfs.ext2 /dev/zram0  # Format the new device as ext2
#    mkudffs --media-type=hd --blocksize=512 /dev/zram # non
          sleep 0.1s
          mount /dev/zram0 /mnt/ram1 # Ramdisk  # Mount the new device on Ramdisk
#    mount -t udf -o bs=512 /dev/zram0 /mnt/ram1 # mount-point
          sleep 0.1s
          chmod 1777 /mnt/ram1 # Ramdisk  # Change Ramdisk flags to be like a /tmp/ folder
          sleep 0.1s
          mkdir -p /mnt/ram1/Downloads # Make a Downloads folder in Ramdisk
          sleep 0.1s

          cd /mnt/home/ramdisk
          rsync -qavz . "/mnt/ram1" # --delete # optionnel

          sleep 0.5s # Cette section par musher0, 17-10-14, 17-10-26
          case "${LANG:0:2}" in fr) MsG="

Un disque virtuel de
$SIZE Mo a été créé." ;;
               en|*) MsG="

A $SIZE Mb ramdisk
has been created." ;;
          esac
          bcm -u /mnt/ram1/gnome-dev-memory.png -a 1 -g c:c -d 5 -b "#000000FF" -c "#0c0c0c8F" -t "<span font='LiberationSerif Bold Italic 18' color='#FFFFFFFF' gravity='north' gravity_hint='line'>$MsG</span>" 2>/dev/null &

     else
          case "${LANG:0:2}" in fr) MsG="

Un disque virtuel
existe déja." ;;
               en|*) MsG="

A ramdisk
already exists." ;;
          esac
          bcm -u /mnt/ram1/gnome-dev-memory.png -a 1 -g c:c -d 5 -b "#000000FF" -c "#0c0c0c8F" -t "<span font='LiberationSerif Bold Italic 18' color='#FFFFFFFF' gravity='north' gravity_hint='line'>$MsG</span>" 2>/dev/null &
     fi # Fin de la section par musher0, 17-10-14, rév. 17-10-26
fi

Final note --
If you don't have the Liberation font, it will show the message in an ugly
default font. So go get it at:
https://www.fontsquirrel.com/fonts/download/liberation-serif
Smile

Besides, this Liberation font is an important landmark in Linux history: it
was the first font to free us from servitude to WhineDose fonts. Every
Linuxian should have it.

Enjoy!
DV-zram-3a.sh.zip
Description  Same as above, in zip form. Unzip in a "bin" directory in your path and
make executable before using.
zip

 Download 
Filename  DV-zram-3a.sh.zip 
Filesize  1.34 KB 
Downloaded  5 Time(s) 

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)

Last edited by musher0 on Tue 11 Dec 2018, 22:59; edited 1 time in total
Back to top
View user's profile Send private message 
perdido


Joined: 09 Dec 2013
Posts: 1063
Location: ¿Altair IV , Just north of Eeyore Junction.?

PostPosted: Mon 10 Dec 2018, 17:49    Post subject:  

I prefer deciding what size ram disk I want, no hard coding that is necessary or over-complicating a simple ram disk like pizzasgood made
http://www.murga-linux.com/puppy/viewtopic.php?t=74663
HaHa just kidding


Pizzasgood is only 500 bytes for a GUI that lets you mount/unmount the disk and recover memory. Like it should be.

pizzasgood 1128 downloads and simple one file script, the one I use
Just my 2 cents

.
pizza-is-good ram disk(1).jpg
 Description   Then unmount if you are done no system crash
 Filesize   16.44 KB
 Viewed   78 Time(s)

pizza-is-good ram disk(1).jpg

pizza-is-good ram disk.jpg
 Description   pizzasgood simple chooser for your wanted size of ram disk
 Filesize   11.71 KB
 Viewed   78 Time(s)

pizza-is-good ram disk.jpg

Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13162
Location: Gatineau (Qc), Canada

PostPosted: Mon 10 Dec 2018, 18:33    Post subject:  

Hey, perdido!

However, pizzagood's experiment does not use the zram code. He's using
tmpfs to structure his RAMdisk. Which means his RAMdisk is not elastic.

The zram technique starts zipping the contents of the ramdisk when it
starts getting full. Which means a zram-type RAMdisk can store almost
two times (or thereabouts) as much stuff as a regular RAMdisk of same
size can.

In plain text, that means that a 1.5G zram-type RAMdisk will probably be
able to store up to 2.99G of stuff, whereas the regular-type RAMdisk will
choke at 1.49G.

(I said "probably" because the z-ram zipping depends largely on the file.
If there's a zip file stored in a zram-type RAMdisk, zram won't be able to
compress it more than it is already compressed. That said, zram will
probably do wonders compressing a 1M text file -- down to 100K?)

Also, IMO, too small a RAMdisk can't help the user much: it's better to
create something consistent.

BTW, pizzasgood script unpacked is 1036 bytes, not 551!
Another thing: his script won't tell you if you're creating too big a RAMdisk
for the RAM that's available. Mine won't let you unless you fiddle with the
code -- and then: good luck!

Finally, pizzasgood has been a great contributor to puppy. But is he here
now to update his stuff? Somebody has to do it! Twisted Evil

So there you go. Anyway -- to each his/her own.

BFN.

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13162
Location: Gatineau (Qc), Canada

PostPosted: Tue 11 Dec 2018, 14:42    Post subject:  

Hello.

Here are a few more remarks about zram-type ramdisks, grappled here
and there, that may turn off some question marks blinking overhead.
Quote:
Note:
There is little point creating a zram of greater than twice the size of
memory since we expect a 2:1 compression ratio. Note that zram uses
about 0.1% of the size of the disk when not in use so a huge zram is
wasteful.
Source

~~~~~~~~~

Q. -- Someone asked me yesterday by PM why use this script since
Puppy loads entirely in RAM.

A. -- The answer is that a Puppy loaded in RAM does not use all the RAM.
Even on a PC that has 1G of RAM.

The Puppy sfs unzips in RAM to approx. 3.3 times its size. E.g. if the
Puppy sfs is 235M big, in RAM, it will occupy alittle over 775M. If you
have 4G of RAM, that leaves 3.25G of RAM unused.
(Example edited, Dec. 12 2018, 19 h 40)

My reasoning is that we might as well use that remaining RAM for a
zram-type RAMdisk, given the advantages it offers in speed and
compression of data.

Of course you have to leave some room in RAM for the various execs
that you use. Which is why my script uses 55% fo what's left after
Puppy has loaded. I.e., the number in the 4th column when you type
< free -m >, NOT the number in the 2nd column, which indicates the
total amount of RAM in your system.
Code:
free -m
       total       used       free     shared    buffers     cached
Mem:    3915       2252       1663          5        193       1287
(...)
E.g., on this xenialPup-706, the ROX properties function or < df -m >
reports the RAMdisk using:
Code:
df -m /mnt/ram1
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/zram0          1839   147      1599   9% /mnt/ram1
So your Puppy in RAM occupies 660M, plus the zram-type RAMdisk occupies
1,839M. Therefore
Code:
echo $[3915-(775+1839)]
1301
(Example edited, Dec. 12 2018, 19 h 42)
you have 1.3G of free RAM left for the execution of your programs. That's
more than enough, even for biggies such as Open|Libre|Office or
Chromium.

~~~~~~~~~~~~~~

(More to come as I find them.)

BFN.

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Filesystem
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0625s ][ Queries: 13 (0.0132s) ][ GZIP on ]